Delay adding imported entity DIEs to the lexical scope, streamlining the check for...
authorDavid Blaikie <dblaikie@gmail.com>
Sun, 31 Aug 2014 05:46:17 +0000 (05:46 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sun, 31 Aug 2014 05:46:17 +0000 (05:46 +0000)
This makes the emptiness of the scope with regards to variables and
nested scopes is the same as with regards to imported entities. Just
check if we had nothing at all before we build the node.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216840 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 56ad9666e95ba6a8373622bdb1355ea915c8cc5b..cfffef7e747edb7b0a8e922562568ba9d4ff8209 100644 (file)
@@ -597,14 +597,14 @@ std::unique_ptr<DIE> DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU,
                          ScopesWithImportedEntities.end(),
                          std::pair<const MDNode *, const MDNode *>(DS, nullptr),
                          less_first());
-    if (Children.empty() && Range.first == Range.second)
-      return nullptr;
-    ScopeDIE = constructLexicalScopeDIE(TheCU, Scope);
-    assert(ScopeDIE && "Scope DIE should not be null.");
     for (ImportedEntityMap::const_iterator i = Range.first; i != Range.second;
          ++i)
-      ScopeDIE->addChild(
+      Children.push_back(
           constructImportedEntityDIE(TheCU, DIImportedEntity(i->second)));
+    if (Children.empty())
+      return nullptr;
+    ScopeDIE = constructLexicalScopeDIE(TheCU, Scope);
+    assert(ScopeDIE && "Scope DIE should not be null.");
   }
 
   // Add children