Skip to content

Respect #sourceLocation directives in SourceLocationConverter #1827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 21, 2023

Add a presumedFile and presumedLine property to SourceLocation that contains the file and line of the location while taking #sourceLocation directives into account.

The terms “presumed file” and “presumed line” have been taken from LLVM and the Swift compiler.

rdar://99187174

@ahoppen ahoppen requested a review from bnbarham June 21, 2023 13:06
@ahoppen
Copy link
Member Author

ahoppen commented Jun 21, 2023

@swift-ci Please test

Comment on lines 257 to 285
/// is returned. If position is negative the location for start of file is
/// returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we allow negative AbsolutePosition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think there’s a real use case. Would you prefer to assert or precondition? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precondition seems fine to me

Comment on lines +81 to +75
presumedLine: Int? = nil,
presumedFile: String? = nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to debug description?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not super happy with the debug description as-is anyway because it also doesn’t include the file name and have been tempted to just remove it. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just extend it to include file as well 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to remove debugDescription

The debug description was lossy because it didn’t print file and offset. If we include that information, it’s so verbose that the debug description doesn’t really provide any benefit over the default debug description. Let’s just remove it.

@ahoppen ahoppen force-pushed the ahoppen/respect-source-location branch from ca31078 to 282ba8d Compare June 22, 2023 11:17
@ahoppen
Copy link
Member Author

ahoppen commented Jun 22, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 22, 2023

@swift-ci Please test Windows

@ahoppen ahoppen force-pushed the ahoppen/respect-source-location branch from 282ba8d to 4ea691c Compare June 22, 2023 20:14
@ahoppen
Copy link
Member Author

ahoppen commented Jun 22, 2023

@swift-ci Please test

ahoppen added 2 commits June 23, 2023 16:12
Add a `presumedFile` and `presumedLine` property to `SourceLocation` that contains the file and line of the location while taking `#sourceLocation` directives into account.

The terms “presumed file” and “presumed line” have been taken from LLVM and the Swift compiler.

rdar://99187174
The debug description was lossy because it didn’t print file and offset. If we include that information, it’s so verbose that the debug description doesn’t really provide any benefit over the default debug description. Let’s just remove it.
@ahoppen ahoppen force-pushed the ahoppen/respect-source-location branch from 4ea691c to 9c8e011 Compare June 23, 2023 14:12
@ahoppen
Copy link
Member Author

ahoppen commented Jun 23, 2023

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge June 23, 2023 14:12
@ahoppen
Copy link
Member Author

ahoppen commented Jun 23, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit dbd3e78 into swiftlang:main Jun 23, 2023
@ahoppen ahoppen deleted the ahoppen/respect-source-location branch July 7, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants