[clang] [clang] Restrict -Wnrvo to C++ code only. (PR #157059)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 15:53:55 PDT 2025


Javier =?utf-8?q?Muñoz?= Kirschberg
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/157059 at github.com>


================
@@ -16174,8 +16174,10 @@ void Sema::computeNRVO(Stmt *Body, FunctionScopeInfo *Scope) {
   for (unsigned I = 0, E = Scope->Returns.size(); I != E; ++I) {
     if (const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
       if (!NRVOCandidate->isNRVOVariable()) {
-        Diag(Returns[I]->getRetValue()->getExprLoc(),
-             diag::warn_not_eliding_copy_on_return);
+        if (getLangOpts().CPlusPlus) {
----------------
Sirraide wrote:

Ah, no, disregard that. I misread that because of how the diff was formatted; we do in fact need to keep them separate yes.

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


More information about the cfe-commits mailing list