diff options
| author | Momchil Velikov <momchil.velikov@arm.com> | 2018-02-07 16:52:02 +0000 |
|---|---|---|
| committer | Momchil Velikov <momchil.velikov@arm.com> | 2018-02-07 16:52:02 +0000 |
| commit | d7e17c232fb7ee57e5fbbe073b351d65560823cc (patch) | |
| tree | 0e75323080dd23772638120c21cea07a279c8267 /clang/lib/CodeGen | |
| parent | c502027efdf0361d5f8f57af6ad62d8096f0b6da (diff) | |
| download | bcm5719-llvm-d7e17c232fb7ee57e5fbbe073b351d65560823cc.tar.gz bcm5719-llvm-d7e17c232fb7ee57e5fbbe073b351d65560823cc.zip | |
[DebugInfo] Improvements to representation of enumeration types (PR36168)
This patch:
* fixes an incorrect sign-extension of unsigned values, when emitting
debug info metadata for enumerators
* the enumerators metadata is created with a flag, which determines
interpretation of the value bits (signed or unsigned)
* the enumerations metadata contains the underlying integer type and a
flag, indicating whether this is a C++ "fixed enum"
Differential Revision: https://reviews.llvm.org/D42736
llvm-svn: 324490
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, |

