[clang] [clang] Restrict -Wnrvo to C++ code only. (PR #157059)
Javier Muñoz Kirschberg via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 8 15:52:09 PDT 2025
================
@@ -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) {
----------------
javiermunozkirschberg wrote:
One question, after the Diag, and as part of if(!NRVOCandidate) there is a
Returns[I]->setNRVOCandidate(nullptr);
If I merge the two ifs(), then diag will be skip, but returns[i]->setNRVOCandidate(nullptr) will be also skipped. Is that ok?
https://github.com/llvm/llvm-project/pull/157059
More information about the cfe-commits
mailing list