Skip to content

Commit 7043f8a

Browse files
committed
rebase
Created using spr 1.3.7
2 parents c1b08dd + abff778 commit 7043f8a

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
@@ -741,15 +741,26 @@ static void transferPointerToBoolean(const ImplicitCastExpr *Expr,
741741
dyn_cast_or_null<BoolValue>(State.Env.getValue(*Expr->getSubExpr())))
742742
State.Env.setValue(*Expr, *SubExprVal);
743743
}
744-
static void handleConstStatusOrAccessorMemberCall(
744+
745+
static void transferStatusOrReturningCall(const CallExpr *Expr,
746+
LatticeTransferState &State) {
747+
RecordStorageLocation *StatusOrLoc =
748+
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
749+
: State.Env.get<RecordStorageLocation>(*Expr);
750+
if (StatusOrLoc != nullptr &&
751+
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
752+
initializeStatusOr(*StatusOrLoc, State.Env);
753+
}
754+
755+
static bool doHandleConstStatusOrAccessorMemberCall(
745756
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
746757
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
747758
assert(isStatusOrType(Expr->getType()));
748759
if (RecordLoc == nullptr)
749-
return;
760+
return false;
750761
const FunctionDecl *DirectCallee = Expr->getDirectCallee();
751762
if (DirectCallee == nullptr)
752-
return;
763+
return false;
753764
StorageLocation &Loc =
754765
State.Lattice.getOrCreateConstMethodReturnStorageLocation(
755766
*RecordLoc, DirectCallee, State.Env, [&](StorageLocation &Loc) {
@@ -761,8 +772,15 @@ static void handleConstStatusOrAccessorMemberCall(
761772
} else {
762773
State.Env.setStorageLocation(*Expr, Loc);
763774
}
775+
return true;
764776
}
765777

778+
static void handleConstStatusOrAccessorMemberCall(
779+
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
780+
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
781+
if (!doHandleConstStatusOrAccessorMemberCall(Expr, RecordLoc, Result, State))
782+
transferStatusOrReturningCall(Expr, State);
783+
}
766784
static void handleConstStatusOrPointerAccessorMemberCall(
767785
const CallExpr *Expr, RecordStorageLocation *RecordLoc,
768786
const MatchFinder::MatchResult &Result, LatticeTransferState &State) {
@@ -804,16 +822,6 @@ static void transferConstStatusOrPointerAccessorMemberOperatorCall(
804822
handleConstStatusOrPointerAccessorMemberCall(Expr, RecordLoc, Result, State);
805823
}
806824

807-
static void transferStatusOrReturningCall(const CallExpr *Expr,
808-
LatticeTransferState &State) {
809-
RecordStorageLocation *StatusOrLoc =
810-
Expr->isPRValue() ? &State.Env.getResultObjectLocation(*Expr)
811-
: State.Env.get<RecordStorageLocation>(*Expr);
812-
if (StatusOrLoc != nullptr &&
813-
State.Env.getValue(locForOk(locForStatus(*StatusOrLoc))) == nullptr)
814-
initializeStatusOr(*StatusOrLoc, State.Env);
815-
}
816-
817825
static void handleNonConstMemberCall(const CallExpr *Expr,
818826
RecordStorageLocation *RecordLoc,
819827
const MatchFinder::MatchResult &Result,

clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,7 +3303,7 @@ TEST_P(UncheckedStatusOrAccessModelTest, AccessorCall) {
33033303
}
33043304
)cc");
33053305

3306-
// Calls nonconst method inbetween.
3306+
// Calls nonconst method in between.
33073307
ExpectDiagnosticsFor(
33083308
R"cc(
33093309
#include "unchecked_statusor_access_test_defs.h"
@@ -3324,7 +3324,7 @@ TEST_P(UncheckedStatusOrAccessModelTest, AccessorCall) {
33243324
}
33253325
)cc");
33263326

3327-
// Calls nonconst operator inbetween.
3327+
// Calls nonconst operator in between.
33283328
ExpectDiagnosticsFor(
33293329
R"cc(
33303330
#include "unchecked_statusor_access_test_defs.h"

0 commit comments

Comments
 (0)