Skip to content

Commit bdea8c2

Browse files
committed
test
Created using spr 1.3.7
1 parent 5f0f216 commit bdea8c2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ static void transferStatusOkCall(const CXXMemberCallExpr *Expr,
296296
static void transferStatusUpdateCall(const CXXMemberCallExpr *Expr,
297297
const MatchFinder::MatchResult &,
298298
LatticeTransferState &State) {
299+
// S.Update(OtherS) sets S to the error code of OtherS if it is OK,
300+
// otherwise does nothing.
299301
assert(Expr->getNumArgs() == 1);
300302
auto *Arg = Expr->getArg(0);
301303
RecordStorageLocation *ArgRecord =

clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,19 @@ TEST_P(UncheckedStatusOrAccessModelTest, UnwrapValueWithStatusPtrCheck) {
24942494
)cc");
24952495
}
24962496

2497+
TEST_P(UncheckedStatusOrAccessModelTest, UnwrapValueWithMovedStatus) {
2498+
ExpectDiagnosticsFor(R"cc(
2499+
#include "unchecked_statusor_access_test_defs.h"
2500+
2501+
void target(STATUSOR_INT sor) {
2502+
if (std::move(sor.status()).ok())
2503+
sor.value();
2504+
else
2505+
sor.value(); // [[unsafe]]
2506+
}
2507+
)cc");
2508+
}
2509+
24972510
TEST_P(UncheckedStatusOrAccessModelTest, MembersUsedInsideStatus) {
24982511
ExpectDiagnosticsFor(R"cc(
24992512
namespace absl {

0 commit comments

Comments
 (0)