summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-04-29 15:05:50 +0000
committerAdrian Prantl <aprantl@apple.com>2015-04-29 15:05:50 +0000
commit0d8208923386cd5f8c4e95a4b251e66f4271b88c (patch)
treec717f089abb95e8b3541fdeb2695c7f2caef4597 /clang/lib/CodeGen
parentc09bdfa4cbfdf17989be8da18044ec8e65bd8f54 (diff)
downloadbcm5719-llvm-0d8208923386cd5f8c4e95a4b251e66f4271b88c.tar.gz
bcm5719-llvm-0d8208923386cd5f8c4e95a4b251e66f4271b88c.zip
Revert "Debug Info: Represent local anonymous unions as anonymous unions"
This reverts commit r236059 as it breaks the gdb buildbot. llvm-svn: 236110
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8118a9d7aaf..fd45f620dcd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2835,6 +2835,31 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::Tag Tag,
return;
} else if (isa<VariableArrayType>(VD->getType()))
Expr.push_back(llvm::dwarf::DW_OP_deref);
+ } else if (const RecordType *RT = dyn_cast<RecordType>(VD->getType())) {
+ // If VD is an anonymous union then Storage represents value for
+ // all union fields.
+ const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
+ if (RD->isUnion() && RD->isAnonymousStructOrUnion()) {
+ for (const auto *Field : RD->fields()) {
+ llvm::MDType *FieldTy = getOrCreateType(Field->getType(), Unit);
+ StringRef FieldName = Field->getName();
+
+ // Ignore unnamed fields. Do not ignore unnamed records.
+ if (FieldName.empty() && !isa<RecordType>(Field->getType()))
+ continue;
+
+ // Use VarDecl's Tag, Scope and Line number.
+ auto *D = DBuilder.createLocalVariable(
+ Tag, Scope, FieldName, Unit, Line, FieldTy,
+ CGM.getLangOpts().Optimize, Flags, ArgNo);
+
+ // Insert an llvm.dbg.declare into the current block.
+ DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
+ llvm::DebugLoc::get(Line, Column, Scope),
+ Builder.GetInsertBlock());
+ }
+ return;
+ }
}
// Create the descriptor for the variable.
OpenPOWER on IntegriCloud