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

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 8 16:41:54 PST 2022


xazax.hun accepted this revision.
xazax.hun added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:115
+      // optional::has_value
+      .CaseOf(isOptionalMemberCallWithName("has_value"),
+              transferOptionalHasValueCall)
----------------
One very important omission seems to be `optional::operator bool`. This is a widely used method and I'd love to see it supported.

Also would love to see FIXMEs for some of the most more frequently used functions/methods:
* make_optional makes a non-empty optional
* swap (free function and method)
* value_or returning its argument when the optional is known to be empty
* Model the value semantics:  Copy ctor, assignment operator
* Model the move semantics
* Default constructed optional is empty
* Invalidation: passing optional by non-const reference/pointer can invalidate its state




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