aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-06 19:12:38 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-06 19:12:38 +0000
commit1cf9ff87ee235ad252332a96699abdb32bd6facb (patch)
tree370e9e0a0f71cbec27755371e579451693e2ffdb /lib/Sema
parent70101ce87ff1d73ac90e4d99a3af0ae509e5934f (diff)
Set and use Elidable in elimination of copy ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaExprCXX.cpp6
-rw-r--r--lib/Sema/SemaInit.cpp5
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 7e0422e432..5b74938191 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -911,8 +911,10 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
assert(!ToType->isReferenceType());
// FIXME: Keep track of whether the copy constructor is elidable or not.
- From = BuildCXXConstructExpr(Context,
- ToType, SCS.CopyConstructor, false, &From, 1);
+ bool Elidable = (isa<CallExpr>(From) ||
+ isa<CXXTemporaryObjectExpr>(From));
+ From = BuildCXXConstructExpr(Context, ToType,
+ SCS.CopyConstructor, Elidable, &From, 1);
return false;
}
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 445cd691d6..29113822f7 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -176,9 +176,10 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
DirectInit? IK_Direct : IK_Copy);
if (!Constructor)
return true;
-
+ bool Elidable = (isa<CallExpr>(Init) ||
+ isa<CXXTemporaryObjectExpr>(Init));
Init = BuildCXXConstructExpr(Context,
- DeclType, Constructor, false, &Init, 1);
+ DeclType, Constructor, Elidable, &Init, 1);
Init = MaybeCreateCXXExprWithTemporaries(Init, /*DestroyTemps=*/true);
return false;
}