r262851 - Module Debugging: Fix a crash when emitting debug info for nested tag types
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 10 16:13:42 PST 2016
Not sure if it's worth it, but you might be able to abort the loop if you
ever reach a namespace (or anything that's not a tag decl maybe? Not sure
about function local types)
On Thu, Mar 10, 2016 at 4:09 PM, Adrian Prantl <aprantl at apple.com> wrote:
>
> On Mar 10, 2016, at 3:21 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
> 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?
>
>
> Yes. If there’s a more direct way top achieve this without walking the
> declcontext, that would be even better of course.
>
> -- adrian
>
>
> On Thu, Mar 10, 2016 at 8:19 AM, Adrian Prantl <aprantl at apple.com> wrote:
>
>>
>> > On Mar 9, 2016, at 5:22 PM, David Blaikie <dblaikie at gmail.com> wrote:
>> >
>> > Is this bug only reachable with modules debug info?
>>
>> Yes, it’s in ObjectFilePCHContainerOperations.cpp, which is only used
>> while building a PCH or module with -gmodules.
>>
>> > Could you describe the nature of the fix (not quite clear to me just by
>> looking at it)
>>
>> 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.
>>
>> -- adrian
>>
>> >
>> > On Mon, Mar 7, 2016 at 12:58 PM, Adrian Prantl via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>> > Author: adrian
>> > Date: Mon Mar 7 14:58:52 2016
>> > New Revision: 262851
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=262851&view=rev
>> > Log:
>> > Module Debugging: Fix a crash when emitting debug info for nested tag
>> types
>> > whose DeclContext is not yet complete by deferring their emission.
>> >
>> > rdar://problem/24918680
>> >
>> > Modified:
>> > cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> > cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> > cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> >
>> > Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=262851&r1=262850&r2=262851&view=diff
>> >
>> ==============================================================================
>> > --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> (original)
>> > +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Mon Mar
>> 7 14:58:52 2016
>> > @@ -201,6 +201,15 @@ public:
>> > if (D->getName().empty())
>> > return;
>> >
>> > + // Defer tag decls until their declcontext is complete.
>> > + auto *DeclCtx = D->getDeclContext();
>> > + while (DeclCtx) {
>> > + if (auto *D = dyn_cast<TagDecl>(DeclCtx))
>> > + if (!D->isCompleteDefinition())
>> > + return;
>> > + DeclCtx = DeclCtx->getParent();
>> > + }
>> > +
>> > DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
>> > DTV.TraverseDecl(D);
>> > Builder->UpdateCompletedType(D);
>> >
>> > Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=262851&r1=262850&r2=262851&view=diff
>> >
>> ==============================================================================
>> > --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
>> > +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Mon Mar 7 14:58:52 2016
>> > @@ -72,3 +72,14 @@ namespace {
>> > struct InAnonymousNamespace { int i; };
>> > }
>> > }
>> > +
>> > +class Base;
>> > +class A {
>> > + virtual Base *getParent() const;
>> > +};
>> > +class Base {};
>> > +class Derived : Base {
>> > + class B : A {
>> > + Derived *getParent() const override;
>> > + };
>> > +};
>> >
>> > Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=262851&r1=262850&r2=262851&view=diff
>> >
>> ==============================================================================
>> > --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
>> > +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Mon Mar 7 14:58:52 2016
>> > @@ -71,6 +71,13 @@
>> > // CHECK-NOT: name:
>> > // CHECK-SAME: identifier: "_ZTS13TypedefStruct")
>> >
>> > +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Derived",
>> > +// CHECK-SAME: identifier: "_ZTS7Derived")
>> > +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope:
>> !"_ZTS7Derived",
>> > +// CHECK-SAME: elements: ![[B_MBRS:.*]], vtableHolder:
>> !"_ZTS1A"
>> > +// CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
>> > +// CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
>> > +
>> > // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
>> > // no mangled name here yet.
>> >
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160310/116c7702/attachment-0001.html>
More information about the cfe-commits
mailing list