From b23407aab1bf2d4baaeca37b8f5ce07e95009dac Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 1 Oct 2015 00:48:51 +0000 Subject: [PATCH] Module debugging: Emit Objective-C interfaces in their module scope when building a clang module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248974 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 5 +++-- test/Modules/ModuleDebugInfo.m | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 443c45cc64..d5ed7ea1d6 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1743,9 +1743,10 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, if (ID->getImplementation()) Flags |= llvm::DINode::FlagObjcClassComplete; + llvm::DIScope *Mod = getParentModuleOrNull(ID); llvm::DICompositeType *RealDecl = DBuilder.createStructType( - Unit, ID->getName(), DefUnit, Line, Size, Align, Flags, nullptr, - llvm::DINodeArray(), RuntimeLang); + Mod ? Mod : Unit, ID->getName(), DefUnit, Line, Size, Align, Flags, + nullptr, llvm::DINodeArray(), RuntimeLang); QualType QTy(Ty, 0); TypeCache[QTy.getAsOpaquePtr()].reset(RealDecl); diff --git a/test/Modules/ModuleDebugInfo.m b/test/Modules/ModuleDebugInfo.m index 546a62a2c4..8fac5f41f0 100644 --- a/test/Modules/ModuleDebugInfo.m +++ b/test/Modules/ModuleDebugInfo.m @@ -7,6 +7,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll // RUN: cat %t-mod.ll | FileCheck %s +// RUN: cat %t-mod.ll | FileCheck %s --check-prefix=MODULE-CHECK // PCH: // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugObjC.h -mllvm -debug-only=pchcontainer &>%t-pch.ll @@ -18,9 +19,15 @@ // CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC // CHECK-SAME: isOptimized: false, -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass" +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// CHECK-SAME: name: "ObjCClass", // CHECK: !DIObjCProperty(name: "property", // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "ivar" // CHECK: !DISubprogram(name: "+[ObjCClass classMethod]" // CHECK: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]" // CHECK: !DISubprogram(name: "-[ categoryMethod]" + +// MODULE-CHECK: !DICompositeType(tag: DW_TAG_structure_type, +// MODULE-CHECK-SAME: name: "ObjCClass", +// MODULE-CHECK-SAME: scope: ![[MODULE:[0-9]+]], +// MODULE-CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC" -- 2.40.0