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

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 14 12:36:13 PDT 2022


ymandel accepted this revision.
ymandel 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));
----------------
sgatev wrote:
> 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.
Sounds good. I think we can discuss further in the next patch as needed.


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