aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
diff options
context:
space:
mode:
authorMartin Braenne <mboehme@google.com>2023-07-17 06:31:03 +0000
committerMartin Braenne <mboehme@google.com>2023-07-17 07:26:11 +0000
commit243a79ca01f8142a8d8c9873ba58fefdafa48745 (patch)
tree08ee5581bde5997e8b441dce9ab69f661c452e78 /clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
parent6d768548ecc0ca37026986f397392c1d0ace9736 (diff)
downloadllvm-243a79ca01f8142a8d8c9873ba58fefdafa48745.zip
llvm-243a79ca01f8142a8d8c9873ba58fefdafa48745.tar.gz
llvm-243a79ca01f8142a8d8c9873ba58fefdafa48745.tar.bz2
[clang][dataflow] Simplify implementation of `transferStdForwardCall()` in optional check.
The argument and return value of `std::forward` is always a reference, so we can simply forward the storage location. Depends On D155075 Reviewed By: ymandel, gribozavr2, xazax.hun Differential Revision: https://reviews.llvm.org/D155202
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp')
-rw-r--r--clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index 7f51698..a39aa224 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -683,25 +683,8 @@ void transferStdForwardCall(const CallExpr *E, const MatchFinder::MatchResult &,
LatticeTransferState &State) {
assert(E->getNumArgs() == 1);
- StorageLocation *LocRet = State.Env.getStorageLocation(*E, SkipPast::None);
- if (LocRet != nullptr)
- return;
-
- StorageLocation *LocArg =
- State.Env.getStorageLocation(*E->getArg(0), SkipPast::Reference);
-
- if (LocArg == nullptr)
- return;
-
- Value *ValArg = State.Env.getValue(*LocArg);
- if (ValArg == nullptr)
- ValArg = &createOptionalValue(State.Env.makeAtomicBoolValue(), State.Env);
-
- // Create a new storage location
- LocRet = &State.Env.createStorageLocation(*E);
- State.Env.setStorageLocation(*E, *LocRet);
-
- State.Env.setValue(*LocRet, *ValArg);
+ if (auto *Loc = State.Env.getStorageLocationStrict(*E->getArg(0)))
+ State.Env.setStorageLocationStrict(*E, *Loc);
}
const Formula &evaluateEquality(Arena &A, const Formula &EqVal,