From bafe90b0579a5619630c99be7fbdaad82aef208d Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 27 Apr 2017 15:10:33 +0000 Subject: [PATCH] [OPENMP] Add a check for iterator not reached the end of stack, NFC. Add an extra check for the iterator during checks of the data-sharing attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301549 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOpenMP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 9a19023658..43fd055bbc 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -828,14 +828,14 @@ DSAStackTy::hasDSA(ValueDecl *D, ? std::next(Stack.back().first.rbegin()) : Stack.back().first.rbegin(); auto EndI = Stack.back().first.rend(); - do { + while (std::distance(I, EndI) > 1) { std::advance(I, 1); if (!DPred(I->Directive) && !isParallelOrTaskRegion(I->Directive)) continue; DSAVarData DVar = getDSA(I, D); if (CPred(DVar.CKind)) return DVar; - } while (std::distance(I, EndI) > 1); + } return {}; } -- 2.50.1