[clang] f529c0a - Fix unused variable warning. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 11 05:49:07 PDT 2020


Author: Simon Pilgrim
Date: 2020-06-11T13:48:42+01:00
New Revision: f529c0a8a149ce6d027400a12a1637eda19e03b5

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

LOG: Fix unused variable warning. NFCI.

We're only using the D2 iteration value inside the assert (the only component of the loop) - move the entire loop inside the assert by using llvm::all_of.

Added: 
    

Modified: 
    clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
index 4edbeb30df1c..52789fdf5b9d 100644
--- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -19,10 +19,10 @@ class ParamRegionTestConsumer : public ExprEngineConsumer {
   void checkForSameParamRegions(MemRegionManager &MRMgr,
                                 const StackFrameContext *SFC,
                                 const ParmVarDecl *PVD) {
-    for (const auto *D2: PVD->redecls()) {
-      assert(MRMgr.getVarRegion(PVD, SFC) ==
-             MRMgr.getVarRegion(cast<ParmVarDecl>(D2), SFC));
-    }
+    assert(llvm::all_of(PVD->redecls(), [](const clang::VarDecl *D2) {
+      return MRMgr.getVarRegion(PVD, SFC) ==
+             MRMgr.getVarRegion(cast<ParmVarDecl>(D2), SFC)
+    }));
   }
 
   void performTest(const Decl *D) {


        


More information about the cfe-commits mailing list