mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 08:46:06 +00:00

Summary: With DWARF5 it is no longer possible to distinguish normal methods and methods with `__attribute__((objc_direct))` by just looking at the debug information as they are both now children of the of the DW_TAG_structure_type that defines them (before only the `__attribute__((objc_direct))` methods were children). This means that in LLDB we are no longer able to create a correct Clang AST of a module by just looking at the debug information. Instead we would need to call the Objective-C runtime to see which of the methods have a `__attribute__((objc_direct))` and then add the attribute to our own Clang AST depending on what the runtime returns. This would mean that we either let the module AST be dependent on the Objective-C runtime (which doesn't seem right) or we retroactively add the missing attribute to the imported AST in our expressions. A third option is to annotate methods with `__attribute__((objc_direct))` as `DW_AT_APPLE_objc_direct` which is what this patch implements. This way LLDB doesn't have to call the runtime for any `__attribute__((objc_direct))` method and the AST in our module will already be correct when we create it. Reviewers: aprantl, SouraVX Reviewed By: aprantl Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D71201
30 lines
1.1 KiB
Objective-C
30 lines
1.1 KiB
Objective-C
// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -dwarf-version=4 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - -DDISABLE_DIRECT | FileCheck --check-prefix=CHECK-DISABLED %s
|
|
|
|
__attribute__((objc_root_class))
|
|
@interface Root
|
|
@end
|
|
|
|
@implementation Root
|
|
- (int)getInt
|
|
#ifndef DISABLE_DIRECT
|
|
__attribute__((objc_direct))
|
|
#endif
|
|
{
|
|
return 42;
|
|
}
|
|
@end
|
|
|
|
// Test that objc_direct methods are always (even in DWARF < 5) emitted
|
|
// as members of their containing class.
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Root",
|
|
// CHECK-SAME: elements: ![[MEMBERS:[0-9]+]],
|
|
// CHECK-SAME: runtimeLang: DW_LANG_ObjC)
|
|
// CHECK: ![[MEMBERS]] = !{![[GETTER:[0-9]+]]}
|
|
// CHECK: ![[GETTER]] = !DISubprogram(name: "-[Root getInt]",
|
|
// CHECK-SAME: spFlags: DISPFlagObjCDirect
|
|
|
|
// CHECK-DISABLED-NOT: DISPFlagObjCDirect
|