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

Stanislav Gatev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 14 12:03:59 PDT 2022


sgatev marked 2 inline comments as done.
sgatev added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:264
+          +[](const CXXMemberCallExpr *E, LatticeTransferState &State) {
+            assignOptionalValue(*E->getImplicitObjectArgument(), State,
+                                State.Env.getBoolLiteralValue(true));
----------------
ymandel wrote:
> I realize this is consistent with the previous version, but just noticed this issue. By using `assignOptionalValue` for `emplace` (and `reset`), does that break the following case?
> 
> ```
> optional<int> opt;
> if (p) opt.emplace(3);
> someCode();
> if (p) use(*opt);
> ```
This isn't supported yet. Still, I don't think `assignOptionalValue` breaks it because this seems more related to the way information from different branches is joined than the way values are initialized. I'll add this case (and others) in a following patch that adds support for joining.


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