[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
hokein wrote: I'm landing it now to unblock our integration. I'm happy to address any post comments. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/4] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f2dc331e61 The incremental processing mode doesn't seem to work well for C++. --- clang/lib/Sema/SemaDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. >From 5d3e60cc5839fece4f3f8d8d158ae562d7604580 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 20:34:30 +0200 Subject: [PATCH 2/4] Fix more --- clang/lib/Interpreter/IncrementalParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index 5bc8385d874a1..bbc6d3addb085 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI->getPreprocessor().isIncrementalProcessingEnabled() && +!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } } >From 59b94757009ceae2a7fe685afd42d933b18cf3dc Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 21:11:25 +0200 Subject: [PATCH 3/4] address review comment. --- clang/lib/Interpreter/IncrementalParser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index bbc6d3addb085..f709875379d7b 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -414,7 +414,6 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { continue; // Check if we need to clean up the IdResolver chain. if (ND->getDeclName().getFETokenInfo() && -CI->getPreprocessor().isIncrementalProcessingEnabled() && !D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } >From 8894026730a65e9f3f352544d3a04251d2b246f1 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 21:30:02 +0200 Subject: [PATCH 4/4] clang-format --- clang/lib/Interpreter/IncrementalParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index f709875379d7b..a8d0294fb6151 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -413,8 +413,8 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo() && -!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) +if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC && +!D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 2d9b83750fea782276ec1f70157122b0b7d1856e 59b94757009ceae2a7fe685afd42d933b18cf3dc -- clang/lib/Interpreter/IncrementalParser.cpp clang/lib/Sema/SemaDecl.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index f709875379..a8d0294fb6 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -413,8 +413,8 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo() && -!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) +if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC && +!D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } } `` https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
@@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI->getPreprocessor().isIncrementalProcessingEnabled() && hokein wrote: good point. Removed. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/3] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f2dc331e61 The incremental processing mode doesn't seem to work well for C++. --- clang/lib/Sema/SemaDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. >From 5d3e60cc5839fece4f3f8d8d158ae562d7604580 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 20:34:30 +0200 Subject: [PATCH 2/3] Fix more --- clang/lib/Interpreter/IncrementalParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index 5bc8385d874a1..bbc6d3addb085 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI->getPreprocessor().isIncrementalProcessingEnabled() && +!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } } >From 59b94757009ceae2a7fe685afd42d933b18cf3dc Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 21:11:25 +0200 Subject: [PATCH 3/3] address review comment. --- clang/lib/Interpreter/IncrementalParser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index bbc6d3addb085..f709875379d7b 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -414,7 +414,6 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { continue; // Check if we need to clean up the IdResolver chain. if (ND->getDeclName().getFETokenInfo() && -CI->getPreprocessor().isIncrementalProcessingEnabled() && !D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
@@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI->getPreprocessor().isIncrementalProcessingEnabled() && vgvassilev wrote: Here the incremental processing is guaranteed. We do not need to check. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
hokein wrote: I have update a new version, please take a second look. https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/94471 >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH 1/2] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f2dc331e61 The incremental processing mode doesn't seem to work well for C++. --- clang/lib/Sema/SemaDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. >From 5d3e60cc5839fece4f3f8d8d158ae562d7604580 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 20:34:30 +0200 Subject: [PATCH 2/2] Fix more --- clang/lib/Interpreter/IncrementalParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index 5bc8385d874a1..bbc6d3addb085 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -413,7 +413,9 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit ) { if (!ND) continue; // Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) +if (ND->getDeclName().getFETokenInfo() && +CI->getPreprocessor().isIncrementalProcessingEnabled() && +!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus) getCI()->getSema().IdResolver.RemoveDecl(ND); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
vgvassilev wrote: > > Oh, we need to adjust > > https://github.com/root-project/root/blob/be5d34934de883270683030b3af2cd1195d17ea8/cmake/modules/RootMacros.cmake#L272 > > to skip in case of C++... > > The link points to an irrelevant project, I assume you mean here > https://github.com/llvm/llvm-project/blob/main/clang/lib/Interpreter/IncrementalParser.cpp#L416? > If we need to skip for C++, I think we should do it for ObjectiveC as well, > like > > ``` > if (ND->getDeclName().getFETokenInfo() && > !(!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC || > getLangOpts().CPlusPlus)) { >... > } > ``` Not sure how that happened. I meant https://github.com/llvm/llvm-project/blob/70550cd6aa9f2587e166d6ab9636192af3f3264d/clang/lib/Interpreter/IncrementalParser.cpp#L416-L417 https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
hokein wrote: > Oh, we need to adjust > https://github.com/root-project/root/blob/be5d34934de883270683030b3af2cd1195d17ea8/cmake/modules/RootMacros.cmake#L272 > to skip in case of C++... The link points to an irrelevant project, I assume you mean here https://github.com/llvm/llvm-project/blob/main/clang/lib/Interpreter/IncrementalParser.cpp#L416? If we need to skip for C++, I think we should do it for ObjectiveC as well, like ``` if (ND->getDeclName().getFETokenInfo() && !(!PP.isIncrementalProcessingEnabled() || getLangOpts().ObjC || getLangOpts().CPlusPlus)) { ... } ``` https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
vgvassilev wrote: Oh, we need to adjust https://github.com/root-project/root/blob/be5d34934de883270683030b3af2cd1195d17ea8/cmake/modules/RootMacros.cmake#L272 to skip in case of C++... https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
hokein wrote: unfortunately, this seems to break an existing test: ``` OK ] InterpreterTest.IncrementalInputTopLevelDecls (66 ms) [ RUN ] InterpreterTest.Errors ClangReplInterpreterTests: /usr/local/google/home/hokein/workspace/llvm-project/clang/lib/Sema/IdentifierResolver.cpp:228: void clang::IdentifierResolver::RemoveDecl(NamedDecl *): Assertion `Ptr && "Didn't find this decl on its identifier's chain!"' failed. #0 0x5591835285e1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (tools/clang/unittests/Interpreter/ClangReplInterpreterTests+0xa4e45e1) #1 0x559183528b9b PrintStackTraceSignalHandler(void*) Signals.cpp:0:0 #2 0x559183526356 llvm::sys::RunSignalHandlers() (tools/clang/unittests/Interpreter/ClangReplInterpreterTests+0xa4e2356) #3 0x559183529d35 SignalHandler(int) Signals.cpp:0:0 #4 0x7f5baf25a510 (/lib/x86_64-linux-gnu/libc.so.6+0x3c510) #5 0x7f5baf2a816 ``` https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/vgvassilev approved this pull request. LGTM, can you include the produced errors and the steps to reproduce the failure in the commit log? Or refer to the github post describing it? https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haojian Wu (hokein) Changes The incremental processing mode doesn't seem to work well for C++. --- Full diff: https://github.com/llvm/llvm-project/pull/94471.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaDecl.cpp (+2-1) ``diff 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. `` https://github.com/llvm/llvm-project/pull/94471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f (PR #94471)
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/94471 The incremental processing mode doesn't seem to work well for C++. >From 8457c4aa1758d10188da5978d30d2d1ed505e01e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 5 Jun 2024 15:46:56 +0200 Subject: [PATCH] Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f2dc331e61 The incremental processing mode doesn't seem to work well for C++. --- clang/lib/Sema/SemaDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits