Skip to content

Commit 3beb232

Browse files
authored
Fix clang reject valid C++ code after d999ce0 (#94471)
The incremental processing mode doesn't seem to work well for C++, see the #89804 (comment) for details.
1 parent 73a2fd4 commit 3beb232

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/Interpreter/IncrementalParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
413413
if (!ND)
414414
continue;
415415
// Check if we need to clean up the IdResolver chain.
416-
if (ND->getDeclName().getFETokenInfo())
416+
if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
417+
!D->getLangOpts().CPlusPlus)
417418
getCI()->getSema().IdResolver.RemoveDecl(ND);
418419
}
419420
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,8 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
22882288
// Partial translation units that are created in incremental processing must
22892289
// not clean up the IdResolver because PTUs should take into account the
22902290
// declarations that came from previous PTUs.
2291-
if (!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC)
2291+
if (!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC ||
2292+
getLangOpts().CPlusPlus)
22922293
IdResolver.RemoveDecl(D);
22932294

22942295
// Warn on it if we are shadowing a declaration.

0 commit comments

Comments
 (0)