-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[cxxmodules] Avoid lookup from system headers #11514
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
|
Starting build on |
|
@junaire, can you test if this solves also your problems? |
| auto *D = dyn_cast<Decl>(DC); | ||
| if (D) { | ||
| SourceLocation Loc = D->getLocation(); | ||
| if (Loc.isValid() && SemaR.getSourceManager().isInSystemHeader(Loc)) { |
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.
We could ask if Decls OwningModule is a system one. This way we could "annotate" modules which we do not need to mess with. We consider modules starting with ROOT_ system modules because a pure [system] tag also changes a little the semantics of the whole thing but I think we are fine to do that check here.
I think we probably can explore a little more the heuristics you came up with as it looks promising. Namely, can a declaration context of a module be 'extended with' declarations from a module that is not listed among the module dependencies? I suspect the only cases where this can happen is friend declarations and ADL lookups. I don't think we need to support that... Eg. what happens if we have a module that adds another std::swap with MyClass parameter - are we expected to autoload the module exporting MyClass?
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.
I like asking the OwningModule and changed both the existing and the new check 😃
I think we probably can explore a little more the heuristics you came up with as it looks promising.
Yes, we likely need to understand the other failure modes and then abstract that to a heuristic / check that we can add here. For now I just want to make both LookupObject methods bail out on the same conditions, namely a Decl coming from a system module.
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.
Hm well, I guess this doesn't work for the nortcxxmod case? 😬
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.
I don't think we care for the nortcxxmod as the PCH is preloaded and we don't react to entities that come from an ASTFile. I don't think we have "system" headers which are not in the PCH.
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.
I reverted back to asking isInSystemHeader which did better in the tests...
I haven't tested this, but @hahnjo said this almost fixes my issue in #10910, only I also made my own fix (4757b60) and I feel like it may be a better direction to work on (even though it also failed to fix |
FWIW I pushed a new commit to #10910 and it looks like surprisingly fixes all issues even without preloading |
OK, so we still got some failures but I can't see it locally. I'll try to reproduce them, but I feel like that's the right direction. CC @hahnjo @vgvassilev |
|
@vgvassilev as I wrote on Mattermost, this change was particularly written to address Jun's problem. FWIW I don't agree that the workarounds (hacks) introduced in #10910 are a good way to go, as shown by the many failing tests. The scope of the changes is too big and there are valid reasons to do something with |
The "workaround" introduced in #10910 is not only intended to address my problem but also serves as a more generic fix. It makes more sense right? disable the callback when we're instantiating templates.
Ahh... yes and no, actually we're almost getting there. Currently, it is just some strange failures in some specific build bots ( I'm not really sure which way is the best to go, we still need time to discover, can you check if that patch fixes your issue? Also, I would appreciate it if you can take a look at the failures to see if you have a clue or not :) |
|
@junaire tests should be clean in CI builds, as you can see for this PR. Any failures are introduced by the code changes, possibly due to exposing other issues (as was the case here, leading to this fix). And it's not only some obscure platforms, but both macOS and two of the three Linux platforms. But we should discuss this on the PR itself, not here... |
Sorry about discussing unrelated content here, I sent you a message in mattermost. Anyway, thanks for your help! |
|
Starting build on |
|
Build failed on ROOT-ubuntu2004/python3. Errors:
|
|
Build failed on ROOT-ubuntu18.04/nortcxxmod. Failing tests: |
|
Build failed on windows10/cxx14. Failing tests: |
|
This change looks good to me, do we have a plan what to do with the current failures? |
|
@vgvassilev the failure is in a |
I suspect that PS: On a second thought that would probably fail elsewhere.. |
Avoid loading ROOT modules while Clang is instantiating a template class from STL, leading to ODR checks with an incomplete class.
|
Starting build on |
|
Build failed on ROOT-ubuntu2004/python3. Failing tests: |
|
Build failed on ROOT-ubuntu18.04/nortcxxmod. Errors:
|
|
ping... |
As long as we do before hand the side effects. ie seeing |
vgvassilev
left a comment
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.
This looks good to me assuming @pcanal does not have objections.
pcanal
left a comment
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.
Thanks.
Avoid loading ROOT modules while Clang is instantiating a template class from STL, leading to ODR checks with an incomplete class.