From: Alexey Bataev Date: Tue, 24 Dec 2019 21:02:58 +0000 (-0500) Subject: [OPENMP]Add extra checks and initialization for clause modifier. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3732f4e093f9aed7aad9740e460e00a248f28572;p=platform%2Fupstream%2Fllvm.git [OPENMP]Add extra checks and initialization for clause modifier. Added initialization of the extra modifier to silence sanitizer. Added extra checks to avoid such trouble in future. --- diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 3e8c75b..a62c68b 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -735,10 +735,12 @@ static bool parseDeclareSimdClauses( CKind == OMPC_linear) { Parser::OpenMPVarListDataTy Data; SmallVectorImpl *Vars = &Uniforms; - if (CKind == OMPC_aligned) + if (CKind == OMPC_aligned) { Vars = &Aligneds; - else if (CKind == OMPC_linear) + } else if (CKind == OMPC_linear) { + Data.ExtraModifier = OMPC_LINEAR_val; Vars = &Linears; + } P.ConsumeToken(); if (P.ParseOpenMPVarList(OMPD_declare_simd, @@ -747,6 +749,9 @@ static bool parseDeclareSimdClauses( if (CKind == OMPC_aligned) { Alignments.append(Aligneds.size() - Alignments.size(), Data.TailExpr); } else if (CKind == OMPC_linear) { + assert(0 <= Data.ExtraModifier && + Data.ExtraModifier <= OMPC_LINEAR_unknown && + "Unexpected linear modifier."); if (P.getActions().CheckOpenMPLinearModifier( static_cast(Data.ExtraModifier), Data.DepLinMapLastLoc)) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 404ca50..f19cf43 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -12418,6 +12418,8 @@ OMPClause *Sema::ActOnOpenMPVarListClause( Res = ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_lastprivate: + assert(0 <= ExtraModifier && ExtraModifier <= OMPC_LASTPRIVATE_unknown && + "Unexpected lastprivate modifier."); Res = ActOnOpenMPLastprivateClause( VarList, static_cast(ExtraModifier), DepLinMapLastLoc, ColonLoc, StartLoc, LParenLoc, EndLoc); @@ -12441,6 +12443,8 @@ OMPClause *Sema::ActOnOpenMPVarListClause( ReductionOrMapperId); break; case OMPC_linear: + assert(0 <= ExtraModifier && ExtraModifier <= OMPC_LINEAR_unknown && + "Unexpected linear modifier."); Res = ActOnOpenMPLinearClause( VarList, TailExpr, StartLoc, LParenLoc, static_cast(ExtraModifier), DepLinMapLastLoc, @@ -12460,11 +12464,15 @@ OMPClause *Sema::ActOnOpenMPVarListClause( Res = ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_depend: + assert(0 <= ExtraModifier && ExtraModifier <= OMPC_DEPEND_unknown && + "Unexpected depend modifier."); Res = ActOnOpenMPDependClause( static_cast(ExtraModifier), DepLinMapLastLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_map: + assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown && + "Unexpected map modifier."); Res = ActOnOpenMPMapClause( MapTypeModifiers, MapTypeModifiersLoc, ReductionOrMapperIdScopeSpec, ReductionOrMapperId, static_cast(ExtraModifier),