summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAmy Huang <akhuang@google.com>2019-05-30 22:04:11 +0000
committerAmy Huang <akhuang@google.com>2019-05-30 22:04:11 +0000
commitdd3a9caf477a01375b9a30416aed834cf85ed3ae (patch)
treec73599a5043d0a2f6a3cd1a333893622ee36bc21 /clang/lib/CodeGen
parent48998d10e089bb20ff1e47fcf573b58602b285b2 (diff)
downloadbcm5719-llvm-dd3a9caf477a01375b9a30416aed834cf85ed3ae.tar.gz
bcm5719-llvm-dd3a9caf477a01375b9a30416aed834cf85ed3ae.zip
Add enums as global variables in the IR metadata.
Summary: Keeps track of the enums that were used by saving them as DIGlobalVariables, since CodeView emits debug info for global constants. Reviewers: rnk Subscribers: aprantl, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62635 llvm-svn: 362166
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index b79169f0a06..a297025547e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4240,7 +4240,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
llvm::DIDerivedType *
CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) {
- if (!D->isStaticDataMember())
+ if (!D || !D->isStaticDataMember())
return nullptr;
auto MI = StaticDataMemberCache.find(D->getCanonicalDecl());
@@ -4353,12 +4353,14 @@ 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.
+ // Do not use global variables for enums, unless for 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;
- return;
+
+ if (!CGM.getCodeGenOpts().EmitCodeView)
+ return;
}
llvm::DIScope *DContext = nullptr;
@@ -4369,8 +4371,8 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
// Emit definition for static members in CodeView.
VD = cast<ValueDecl>(VD->getCanonicalDecl());
- auto *VarD = cast<VarDecl>(VD);
- if (VarD->isStaticDataMember()) {
+ auto *VarD = dyn_cast<VarDecl>(VD);
+ if (VarD && VarD->isStaticDataMember()) {
auto *RD = cast<RecordDecl>(VarD->getDeclContext());
getDeclContextDescriptor(VarD);
// Ensure that the type is retained even though it's otherwise unreferenced.
OpenPOWER on IntegriCloud