Skip to content

Commit 145815c

Browse files
committed
[clang][Interp][NFC] Move EvaluationResult::dump() to Disasm.cpp
Where all the other dump() functions live.
1 parent 5f2aa91 commit 145815c

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

clang/lib/AST/Interp/Disasm.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "Boolean.h"
14+
#include "Context.h"
15+
#include "EvaluationResult.h"
1416
#include "Floating.h"
1517
#include "Function.h"
1618
#include "FunctionPointer.h"
@@ -305,3 +307,43 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
305307
OS << " Extern: " << IsExtern << "\n";
306308
OS << " Initialized: " << IsInitialized << "\n";
307309
}
310+
311+
LLVM_DUMP_METHOD void EvaluationResult::dump() const {
312+
assert(Ctx);
313+
auto &OS = llvm::errs();
314+
const ASTContext &ASTCtx = Ctx->getASTContext();
315+
316+
switch (Kind) {
317+
case Empty:
318+
OS << "Empty\n";
319+
break;
320+
case RValue:
321+
OS << "RValue: ";
322+
std::get<APValue>(Value).dump(OS, ASTCtx);
323+
break;
324+
case LValue: {
325+
assert(Source);
326+
QualType SourceType;
327+
if (const auto *D = Source.dyn_cast<const Decl *>()) {
328+
if (const auto *VD = dyn_cast<ValueDecl>(D))
329+
SourceType = VD->getType();
330+
} else if (const auto *E = Source.dyn_cast<const Expr *>()) {
331+
SourceType = E->getType();
332+
}
333+
334+
OS << "LValue: ";
335+
if (const auto *P = std::get_if<Pointer>(&Value))
336+
P->toAPValue().printPretty(OS, ASTCtx, SourceType);
337+
else if (const auto *FP = std::get_if<FunctionPointer>(&Value)) // Nope
338+
FP->toAPValue().printPretty(OS, ASTCtx, SourceType);
339+
OS << "\n";
340+
break;
341+
}
342+
case Invalid:
343+
OS << "Invalid\n";
344+
break;
345+
case Valid:
346+
OS << "Valid\n";
347+
break;
348+
}
349+
}

clang/lib/AST/Interp/EvaluationResult.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "EvaluationResult.h"
10-
#include "Context.h"
1110
#include "InterpState.h"
1211
#include "Record.h"
1312
#include "clang/AST/ExprCXX.h"
@@ -159,45 +158,5 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S,
159158
return CheckArrayInitialized(S, InitLoc, Ptr, CAT);
160159
}
161160

162-
void EvaluationResult::dump() const {
163-
assert(Ctx);
164-
auto &OS = llvm::errs();
165-
const ASTContext &ASTCtx = Ctx->getASTContext();
166-
167-
switch (Kind) {
168-
case Empty:
169-
OS << "Empty\n";
170-
break;
171-
case RValue:
172-
OS << "RValue: ";
173-
std::get<APValue>(Value).dump(OS, ASTCtx);
174-
break;
175-
case LValue: {
176-
assert(Source);
177-
QualType SourceType;
178-
if (const auto *D = Source.dyn_cast<const Decl *>()) {
179-
if (const auto *VD = dyn_cast<ValueDecl>(D))
180-
SourceType = VD->getType();
181-
} else if (const auto *E = Source.dyn_cast<const Expr *>()) {
182-
SourceType = E->getType();
183-
}
184-
185-
OS << "LValue: ";
186-
if (const auto *P = std::get_if<Pointer>(&Value))
187-
P->toAPValue().printPretty(OS, ASTCtx, SourceType);
188-
else if (const auto *FP = std::get_if<FunctionPointer>(&Value)) // Nope
189-
FP->toAPValue().printPretty(OS, ASTCtx, SourceType);
190-
OS << "\n";
191-
break;
192-
}
193-
case Invalid:
194-
OS << "Invalid\n";
195-
break;
196-
case Valid:
197-
OS << "Valid\n";
198-
break;
199-
}
200-
}
201-
202161
} // namespace interp
203162
} // namespace clang

0 commit comments

Comments
 (0)