<div dir="ltr">Is this bug only reachable with modules debug info?<br>Could you describe the nature of the fix (not quite clear to me just by looking at it)</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 7, 2016 at 12:58 PM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Mon Mar  7 14:58:52 2016<br>
New Revision: 262851<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=262851&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=262851&view=rev</a><br>
Log:<br>
Module Debugging: Fix a crash when emitting debug info for nested tag types<br>
whose DeclContext is not yet complete by deferring their emission.<br>
<br>
rdar://problem/24918680<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp<br>
    cfe/trunk/test/Modules/Inputs/DebugCXX.h<br>
    cfe/trunk/test/Modules/ModuleDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=262851&r1=262850&r2=262851&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=262851&r1=262850&r2=262851&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Mon Mar  7 14:58:52 2016<br>
@@ -201,6 +201,15 @@ public:<br>
     if (D->getName().empty())<br>
       return;<br>
<br>
+    // Defer tag decls until their declcontext is complete.<br>
+    auto *DeclCtx = D->getDeclContext();<br>
+    while (DeclCtx) {<br>
+      if (auto *D = dyn_cast<TagDecl>(DeclCtx))<br>
+        if (!D->isCompleteDefinition())<br>
+          return;<br>
+      DeclCtx = DeclCtx->getParent();<br>
+    }<br>
+<br>
     DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);<br>
     DTV.TraverseDecl(D);<br>
     Builder->UpdateCompletedType(D);<br>
<br>
Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=262851&r1=262850&r2=262851&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=262851&r1=262850&r2=262851&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)<br>
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Mon Mar  7 14:58:52 2016<br>
@@ -72,3 +72,14 @@ namespace {<br>
     struct InAnonymousNamespace { int i; };<br>
   }<br>
 }<br>
+<br>
+class Base;<br>
+class A {<br>
+  virtual Base *getParent() const;<br>
+};<br>
+class Base {};<br>
+class Derived : Base {<br>
+  class B : A {<br>
+    Derived *getParent() const override;<br>
+  };<br>
+};<br>
<br>
Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=262851&r1=262850&r2=262851&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=262851&r1=262850&r2=262851&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)<br>
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Mon Mar  7 14:58:52 2016<br>
@@ -71,6 +71,13 @@<br>
 // CHECK-NOT:              name:<br>
 // CHECK-SAME:             identifier: "_ZTS13TypedefStruct")<br>
<br>
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Derived",<br>
+// CHECK-SAME:             identifier: "_ZTS7Derived")<br>
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: !"_ZTS7Derived",<br>
+// CHECK-SAME:             elements: ![[B_MBRS:.*]], vtableHolder: !"_ZTS1A"<br>
+// CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}<br>
+// CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"<br>
+<br>
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"<br>
 // no mangled name here yet.<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>