https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/156858

Otherwise we get the char representation in our disassembly output, which we 
don't want.

>From 51a71d470c870d23cf073b87232ed7d00000d961 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 4 Sep 2025 08:58:45 +0200
Subject: [PATCH] [clang][bytecode] Print 8 bit integers as 32 bit in
 Function::dump()

Otherwise we get the char representation in our disassembly output,
which we don't want.
---
 clang/lib/AST/ByteCode/Disasm.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to