-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Revert "Implement ClangImporter importSourceLoc and importSourceRange" #40143
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
Conversation
CC @NuriAmari |
Please don't merge until we verify that this was actually the commit that broke the source compatibility test suite. |
@swift-ci please test source compatibility |
Thanks @zoecarver! |
Slightly early to call, but seems that ProcedureKit and SwiftyStoreKit are passing in those two builds of the compatibility suite. Seems that both are related to |
Found the work around, at least for SwiftyStoreKit (ProcedureKit is a little bit more complicated to setup, but I think if it is not because of the same, it might be something related). If after https://github.com/apple/swift/blob/7afb4752791c3ca00a7e7de24716ec51c21e82ad/lib/ClangImporter/ImportDecl.cpp#L2926 one adds a line |
|
@NuriAmari and @drodriguez do you want to fix this or should I revert? |
@zoecarver revert with this one. We will resend the other one with whatever fix is needed and test it properly. |
Sounds good. Thanks, Daniel! @swift-ci please smoke test |
@swift-ci please smoke test Linux |
@swift-ci please smoke test Windows |
@swift-ci please test Windows |
@NuriAmari I didn't see the original PR, but I'd like to discuss whether we want the original change at all. (This is an awkward place to discuss it, so if you'd rather do that elsewhere, let me know.) I'm not convinced that it's a good idea to put translated Clang source locations into AST nodes for three reasons:
To be sure, in the cases where 3 is involved, it would be helpful to also see the Clang declaration. Perhaps the diagnostic engine could arrange to have an additional note emitted pointing to the imported declaration in the header file. But I don't think we should only emit at that source location. (This could also avoid eagerly importing source buffers we won't ever use just so that we can create Swift SourceLocs for them.) |
@swift-ci please smoke test linux. |
@beccadax Thanks for bringing these points to my attention, I wasn't aware of the first two. With this new information, I don't feel strongly that the original change is necessarily desirable. I simply needed a helper to translate Clang source locations for use in diagnostics and figured I would implement these methods rather than create a new one. I do have some questions / thoughts about the matter though.
I suppose my question is, it is somehow desirable or correct to provide empty SourceLocs, or is it more that providing valid source locations is a risky change, but one that would be an improvement if done correctly? If empty source locations are desired, perhaps it would make sense to replace some (if not all) calls to
Fair enough, my use case is entirely for producing diagnostics where which the ClangImporter fails, so there is no Swift Decl to speak of. I still think a sort of utility method for converting source locations would be helpful, lest the few lines required be repeated for every diagnostics. In another PR I've called this method |
I actually recently wrote a helper for diagnosing errors in headers, although it's not yet merged (or even code-reviewed): b372ff6 This is designed only for use in ClangImporter, and only for diagnostics we want to emit in headers, but it might be something we could extend further. |
Reverts #40010.
Verifying that this broke the source compatibility test suite.