Skip to content

Commit 8bb56ce

Browse files
committed
remove redundant vector
1 parent a2a7346 commit 8bb56ce

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,30 +1237,27 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A,
12371237
void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E,
12381238
ExplodedNode *Pred,
12391239
ExplodedNodeSet &Dst) {
1240-
StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
1240+
const LocationContext *LC = Pred->getLocationContext();
12411241

1242+
StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
12421243
ProgramStateRef S = Pred->getState();
1243-
QualType T = getContext().getCanonicalType(E->getType());
12441244

1245-
const LocationContext *LCtx = Pred->getLocationContext();
1245+
QualType T = E->getType().getCanonicalType();
1246+
ArrayRef<Expr *> Inits = E->getInitExprs();
12461247

1247-
SmallVector<SVal, 4> ArgVals;
1248-
for (Expr *Arg : E->getInitExprs())
1249-
ArgVals.push_back(S->getSVal(Arg, LCtx));
1250-
1251-
if (!E->isGLValue() && (T->isRecordType() || T->isArrayType())) {
1248+
if (Inits.size() > 1 ||
1249+
(E->isPRValue() && (T->isRecordType() || T->isArrayType()))) {
12521250
llvm::ImmutableList<SVal> ArgList = getBasicVals().getEmptySValList();
1253-
1254-
for (const SVal &V : llvm::reverse(ArgVals))
1255-
ArgList = getBasicVals().prependSVal(V, ArgList);
1251+
for (Expr *E : llvm::reverse(Inits))
1252+
ArgList = getBasicVals().prependSVal(S->getSVal(E, LC), ArgList);
12561253

12571254
Bldr.generateNode(
1258-
E, Pred, S->BindExpr(E, LCtx, svalBuilder.makeCompoundVal(T, ArgList)));
1255+
E, Pred, S->BindExpr(E, LC, svalBuilder.makeCompoundVal(T, ArgList)));
12591256
} else {
12601257
Bldr.generateNode(E, Pred,
1261-
S->BindExpr(E, LCtx,
1262-
ArgVals.empty()
1258+
S->BindExpr(E, LC,
1259+
Inits.size() == 0
12631260
? getSValBuilder().makeZeroVal(T)
1264-
: ArgVals.front()));
1261+
: S->getSVal(Inits.front(), LC)));
12651262
}
12661263
}

0 commit comments

Comments
 (0)