Author: Timm Baeder
Date: 2025-09-04T14:15:05+02:00
New Revision: 8f376689ecdb76f78053f9186646dc14c82d5628

URL: 
https://github.com/llvm/llvm-project/commit/8f376689ecdb76f78053f9186646dc14c82d5628
DIFF: 
https://github.com/llvm/llvm-project/commit/8f376689ecdb76f78053f9186646dc14c82d5628.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Disasm.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Disasm.cpp 
b/clang/lib/AST/ByteCode/Disasm.cpp
index ac904d359d8cc..ab3b9f7c3b1d7 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;
   }
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to