Author: Martin Braenne Date: 2023-07-17T07:26:11Z New Revision: 243a79ca01f8142a8d8c9873ba58fefdafa48745
URL: https://github.com/llvm/llvm-project/commit/243a79ca01f8142a8d8c9873ba58fefdafa48745 DIFF: https://github.com/llvm/llvm-project/commit/243a79ca01f8142a8d8c9873ba58fefdafa48745.diff LOG: [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 Added: Modified: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp Removed: ################################################################################ diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index 7f516984094648..a39aa2240c4fc6 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, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits