aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-02-17 19:36:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-02-17 19:36:19 +0000
commiteb2854521a26d3f186018f1b119761ca7bb90dc2 (patch)
tree8cb7e2fc50b6c6580827cc26dc7c9a5921b4bdb2 /lib/Sema/SemaStmt.cpp
parent3bae5253046bf2859f76e3d0d22f47a5fc0844c7 (diff)
downloadsrc-eb2854521a26d3f186018f1b119761ca7bb90dc2.tar.gz
src-eb2854521a26d3f186018f1b119761ca7bb90dc2.zip
Vendor import of clang release_40 branch r295380:vendor/clang/clang-release_40-r295380
Notes
Notes: svn path=/vendor/clang/dist/; revision=313883 svn path=/vendor/clang/clang-release_40-r295380/; revision=313884; tag=vendor/clang/clang-release_40-r295380
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index a8832e9a1c54..390e1b52c8ed 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2743,15 +2743,17 @@ bool Sema::isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
// ...automatic...
if (!VD->hasLocalStorage()) return false;
+ // Return false if VD is a __block variable. We don't want to implicitly move
+ // out of a __block variable during a return because we cannot assume the
+ // variable will no longer be used.
+ if (VD->hasAttr<BlocksAttr>()) return false;
+
if (AllowParamOrMoveConstructible)
return true;
// ...non-volatile...
if (VD->getType().isVolatileQualified()) return false;
- // __block variables can't be allocated in a way that permits NRVO.
- if (VD->hasAttr<BlocksAttr>()) return false;
-
// Variables with higher required alignment than their type's ABI
// alignment cannot use NRVO.
if (!VD->getType()->isDependentType() && VD->hasAttr<AlignedAttr>() &&