Skip to content

Commit 354ffb9

Browse files
committed
Rebase and address comments
Signed-off-by: yronglin <[email protected]>
1 parent b806f12 commit 354ffb9

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,11 +1964,11 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
19641964
case Stmt::CXXDefaultArgExprClass:
19651965
case Stmt::CXXDefaultInitExprClass: {
19661966
Bldr.takeNodes(Pred);
1967-
ExplodedNodeSet CheckedSet;
1968-
getCheckerManager().runCheckersForPreStmt(CheckedSet, Pred, S, *this);
1967+
ExplodedNodeSet PreVisit;
1968+
getCheckerManager().runCheckersForPreStmt(PreVisit, Pred, S, *this);
19691969

19701970
ExplodedNodeSet Tmp;
1971-
StmtNodeBuilder Bldr2(CheckedSet, Tmp, *currBldrCtx);
1971+
StmtNodeBuilder Bldr2(PreVisit, Tmp, *currBldrCtx);
19721972

19731973
bool HasRewrittenInit = false;
19741974
const Expr *ArgE = nullptr;
@@ -1982,12 +1982,11 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
19821982
llvm_unreachable("unknown constant wrapper kind");
19831983

19841984
if (HasRewrittenInit) {
1985-
for (auto *I : CheckedSet) {
1986-
ProgramStateRef state = (*I).getState();
1987-
const LocationContext *LCtx = (*I).getLocationContext();
1988-
SVal Val = state->getSVal(ArgE, LCtx);
1989-
state = state->BindExpr(S, LCtx, Val);
1990-
Bldr2.generateNode(S, I, state);
1985+
for (auto *N : PreVisit) {
1986+
ProgramStateRef state = N->getState();
1987+
const LocationContext *LCtx = N->getLocationContext();
1988+
state = state->BindExpr(S, LCtx, state->getSVal(ArgE, LCtx));
1989+
Bldr2.generateNode(S, N, state);
19911990
}
19921991
} else {
19931992
// If it's not rewritten, the contents of these expressions are not
@@ -2000,13 +1999,10 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
20001999
}
20012000

20022001
std::optional<SVal> ConstantVal = svalBuilder.getConstantVal(ArgE);
2003-
if (!ConstantVal)
2004-
ConstantVal = UnknownVal();
2005-
20062002
const LocationContext *LCtx = Pred->getLocationContext();
2007-
for (auto *I : CheckedSet) {
2003+
for (auto *I : PreVisit) {
20082004
ProgramStateRef State = I->getState();
2009-
State = State->BindExpr(S, LCtx, *ConstantVal);
2005+
State = State->BindExpr(S, LCtx, ConstantVal.value_or(UnknownVal()));
20102006
if (IsTemporary)
20112007
State = createTemporaryRegionIfNeeded(State, LCtx, cast<Expr>(S),
20122008
cast<Expr>(S));

clang/test/Analysis/cxx-uninitialized-object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_analyze_cc1 -std=c++14 -verify=expected,pedantic %s \
1+
// RUN: %clang_analyze_cc1 -std=c++14 -verify %s \
22
// RUN: -analyzer-checker=core \
33
// RUN: -analyzer-checker=optin.cplusplus.UninitializedObject \
44
// RUN: -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
@@ -1123,7 +1123,7 @@ struct CXX11MemberInitTest2 {
11231123
RecordType(int) {}
11241124
};
11251125

1126-
RecordType rec = RecordType(int()); // expected-warning {{2 uninitialized fields at the end of the constructor call}}
1126+
RecordType rec = RecordType(int()); // expected-warning {{2 uninitialized fields}}
11271127
int dontGetFilteredByNonPedanticMode = 0;
11281128

11291129
CXX11MemberInitTest2() {}

0 commit comments

Comments
 (0)