From b79caa0e7b2fc91080dc34f47d69fd5c1535bb5a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 2 Oct 2015 17:36:14 +0000 Subject: [PATCH] Module debugging: Don't emit forward declarations in module scopes. A forward declaration inside a module header does not belong to the module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249157 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 3 +++ test/Modules/Inputs/DebugObjC.h | 1 + test/Modules/ModuleDebugInfo.m | 3 +++ 3 files changed, 7 insertions(+) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 388cbd91a1..4a5c16e219 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2172,6 +2172,9 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) { } llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) { + // A forward declaration inside a module header does not belong to the module. + if (isa(D) && !cast(D)->getDefinition()) + return nullptr; if (DebugTypeExtRefs && D->isFromASTFile()) { // Record a reference to an imported clang module or precompiled header. auto *Reader = CGM.getContext().getExternalSource(); diff --git a/test/Modules/Inputs/DebugObjC.h b/test/Modules/Inputs/DebugObjC.h index a44a362c92..979871d33c 100644 --- a/test/Modules/Inputs/DebugObjC.h +++ b/test/Modules/Inputs/DebugObjC.h @@ -5,6 +5,7 @@ } + classMethod; - instanceMethodWithInt:(int)i; +- (struct OpaqueData*) getSomethingOpaque; @property int property; @end diff --git a/test/Modules/ModuleDebugInfo.m b/test/Modules/ModuleDebugInfo.m index 36a151cd70..8139343147 100644 --- a/test/Modules/ModuleDebugInfo.m +++ b/test/Modules/ModuleDebugInfo.m @@ -41,3 +41,6 @@ // MODULE-CHECK: !DICompositeType(tag: DW_TAG_structure_type, // MODULE-CHECK-SAME: name: "ObjCClass", // MODULE-CHECK-SAME: scope: ![[MODULE]], + +// The forward declaration should not be in the module scope. +// MODULE-CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file -- 2.40.0