From 60859c068a6ab6880b5c34aad58e48fe1fee3075 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. llvm-svn: 301549 --- clang/lib/Sema/SemaOpenMP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 9a19023..43fd055 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/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.7.4