https://github.com/OCHyams created
https://github.com/llvm/llvm-project/pull/165583
Follow on from #164372
```diff
DWARF for _BitInt(23):
DW_TAG_base_type
DW_AT_byte_size (0x04)
DW_AT_encoding (DW_ATE_signed)
DW_AT_bit_size (0x17)
- DW_AT_name ("_BitInt")
+ DW_AT_name ("_BitInt(23)")
```
This matches GCC. It's what our (Sony) debugger would prefer to see, but it's
possibly not useful for LLDB - so maybe we want to avoid doing this with -glldb
tuning?
>From 16743d741a6ad92df0516246c25175b314f1e855 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <[email protected]>
Date: Wed, 29 Oct 2025 15:37:41 +0000
Subject: [PATCH] [DebugInfo] Add bit size to _BitInt name in debug info
---
clang/lib/CodeGen/CGDebugInfo.cpp | 5 ++++-
clang/test/DebugInfo/Generic/bit-int.c | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 07a2cfb21bef2..fd2f6dcf182b5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1174,7 +1174,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType
*BT) {
}
llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) {
- StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt";
+ SmallString<32> Name;
+ llvm::raw_svector_ostream OS(Name);
+ OS << (Ty->isUnsigned() ? "unsigned _BitInt(" : "_BitInt(")
+ << Ty->getNumBits() << ")";
llvm::dwarf::TypeKind Encoding = Ty->isUnsigned()
? llvm::dwarf::DW_ATE_unsigned
: llvm::dwarf::DW_ATE_signed;
diff --git a/clang/test/DebugInfo/Generic/bit-int.c
b/clang/test/DebugInfo/Generic/bit-int.c
index 94b93013e3b46..88ecc139eee9f 100644
--- a/clang/test/DebugInfo/Generic/bit-int.c
+++ b/clang/test/DebugInfo/Generic/bit-int.c
@@ -4,5 +4,5 @@
unsigned _BitInt(17) a;
_BitInt(2) b;
-// CHECK: !DIBasicType(name: "_BitInt", size: 8, dataSize: 2, encoding:
DW_ATE_signed)
-// CHECK: !DIBasicType(name: "unsigned _BitInt", size: 32, dataSize: 17,
encoding: DW_ATE_unsigned)
+// CHECK: !DIBasicType(name: "_BitInt(2)", size: 8, dataSize: 2, encoding:
DW_ATE_signed)
+// CHECK: !DIBasicType(name: "unsigned _BitInt(17)", size: 32, dataSize: 17,
encoding: DW_ATE_unsigned)
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits