diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-04-28 23:01:24 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-04-28 23:01:24 +0000 |
commit | 0a4ddc180b2da65343c2a2fd5deada5aeed11a8a (patch) | |
tree | 1e99578ce35b3e85eabff10c5184009ed571f9b8 /clang/lib/CodeGen | |
parent | 89feff3b76579abac532746cc1317c72bfd565eb (diff) | |
download | bcm5719-llvm-0a4ddc180b2da65343c2a2fd5deada5aeed11a8a.tar.gz bcm5719-llvm-0a4ddc180b2da65343c2a2fd5deada5aeed11a8a.zip |
Debug Info: Represent local anonymous unions as anonymous unions
in the debug info. This patch deletes a hack that emits the members
of local anonymous unions as local variables.
Besides being morally wrong, the existing representation using local
variables breaks internal assumptions about the local variables' storage
size.
Compiling
```
void fn1() {
union {
int i;
char c;
};
i = c;
}
```
with -g -O3 -verify will cause the verifier to fail after SROA splits
the 32-bit storage for the "local variable" c into two pieces because the
second piece is clearly outside the 8-bit range that is expected for a
variable of type char. Given the choice I'd rather fix the debug
representation than weaken the verifier.
Debuggers generally already know how to deal with anonymous unions when
they are members of C++ record types, but they may have problems finding
the local anonymous struct members in the expression evaluator.
rdar://problem/20730771
llvm-svn: 236059
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index fd45f620dcd..8118a9d7aaf 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2835,31 +2835,6 @@ 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. |