summaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Disasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ByteCode/Disasm.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Disasm.cpp55
1 files changed, 22 insertions, 33 deletions
diff --git a/clang/lib/AST/ByteCode/Disasm.cpp b/clang/lib/AST/ByteCode/Disasm.cpp
index 58e6d1a722af..ab3b9f7c3b1d 100644
--- a/clang/lib/AST/ByteCode/Disasm.cpp
+++ b/clang/lib/AST/ByteCode/Disasm.cpp
@@ -44,7 +44,20 @@ inline static std::string printArg(Program &P, CodePtr &OpPC) {
std::string Result;
llvm::raw_string_ostream SS(Result);
auto Arg = OpPC.read<T>();
- SS << Arg;
+ // Make sure we print the integral value of chars.
+ if constexpr (std::is_integral_v<T>) {
+ if constexpr (sizeof(T) == 1) {
+ if constexpr (std::is_signed_v<T>)
+ SS << static_cast<int32_t>(Arg);
+ else
+ SS << static_cast<uint32_t>(Arg);
+ } else {
+ SS << Arg;
+ }
+ } else {
+ SS << Arg;
+ }
+
return Result;
}
}
@@ -549,41 +562,17 @@ LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
}
LLVM_DUMP_METHOD void EvaluationResult::dump() const {
- assert(Ctx);
auto &OS = llvm::errs();
- const ASTContext &ASTCtx = Ctx->getASTContext();
- switch (Kind) {
- case Empty:
+ if (empty()) {
OS << "Empty\n";
- break;
- case RValue:
- OS << "RValue: ";
- std::get<APValue>(Value).dump(OS, ASTCtx);
- break;
- case LValue: {
- assert(Source);
- QualType SourceType;
- if (const auto *D = dyn_cast<const Decl *>(Source)) {
- if (const auto *VD = dyn_cast<ValueDecl>(D))
- SourceType = VD->getType();
- } else if (const auto *E = dyn_cast<const Expr *>(Source)) {
- SourceType = E->getType();
- }
-
- OS << "LValue: ";
- if (const auto *P = std::get_if<Pointer>(&Value))
- P->toAPValue(ASTCtx).printPretty(OS, ASTCtx, SourceType);
- else if (const auto *FP = std::get_if<FunctionPointer>(&Value)) // Nope
- FP->toAPValue(ASTCtx).printPretty(OS, ASTCtx, SourceType);
- OS << "\n";
- break;
- }
- case Invalid:
+ } else if (isInvalid()) {
OS << "Invalid\n";
- break;
- case Valid:
- OS << "Valid\n";
- break;
+ } else {
+ OS << "Value: ";
+#ifndef NDEBUG
+ assert(Ctx);
+ Value.dump(OS, Ctx->getASTContext());
+#endif
}
}