Skip to content

[clang][include-tree] Load even spurious modular dependencies (cherry-pick) #8156

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

Conversation

jansvoboda11
Copy link

No description provided.

…allback (llvm#81061)

This patch provides more information to the
`PPCallbacks::InclusionDirective()` hook. We now always pass the
suggested module, regardless of whether it was actually imported or not.
The extra `bool ModuleImported` parameter then denotes whether the
header `#include` will be automatically translated into import the the
module.

The main change is in `clang/lib/Lex/PPDirectives.cpp`, where we take
care to not modify `SuggestedModule` after it's been populated by
`LookupHeaderIncludeOrImport()`. We now exclusively use the `SM`
(`ModuleToImport`) variable instead, which has been equivalent to
`SuggestedModule` until now. This allows us to use the original
non-modified `SuggestedModule` for the callback itself.

(This patch turns out to be necessary for
#8011).

(cherry picked from commit da95d92)
With implicit modules, some modular dependencies can be "spurious". By that I mean that `#include "Header.h"` results in a PCM file load, but the header ends up being included textually anyways. (This can happen in situations that would trigger the `-Wincomplete-umbrella` warning.)

This patch ensures this behavior is preserved with include-tree. Previously, include-tree would simply textually include the header file and skip the PCM file load. This now ensures consistent behavior in edge-cases like the one in the attached test case (with `-fmodule-name=X`).

rdar://121220983
(cherry picked from commit b230339)
@jansvoboda11
Copy link
Author

@swift-ci please test
swiftlang/swift#71475

@jansvoboda11
Copy link
Author

swiftlang/swift#71475
@swift-ci please test

1 similar comment
@jansvoboda11
Copy link
Author

swiftlang/swift#71475
@swift-ci please test

@jansvoboda11 jansvoboda11 merged commit ed12e34 into stable/20230725 Feb 9, 2024
@jansvoboda11 jansvoboda11 deleted the jan_svoboda/20230726-include-tree-spurious-deps branch February 9, 2024 04:17
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.

1 participant