Skip to content

Commit 8f37668

Browse files
authored
[clang][bytecode] Print 8 bit integers as 32 bit in Function::dump() (#156858)
Otherwise we get the char representation in our disassembly output, which we don't want.
1 parent f84d231 commit 8f37668

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

clang/lib/AST/ByteCode/Disasm.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,20 @@ inline static std::string printArg(Program &P, CodePtr &OpPC) {
4444
std::string Result;
4545
llvm::raw_string_ostream SS(Result);
4646
auto Arg = OpPC.read<T>();
47-
SS << Arg;
47+
// Make sure we print the integral value of chars.
48+
if constexpr (std::is_integral_v<T>) {
49+
if constexpr (sizeof(T) == 1) {
50+
if constexpr (std::is_signed_v<T>)
51+
SS << static_cast<int32_t>(Arg);
52+
else
53+
SS << static_cast<uint32_t>(Arg);
54+
} else {
55+
SS << Arg;
56+
}
57+
} else {
58+
SS << Arg;
59+
}
60+
4861
return Result;
4962
}
5063
}

0 commit comments

Comments
 (0)