[OPENMP] Add a check for iterator not reached the end of stack, NFC.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 27 Apr 2017 15:10:33 +0000 (15:10 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 27 Apr 2017 15:10:33 +0000 (15:10 +0000)
Add an extra check for the iterator during checks of the data-sharing
attributes.

llvm-svn: 301549

clang/lib/Sema/SemaOpenMP.cpp

index 9a19023..43fd055 100644 (file)
@@ -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 {};
 }