| commit | f8b004dd7bdbebb8377be03ad54ecaf55082273b | [log] [tgz] |
|---|---|---|
| author | Michael Buch <michaelbuch12@gmail.com> | Mon Oct 27 07:49:06 2025 +0000 |
| committer | GitHub <noreply@github.com> | Mon Oct 27 07:49:06 2025 +0000 |
| tree | 079540bb763bed42d07db0c53b52dce28531124e | |
| parent | 1322e71f2baac9d7cfa77cfa5345bfffbff74cf7 [diff] |
[clang][DebugInfo] Don't mark explicit parameter of synthesized ObjC property accessors artificial (#164998) In the past we used to only mark variables artificial that were `isImplicit`. We would also omit the location information if the variable's parent was implicit. Since https://github.com/llvm/llvm-project/pull/100355 we made the logic to mark variables as artificial the same as determining whether to omit its location or not. This was to support binding variable declarations, which we would like to have line information for (and don't want to mark artificial as they are explicitly named in source). However, this doesn't quite do the expected for parameters of Objective-C synthesised property accessors. An Objective-C setter will have an explicit parameter, which is the ivar to write to. However, because the parent (i.e., the synthesised method) is artificial, we now mark that parameter artificial. This is example debug-info for such an accessor: ``` 0x00000118: DW_TAG_subprogram DW_AT_low_pc (0x0000000000000044) DW_AT_high_pc (0x0000000000000078) DW_AT_frame_base (DW_OP_reg29 W29) DW_AT_object_pointer (0x00000128) DW_AT_specification (0x00000068 "-[Foo setFooProp:]") 0x00000128: DW_TAG_formal_parameter DW_AT_location (DW_OP_fbreg -8) DW_AT_name ("self") DW_AT_type (0x00000186 "Foo *") DW_AT_artificial (true) 0x00000131: DW_TAG_formal_parameter DW_AT_location (DW_OP_breg31 WSP+16) DW_AT_name ("_cmd") DW_AT_type (0x0000018b "SEL") DW_AT_artificial (true) 0x0000013a: DW_TAG_formal_parameter DW_AT_location (DW_OP_breg31 WSP+8) DW_AT_name ("fooProp") DW_AT_type (0x000000aa "id") DW_AT_artificial (true) ``` Note how the `fooProp` parameter is marked artificial, although it technically is an explicitly passed parameter. We want to treat the synthesised method like any other, where explicitly passed parameters aren't artificial. But we do want to omit the file/line info because it doesn't exist in the source. This patch prevents such parameters from being marked artificial. We could probably generalise this to any kind of synthesised method, not just Objective-C. But I'm currently not aware of such synthesised functions, so made it Objective-C specific for now for testability. *Motivator* Marking such parameters artificial makes LLDB fail to parse the ObjC method and emit an error such as: ``` error: Foo.o [0x00000000000009d7]: invalid Objective-C method DW_TAG_subprogram (DW_TAG_subprogram), please file a bug and attach the file at the start of this error message ``` rdar://163063569
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.