[clang] f9f5648 - [DebugInfo] Use per-enumerator signedness for DIEnumerator

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 26 16:14:36 PDT 2021


Author: Reid Kleckner
Date: 2021-07-26T16:14:28-07:00
New Revision: f9f56488e02d1c09a9cd4acde61ce1c712e71405

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

LOG: [DebugInfo] Use per-enumerator signedness for DIEnumerator

Allegedly the DWARF backend ignores this field of DIEnumerator, but we
set it nonetheless in case we decide to use it in the future.
Alternatively, we could remove it, but it is simpler to pass down the
signed bit as it is in the AST for now.

Implemented to address comments on D106585

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp
    clang/test/CodeGen/enum2.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f96c5ef43ff0..81c910f40bf8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3084,17 +3084,11 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
 
   SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
 
-  // Create elements for each enumerator. Use the signed-ness of the enum type,
-  // not the signedness of the enumerator. This matches the DWARF produced by
-  // GCC for C enums with positive enumerators.
   SmallVector<llvm::Metadata *, 16> Enumerators;
   ED = ED->getDefinition();
-  bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-    llvm::APSInt Value = Enum->getInitVal();
-    Value.setIsSigned(IsSigned);
     Enumerators.push_back(
-        DBuilder.createEnumerator(Enum->getName(), std::move(Value)));
+        DBuilder.createEnumerator(Enum->getName(), Enum->getInitVal()));
   }
 
   // Return a CompositeType for the enum itself.

diff  --git a/clang/test/CodeGen/enum2.c b/clang/test/CodeGen/enum2.c
index f41d5a18d027..fcf638150020 100644
--- a/clang/test/CodeGen/enum2.c
+++ b/clang/test/CodeGen/enum2.c
@@ -12,4 +12,4 @@ void foo (void)
 // CHECK-SAME: elements: ![[ELTS:[0-9]+]]
 // CHECK: ![[LONG]] = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
 // CHECK: ![[ELTS]] = !{![[MAX:[0-9]+]]}
-// CHECK: ![[MAX]] = !DIEnumerator(name: "MAX", value: 0, isUnsigned: true)
+// CHECK: ![[MAX]] = !DIEnumerator(name: "MAX", value: 0)


        


More information about the cfe-commits mailing list