From 145815c180fc82c5a55bf568d01d98d250490a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 5 Jun 2024 13:21:40 +0200 Subject: [PATCH] [clang][Interp][NFC] Move EvaluationResult::dump() to Disasm.cpp Where all the other dump() functions live. --- clang/lib/AST/Interp/Disasm.cpp | 42 +++++++++++++++++++++++ clang/lib/AST/Interp/EvaluationResult.cpp | 41 ---------------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp index e442c6c709f14d..3f8a92ed2f0bde 100644 --- a/clang/lib/AST/Interp/Disasm.cpp +++ b/clang/lib/AST/Interp/Disasm.cpp @@ -11,6 +11,8 @@ //===----------------------------------------------------------------------===// #include "Boolean.h" +#include "Context.h" +#include "EvaluationResult.h" #include "Floating.h" #include "Function.h" #include "FunctionPointer.h" @@ -305,3 +307,43 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const { OS << " Extern: " << IsExtern << "\n"; OS << " Initialized: " << IsInitialized << "\n"; } + +LLVM_DUMP_METHOD void EvaluationResult::dump() const { + assert(Ctx); + auto &OS = llvm::errs(); + const ASTContext &ASTCtx = Ctx->getASTContext(); + + switch (Kind) { + case Empty: + OS << "Empty\n"; + break; + case RValue: + OS << "RValue: "; + std::get(Value).dump(OS, ASTCtx); + break; + case LValue: { + assert(Source); + QualType SourceType; + if (const auto *D = Source.dyn_cast()) { + if (const auto *VD = dyn_cast(D)) + SourceType = VD->getType(); + } else if (const auto *E = Source.dyn_cast()) { + SourceType = E->getType(); + } + + OS << "LValue: "; + if (const auto *P = std::get_if(&Value)) + P->toAPValue().printPretty(OS, ASTCtx, SourceType); + else if (const auto *FP = std::get_if(&Value)) // Nope + FP->toAPValue().printPretty(OS, ASTCtx, SourceType); + OS << "\n"; + break; + } + case Invalid: + OS << "Invalid\n"; + break; + case Valid: + OS << "Valid\n"; + break; + } +} diff --git a/clang/lib/AST/Interp/EvaluationResult.cpp b/clang/lib/AST/Interp/EvaluationResult.cpp index 150a793da881db..c04b0fc0a11212 100644 --- a/clang/lib/AST/Interp/EvaluationResult.cpp +++ b/clang/lib/AST/Interp/EvaluationResult.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "EvaluationResult.h" -#include "Context.h" #include "InterpState.h" #include "Record.h" #include "clang/AST/ExprCXX.h" @@ -159,45 +158,5 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S, return CheckArrayInitialized(S, InitLoc, Ptr, CAT); } -void EvaluationResult::dump() const { - assert(Ctx); - auto &OS = llvm::errs(); - const ASTContext &ASTCtx = Ctx->getASTContext(); - - switch (Kind) { - case Empty: - OS << "Empty\n"; - break; - case RValue: - OS << "RValue: "; - std::get(Value).dump(OS, ASTCtx); - break; - case LValue: { - assert(Source); - QualType SourceType; - if (const auto *D = Source.dyn_cast()) { - if (const auto *VD = dyn_cast(D)) - SourceType = VD->getType(); - } else if (const auto *E = Source.dyn_cast()) { - SourceType = E->getType(); - } - - OS << "LValue: "; - if (const auto *P = std::get_if(&Value)) - P->toAPValue().printPretty(OS, ASTCtx, SourceType); - else if (const auto *FP = std::get_if(&Value)) // Nope - FP->toAPValue().printPretty(OS, ASTCtx, SourceType); - OS << "\n"; - break; - } - case Invalid: - OS << "Invalid\n"; - break; - case Valid: - OS << "Valid\n"; - break; - } -} - } // namespace interp } // namespace clang