Fix unused variable warning. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 11 Jun 2020 12:48:42 +0000 (13:48 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 11 Jun 2020 12:48:42 +0000 (13:48 +0100)
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.

clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

index 4edbeb3..52789fd 100644 (file)
@@ -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) {