Skip to content

Commit

Permalink
[clang][Sema] Always clear UndefinedButUsed (#73955)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
hahnjo committed Dec 12, 2023
1 parent 4b4dcb4 commit ac61640
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit ac61640

Please sign in to comment.