-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[clang][Sema] Always clear UndefinedButUsed #73955
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
Before, it was only cleared if there were undefined entities. This is important for Clang's incremental parsing as used by clang-repl that might receive multiple calls to Sema.ActOnEndOfTranslationUnit.
@llvm/pr-subscribers-clang Author: Jonas Hahnfeld (hahnjo) ChangesBefore, it was only cleared if there were undefined entities. This is important for Clang's incremental parsing as used by Full diff: https://github.com/llvm/llvm-project/pull/73955.diff 1 Files Affected:
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 9771aaa2f3b0371..d08f8cd56b39bde 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -870,6 +870,7 @@ static void checkUndefinedButUsed(Sema &S) {
// Collect all the still-undefined entities with internal linkage.
SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined;
S.getUndefinedButUsed(Undefined);
+ S.UndefinedButUsed.clear();
if (Undefined.empty()) return;
for (const auto &Undef : Undefined) {
@@ -923,8 +924,6 @@ static void checkUndefinedButUsed(Sema &S) {
if (UseLoc.isValid())
S.Diag(UseLoc, diag::note_used_here);
}
-
- S.UndefinedButUsed.clear();
}
void Sema::LoadExternalWeakUndeclaredIdentifiers() {
|
Can you add a test? |
I will try, but observing the consequences of this depends on unloading: Basically it happens if a declaration in |
I think I understand. @AaronBallman from what concerns me that change seems fine it'd be hard to add a test for it right now. Do you have any concerns? |
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'm okay landing these changes without test coverage, though tests are always preferred. LGTM
I tried to craft a test here, but declaration unloading in On a high level, the problem should be triggered by:
In principle, the The slightly more complex
ie unloading the entire class doesn't work either for the same reason, we never actually treat the instantiated member function. (Subsequently this leads to the entire |
In principle we could add this test as an xfail to make sure we have this scenario when unloading support is up to that stage. |
Before, it was only cleared if there were undefined entities. This is important for Clang's incremental parsing as used by
clang-repl
that might receive multiple calls toSema.ActOnEndOfTranslationUnit
.