[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 11:12:55 PDT 2022
ymandel added inline comments.
================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:110
+ return false;
+ auto TypeName = Type->getAsCXXRecordDecl()->getQualifiedNameAsString();
+ return TypeName == "std::optional" || TypeName == "absl::optional" ||
----------------
This could get expensive. Maybe add a FIXME to optimize this by avoiding `getQualifiedNameAsString`?
================
Comment at: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:264
+ +[](const CXXMemberCallExpr *E, LatticeTransferState &State) {
+ assignOptionalValue(*E->getImplicitObjectArgument(), State,
+ State.Env.getBoolLiteralValue(true));
----------------
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);
```
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