[clang] [CIR] Add support for copy elision (PR #157713)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 9 10:03:42 PDT 2025


================
@@ -445,8 +445,8 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const ReturnStmt &s) {
 
   if (getContext().getLangOpts().ElideConstructors && s.getNRVOCandidate() &&
       s.getNRVOCandidate()->isNRVOVariable()) {
-    getCIRGenModule().errorNYI(s.getSourceRange(),
-                               "named return value optimization");
+    assert(!cir::MissingFeatures::openMP());
+    assert(!cir::MissingFeatures::nrvo());
----------------
andykaylor wrote:

This should set a flag if there is an associated NRVO candidate based on a map in CIRGenFunction, but that isn't implemented yet. The case where the variable would have been added to the map triggers an `errorNYI` diagnostic in `emitCXXConstructExpr` so it's safe to ignore it here until it is implemented.

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


More information about the cfe-commits mailing list