================
@@ -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;
----------------
NagyDonat wrote:
> Also it would be nice to have a comment block that describes that there are
> three indexing conventions, explains their customary names (which should be
> used very consistently!) and for each of them lists the places where it
> should be used.
I'm not sure where should we place this comment block to ensure that it is
visible everywhere :thinking: It is helpful for this particular place where you
placed it right now, but it is also relevant for many other parts of the
codebase.
Perhaps it could be placed e.g. as a doc-comment of `class CallEvent`, perhaps
extended with concrete examples that show function declarations and calls, and
then say something like "valid values of `NativeIdx` : 0 means ..., 1means ...,
2 means ... ; valid values of `ParamDeclIdx`: 0 means ..., 1 means ... ". If
you have this central documentation, then concrete locations (like this code
fragment that uses `NativeIdx`) could be documented with a shorter comment like
"`NativeIdx` is the indexing used by `CallEvent`; the doc-comment before `class
CallEvent` describes the differences between it and the other two indexing
kinds".
What do you think about this? Where would _you_ prefer this description of the
indexing kinds? Where would you look for it if you weren't the one who writes
it and didn't know about its existence?
By the way, take my suggestions with a grain of salt, as I still don't
completely understand the differences between the three indexing kinds
:sweat_smile:
https://github.com/llvm/llvm-project/pull/221977
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits