[clang] [CIR] Implement devirtualized member function calls (PR #195106)

via cfe-commits cfe-commits at lists.llvm.org
Sat May 2 10:23:05 PDT 2026


================
@@ -132,7 +139,33 @@ RValue CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(
   // Compute the object pointer.
   bool canUseVirtualCall = md->isVirtual() && !hasQualifier;
   const CXXMethodDecl *devirtualizedMethod = nullptr;
-  assert(!cir::MissingFeatures::devirtualizeMemberFunction());
+  if (canUseVirtualCall &&
+      md->getDevirtualizedMethod(base, getLangOpts().AppleKext)) {
+    const CXXRecordDecl *bestDynamicDecl = base->getBestDynamicClassType();
+    devirtualizedMethod = md->getCorrespondingMethodInClass(bestDynamicDecl);
+    assert(devirtualizedMethod);
+    const CXXRecordDecl *devirtualizedClass = devirtualizedMethod->getParent();
+    const Expr *inner = base->IgnoreParenBaseCasts();
+    if (devirtualizedMethod->getReturnType().getCanonicalType() !=
----------------
AbdallahRashed wrote:

updated the test cases, thank you 

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


More information about the cfe-commits mailing list