summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorTaiju Tsuiki <tzik@google.com>2018-06-19 04:39:07 +0000
committerTaiju Tsuiki <tzik@google.com>2018-06-19 04:39:07 +0000
commitb000a8860e9ec26f4a2834dbeaba44cd27025306 (patch)
treeacb0e6018e9e3cfc7fc0c3efaf2eace9de21fb69 /clang/lib/Sema/SemaExpr.cpp
parentc2965214efbd35ed54e08cce042e8eed778646aa (diff)
downloadbcm5719-llvm-b000a8860e9ec26f4a2834dbeaba44cd27025306.tar.gz
bcm5719-llvm-b000a8860e9ec26f4a2834dbeaba44cd27025306.zip
Update NRVO logic to support early return (Attempt 2)
Summary: This is the second attempt of r333500 (Update NRVO logic to support early return). The previous one was reverted for a miscompilation for an incorrect NRVO set up on templates such as: ``` struct Foo {}; template <typename T> T bar() { T t; if (false) return T(); return t; } ``` Where, `t` is marked as non-NRVO variable before its instantiation. However, while its instantiation, it's left an NRVO candidate, turned into an NRVO variable later. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47586 llvm-svn: 335019
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index aeedd6b1691..220d6906954 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13385,13 +13385,9 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
DiagnoseUnguardedAvailabilityViolations(BSI->TheDecl);
- // Try to apply the named return value optimization. We have to check again
- // if we can do this, though, because blocks keep return statements around
- // to deduce an implicit return type.
- if (getLangOpts().CPlusPlus && RetTy->isRecordType() &&
- !BSI->TheDecl->isDependentContext())
- computeNRVO(Body, BSI);
-
+ // Try to apply the named return value optimization.
+ computeNRVO(Body, BSI);
+
BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);
AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy();
PopFunctionScopeInfo(&WP, Result->getBlockDecl(), Result);
OpenPOWER on IntegriCloud