[Clang][Sema][OpenMP] Fix uninitialized variable Op

This can fix the case atomic_messages
This commit is contained in:
Shilei Tian 2022-02-04 15:00:36 -05:00
parent 254ee89c7a
commit b8ec430de7
1 changed files with 23 additions and 4 deletions

View File

@ -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();