aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
diff options
context:
space:
mode:
authorMartin Braenne <mboehme@google.com>2023-07-31 12:35:44 +0000
committerMartin Braenne <mboehme@google.com>2023-07-31 19:40:04 +0000
commitf76f6674d8221f59f9e515e3cc03ad07fa72fe46 (patch)
tree7ae0dbf75dc3c7fbff7f773bbfd3688c2c70cdc8 /clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
parente0b3f45d87a6677efb59d8a4f0e6deac9c346c76 (diff)
downloadllvm-f76f6674d8221f59f9e515e3cc03ad07fa72fe46.zip
llvm-f76f6674d8221f59f9e515e3cc03ad07fa72fe46.tar.gz
llvm-f76f6674d8221f59f9e515e3cc03ad07fa72fe46.tar.bz2
[clang][dataflow] Use `Strict` accessors where we weren't using them yet.
This eliminates all uses of the deprecated accessors. Reviewed By: ymandel, xazax.hun Differential Revision: https://reviews.llvm.org/D156672
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp')
-rw-r--r--clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index 14afb3f..1edadfd 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -242,10 +242,8 @@ const Formula &forceBoolValue(Environment &Env, const Expr &Expr) {
if (Value != nullptr)
return Value->formula();
- auto &Loc = Env.createStorageLocation(Expr);
Value = &Env.makeAtomicBoolValue();
- Env.setValue(Loc, *Value);
- Env.setStorageLocation(Expr, Loc);
+ Env.setValueStrict(Expr, *Value);
return Value->formula();
}
@@ -439,10 +437,10 @@ void transferUnwrapCall(const Expr *UnwrapExpr, const Expr *ObjectExpr,
LatticeTransferState &State) {
if (auto *OptionalVal =
getValueBehindPossiblePointer(*ObjectExpr, State.Env)) {
- if (State.Env.getStorageLocation(*UnwrapExpr, SkipPast::None) == nullptr)
+ if (State.Env.getStorageLocationStrict(*UnwrapExpr) == nullptr)
if (auto *Loc = maybeInitializeOptionalValueMember(
UnwrapExpr->getType(), *OptionalVal, State.Env))
- State.Env.setStorageLocation(*UnwrapExpr, *Loc);
+ State.Env.setStorageLocationStrict(*UnwrapExpr, *Loc);
}
}
@@ -471,9 +469,7 @@ void transferOptionalHasValueCall(const CXXMemberCallExpr *CallExpr,
if (auto *HasValueVal = getHasValue(
State.Env, getValueBehindPossiblePointer(
*CallExpr->getImplicitObjectArgument(), State.Env))) {
- auto &CallExprLoc = State.Env.createStorageLocation(*CallExpr);
- State.Env.setValue(CallExprLoc, *HasValueVal);
- State.Env.setStorageLocation(*CallExpr, CallExprLoc);
+ State.Env.setValueStrict(*CallExpr, *HasValueVal);
}
}
@@ -534,15 +530,20 @@ void transferValueOrNotEqX(const Expr *ComparisonExpr,
void transferCallReturningOptional(const CallExpr *E,
const MatchFinder::MatchResult &Result,
LatticeTransferState &State) {
- if (State.Env.getStorageLocation(*E, SkipPast::None) != nullptr)
+ if (State.Env.getValue(*E) != nullptr)
return;
AggregateStorageLocation *Loc = nullptr;
if (E->isPRValue()) {
Loc = &State.Env.getResultObjectLocation(*E);
} else {
- Loc = &cast<AggregateStorageLocation>(State.Env.createStorageLocation(*E));
- State.Env.setStorageLocationStrict(*E, *Loc);
+ Loc = cast_or_null<AggregateStorageLocation>(
+ State.Env.getStorageLocationStrict(*E));
+ if (Loc == nullptr) {
+ Loc =
+ &cast<AggregateStorageLocation>(State.Env.createStorageLocation(*E));
+ State.Env.setStorageLocationStrict(*E, *Loc);
+ }
}
createOptionalValue(*Loc, State.Env.makeAtomicBoolValue(), State.Env);