[PATCH] D130600: [clang][dataflow] Handle return statements
Stanislav Gatev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 3 22:48:23 PDT 2022
sgatev added inline comments.
================
Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:345
+ // FIXME: Support reference-type returns.
+ assert(Val->getKind() != Value::Kind::Reference);
+
----------------
Let's do `if (Val->getKind() == Value::Kind::Reference) return;`. Otherwise the framework will be unusable in practice.
================
Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:348
+ auto *Loc = Env.getReturnStorageLocation();
+ assert(Loc != nullptr);
+ // FIXME: Model NRVO.
----------------
Let's do `if (Loc == nullptr) return;`
================
Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:564
+ assert(ReturnLoc != nullptr);
+ Env.setStorageLocation(*S, *ReturnLoc);
+ Env.popCall(ExitEnv);
----------------
We use stable storage locations to ensure convergence. In that spirit, shouldn't we assign `ReturnLoc`'s value to `S`'s storage location instead of changing the storage location? Alternatively, we can pass `S`'s storage location to `pushCall` so that it can store it as `ReturnLoc`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130600/new/
https://reviews.llvm.org/D130600
More information about the cfe-commits
mailing list