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

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 09:23:16 PDT 2022


xazax.hun added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:64
+                               callee(cxxMethodDecl(ofClass(optionalClass()))),
+                               unless(hasArgument(0, *Ignorable)));
+  return cxxOperatorCallExpr(hasOverloadedOperatorName(operator_name),
----------------
Maybe removing the duplication with something like: `auto Exception = Ignorable? expr() : expr(unless(...))` and use it in the matcher?


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:301
+        cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("->"),
+                                  hasOverloadedOperatorName("*")),
+                            unless(hasArgument(0, expr(hasOptionalType())))))));
----------------
It is probably rarely used, but one could use `std::unique_ptr` with an array of `std::optional`s and use `operator[]` to access the optional.


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