<div dir="ltr">OK, so the idea is that when you see that a tag definition, skip it if any parent is incomplete - because when the parent's definition is complete, you'll emit all its children anyway?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 10, 2016 at 8:19 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Mar 9, 2016, at 5:22 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
> Is this bug only reachable with modules debug info?<br>
<br>
</span>Yes, it’s in ObjectFilePCHContainerOperations.cpp, which is only used while building a PCH or module with -gmodules.<br>
<span class=""><br>
> Could you describe the nature of the fix (not quite clear to me just by looking at it)<br>
<br>
</span>In the ASTConsumer callback for a finished TagDecl, we check whether the DeclContext is complete and only try to emit debug info for the Decl if the DeclContext is available.<br>
<span class="HOEnZb"><font color="#888888"><br>
-- adrian<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> On Mon, Mar 7, 2016 at 12:58 PM, Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> 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>
><br>
<br>
</div></div></blockquote></div><br></div>