Skip to content

Commit 06a8079

Browse files
committed
rebase
Created using spr 1.3.7
2 parents eccbae3 + a080134 commit 06a8079

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

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

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