r262851 - Module Debugging: Fix a crash when emitting debug info for nested tag types
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 10 08:19:59 PST 2016
> 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
>
More information about the cfe-commits
mailing list