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

Stanislav Gatev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 02:53:55 PDT 2022


sgatev accepted this revision.
sgatev added inline comments.
This revision is now accepted and ready to land.


================
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
----------------
Can you clarify what "smart pointer" refers to? It's not only standard types like `unique_ptr`, `shared_ptr`, and `weak_ptr`, right?


================
Comment at: clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:32
+  /// Ignore optionals reachable by derefencing a smart pointer (other than
+  /// optional itself). The analysis does not track smart-pointer pointees, so
+  /// it can't identify when optionals resulting from dereferencing such
----------------



================
Comment at: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1923-1927
+    template <typename T>
+    struct unique_ptr {
+      T& operator*() &;
+      T* operator->();
+    };
----------------
Let's add this to a `memory.h` header.


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


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