[clang] b8ec430 - [Clang][Sema][OpenMP] Fix uninitialized variable Op
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 4 12:00:56 PST 2022
Author: Shilei Tian
Date: 2022-02-04T15:00:43-05:00
New Revision: b8ec430de71766d9a35a6b737c8a789c0c7cf812
URL: https://github.com/llvm/llvm-project/commit/b8ec430de71766d9a35a6b737c8a789c0c7cf812
DIFF: https://github.com/llvm/llvm-project/commit/b8ec430de71766d9a35a6b737c8a789c0c7cf812.diff
LOG: [Clang][Sema][OpenMP] Fix uninitialized variable Op
This can fix the case atomic_messages
Added:
Modified:
clang/lib/Sema/SemaOpenMP.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 4143e070a8738..7486e1389172c 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11063,8 +11063,18 @@ bool OpenMPAtomicCompareChecker::checkCondUpdateStmt(IfStmt *S,
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = S->getCond()->getSourceRange();
return false;
}
- if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
- Cond->getOpcode() != BO_GT) {
+
+ switch (Cond->getOpcode()) {
+ case BO_EQ:
+ Op = OMPAtomicCompareOp::EQ;
+ break;
+ case BO_LT:
+ Op = OMPAtomicCompareOp::MIN;
+ break;
+ case BO_GT:
+ Op = OMPAtomicCompareOp::MAX;
+ break;
+ default:
ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
@@ -11148,8 +11158,17 @@ bool OpenMPAtomicCompareChecker::checkCondExprStmt(Stmt *S,
return false;
}
- if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
- Cond->getOpcode() != BO_GT) {
+ switch (Cond->getOpcode()) {
+ case BO_EQ:
+ Op = OMPAtomicCompareOp::EQ;
+ break;
+ case BO_LT:
+ Op = OMPAtomicCompareOp::MIN;
+ break;
+ case BO_GT:
+ Op = OMPAtomicCompareOp::MAX;
+ break;
+ default:
ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
More information about the cfe-commits
mailing list