Skip to content

Commit 09c625d

Browse files
committed
rebase
Created using spr 1.3.7
2 parents 698cd1d + 24d0cf0 commit 09c625d

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
@@ -844,15 +844,26 @@ static void transferPointerToBoolean(const ImplicitCastExpr *Expr,
844844
dyn_cast_or_null<BoolValue>(State.Env.getValue(*Expr->getSubExpr())))
845845
State.Env.setValue(*Expr, *SubExprVal);
846846
}
847-
static void handleConstStatusOrAccessorMemberCall(
847+
848+
static void transferStatusOrReturningCall(const CallExpr *Expr,
849+
LatticeTransferState &State) {
850+
RecordStorageLocation *StatusOrLoc =
851+
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
852+
: State.Env.get<RecordStorageLocation>(*Expr);
853+
if (StatusOrLoc != nullptr &&
854+
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
855+
initializeStatusOr(*StatusOrLoc, State.Env);
856+
}
857+
858+
static bool doHandleConstStatusOrAccessorMemberCall(
848859
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
849860
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
850861
assert(isStatusOrType(Expr->getType()));
851862
if (RecordLoc == nullptr)
852-
return;
863+
return false;
853864
const FunctionDecl *DirectCallee = Expr->getDirectCallee();
854865
if (DirectCallee == nullptr)
855-
return;
866+
return false;
856867
StorageLocation &Loc =
857868
State.Lattice.getOrCreateConstMethodReturnStorageLocation(
858869
*RecordLoc, DirectCallee, State.Env, [&](StorageLocation &Loc) {
@@ -864,8 +875,15 @@ static void handleConstStatusOrAccessorMemberCall(
864875
} else {
865876
State.Env.setStorageLocation(*Expr, Loc);
866877
}
878+
return true;
867879
}
868880

881+
static void handleConstStatusOrAccessorMemberCall(
882+
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
883+
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
884+
if (!doHandleConstStatusOrAccessorMemberCall(Expr, RecordLoc, Result, State))
885+
transferStatusOrReturningCall(Expr, State);
886+
}
869887
static void handleConstStatusOrPointerAccessorMemberCall(
870888
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
871889
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
@@ -907,16 +925,6 @@ static void transferConstStatusOrPointerAccessorMemberOperatorCall(
907925
handleConstStatusOrPointerAccessorMemberCall(Expr, RecordLoc, Result, State);
908926
}
909927

910-
static void transferStatusOrReturningCall(const CallExpr *Expr,
911-
LatticeTransferState &State) {
912-
RecordStorageLocation *StatusOrLoc =
913-
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
914-
: State.Env.get<RecordStorageLocation>(*Expr);
915-
if (StatusOrLoc != nullptr &&
916-
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
917-
initializeStatusOr(*StatusOrLoc, State.Env);
918-
}
919-
920928
static void handleNonConstMemberCall(const CallExpr *Expr,
921929
RecordStorageLocation *RecordLoc,
922930
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)