Skip to content

Commit f40b5b7

Browse files
committed
rebase
Created using spr 1.3.7
2 parents 9e53770 + 5919c6e commit f40b5b7

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -863,15 +863,26 @@ static void transferPointerToBoolean(const ImplicitCastExpr *Expr,
863863
dyn_cast_or_null<BoolValue>(State.Env.getValue(*Expr->getSubExpr())))
864864
State.Env.setValue(*Expr, *SubExprVal);
865865
}
866-
static void handleConstStatusOrAccessorMemberCall(
866+
867+
static void transferStatusOrReturningCall(const CallExpr *Expr,
868+
LatticeTransferState &State) {
869+
RecordStorageLocation *StatusOrLoc =
870+
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
871+
: State.Env.get<RecordStorageLocation>(*Expr);
872+
if (StatusOrLoc != nullptr &&
873+
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
874+
initializeStatusOr(*StatusOrLoc, State.Env);
875+
}
876+
877+
static bool doHandleConstStatusOrAccessorMemberCall(
867878
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
868879
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
869880
assert(isStatusOrType(Expr->getType()));
870881
if (RecordLoc == nullptr)
871-
return;
882+
return false;
872883
const FunctionDecl *DirectCallee = Expr->getDirectCallee();
873884
if (DirectCallee == nullptr)
874-
return;
885+
return false;
875886
StorageLocation &Loc =
876887
State.Lattice.getOrCreateConstMethodReturnStorageLocation(
877888
*RecordLoc, DirectCallee, State.Env, [&](StorageLocation &Loc) {
@@ -883,8 +894,15 @@ static void handleConstStatusOrAccessorMemberCall(
883894
} else {
884895
State.Env.setStorageLocation(*Expr, Loc);
885896
}
897+
return true;
886898
}
887899

900+
static void handleConstStatusOrAccessorMemberCall(
901+
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
902+
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
903+
if (!doHandleConstStatusOrAccessorMemberCall(Expr, RecordLoc, Result, State))
904+
transferStatusOrReturningCall(Expr, State);
905+
}
888906
static void handleConstStatusOrPointerAccessorMemberCall(
889907
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
890908
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
@@ -926,16 +944,6 @@ static void transferConstStatusOrPointerAccessorMemberOperatorCall(
926944
handleConstStatusOrPointerAccessorMemberCall(Expr, RecordLoc, Result, State);
927945
}
928946

929-
static void transferStatusOrReturningCall(const CallExpr *Expr,
930-
LatticeTransferState &State) {
931-
RecordStorageLocation *StatusOrLoc =
932-
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
933-
: State.Env.get<RecordStorageLocation>(*Expr);
934-
if (StatusOrLoc != nullptr &&
935-
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
936-
initializeStatusOr(*StatusOrLoc, State.Env);
937-
}
938-
939947
static void handleNonConstMemberCall(const CallExpr *Expr,
940948
RecordStorageLocation *RecordLoc,
941949
const MatchFinder::MatchResult &Result,

clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,7 @@ TEST_P(UncheckedStatusOrAccessModelTest, AccessorCall) {
34783478
}
34793479
)cc");
34803480

3481-
// Calls nonconst method inbetween.
3481+
// Calls nonconst method in between.
34823482
ExpectDiagnosticsFor(
34833483
R"cc(
34843484
#include "unchecked_statusor_access_test_defs.h"
@@ -3499,7 +3499,7 @@ TEST_P(UncheckedStatusOrAccessModelTest, AccessorCall) {
34993499
}
35003500
)cc");
35013501

3502-
// Calls nonconst operator inbetween.
3502+
// Calls nonconst operator in between.
35033503
ExpectDiagnosticsFor(
35043504
R"cc(
35053505
#include "unchecked_statusor_access_test_defs.h"

0 commit comments

Comments
 (0)