summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-05-30 14:14:58 +0000
committerSam McCall <sam.mccall@gmail.com>2018-05-30 14:14:58 +0000
commit5429bd751cc0729a3b2f49d8c346aa288cd8d2fc (patch)
treeecb7a8e0a08efc304285a887cc295f5915ffad96 /clang/lib/Sema/SemaExpr.cpp
parent173e225f1c2f601536f2e625c05e46fe99ca22b1 (diff)
downloadbcm5719-llvm-5429bd751cc0729a3b2f49d8c346aa288cd8d2fc.tar.gz
bcm5719-llvm-5429bd751cc0729a3b2f49d8c346aa288cd8d2fc.zip
Revert "Update NRVO logic to support early return"
This reverts commit r333500, which causes stage2 compiler crashes. llvm-svn: 333547
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 220d6906954..aeedd6b1691 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13385,9 +13385,13 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
DiagnoseUnguardedAvailabilityViolations(BSI->TheDecl);
- // Try to apply the named return value optimization.
- computeNRVO(Body, BSI);
-
+ // 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);
+
BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy);
AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy();
PopFunctionScopeInfo(&WP, Result->getBlockDecl(), Result);
OpenPOWER on IntegriCloud