[clang] 3beb232 - Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (#94471)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 12:42:47 PDT 2024


Author: Haojian Wu
Date: 2024-06-05T21:42:44+02:00
New Revision: 3beb232fb4fd1943155174d58a454493828cd719

URL: https://github.com/llvm/llvm-project/commit/3beb232fb4fd1943155174d58a454493828cd719
DIFF: https://github.com/llvm/llvm-project/commit/3beb232fb4fd1943155174d58a454493828cd719.diff

LOG: Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (#94471)

The incremental processing mode doesn't seem to work well for C++, see
the
https://github.com/llvm/llvm-project/pull/89804#issuecomment-2149840711
for details.

Added: 
    

Modified: 
    clang/lib/Interpreter/IncrementalParser.cpp
    clang/lib/Sema/SemaDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index 5bc8385d874a1..a8d0294fb6151 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -413,7 +413,8 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
     if (!ND)
       continue;
     // Check if we need to clean up the IdResolver chain.
-    if (ND->getDeclName().getFETokenInfo())
+    if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
+        !D->getLangOpts().CPlusPlus)
       getCI()->getSema().IdResolver.RemoveDecl(ND);
   }
 }

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a6734ef8c30aa..4b9b735f1cfb4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2288,7 +2288,8 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
     // Partial translation units that are created in incremental processing must
     // not clean up the IdResolver because PTUs should take into account the
     // declarations that came from previous PTUs.
-    if (!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC)
+    if (!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC ||
+        getLangOpts().CPlusPlus)
       IdResolver.RemoveDecl(D);
 
     // Warn on it if we are shadowing a declaration.


        


More information about the cfe-commits mailing list