[clang] [CIR] Handle static methods in emitCXXMemberCallExpr and add tests for static calls via instance (PR #237420)
Aman Maurya via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 13:59:38 PST 2026
amanmaurya92 wrote:
Yeah, that's actually a really fair point about Sema lowering these into CallExpr nodes.
Looking into why this was filed in the first place, emitCXXMemberCallExpr had that explicit `cgm.errorNYI(..., "emitCXXMemberCallExpr: static method")` stub, which made it look like static method calls through instances weren't supported at all in CIR (and that's what triggered issue #237402).
Classic Clang still keeps that `if (MD->isStatic())` block in `EmitCXXMemberCallExpr` as a defensive fallback. I figure replacing the `errorNYI` in CIR makes sense for parity with classic Clang so we don't abort if an AST consumer or plugin ever produces a `CXXMemberCallExpr` for a static method.
Also, CIR didn't actually have any tests verifying that calling static methods through instances or pointers evaluates base expressions for side effects. So I went ahead and added test coverage for `get_s().static_func()` and `(p++)->static_func()`, added a clarifying comment in the code, and updated the PR description and title so the purpose of the patch is clear.
https://github.com/llvm/llvm-project/pull/237420
More information about the cfe-commits
mailing list