-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] Cache SourceLocationConverter
in ExportedSourceFile
#70415
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
[Macros] Cache SourceLocationConverter
in ExportedSourceFile
#70415
Conversation
19a9cd7
to
67f04d9
Compare
@swift-ci Please smoke test |
67f04d9
to
cc378e4
Compare
cc378e4
to
ede70fa
Compare
@bnbarham Running test uncovered that I wasn’t handling the file path mode properly in |
@swift-ci Please smoke test |
if adjustedFile == exportedSourceFile.fileName { | ||
adjustedFile = fileID | ||
} | ||
var adjustePresumedFile = location.presumedFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var adjustePresumedFile = location.presumedFile | |
var adjustedPresumedFile = location.presumedFile |
let fileID = "\(exportedSourceFile.moduleName)/\(exportedSourceFile.fileName.basename)" | ||
var adjustedFile = location.file | ||
if adjustedFile == exportedSourceFile.fileName { | ||
adjustedFile = fileID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it mean if they aren't equal? I thought that would be the presumed file case, but apparently not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK it can only happen for the presumed file. I can change it to an assertion that adjustedFile == exportedSourceFile.fileName
. Don’t have strong opinions here. Just thought that it would be better to recover instead of crashing/asserting.
We need a `SourceLocationConverter` every time we create a `PluginMessage.Syntax` to know the source location of that syntax node within the source file. This means that we needed to re-build the line table of the entire source file multiple times for every macro that we expand. Cache it to improve performance. rdar://119047550
ede70fa
to
8da0754
Compare
@swift-ci Please test |
@swift-ci please test |
We need a
SourceLocationConverter
every time we create aPluginMessage.Syntax
to know the source location of that syntax node within the source file. This means that we needed to re-build the line table of the entire source file multiple times for every macro that we expand. Cache it to improve performance.rdar://119047550