[PATCH] D94391: CGDebugInfo: Drop Loc.isInvalid() special case from getLineNumber

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 12 17:37:49 PST 2021


MaskRay added a comment.

In D94391#2494531 <https://reviews.llvm.org/D94391#2494531>, @dblaikie wrote:

> In D94391#2494316 <https://reviews.llvm.org/D94391#2494316>, @MaskRay wrote:
>
>> I removed `CurLoc` from call sites and tried a stage 2 build. There is such a difference:
>>
>>   0x00062228:   DW_TAG_structure_type
>>                   DW_AT_calling_convention        (DW_CC_pass_by_value)
>>                   DW_AT_name      ("__va_list_tag")
>>                   DW_AT_byte_size (0x18)
>>                   DW_AT_decl_file ("/home/maskray/llvm/clang/tools/driver/driver.cpp")
>>                   DW_AT_decl_line (23)
>>
>> driver.cpp:23 is a `#include`. So this looks strange. The DW_AT_decl_file/DW_AT_decl_line attributes are undesired due to `CurLoc` getLineNumber.
>
> I don't understand what you're describing - could you describe it in more detail/help me connect the dots?

The ObjC example `debug-info-blocks.m` is: `CurLoc` has been advanced to the closing brace. Then `getLineNumber` is called on `ImplicitVarParameter` and the code attaches the location of `}` to this implicit parameter which misses SourceLocation. The location is a bit arbitrary - perhaps the location of `^{` is better.

A worse example is that `CurLoc` moves further away and `getLineNumber` is used to attach the line information to a far-away structure. This may potentially unintentionally apply to future AST nodes.

The `DW_AT_decl_file` `__va_list_tag` example is about attaching the line of a `#include` to some declaration deep in the included hierarchy.

> It sounds like you're saying you removed the CurLoc fallback and then did a stage 2 build of clang and found an example of worse debug info (I'm not sure what file/line this struct was attributed to currently/without the change you were experimenting with) - that would suggest to me that the CurLoc fallback is helping, by providing a better location than the one you've mentioned here?

Clarified the description.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94391/new/

https://reviews.llvm.org/D94391



More information about the cfe-commits mailing list