-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[Clang][OpenMP] fixed crash due to invalid binary expression in checking atomic semantics #71480
Conversation
…ic semantic checker
@llvm/pr-subscribers-clang Author: Chia (sun-jacobi) ChangesThis PR fixes #69069 . Full diff: https://github.com/llvm/llvm-project/pull/71480.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1bd34f73e5f7e00..e05fa54d8118319 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11605,6 +11605,9 @@ class OpenMPAtomicUpdateChecker {
/// RHS binary operation does not have reference to the updated LHS
/// part.
NotAnUpdateExpression,
+ /// An expression contains semantical error not related to
+ /// 'omp atomic [update]'
+ NotAValidExpression,
/// No errors is found.
NoError
};
@@ -11782,6 +11785,10 @@ bool OpenMPAtomicUpdateChecker::checkStatement(Stmt *S, unsigned DiagId,
ErrorFound = NotABinaryOrUnaryExpression;
NoteLoc = ErrorLoc = AtomicBody->getExprLoc();
NoteRange = ErrorRange = AtomicBody->getSourceRange();
+ } else if (AtomicBody->containsErrors()) {
+ ErrorFound = NotAValidExpression;
+ NoteLoc = ErrorLoc = AtomicBody->getExprLoc();
+ NoteRange = ErrorRange = AtomicBody->getSourceRange();
}
} else {
ErrorFound = NotAScalarType;
|
This doesn't look like the right place to fix this issue to me. @alexey-bataev might have better suggestion. |
The crash occurs at llvm-project/clang/lib/Sema/SemaOpenMP.cpp Line 13011 in d34a10a
The reason why I fixed the issue like this is that, I think here The llvm-project/clang/lib/Sema/SemaOpenMP.cpp Line 12994 in d34a10a
This function returns |
Moreover, in the original implementation, the In my opinion, for such a case, it should be considered as an invalid statement. |
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.
Looks like correct fix to me.
I have merged it given our front end expert @alexey-bataev has approved it. |
This PR fixes #69069 .