================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to