[PATCH] D122143: [clang][dataflow] Add support for disabling warnings on smart pointers.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 04:46:41 PDT 2022


ymandel marked 4 inline comments as done.
ymandel added inline comments.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:31
+struct UncheckedOptionalAccessModelOptions {
+  /// Ignore optionals reachable by derefencing a smart pointer (other than
+  /// optional itself). The analysis does not track smart-pointer pointees, so
----------------
sgatev wrote:
> Can you clarify what "smart pointer" refers to? It's not only standard types like `unique_ptr`, `shared_ptr`, and `weak_ptr`, right?
I've rewritten it to specify the operators directly.


================
Comment at: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1923-1927
+    template <typename T>
+    struct unique_ptr {
+      T& operator*() &;
+      T* operator->();
+    };
----------------
sgatev wrote:
> Let's add this to a `memory.h` header.
I specifically wanted a locally-defined type. Notice that it's not in `std`. I've renamed to generic "smart_ptr" to emphasize that. WDYT?


================
Comment at: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1929
+
+    struct Member {
+      $ns::$optional<int> opt;
----------------
sgatev wrote:
> Why `Member`? I suggest either using one of the generic names that we use above or maybe something more descriptive.
Went with generic. I think `Member` was from copy pasting...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122143



More information about the cfe-commits mailing list