diff options
author | Manman Ren <manman.ren@gmail.com> | 2014-11-21 19:47:48 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2014-11-21 19:47:48 +0000 |
commit | bfd2b829d912ecd89f73ae32d4c683856dd677a3 (patch) | |
tree | 5cfd1e457d64f4dcb499a3a63851d4b0b5b724d5 | |
parent | 6a629c59ba685c1e7c6e1030cd7ea75de80e3506 (diff) | |
download | bcm5719-llvm-bfd2b829d912ecd89f73ae32d4c683856dd677a3.tar.gz bcm5719-llvm-bfd2b829d912ecd89f73ae32d4c683856dd677a3.zip |
Debug Info: add an assertion that the context field of a global variable can not
be a DIType with identifier.
This makes sure that there is no need to use DIScopeRef for global variable's
context.
rdar://18958417
llvm-svn: 222561
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 4fe2be61b8f..be43673bb3e 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -836,6 +836,13 @@ static DIGlobalVariable createGlobalVariableHelper( StringRef LinkageName, DIFile F, unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit, Constant *Val, MDNode *Decl, bool isDefinition, std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) { + + MDNode *TheCtx = getNonCompileUnitScope(Context); + if (DIScope(TheCtx).isCompositeType()) { + assert(!DICompositeType(TheCtx).getIdentifier() && + "Context of a global variable should not be a type with identifier"); + } + Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_variable) .concat(Name) .concat(Name) @@ -844,7 +851,7 @@ static DIGlobalVariable createGlobalVariableHelper( .concat(isLocalToUnit) .concat(isDefinition) .get(VMContext), - DIScope(getNonCompileUnitScope(Context)).getRef(), F, Ty, Val, + DIScope(TheCtx).getRef(), F, Ty, Val, DIDescriptor(Decl)}; return DIGlobalVariable(CreateFunc(Elts)); |