[llvm-branch-commits] [clang] [analyzer][NFC] Index parameter lookups by argument position (PR #221977)
DonĂ¡t Nagy via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 8 10:54:27 PDT 2026
================
@@ -46,10 +46,27 @@ class NonNullParamChecker
const Expr *ArgE) const;
};
+/// The bit vectors below are indexed by \p Call's own argument numbering
+/// and not by the declared parameter index. The two differ for an
+/// explicit object parameter. The explicit object parameter is declared
+/// as #0, but \p Call does not count the object as one of its arguments.
+///
+/// \returns how many leading declared parameters \p Call has no argument
+/// for.
+template <class CallType>
+unsigned getDeclParameterOffset(const CallType &Call) {
+ if (const auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(Call.getDecl())) {
+ assert(FD->getNumParams() >= Call.parameters().size());
+ return FD->getNumParams() - Call.parameters().size();
----------------
NagyDonat wrote:
Are you sure that this is correct? Did you think about other potential sources of discrepancies, e.g. functions like `int printf(const char *fmt, ...)`. (It may easily be correct, I can't give a confident answer either way.)
https://github.com/llvm/llvm-project/pull/221977
More information about the llvm-branch-commits
mailing list