diff options
| author | Momchil Velikov <momchil.velikov@arm.com> | 2018-02-12 16:12:52 +0000 |
|---|---|---|
| committer | Momchil Velikov <momchil.velikov@arm.com> | 2018-02-12 16:12:52 +0000 |
| commit | 25f6be53260b80676990d9cb6de8333487f59983 (patch) | |
| tree | 56c58efb4ab2e1d0b0187d0f7e44fab8108b0938 /clang/lib/CodeGen | |
| parent | 08dc66eff0c7ad594584a8a6925ef830cd6873a1 (diff) | |
| download | bcm5719-llvm-25f6be53260b80676990d9cb6de8333487f59983.tar.gz bcm5719-llvm-25f6be53260b80676990d9cb6de8333487f59983.zip | |
Re-commit r324490: [DebugInfo] Improvements to representation of enumeration types (PR36168)
Differential revision: https://reviews.llvm.org/D42736
llvm-svn: 324900
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e766ccc203b..9d12130376f 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2492,9 +2492,12 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { // Create elements for each enumerator. SmallVector<llvm::Metadata *, 16> Enumerators; ED = ED->getDefinition(); + bool IsSigned = ED->getIntegerType()->isSignedIntegerType(); for (const auto *Enum : ED->enumerators()) { - Enumerators.push_back(DBuilder.createEnumerator( - Enum->getName(), Enum->getInitVal().getSExtValue())); + const auto &InitVal = Enum->getInitVal(); + auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue(); + Enumerators.push_back( + DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned)); } // Return a CompositeType for the enum itself. @@ -2503,11 +2506,10 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation()); unsigned Line = getLineNumber(ED->getLocation()); llvm::DIScope *EnumContext = getDeclContextDescriptor(ED); - llvm::DIType *ClassTy = - ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr; + llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit); return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy, - FullName); + FullName, ED->isFixed()); } llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent, |

