diff options
author | Yuanfang Chen <yuanfang.chen@sony.com> | 2019-09-04 20:58:15 +0000 |
---|---|---|
committer | Yuanfang Chen <yuanfang.chen@sony.com> | 2019-09-04 20:58:15 +0000 |
commit | 48c6fadc0daceb3374d7cc1df1e99ffef4b89d4c (patch) | |
tree | e82beae310037beb6048b9171d4d484060e885eb /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 2df41a8e38976de5a161b2cd06bc5d1e0136df74 (diff) | |
download | bcm5719-llvm-48c6fadc0daceb3374d7cc1df1e99ffef4b89d4c.tar.gz bcm5719-llvm-48c6fadc0daceb3374d7cc1df1e99ffef4b89d4c.zip |
[DebugInfo] Emit DW_TAG_enumeration_type for referenced global enumerator.
This essentially reverts changes from r361400 while keeping behavior for
CodeView.
Reviewers: akhuang, rnk, probinson
Reviewed by: rnk
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D67141
llvm-svn: 370981
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index b1f82d47d44..e36f6932f86 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4438,19 +4438,27 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { StringRef Name = VD->getName(); llvm::DIType *Ty = getOrCreateType(VD->getType(), Unit); - // Do not use global variables for enums, unless in CodeView. if (const auto *ECD = dyn_cast<EnumConstantDecl>(VD)) { const auto *ED = cast<EnumDecl>(ECD->getDeclContext()); assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?"); - (void)ED; - - // If CodeView, emit enums as global variables, unless they are defined - // inside a class. We do this because MSVC doesn't emit S_CONSTANTs for - // enums in classes, and because it is difficult to attach this scope - // information to the global variable. - if (!CGM.getCodeGenOpts().EmitCodeView || - isa<RecordDecl>(ED->getDeclContext())) + + if (CGM.getCodeGenOpts().EmitCodeView) { + // If CodeView, emit enums as global variables, unless they are defined + // inside a class. We do this because MSVC doesn't emit S_CONSTANTs for + // enums in classes, and because it is difficult to attach this scope + // information to the global variable. + if (isa<RecordDecl>(ED->getDeclContext())) + return; + } else { + // If not CodeView, emit DW_TAG_enumeration_type if necessary. For + // example: for "enum { ZERO };", a DW_TAG_enumeration_type is created the + // first time `ZERO` is referenced in a function. + llvm::DIType *EDTy = + getOrCreateType(QualType(ED->getTypeForDecl(), 0), Unit); + assert (EDTy->getTag() == llvm::dwarf::DW_TAG_enumeration_type); + (void)EDTy; return; + } } llvm::DIScope *DContext = nullptr; |