Skip to content

Commit

Permalink
[clang][dataflow] Simplify implementation of `transferStdForwardCall(…
Browse files Browse the repository at this point in the history
…)` 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
  • Loading branch information
martinboehme committed Jul 17, 2023
1 parent 6d76854 commit 243a79c
Showing 1 changed file with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 243a79c

Please sign in to comment.