[PATCH] D121197: [clang][dataflow] Add analysis that detects unsafe accesses to optionals

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 8 06:42:56 PST 2022


ymandel added a comment.

Maybe add explanation to the patch description for move of `TestingSupport.h`?  Also, mention that this just a core implementation, and fuller support is coming?



================
Comment at: clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:20
+///
+/// FIXME: Consider separating the models from the unchecked access analysis.
+class UncheckedOptionalAccessModel
----------------
Delete?


================
Comment at: clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:35-36
+private:
+  std::function<void(const Stmt &, ASTContext &,
+                     TransferState<SourceLocationsLattice> &)>
+      TransferMatchSwitch;
----------------



================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:84
+    auto *HasValueVal = getHasValue(OptionalVal);
+    assert(HasValueVal != nullptr);
+
----------------
How are we confident that the `has_value` property is populated? Since we're only picking up on declr-refs and members, I think this won't hold otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121197



More information about the cfe-commits mailing list