-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Fix clang reject valid C++ code after d999ce0302f06d250f6d496b56a5a5f #94471
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
The incremental processing mode doesn't seem to work well for C++.
@llvm/pr-subscribers-clang Author: Haojian Wu (hokein) ChangesThe 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:
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.
|
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.
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?
unfortunately, this seems to break an existing test:
|
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
|
Not sure how that happened. I meant llvm-project/clang/lib/Interpreter/IncrementalParser.cpp Lines 416 to 417 in 70550cd
|
I have update a new version, please take a second look. |
The incremental processing mode doesn't seem to work well for C++, see the llvm#89804 (comment) for details. This patches in llvm#94471 as well as applies some followup comments.
@@ -413,7 +413,9 @@ 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() && | |||
CI->getPreprocessor().isIncrementalProcessingEnabled() && |
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.
Here the incremental processing is guaranteed. We do not need to check.
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.
good point. Removed.
✅ With the latest revision this PR passed the C/C++ code formatter. |
I'm landing it now to unblock our integration. I'm happy to address any post comments. |
The incremental processing mode doesn't seem to work well for C++, see the #89804 (comment) for details.