From ea692ff7123d87ae3147d9a02f4c1a39d6973603 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Fri, 21 Nov 2014 19:47:48 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222561 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DIBuilder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 4fe2be61b8f..be43673bb3e 100644 --- a/lib/IR/DIBuilder.cpp +++ b/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)> 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));