[PATCH] D121602: [clang][dataflow] Model the behavior of non-standard optional constructors

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


xazax.hun added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:55
+  return hasType(
+      recordDecl(anyOf(hasName("std::nullopt_t"), hasName("absl::nullopt_t"),
+                       hasName("base::nullopt_t"))));
----------------
Did you consider `hasAnyName`? Or would that not work in this context?


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:75
+
+auto isOptionalNonStandardConstructor() {
+  return cxxConstructExpr(
----------------
What is a `non-standard` constructor? This might be a well-known term I'm not aware of. If that is not the case I'd prefer a comment or a more descriptive name.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:263
+          isOptionalMemberCallWithName("emplace"),
+          +[](const CXXMemberCallExpr *E, LatticeTransferState &State) {
+            assignOptionalValue(*E->getImplicitObjectArgument(), State,
----------------
Do we need this `+` to force conversion to function pointer? Is it possible to fix `CaseOf` so it works with lambdas or is that not desirable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121602



More information about the cfe-commits mailing list