Author: Yang Fan
Date: 2020-09-01T08:45:38-04:00
New Revision: 2114f71aaa8dc2e75fe9cd79aa4d72d164e9b95d

URL: 
https://github.com/llvm/llvm-project/commit/2114f71aaa8dc2e75fe9cd79aa4d72d164e9b95d
DIFF: 
https://github.com/llvm/llvm-project/commit/2114f71aaa8dc2e75fe9cd79aa4d72d164e9b95d.diff

LOG: [OpenMP] Fix infinite loop in Sema::isOpenMPGlobalCapturedDecl()

Function Sema::isOpenMPGlobalCapturedDecl() has a parameter `unsigned Level`,
but use `Level >= 0` as the condition of `while`, thus cause an infinite loop.
Fix by changing the loop condition to `Level > 0`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D86858

Added: 
    

Modified: 
    clang/lib/Sema/SemaOpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 7b62c841b48a2..352f52d2f6260 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2430,7 +2430,7 @@ bool Sema::isOpenMPGlobalCapturedDecl(ValueDecl *D, 
unsigned Level,
         DSAStackTy::DSAVarData DVar = DSAStack->getImplicitDSA(D, Level);
         if (DVar.CKind != OMPC_shared)
           return true;
-      } while (Level >= 0);
+      } while (Level > 0);
     }
   }
   return true;


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to