Skip to content

[clang][include-tree] Fix spurious dependencies #8264

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 4 commits into from
Feb 27, 2024

Conversation

jansvoboda11
Copy link

@jansvoboda11 jansvoboda11 commented Feb 22, 2024

This patch fixes an incorrect assumption that only spurious imports cause both IncludeTreeBuilder::moduleImport() and IncludeTreeBuilder::exitedInclude() to be called for the same directive. This can also happen for #include of a header that belongs to the module being implemented that previously got transitively loaded from a PCM.

Instead of trying to guess that a submodule was a spurious import (by checking that it was not imported, is not from module file but its parent is from module file), we just mark it missing from umbrella header when we detect this. This allows us to stop putting the temporary ModuleImport onto the stack in one function and later popping and replacing it by SpuriousImport in another function.

rdar://123253616

jansvoboda11 added a commit that referenced this pull request Feb 22, 2024
This patch fixes an incorrect assumption that only spurious imports cause both `IncludeTreeBuilder::moduleImport()` and `IncludeTreeBuilder::exitedInclude()` to be called for the same directive. This can also happen for `#include` of a header that belongs to the module being implemented that previously got transitively loaded from a PCM.

Instead of trying to guess that a submodule was a spurious import (by checking that it was not imported, is not from module file but its parent is from module file), we just mark it missing from umbrella header when we detect this. This allows us to stop putting the temporary `ModuleImport` onto the stack in one function and later popping and replacing it by `SpuriousImport` in another function.

rdar://123253616

Cherry-pick of /pull/8264
@jansvoboda11 jansvoboda11 merged commit 27c09ae into next Feb 27, 2024
@jansvoboda11 jansvoboda11 deleted the jan_svoboda/include-tree-spurious-fix branch February 27, 2024 03:44
jansvoboda11 added a commit that referenced this pull request Feb 27, 2024
This patch fixes an incorrect assumption that only spurious imports cause both `IncludeTreeBuilder::moduleImport()` and `IncludeTreeBuilder::exitedInclude()` to be called for the same directive. This can also happen for `#include` of a header that belongs to the module being implemented that previously got transitively loaded from a PCM.

Instead of trying to guess that a submodule was a spurious import (by checking that it was not imported, is not from module file but its parent is from module file), we just mark it missing from umbrella header when we detect this. This allows us to stop putting the temporary `ModuleImport` onto the stack in one function and later popping and replacing it by `SpuriousImport` in another function.

rdar://123253616

Cherry-pick of /pull/8264
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