[PATCH] D155202: [clang][dataflow] Simplify implementation of `transferStdForwardCall()` in optional check.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 17 00:26:49 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.
Closed by commit rG243a79ca01f8: [clang][dataflow] Simplify implementation of `transferStdForwardCall()` in… (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D155202?vs=540023&id=540882#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155202/new/

https://reviews.llvm.org/D155202

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp


Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -683,25 +683,8 @@
                             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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155202.540882.patch
Type: text/x-patch
Size: 1205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230717/336a4f2f/attachment.bin>


More information about the cfe-commits mailing list