[llvm] r222561 - Debug Info: add an assertion that the context field of a global variable can not

Manman Ren manman.ren at gmail.com
Fri Nov 21 11:47:49 PST 2014


Author: mren
Date: Fri Nov 21 13:47:48 2014
New Revision: 222561

URL: http://llvm.org/viewvc/llvm-project?rev=222561&view=rev
Log:
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

Modified:
    llvm/trunk/lib/IR/DIBuilder.cpp

Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=222561&r1=222560&r2=222561&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Fri Nov 21 13:47:48 2014
@@ -836,6 +836,13 @@ static DIGlobalVariable createGlobalVari
     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 createGlobalVari
                        .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));





More information about the llvm-commits mailing list