[clang] [CIR] Upstream CIR method attribute handling (PR #174640)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 12:37:02 PST 2026


================
@@ -1527,9 +1527,18 @@ mlir::Value CIRGenModule::emitMemberPointerConstant(const UnaryOperator *e) {
   const auto *decl = cast<DeclRefExpr>(e->getSubExpr())->getDecl();
 
   // A member function pointer.
-  if (isa<CXXMethodDecl>(decl)) {
-    errorNYI(e->getSourceRange(), "emitMemberPointerConstant: method pointer");
-    return {};
+  if (const auto *methodDecl = dyn_cast<CXXMethodDecl>(decl)) {
+    auto ty = mlir::cast<cir::MethodType>(convertType(e->getType()));
+    if (methodDecl->isVirtual()) {
+      assert(!cir::MissingFeatures::virtualMethodAttr());
+      errorNYI(e->getSourceRange(),
+               "emitMemberPointerConstant: virtual method pointer");
+      return {};
+    }
+
+    auto methodFuncOp = getAddrOfFunction(methodDecl);
----------------
erichkeane wrote:

```suggestion
    cir::FuncOp methodFuncOp = getAddrOfFunction(methodDecl);
```

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


More information about the cfe-commits mailing list