[PATCH] D81522: Fix variables used only in asserts.

Sterling Augustine via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 17:42:54 PDT 2020


saugustine created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
saugustine edited the summary of this revision.
saugustine added a reviewer: baloghadamsoftware.
Herald added a subscriber: rnkovacs.

Fix variables used only in asserts.

For post-commit review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81522

Files:
  clang/unittests/StaticAnalyzer/ParamRegionTest.cpp


Index: clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
===================================================================
--- clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
+++ clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -20,8 +20,8 @@
                                 const StackFrameContext *SFC,
                                 const ParmVarDecl *PVD) {
     for (const auto *D2: PVD->redecls()) {
-      const auto *PVD2 = cast<ParmVarDecl>(D2);
-      assert(MRMgr.getVarRegion(PVD, SFC) == MRMgr.getVarRegion(PVD2, SFC));
+      assert(MRMgr.getVarRegion(PVD, SFC) ==
+             MRMgr.getVarRegion(cast<ParmVarDecl>(D2), SFC));
     }
   }
 
@@ -33,29 +33,26 @@
 
     if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
       for (const auto *P : FD->parameters()) {
-        const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC);
         if (SFC->inTopFrame())
-          assert(isa<NonParamVarRegion>(Reg));
+          assert(isa<NonParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         else
-          assert(isa<ParamVarRegion>(Reg));
+          assert(isa<ParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         checkForSameParamRegions(MRMgr, SFC, P);
       }
     } else if (const auto *CD = dyn_cast<CXXConstructorDecl>(D)) {
       for (const auto *P : CD->parameters()) {
-        const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC);
         if (SFC->inTopFrame())
-          assert(isa<NonParamVarRegion>(Reg));
+          assert(isa<NonParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         else
-          assert(isa<ParamVarRegion>(Reg));
+          assert(isa<ParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         checkForSameParamRegions(MRMgr, SFC, P);
       }
     } else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
       for (const auto *P : MD->parameters()) {
-        const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC);
         if (SFC->inTopFrame())
-          assert(isa<NonParamVarRegion>(Reg));
+          assert(isa<NonParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         else
-          assert(isa<ParamVarRegion>(Reg));
+          assert(isa<ParamVarRegion>(MRMgr.getVarRegion(P, SFC)));
         checkForSameParamRegions(MRMgr, SFC, P);
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81522.269708.patch
Type: text/x-patch
Size: 2242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200610/09f4387e/attachment-0001.bin>


More information about the cfe-commits mailing list