[PATCH] D119792: [Clang] [P2025] Analyze only potential scopes for NRVO
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 25 19:21:43 PDT 2022
ChuanqiXu added inline comments.
================
Comment at: clang/lib/Sema/Scope.cpp:152-154
+ // Consider the variable as NRVO candidate if the return slot is available
+ // for it in the current scope, or if it can be available in outer scopes.
+ NRVO = CanBePutInReturnSlot ? VD : nullptr;
----------------
What if NRVO contains a value already? It is possible due to the value of NRVO could be set by its children.
================
Comment at: clang/lib/Sema/Scope.cpp:184-185
+ // }
+ if (!getEntity())
+ getParent()->NRVO = *NRVO;
}
----------------
There is a similar problem. It looks not right if the NRVO of the parent owns a value already.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119792/new/
https://reviews.llvm.org/D119792
More information about the cfe-commits
mailing list