r301549 - [OPENMP] Add a check for iterator not reached the end of stack, NFC.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 27 08:10:33 PDT 2017


Author: abataev
Date: Thu Apr 27 10:10:33 2017
New Revision: 301549

URL: http://llvm.org/viewvc/llvm-project?rev=301549&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301549&r1=301548&r2=301549&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 27 10:10:33 2017
@@ -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 {};
 }
 




More information about the cfe-commits mailing list