forked from OSchip/llvm-project
[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
This commit is contained in:
parent
beff86e8ff
commit
f9f56488e0
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue