[clang] [CIR] Upstream support for C++ member function calls (PR #140290)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Fri May 16 15:46:27 PDT 2025


================
@@ -0,0 +1,45 @@
+//===----- CirGenCXXABI.cpp - Interface to C++ ABIs -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This provides an abstract class for C++ code generation. Concrete subclasses
+// of this implement code generation for specific C++ ABIs.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenCXXABI.h"
+#include "CIRGenFunction.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/GlobalDecl.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+CIRGenCXXABI::~CIRGenCXXABI() {}
+
+void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
+                                  FunctionArgList &params) {
+  const auto *md = cast<CXXMethodDecl>(cgf.curGD.getDecl());
+
+  // FIXME: I'm not entirely sure I like using a fake decl just for code
----------------
bcardosolopes wrote:

Ugh, this isn't great, and it's not the only instance in CodeGen/CIRGen where clang current creates AST nodes on the fly - one neat side effect of this is to rely on the pre-existing `ImplicitParamDecl` codegen, so it doesn't needed to be duplicated here (which usually involves handling the scalar/agg/complex versions), but in theory we could hoist the implementation of visitors into common helpers that could be used directly here.

I'm fine leaving this as-is for now.

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


More information about the cfe-commits mailing list