[clang] ca94f28 - [clang] ExprEngine::VisitCXXNewExpr - remove superfluous nullptr tests
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 2 07:59:24 PST 2022
Author: Simon Pilgrim
Date: 2022-03-02T15:59:10Z
New Revision: ca94f28d15d53bb77ad347d6e374486475f86121
URL: https://github.com/llvm/llvm-project/commit/ca94f28d15d53bb77ad347d6e374486475f86121
DIFF: https://github.com/llvm/llvm-project/commit/ca94f28d15d53bb77ad347d6e374486475f86121.diff
LOG: [clang] ExprEngine::VisitCXXNewExpr - remove superfluous nullptr tests
FD has already been dereferenced
Added:
Modified:
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index ba105f34a9158..0a6127d800152 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -883,13 +883,10 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
// where new can return NULL. If we end up supporting that option, we can
// consider adding a check for it here.
// C++11 [basic.stc.dynamic.allocation]p3.
- if (FD) {
- QualType Ty = FD->getType();
- if (const auto *ProtoType = Ty->getAs<FunctionProtoType>())
- if (!ProtoType->isNothrow())
- if (auto dSymVal = symVal.getAs<DefinedOrUnknownSVal>())
- State = State->assume(*dSymVal, true);
- }
+ if (const auto *ProtoType = FD->getType()->getAs<FunctionProtoType>())
+ if (!ProtoType->isNothrow())
+ if (auto dSymVal = symVal.getAs<DefinedOrUnknownSVal>())
+ State = State->assume(*dSymVal, true);
}
StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
@@ -914,7 +911,7 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
// CXXNewExpr, we need to make sure that the constructed object is not
// immediately invalidated here. (The placement call should happen before
// the constructor call anyway.)
- if (FD && FD->isReservedGlobalPlacementOperator()) {
+ if (FD->isReservedGlobalPlacementOperator()) {
// Non-array placement new should always return the placement location.
SVal PlacementLoc = State->getSVal(CNE->getPlacementArg(0), LCtx);
Result = svalBuilder.evalCast(PlacementLoc, CNE->getType(),
More information about the cfe-commits
mailing list