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

Stanislav Gatev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 8 09:53:32 PST 2022


sgatev added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:20
+///
+/// FIXME: Consider separating the models from the unchecked access analysis.
+class UncheckedOptionalAccessModel
----------------
ymandel wrote:
> Delete?
Why? I do think it makes sense to separate the model of optional types from the analysis that tracks unsafe uses. I don't think we're in a place to do the separation yet so that's why I added the FIXME.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:84
+    auto *HasValueVal = getHasValue(OptionalVal);
+    assert(HasValueVal != nullptr);
+
----------------
ymandel wrote:
> 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.
I think that's fine. This isn't set in stone and can change as new tests are added. I don't claim that the implementation in this patch covers all features of the language.


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