From f9f56488e02d1c09a9cd4acde61ce1c712e71405 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 26 Jul 2021 16:06:17 -0700 Subject: [PATCH] [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 --- clang/lib/CodeGen/CGDebugInfo.cpp | 8 +------- clang/test/CodeGen/enum2.c | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) 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 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)