[llvm-branch-commits] [clang] [analyzer][NFC] Index parameter lookups by argument position (PR #221977)
Benedek Kaibas via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 15 03:51:11 PDT 2026
================
@@ -577,14 +577,13 @@ ProgramStateRef CallAndMessageChecker::checkArgInitializedness(
const BugType &BT = isa<ObjCMethodCall>(Call) ? MsgArgBug : CallArgBug;
- const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
+ ArrayRef<ParmVarDecl *> Params = Call.parameters();
for (unsigned i = 0, e = Call.getNumArgs(); i != e; ++i) {
- const ParmVarDecl *ParamDecl = nullptr;
- if (FD && i < FD->getNumParams())
- ParamDecl = FD->getParamDecl(i);
+ // For variadic functions a corresponding parameter decl might not exist.
+ const ParmVarDecl *PVD = i < Params.size() ? Params[i] : nullptr;
----------------
benedekaibas wrote:
I totally agree with your suggestion. I think this change does require the comment blocks to be at the most visible place for others. The main place where I looked for the indexing kinds is `CallEvent`, so I would put it there and with the explanation you have described it would be clear for everyone reading.
To work with index kinds, someone *has to* visit `CallEvent`. Therefore, placing it there would make the most sense for me.
https://github.com/llvm/llvm-project/pull/221977
More information about the llvm-branch-commits
mailing list