[PATCH] D131438: [clang][dataflow] Analyze constructor bodies
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 9 13:18:34 PDT 2022
xazax.hun added inline comments.
================
Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:248-258
+ for (unsigned ArgIndex = 0; ArgIndex < NumArgs; ++ParamIt, ++ArgIndex) {
assert(ParamIt != FuncDecl->param_end());
- const Expr *Arg = *ArgIt;
- auto *ArgLoc = Env.getStorageLocation(*Arg, SkipPast::Reference);
+ const Expr *Arg;
+ if (const auto *ConstructExpr = dyn_cast<CXXConstructExpr>(Call)) {
+ Arg = ConstructExpr->getArg(ArgIndex);
+ } else if (const auto *NonConstructExpr = dyn_cast<CallExpr>(Call)) {
----------------
I think the more idiomatic solution in Clang is to create an ArrayRef for the arguments from the `ConstructExpr` and the `CallExpr`. The args should be stored in a continuous memory area in both cases so you should be able to create the ArrayRef in constant time and you would no longer need to have these pesky if statements in your loop.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131438/new/
https://reviews.llvm.org/D131438
More information about the cfe-commits
mailing list