]> granicus.if.org Git - clang/commitdiff
[analyzer] NFC: Remove dead checks when computing DeclStmt construction region.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 15 Feb 2018 02:30:20 +0000 (02:30 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 15 Feb 2018 02:30:20 +0000 (02:30 +0000)
In CFG, every DeclStmt has exactly one decl, which is always a variable.

It is also pointless to check that the initializer is the constructor because
that's how construction contexts work now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325201 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

index 31351402870c65bd66ee72f830389fbc7347b1da..1ff1ea49b7ab29e7cb59209212f611c17fdc3f15 100644 (file)
@@ -138,15 +138,12 @@ ExprEngine::getRegionForConstructedObject(const CXXConstructExpr *CE,
           }
         }
       } else if (auto *DS = dyn_cast<DeclStmt>(TriggerStmt)) {
-        if (const auto *Var = dyn_cast<VarDecl>(DS->getSingleDecl())) {
-          if (Var->getInit() && Var->getInit()->IgnoreImplicit() == CE) {
-            SVal LValue = State->getLValue(Var, LCtx);
-            QualType Ty = Var->getType();
-            LValue = makeZeroElementRegion(
-                State, LValue, Ty, CallOpts.IsArrayConstructorOrDestructor);
-            return LValue.getAsRegion();
-          }
-        }
+        const auto *Var = cast<VarDecl>(DS->getSingleDecl());
+        SVal LValue = State->getLValue(Var, LCtx);
+        QualType Ty = Var->getType();
+        LValue = makeZeroElementRegion(State, LValue, Ty,
+                                       CallOpts.IsArrayConstructorOrDestructor);
+        return LValue.getAsRegion();
       }
       // TODO: Consider other directly initialized elements.
     } else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {