[clang] [Sema] Fix parameter index checks on explicit object member functions (PR #165586)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 30 04:57:32 PDT 2025


================
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool hasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
+    return MethodDecl->isInstance() &&
+           !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
----------------
Sirraide wrote:

> A method can be static and not have the implicit this available, right? I think we still should check `MethodDecl->isInstance()`

No, `isImplicitObjectMemberFunction()` already checks for that:
```c++
bool CXXMethodDecl::isImplicitObjectMemberFunction() const {
  return !isStatic() && !hasCXXExplicitFunctionObjectParameter();
}
```

https://github.com/llvm/llvm-project/pull/165586


More information about the cfe-commits mailing list