Skip to content

Commit 40f7f30

Browse files
Merge pull request swiftlang#9759 from swiftlang/clang/gmodules-fwd-decl-language-to-6.1
[clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations
2 parents 3612d2d + 3d5d174 commit 40f7f30

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,20 +2966,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
29662966
if (!ID)
29672967
return nullptr;
29682968

2969+
auto RuntimeLang =
2970+
static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
2971+
29692972
// Return a forward declaration if this type was imported from a clang module,
29702973
// and this is not the compile unit with the implementation of the type (which
29712974
// may contain hidden ivars).
29722975
if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() &&
29732976
!ID->getImplementation())
2974-
return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
2975-
ID->getName(),
2976-
getDeclContextDescriptor(ID), Unit, 0);
2977+
return DBuilder.createForwardDecl(
2978+
llvm::dwarf::DW_TAG_structure_type, ID->getName(),
2979+
getDeclContextDescriptor(ID), Unit, 0, RuntimeLang);
29772980

29782981
// Get overall information about the record type for the debug info.
29792982
llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
29802983
unsigned Line = getLineNumber(ID->getLocation());
2981-
auto RuntimeLang =
2982-
static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
29832984

29842985
// If this is just a forward declaration return a special forward-declaration
29852986
// debug type since we won't be able to lay out the entire type.

clang/test/Modules/ExtDebugInfo.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ int foo(ObjCClass *c) {
7575

7676
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
7777
// CHECK-SAME: scope: ![[MOD]],
78-
// CHECK-SAME: flags: DIFlagFwdDecl)
78+
// CHECK-SAME: flags: DIFlagFwdDecl,
79+
// CHECK-SAME: runtimeLang: DW_LANG_ObjC)
7980

8081
// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
8182
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,

clang/test/Modules/ModuleDebugInfo.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
4444
// CHECK-SAME: scope: ![[MODULE]],
45+
// CHECK-SAME: runtimeLang: DW_LANG_ObjC
4546

4647
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
4748
// CHECK-SAME: scope: ![[MODULE]],
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# REQUIRES: system-darwin
2+
3+
# Test that we can set a breakpoint in a method of a class extension.
4+
# This requires us to parse the method into an AST type, and the context
5+
# too (which in DWARF is just a forward declaration).
6+
#
7+
# RUN: split-file %s %t
8+
# RUN: %clangxx_host %t/lib.m -c -g -gmodules -fmodules -o %t/lib.o
9+
# RUN: %clangxx_host %t/main.m -g -gmodules -fmodules %t/lib.o -o %t/a.out -framework Foundation
10+
#
11+
# RUN: %lldb %t/a.out -o "breakpoint set -f lib.m -l 6" -o exit | FileCheck %s
12+
13+
# CHECK: (lldb) breakpoint set -f lib.m -l 6
14+
# CHECK: Breakpoint 1: where = a.out`-[NSObject(Foo) func]
15+
16+
#--- main.m
17+
int main() {
18+
return 0;
19+
}
20+
21+
#--- lib.m
22+
#import <Foundation/Foundation.h>
23+
24+
@implementation NSObject (Foo)
25+
- (NSError *)func {
26+
NSLog(@"Hello, World!");
27+
return 0;
28+
}
29+
@end
30+
31+
NSObject * func() {
32+
return 0;
33+
}
34+

0 commit comments

Comments
 (0)