зеркало из https://github.com/microsoft/clang-1.git
Use MaybeCreateCXXExprWithTemporaries for potential destruction of
created temporary. Use own initialized entity for copied in block variables. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105533 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
998622c101
Коммит
310b1c4216
|
@ -1757,11 +1757,12 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
|
|||
SourceLocation());
|
||||
|
||||
OwningExprResult Res = PerformCopyInitialization(
|
||||
InitializedEntity::InitializeResult(SourceLocation(),
|
||||
T, false),
|
||||
InitializedEntity::InitializeBlock(VD->getLocation(),
|
||||
T, false),
|
||||
SourceLocation(),
|
||||
Owned(E));
|
||||
if (!Res.isInvalid()) {
|
||||
Res = MaybeCreateCXXExprWithTemporaries(move(Res));
|
||||
Expr *Init = Res.takeAs<Expr>();
|
||||
if (isa<CXXConstructExpr>(Init))
|
||||
BDRE->setCopyConstructorExpr(Init);
|
||||
|
|
|
@ -1956,6 +1956,7 @@ DeclarationName InitializedEntity::getName() const {
|
|||
case EK_Base:
|
||||
case EK_ArrayElement:
|
||||
case EK_VectorElement:
|
||||
case EK_BlockElement:
|
||||
return DeclarationName();
|
||||
}
|
||||
|
||||
|
@ -1977,6 +1978,7 @@ DeclaratorDecl *InitializedEntity::getDecl() const {
|
|||
case EK_Base:
|
||||
case EK_ArrayElement:
|
||||
case EK_VectorElement:
|
||||
case EK_BlockElement:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1998,6 +2000,7 @@ bool InitializedEntity::allowsNRVO() const {
|
|||
case EK_Base:
|
||||
case EK_ArrayElement:
|
||||
case EK_VectorElement:
|
||||
case EK_BlockElement:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3170,6 +3173,7 @@ getAssignmentAction(const InitializedEntity &Entity) {
|
|||
case InitializedEntity::EK_Member:
|
||||
case InitializedEntity::EK_ArrayElement:
|
||||
case InitializedEntity::EK_VectorElement:
|
||||
case InitializedEntity::EK_BlockElement:
|
||||
return Sema::AA_Initializing;
|
||||
}
|
||||
|
||||
|
@ -3188,6 +3192,7 @@ static bool shouldBindAsTemporary(const InitializedEntity &Entity) {
|
|||
case InitializedEntity::EK_Base:
|
||||
case InitializedEntity::EK_VectorElement:
|
||||
case InitializedEntity::EK_Exception:
|
||||
case InitializedEntity::EK_BlockElement:
|
||||
return false;
|
||||
|
||||
case InitializedEntity::EK_Parameter:
|
||||
|
@ -3207,6 +3212,7 @@ static bool shouldDestroyTemporary(const InitializedEntity &Entity) {
|
|||
case InitializedEntity::EK_New:
|
||||
case InitializedEntity::EK_Base:
|
||||
case InitializedEntity::EK_VectorElement:
|
||||
case InitializedEntity::EK_BlockElement:
|
||||
return false;
|
||||
|
||||
case InitializedEntity::EK_Variable:
|
||||
|
@ -3291,6 +3297,7 @@ static Sema::OwningExprResult CopyObject(Sema &S,
|
|||
case InitializedEntity::EK_New:
|
||||
case InitializedEntity::EK_Base:
|
||||
case InitializedEntity::EK_VectorElement:
|
||||
case InitializedEntity::EK_BlockElement:
|
||||
Loc = CurInitExpr->getLocStart();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,10 @@ public:
|
|||
EK_Base,
|
||||
/// \brief The entity being initialized is an element of a vector.
|
||||
/// or vector.
|
||||
EK_VectorElement
|
||||
EK_VectorElement,
|
||||
/// \brief The entity being initialized is a field of block descriptor for
|
||||
/// the copied-in c++ object.
|
||||
EK_BlockElement
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -166,6 +169,11 @@ public:
|
|||
return InitializedEntity(EK_Result, ReturnLoc, Type, NRVO);
|
||||
}
|
||||
|
||||
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc,
|
||||
QualType Type, bool NRVO) {
|
||||
return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO);
|
||||
}
|
||||
|
||||
/// \brief Create the initialization entity for an exception object.
|
||||
static InitializedEntity InitializeException(SourceLocation ThrowLoc,
|
||||
QualType Type, bool NRVO) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче