Skip to content

Commit f3dafbd

Browse files
author
git apple-llvm automerger
committed
Merge commit '40f7f305faf9' from swift/release/6.1 into stable/20240723
2 parents a2bfdac + 40f7f30 commit f3dafbd

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
@@ -3037,20 +3037,21 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
30373037
if (!ID)
30383038
return nullptr;
30393039

3040+
auto RuntimeLang =
3041+
static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
3042+
30403043
// Return a forward declaration if this type was imported from a clang module,
30413044
// and this is not the compile unit with the implementation of the type (which
30423045
// may contain hidden ivars).
30433046
if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() &&
30443047
!ID->getImplementation())
3045-
return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
3046-
ID->getName(),
3047-
getDeclContextDescriptor(ID), Unit, 0);
3048+
return DBuilder.createForwardDecl(
3049+
llvm::dwarf::DW_TAG_structure_type, ID->getName(),
3050+
getDeclContextDescriptor(ID), Unit, 0, RuntimeLang);
30483051

30493052
// Get overall information about the record type for the debug info.
30503053
llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
30513054
unsigned Line = getLineNumber(ID->getLocation());
3052-
auto RuntimeLang =
3053-
static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
30543055

30553056
// If this is just a forward declaration return a special forward-declaration
30563057
// 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)