]> granicus.if.org Git - clang/commitdiff
Module debugging: Don't emit forward declarations in module scopes.
authorAdrian Prantl <aprantl@apple.com>
Fri, 2 Oct 2015 17:36:14 +0000 (17:36 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 2 Oct 2015 17:36:14 +0000 (17:36 +0000)
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
test/Modules/Inputs/DebugObjC.h
test/Modules/ModuleDebugInfo.m

index 388cbd91a158f52f389e924b306182c6a7c402d0..4a5c16e219791735df7ee118feb43e0abd99df46 100644 (file)
@@ -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<RecordDecl>(D) && !cast<RecordDecl>(D)->getDefinition())
+    return nullptr;
   if (DebugTypeExtRefs && D->isFromASTFile()) {
     // Record a reference to an imported clang module or precompiled header.
     auto *Reader = CGM.getContext().getExternalSource();
index a44a362c928758c0d46e96a23db701e54ff954cb..979871d33c0a95e6ed9ff4dc775a927719121aab 100644 (file)
@@ -5,6 +5,7 @@
 }
 + classMethod;
 - instanceMethodWithInt:(int)i;
+- (struct OpaqueData*) getSomethingOpaque;
 @property int property;
 @end
 
index 36a151cd7051f11468db5953425a88f2dde1ea16..8139343147833502ecbe8b77739de7f9d10eb41d 100644 (file)
@@ -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