Update Clang for rebase to r212749.
This also fixes a small issue with arm_neon.h not being generated always.
Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android
Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index a169602..a33724a 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -17,6 +17,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/Designator.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/SemaInternal.h"
@@ -312,15 +313,20 @@
int numArrayElements(QualType DeclType);
int numStructUnionElements(QualType DeclType);
- void FillInValueInitForField(unsigned Init, FieldDecl *Field,
+ static ExprResult PerformEmptyInit(Sema &SemaRef,
+ SourceLocation Loc,
+ const InitializedEntity &Entity,
+ bool VerifyOnly);
+ void FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
const InitializedEntity &ParentEntity,
InitListExpr *ILE, bool &RequiresSecondPass);
- void FillInValueInitializations(const InitializedEntity &Entity,
+ void FillInEmptyInitializations(const InitializedEntity &Entity,
InitListExpr *ILE, bool &RequiresSecondPass);
bool CheckFlexibleArrayInit(const InitializedEntity &Entity,
Expr *InitExpr, FieldDecl *Field,
bool TopLevelObject);
- void CheckValueInitializable(const InitializedEntity &Entity);
+ void CheckEmptyInitializable(const InitializedEntity &Entity,
+ SourceLocation Loc);
public:
InitListChecker(Sema &S, const InitializedEntity &Entity,
@@ -333,33 +339,134 @@
};
} // end anonymous namespace
-void InitListChecker::CheckValueInitializable(const InitializedEntity &Entity) {
- assert(VerifyOnly &&
- "CheckValueInitializable is only inteded for verification mode.");
-
- SourceLocation Loc;
+ExprResult InitListChecker::PerformEmptyInit(Sema &SemaRef,
+ SourceLocation Loc,
+ const InitializedEntity &Entity,
+ bool VerifyOnly) {
InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
true);
- InitializationSequence InitSeq(SemaRef, Entity, Kind, None);
- if (InitSeq.Failed())
+ MultiExprArg SubInit;
+ Expr *InitExpr;
+ InitListExpr DummyInitList(SemaRef.Context, Loc, None, Loc);
+
+ // C++ [dcl.init.aggr]p7:
+ // If there are fewer initializer-clauses in the list than there are
+ // members in the aggregate, then each member not explicitly initialized
+ // ...
+ bool EmptyInitList = SemaRef.getLangOpts().CPlusPlus11 &&
+ Entity.getType()->getBaseElementTypeUnsafe()->isRecordType();
+ if (EmptyInitList) {
+ // C++1y / DR1070:
+ // shall be initialized [...] from an empty initializer list.
+ //
+ // We apply the resolution of this DR to C++11 but not C++98, since C++98
+ // does not have useful semantics for initialization from an init list.
+ // We treat this as copy-initialization, because aggregate initialization
+ // always performs copy-initialization on its elements.
+ //
+ // Only do this if we're initializing a class type, to avoid filling in
+ // the initializer list where possible.
+ InitExpr = VerifyOnly ? &DummyInitList : new (SemaRef.Context)
+ InitListExpr(SemaRef.Context, Loc, None, Loc);
+ InitExpr->setType(SemaRef.Context.VoidTy);
+ SubInit = InitExpr;
+ Kind = InitializationKind::CreateCopy(Loc, Loc);
+ } else {
+ // C++03:
+ // shall be value-initialized.
+ }
+
+ InitializationSequence InitSeq(SemaRef, Entity, Kind, SubInit);
+ // libstdc++4.6 marks the vector default constructor as explicit in
+ // _GLIBCXX_DEBUG mode, so recover using the C++03 logic in that case.
+ // stlport does so too. Look for std::__debug for libstdc++, and for
+ // std:: for stlport. This is effectively a compiler-side implementation of
+ // LWG2193.
+ if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
+ InitializationSequence::FK_ExplicitConstructor) {
+ OverloadCandidateSet::iterator Best;
+ OverloadingResult O =
+ InitSeq.getFailedCandidateSet()
+ .BestViableFunction(SemaRef, Kind.getLocation(), Best);
+ (void)O;
+ assert(O == OR_Success && "Inconsistent overload resolution");
+ CXXConstructorDecl *CtorDecl = cast<CXXConstructorDecl>(Best->Function);
+ CXXRecordDecl *R = CtorDecl->getParent();
+
+ if (CtorDecl->getMinRequiredArguments() == 0 &&
+ CtorDecl->isExplicit() && R->getDeclName() &&
+ SemaRef.SourceMgr.isInSystemHeader(CtorDecl->getLocation())) {
+
+
+ bool IsInStd = false;
+ for (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(R->getDeclContext());
+ ND && !IsInStd; ND = dyn_cast<NamespaceDecl>(ND->getParent())) {
+ if (SemaRef.getStdNamespace()->InEnclosingNamespaceSetOf(ND))
+ IsInStd = true;
+ }
+
+ if (IsInStd && llvm::StringSwitch<bool>(R->getName())
+ .Cases("basic_string", "deque", "forward_list", true)
+ .Cases("list", "map", "multimap", "multiset", true)
+ .Cases("priority_queue", "queue", "set", "stack", true)
+ .Cases("unordered_map", "unordered_set", "vector", true)
+ .Default(false)) {
+ InitSeq.InitializeFrom(
+ SemaRef, Entity,
+ InitializationKind::CreateValue(Loc, Loc, Loc, true),
+ MultiExprArg(), /*TopLevelOfInitList=*/false);
+ // Emit a warning for this. System header warnings aren't shown
+ // by default, but people working on system headers should see it.
+ if (!VerifyOnly) {
+ SemaRef.Diag(CtorDecl->getLocation(),
+ diag::warn_invalid_initializer_from_system_header);
+ SemaRef.Diag(Entity.getDecl()->getLocation(),
+ diag::note_used_in_initialization_here);
+ }
+ }
+ }
+ }
+ if (!InitSeq) {
+ if (!VerifyOnly) {
+ InitSeq.Diagnose(SemaRef, Entity, Kind, SubInit);
+ if (Entity.getKind() == InitializedEntity::EK_Member)
+ SemaRef.Diag(Entity.getDecl()->getLocation(),
+ diag::note_in_omitted_aggregate_initializer)
+ << /*field*/1 << Entity.getDecl();
+ else if (Entity.getKind() == InitializedEntity::EK_ArrayElement)
+ SemaRef.Diag(Loc, diag::note_in_omitted_aggregate_initializer)
+ << /*array element*/0 << Entity.getElementIndex();
+ }
+ return ExprError();
+ }
+
+ return VerifyOnly ? ExprResult(static_cast<Expr *>(nullptr))
+ : InitSeq.Perform(SemaRef, Entity, Kind, SubInit);
+}
+
+void InitListChecker::CheckEmptyInitializable(const InitializedEntity &Entity,
+ SourceLocation Loc) {
+ assert(VerifyOnly &&
+ "CheckEmptyInitializable is only inteded for verification mode.");
+ if (PerformEmptyInit(SemaRef, Loc, Entity, /*VerifyOnly*/true).isInvalid())
hadError = true;
}
-void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field,
+void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
const InitializedEntity &ParentEntity,
InitListExpr *ILE,
bool &RequiresSecondPass) {
- SourceLocation Loc = ILE->getLocStart();
+ SourceLocation Loc = ILE->getLocEnd();
unsigned NumInits = ILE->getNumInits();
InitializedEntity MemberEntity
= InitializedEntity::InitializeMember(Field, &ParentEntity);
if (Init >= NumInits || !ILE->getInit(Init)) {
- // If there's no explicit initializer but we have a default initializer, use
- // that. This only happens in C++1y, since classes with default
- // initializers are not aggregates in C++11.
+ // C++1y [dcl.init.aggr]p7:
+ // If there are fewer initializer-clauses in the list than there are
+ // members in the aggregate, then each member not explicitly initialized
+ // shall be initialized from its brace-or-equal-initializer [...]
if (Field->hasInClassInitializer()) {
- Expr *DIE = CXXDefaultInitExpr::Create(SemaRef.Context,
- ILE->getRBraceLoc(), Field);
+ Expr *DIE = CXXDefaultInitExpr::Create(SemaRef.Context, Loc, Field);
if (Init < NumInits)
ILE->setInit(Init, DIE);
else {
@@ -369,9 +476,6 @@
return;
}
- // FIXME: We probably don't need to handle references
- // specially here, since value-initialization of references is
- // handled in InitializationSequence.
if (Field->getType()->isReferenceType()) {
// C++ [dcl.init.aggr]p9:
// If an incomplete or empty initializer-list leaves a
@@ -386,17 +490,8 @@
return;
}
- InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
- true);
- InitializationSequence InitSeq(SemaRef, MemberEntity, Kind, None);
- if (!InitSeq) {
- InitSeq.Diagnose(SemaRef, MemberEntity, Kind, None);
- hadError = true;
- return;
- }
-
- ExprResult MemberInit
- = InitSeq.Perform(SemaRef, MemberEntity, Kind, None);
+ ExprResult MemberInit = PerformEmptyInit(SemaRef, Loc, MemberEntity,
+ /*VerifyOnly*/false);
if (MemberInit.isInvalid()) {
hadError = true;
return;
@@ -405,18 +500,18 @@
if (hadError) {
// Do nothing
} else if (Init < NumInits) {
- ILE->setInit(Init, MemberInit.takeAs<Expr>());
- } else if (InitSeq.isConstructorInitialization()) {
- // Value-initialization requires a constructor call, so
+ ILE->setInit(Init, MemberInit.getAs<Expr>());
+ } else if (!isa<ImplicitValueInitExpr>(MemberInit.get())) {
+ // Empty initialization requires a constructor call, so
// extend the initializer list to include the constructor
// call and make a note that we'll need to take another pass
// through the initializer list.
- ILE->updateInit(SemaRef.Context, Init, MemberInit.takeAs<Expr>());
+ ILE->updateInit(SemaRef.Context, Init, MemberInit.getAs<Expr>());
RequiresSecondPass = true;
}
} else if (InitListExpr *InnerILE
= dyn_cast<InitListExpr>(ILE->getInit(Init)))
- FillInValueInitializations(MemberEntity, InnerILE,
+ FillInEmptyInitializations(MemberEntity, InnerILE,
RequiresSecondPass);
}
@@ -424,25 +519,22 @@
/// with expressions that perform value-initialization of the
/// appropriate type.
void
-InitListChecker::FillInValueInitializations(const InitializedEntity &Entity,
+InitListChecker::FillInEmptyInitializations(const InitializedEntity &Entity,
InitListExpr *ILE,
bool &RequiresSecondPass) {
assert((ILE->getType() != SemaRef.Context.VoidTy) &&
"Should not have void type");
- SourceLocation Loc = ILE->getLocStart();
- if (ILE->getSyntacticForm())
- Loc = ILE->getSyntacticForm()->getLocStart();
if (const RecordType *RType = ILE->getType()->getAs<RecordType>()) {
const RecordDecl *RDecl = RType->getDecl();
if (RDecl->isUnion() && ILE->getInitializedFieldInUnion())
- FillInValueInitForField(0, ILE->getInitializedFieldInUnion(),
+ FillInEmptyInitForField(0, ILE->getInitializedFieldInUnion(),
Entity, ILE, RequiresSecondPass);
else if (RDecl->isUnion() && isa<CXXRecordDecl>(RDecl) &&
cast<CXXRecordDecl>(RDecl)->hasInClassInitializer()) {
for (auto *Field : RDecl->fields()) {
if (Field->hasInClassInitializer()) {
- FillInValueInitForField(0, Field, Entity, ILE, RequiresSecondPass);
+ FillInEmptyInitForField(0, Field, Entity, ILE, RequiresSecondPass);
break;
}
}
@@ -455,7 +547,7 @@
if (hadError)
return;
- FillInValueInitForField(Init, Field, Entity, ILE, RequiresSecondPass);
+ FillInEmptyInitForField(Init, Field, Entity, ILE, RequiresSecondPass);
if (hadError)
return;
@@ -489,7 +581,6 @@
} else
ElementType = ILE->getType();
-
for (unsigned Init = 0; Init != NumElements; ++Init) {
if (hadError)
return;
@@ -500,17 +591,9 @@
Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) : nullptr);
if (!InitExpr && !ILE->hasArrayFiller()) {
- InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc,
- true);
- InitializationSequence InitSeq(SemaRef, ElementEntity, Kind, None);
- if (!InitSeq) {
- InitSeq.Diagnose(SemaRef, ElementEntity, Kind, None);
- hadError = true;
- return;
- }
-
- ExprResult ElementInit
- = InitSeq.Perform(SemaRef, ElementEntity, Kind, None);
+ ExprResult ElementInit = PerformEmptyInit(SemaRef, ILE->getLocEnd(),
+ ElementEntity,
+ /*VerifyOnly*/false);
if (ElementInit.isInvalid()) {
hadError = true;
return;
@@ -522,29 +605,29 @@
// For arrays, just set the expression used for value-initialization
// of the "holes" in the array.
if (ElementEntity.getKind() == InitializedEntity::EK_ArrayElement)
- ILE->setArrayFiller(ElementInit.takeAs<Expr>());
+ ILE->setArrayFiller(ElementInit.getAs<Expr>());
else
- ILE->setInit(Init, ElementInit.takeAs<Expr>());
+ ILE->setInit(Init, ElementInit.getAs<Expr>());
} else {
// For arrays, just set the expression used for value-initialization
// of the rest of elements and exit.
if (ElementEntity.getKind() == InitializedEntity::EK_ArrayElement) {
- ILE->setArrayFiller(ElementInit.takeAs<Expr>());
+ ILE->setArrayFiller(ElementInit.getAs<Expr>());
return;
}
- if (InitSeq.isConstructorInitialization()) {
- // Value-initialization requires a constructor call, so
+ if (!isa<ImplicitValueInitExpr>(ElementInit.get())) {
+ // Empty initialization requires a constructor call, so
// extend the initializer list to include the constructor
// call and make a note that we'll need to take another pass
// through the initializer list.
- ILE->updateInit(SemaRef.Context, Init, ElementInit.takeAs<Expr>());
+ ILE->updateInit(SemaRef.Context, Init, ElementInit.getAs<Expr>());
RequiresSecondPass = true;
}
}
} else if (InitListExpr *InnerILE
= dyn_cast_or_null<InitListExpr>(InitExpr))
- FillInValueInitializations(ElementEntity, InnerILE, RequiresSecondPass);
+ FillInEmptyInitializations(ElementEntity, InnerILE, RequiresSecondPass);
}
}
@@ -562,9 +645,9 @@
if (!hadError && !VerifyOnly) {
bool RequiresSecondPass = false;
- FillInValueInitializations(Entity, FullyStructuredList, RequiresSecondPass);
+ FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass);
if (RequiresSecondPass && !hadError)
- FillInValueInitializations(Entity, FullyStructuredList,
+ FillInEmptyInitializations(Entity, FullyStructuredList,
RequiresSecondPass);
}
}
@@ -673,7 +756,6 @@
InitListExpr *IList, QualType &T,
InitListExpr *StructuredList,
bool TopLevelObject) {
- assert(IList->isExplicit() && "Illegal Implicit InitListExpr");
if (!VerifyOnly) {
SyntacticToSemantic[IList] = StructuredList;
StructuredList->setSyntacticForm(IList);
@@ -878,7 +960,7 @@
hadError = true;
UpdateStructuredListElement(StructuredList, StructuredIndex,
- Result.takeAs<Expr>());
+ Result.getAs<Expr>());
}
++Index;
return;
@@ -894,7 +976,7 @@
// compatible structure or union type. In the latter case, the
// initial value of the object, including unnamed members, is
// that of the expression.
- ExprResult ExprRes = SemaRef.Owned(expr);
+ ExprResult ExprRes = expr;
if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
SemaRef.CheckSingleAssignmentConstraints(ElemType, ExprRes,
!VerifyOnly)
@@ -902,16 +984,16 @@
if (ExprRes.isInvalid())
hadError = true;
else {
- ExprRes = SemaRef.DefaultFunctionArrayLvalueConversion(ExprRes.take());
+ ExprRes = SemaRef.DefaultFunctionArrayLvalueConversion(ExprRes.get());
if (ExprRes.isInvalid())
hadError = true;
}
UpdateStructuredListElement(StructuredList, StructuredIndex,
- ExprRes.takeAs<Expr>());
+ ExprRes.getAs<Expr>());
++Index;
return;
}
- ExprRes.release();
+ ExprRes.get();
// Fall through for subaggregate initialization
}
@@ -930,8 +1012,7 @@
if (!VerifyOnly) {
// We cannot initialize this element, so let
// PerformCopyInitialization produce the appropriate diagnostic.
- SemaRef.PerformCopyInitialization(Entity, SourceLocation(),
- SemaRef.Owned(expr),
+ SemaRef.PerformCopyInitialization(Entity, SourceLocation(), expr,
/*TopLevelOfInitList=*/true);
}
hadError = true;
@@ -1019,15 +1100,14 @@
}
if (VerifyOnly) {
- if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(expr)))
+ if (!SemaRef.CanPerformCopyInitialization(Entity,expr))
hadError = true;
++Index;
return;
}
ExprResult Result =
- SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(),
- SemaRef.Owned(expr),
+ SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr,
/*TopLevelOfInitList=*/true);
Expr *ResultExpr = nullptr;
@@ -1035,7 +1115,7 @@
if (Result.isInvalid())
hadError = true; // types weren't compatible.
else {
- ResultExpr = Result.takeAs<Expr>();
+ ResultExpr = Result.getAs<Expr>();
if (ResultExpr != expr) {
// The type was promoted, update initializer list.
@@ -1082,21 +1162,20 @@
}
if (VerifyOnly) {
- if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(expr)))
+ if (!SemaRef.CanPerformCopyInitialization(Entity,expr))
hadError = true;
++Index;
return;
}
ExprResult Result =
- SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(),
- SemaRef.Owned(expr),
- /*TopLevelOfInitList=*/true);
+ SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr,
+ /*TopLevelOfInitList=*/true);
if (Result.isInvalid())
hadError = true;
- expr = Result.takeAs<Expr>();
+ expr = Result.getAs<Expr>();
IList->setInit(Index, expr);
if (hadError)
@@ -1119,8 +1198,9 @@
if (Index >= IList->getNumInits()) {
// Make sure the element type can be value-initialized.
if (VerifyOnly)
- CheckValueInitializable(
- InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity));
+ CheckEmptyInitializable(
+ InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity),
+ IList->getLocEnd());
return;
}
@@ -1130,22 +1210,21 @@
Expr *Init = IList->getInit(Index);
if (!isa<InitListExpr>(Init) && Init->getType()->isVectorType()) {
if (VerifyOnly) {
- if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(Init)))
+ if (!SemaRef.CanPerformCopyInitialization(Entity, Init))
hadError = true;
++Index;
return;
}
- ExprResult Result =
- SemaRef.PerformCopyInitialization(Entity, Init->getLocStart(),
- SemaRef.Owned(Init),
- /*TopLevelOfInitList=*/true);
+ ExprResult Result =
+ SemaRef.PerformCopyInitialization(Entity, Init->getLocStart(), Init,
+ /*TopLevelOfInitList=*/true);
Expr *ResultExpr = nullptr;
if (Result.isInvalid())
hadError = true; // types weren't compatible.
else {
- ResultExpr = Result.takeAs<Expr>();
+ ResultExpr = Result.getAs<Expr>();
if (ResultExpr != Init) {
// The type was promoted, update initializer list.
@@ -1168,7 +1247,7 @@
// Don't attempt to go past the end of the init list
if (Index >= IList->getNumInits()) {
if (VerifyOnly)
- CheckValueInitializable(ElementEntity);
+ CheckEmptyInitializable(ElementEntity, IList->getLocEnd());
break;
}
@@ -1176,6 +1255,46 @@
CheckSubElementType(ElementEntity, IList, elementType, Index,
StructuredList, StructuredIndex);
}
+
+ if (VerifyOnly)
+ return;
+
+ bool isBigEndian = SemaRef.Context.getTargetInfo().isBigEndian();
+ const VectorType *T = Entity.getType()->getAs<VectorType>();
+ if (isBigEndian && (T->getVectorKind() == VectorType::NeonVector ||
+ T->getVectorKind() == VectorType::NeonPolyVector)) {
+ // The ability to use vector initializer lists is a GNU vector extension
+ // and is unrelated to the NEON intrinsics in arm_neon.h. On little
+ // endian machines it works fine, however on big endian machines it
+ // exhibits surprising behaviour:
+ //
+ // uint32x2_t x = {42, 64};
+ // return vget_lane_u32(x, 0); // Will return 64.
+ //
+ // Because of this, explicitly call out that it is non-portable.
+ //
+ SemaRef.Diag(IList->getLocStart(),
+ diag::warn_neon_vector_initializer_non_portable);
+
+ const char *typeCode;
+ unsigned typeSize = SemaRef.Context.getTypeSize(elementType);
+
+ if (elementType->isFloatingType())
+ typeCode = "f";
+ else if (elementType->isSignedIntegerType())
+ typeCode = "s";
+ else if (elementType->isUnsignedIntegerType())
+ typeCode = "u";
+ else
+ llvm_unreachable("Invalid element type!");
+
+ SemaRef.Diag(IList->getLocStart(),
+ SemaRef.Context.getTypeSize(VT) > 64 ?
+ diag::note_neon_vector_initializer_non_portable_q :
+ diag::note_neon_vector_initializer_non_portable)
+ << typeCode << typeSize;
+ }
+
return;
}
@@ -1345,8 +1464,9 @@
// If so, check if doing that is possible.
// FIXME: This needs to detect holes left by designated initializers too.
if (maxElementsKnown && elementIndex < maxElements)
- CheckValueInitializable(InitializedEntity::InitializeElement(
- SemaRef.Context, 0, Entity));
+ CheckEmptyInitializable(InitializedEntity::InitializeElement(
+ SemaRef.Context, 0, Entity),
+ IList->getLocEnd());
}
}
@@ -1431,8 +1551,9 @@
Field != FieldEnd; ++Field) {
if (Field->getDeclName()) {
if (VerifyOnly)
- CheckValueInitializable(
- InitializedEntity::InitializeMember(*Field, &Entity));
+ CheckEmptyInitializable(
+ InitializedEntity::InitializeMember(*Field, &Entity),
+ IList->getLocEnd());
else
StructuredList->setInitializedFieldInUnion(*Field);
break;
@@ -1544,8 +1665,9 @@
// FIXME: Should check for holes left by designated initializers too.
for (; Field != FieldEnd && !hadError; ++Field) {
if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
- CheckValueInitializable(
- InitializedEntity::InitializeMember(*Field, &Entity));
+ CheckEmptyInitializable(
+ InitializedEntity::InitializeMember(*Field, &Entity),
+ IList->getLocEnd());
}
}
@@ -2373,7 +2495,7 @@
Expr *Index = static_cast<Expr *>(D.getArrayIndex());
llvm::APSInt IndexValue;
if (!Index->isTypeDependent() && !Index->isValueDependent())
- Index = CheckArrayDesignatorExpr(*this, Index, IndexValue).take();
+ Index = CheckArrayDesignatorExpr(*this, Index, IndexValue).get();
if (!Index)
Invalid = true;
else {
@@ -2396,9 +2518,9 @@
EndIndex->isValueDependent();
if (!StartDependent)
StartIndex =
- CheckArrayDesignatorExpr(*this, StartIndex, StartValue).take();
+ CheckArrayDesignatorExpr(*this, StartIndex, StartValue).get();
if (!EndDependent)
- EndIndex = CheckArrayDesignatorExpr(*this, EndIndex, EndValue).take();
+ EndIndex = CheckArrayDesignatorExpr(*this, EndIndex, EndValue).get();
if (!StartIndex || !EndIndex)
Invalid = true;
@@ -2440,13 +2562,13 @@
= DesignatedInitExpr::Create(Context,
Designators.data(), Designators.size(),
InitExpressions, Loc, GNUSyntax,
- Init.takeAs<Expr>());
+ Init.getAs<Expr>());
if (!getLangOpts().C99)
Diag(DIE->getLocStart(), diag::ext_designated_init)
<< DIE->getSourceRange();
- return Owned(DIE);
+ return DIE;
}
//===----------------------------------------------------------------------===//
@@ -4433,7 +4555,7 @@
SetFailed(FK_PlaceholderType);
return;
}
- Args[I] = result.take();
+ Args[I] = result.get();
}
// C++0x [dcl.init]p16:
@@ -4982,7 +5104,7 @@
CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Best->Function);
SmallVector<Expr*, 8> ConstructorArgs;
- CurInit.release(); // Ownership transferred into MultiExprArg, below.
+ CurInit.get(); // Ownership transferred into MultiExprArg, below.
S.CheckConstructorAccess(Loc, Constructor, Entity,
Best->FoundDecl.getAccess(), IsExtraneousCopy);
@@ -5010,7 +5132,7 @@
S.BuildCXXDefaultArgExpr(Loc, Constructor, Parm);
}
- return S.Owned(CurInitExpr);
+ return CurInitExpr;
}
// Determine the arguments required to actually perform the
@@ -5030,7 +5152,7 @@
// If we're supposed to bind temporaries, do so.
if (!CurInit.isInvalid() && shouldBindAsTemporary(Entity))
- CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>());
+ CurInit = S.MaybeBindToTemporary(CurInit.getAs<Expr>());
return CurInit;
}
@@ -5047,8 +5169,7 @@
return;
SourceLocation Loc = getInitializationLoc(Entity, CurInitExpr);
- if (S.Diags.getDiagnosticLevel(diag::warn_cxx98_compat_temp_copy, Loc)
- == DiagnosticsEngine::Ignored)
+ if (S.Diags.isIgnored(diag::warn_cxx98_compat_temp_copy, Loc))
return;
// Find constructors which would have been considered.
@@ -5169,7 +5290,7 @@
S.DefineImplicitDefaultConstructor(Loc, Constructor);
}
- ExprResult CurInit = S.Owned((Expr *)nullptr);
+ ExprResult CurInit((Expr *)nullptr);
// C++ [over.match.copy]p1:
// - When initializing a temporary to be bound to the first parameter
@@ -5204,13 +5325,10 @@
? SourceRange(LBraceLoc, RBraceLoc)
: Kind.getParenRange();
- CurInit = S.Owned(
- new (S.Context) CXXTemporaryObjectExpr(S.Context, Constructor,
- TSInfo, ConstructorArgs,
- ParenOrBraceRange,
- HadMultipleCandidates,
- IsListInitialization,
- ConstructorInitRequiresZeroInit));
+ CurInit = new (S.Context) CXXTemporaryObjectExpr(
+ S.Context, Constructor, TSInfo, ConstructorArgs, ParenOrBraceRange,
+ HadMultipleCandidates, IsListInitialization,
+ ConstructorInitRequiresZeroInit);
} else {
CXXConstructExpr::ConstructionKind ConstructKind =
CXXConstructExpr::CK_Complete;
@@ -5262,7 +5380,7 @@
return ExprError();
if (shouldBindAsTemporary(Entity))
- CurInit = S.MaybeBindToTemporary(CurInit.take());
+ CurInit = S.MaybeBindToTemporary(CurInit.get());
return CurInit;
}
@@ -5589,7 +5707,7 @@
// No steps means no initialization.
if (Steps.empty())
- return S.Owned((Expr *)nullptr);
+ return ExprResult((Expr *)nullptr);
if (S.getLangOpts().CPlusPlus11 && Entity.getType()->isReferenceType() &&
Args.size() == 1 && isa<InitListExpr>(Args[0]) &&
@@ -5622,7 +5740,7 @@
*ResultType = Entity.getDecl() ? Entity.getDecl()->getType() :
Entity.getType();
- ExprResult CurInit = S.Owned((Expr *)nullptr);
+ ExprResult CurInit((Expr *)nullptr);
// For initialization steps that start with a single initializer,
// grab the only argument out the Args and place it into the "current"
@@ -5721,11 +5839,9 @@
(Step->Kind == SK_CastDerivedToBaseXValue ?
VK_XValue :
VK_RValue);
- CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
- Step->Type,
- CK_DerivedToBase,
- CurInit.get(),
- &BasePath, VK));
+ CurInit =
+ ImplicitCastExpr::Create(S.Context, Step->Type, CK_DerivedToBase,
+ CurInit.get(), &BasePath, VK);
break;
}
@@ -5803,7 +5919,7 @@
MTE->getType().isDestructedType()))
S.ExprNeedsCleanups = true;
- CurInit = S.Owned(MTE);
+ CurInit = MTE;
break;
}
@@ -5825,7 +5941,7 @@
// Build a call to the selected constructor.
SmallVector<Expr*, 8> ConstructorArgs;
SourceLocation Loc = CurInit.get()->getLocStart();
- CurInit.release(); // Ownership transferred into MultiExprArg, below.
+ CurInit.get(); // Ownership transferred into MultiExprArg, below.
// Determine the arguments required to actually perform the constructor
// call.
@@ -5870,7 +5986,7 @@
// derived-to-base conversion? I believe the answer is "no", because
// we don't want to turn off access control here for c-style casts.
ExprResult CurInitExprRes =
- S.PerformObjectArgumentInitialization(CurInit.take(),
+ S.PerformObjectArgumentInitialization(CurInit.get(),
/*Qualifier=*/nullptr,
FoundFn, Conversion);
if(CurInitExprRes.isInvalid())
@@ -5904,13 +6020,11 @@
}
}
- CurInit = S.Owned(ImplicitCastExpr::Create(S.Context,
- CurInit.get()->getType(),
- CastKind, CurInit.get(),
- nullptr,
- CurInit.get()->getValueKind()));
+ CurInit = ImplicitCastExpr::Create(S.Context, CurInit.get()->getType(),
+ CastKind, CurInit.get(), nullptr,
+ CurInit.get()->getValueKind());
if (MaybeBindToTemp)
- CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>());
+ CurInit = S.MaybeBindToTemporary(CurInit.getAs<Expr>());
if (RequiresCopy)
CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity,
CurInit, /*IsExtraneousCopy=*/false);
@@ -5927,17 +6041,15 @@
(Step->Kind == SK_QualificationConversionXValue ?
VK_XValue :
VK_RValue);
- CurInit = S.ImpCastExprToType(CurInit.take(), Step->Type, CK_NoOp, VK);
+ CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, CK_NoOp, VK);
break;
}
case SK_LValueToRValue: {
assert(CurInit.get()->isGLValue() && "cannot load from a prvalue");
- CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type,
- CK_LValueToRValue,
- CurInit.take(),
- /*BasePath=*/nullptr,
- VK_RValue));
+ CurInit = ImplicitCastExpr::Create(S.Context, Step->Type,
+ CK_LValueToRValue, CurInit.get(),
+ /*BasePath=*/nullptr, VK_RValue);
break;
}
@@ -5990,10 +6102,10 @@
InitListExpr *StructuredInitList =
PerformInitList.getFullyStructuredList();
- CurInit.release();
+ CurInit.get();
CurInit = shouldBindAsTemporary(InitEntity)
? S.MaybeBindToTemporary(StructuredInitList)
- : S.Owned(StructuredInitList);
+ : StructuredInitList;
break;
}
@@ -6023,18 +6135,18 @@
}
case SK_UnwrapInitList:
- CurInit = S.Owned(cast<InitListExpr>(CurInit.take())->getInit(0));
+ CurInit = cast<InitListExpr>(CurInit.get())->getInit(0);
break;
case SK_RewrapInitList: {
- Expr *E = CurInit.take();
+ Expr *E = CurInit.get();
InitListExpr *Syntactic = Step->WrappingSyntacticList;
InitListExpr *ILE = new (S.Context) InitListExpr(S.Context,
Syntactic->getLBraceLoc(), E, Syntactic->getRBraceLoc());
ILE->setSyntacticForm(Syntactic);
ILE->setType(E->getType());
ILE->setValueKind(E->getValueKind());
- CurInit = S.Owned(ILE);
+ CurInit = ILE;
break;
}
@@ -6075,12 +6187,11 @@
TSInfo = S.Context.getTrivialTypeSourceInfo(Step->Type,
Kind.getRange().getBegin());
- CurInit = S.Owned(new (S.Context) CXXScalarValueInitExpr(
- TSInfo->getType().getNonLValueExprType(S.Context),
- TSInfo,
- Kind.getRange().getEnd()));
+ CurInit = new (S.Context) CXXScalarValueInitExpr(
+ TSInfo->getType().getNonLValueExprType(S.Context), TSInfo,
+ Kind.getRange().getEnd());
} else {
- CurInit = S.Owned(new (S.Context) ImplicitValueInitExpr(Step->Type));
+ CurInit = new (S.Context) ImplicitValueInitExpr(Step->Type);
}
break;
}
@@ -6127,7 +6238,7 @@
}
case SK_ObjCObjectConversion:
- CurInit = S.ImpCastExprToType(CurInit.take(), Step->Type,
+ CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type,
CK_ObjCObjectLValueCast,
CurInit.get()->getValueKind());
break;
@@ -6165,16 +6276,15 @@
case SK_PassByIndirectCopyRestore:
case SK_PassByIndirectRestore:
checkIndirectCopyRestoreSource(S, CurInit.get());
- CurInit = S.Owned(new (S.Context)
- ObjCIndirectCopyRestoreExpr(CurInit.take(), Step->Type,
- Step->Kind == SK_PassByIndirectCopyRestore));
+ CurInit = new (S.Context) ObjCIndirectCopyRestoreExpr(
+ CurInit.get(), Step->Type,
+ Step->Kind == SK_PassByIndirectCopyRestore);
break;
case SK_ProduceObjCObject:
- CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type,
- CK_ARCProduceObject,
- CurInit.take(), nullptr,
- VK_RValue));
+ CurInit =
+ ImplicitCastExpr::Create(S.Context, Step->Type, CK_ARCProduceObject,
+ CurInit.get(), nullptr, VK_RValue);
break;
case SK_StdInitializerList: {
@@ -6197,13 +6307,12 @@
ExtendingEntity->getDecl());
// Wrap it in a construction of a std::initializer_list<T>.
- CurInit = S.Owned(
- new (S.Context) CXXStdInitializerListExpr(Step->Type, MTE));
+ CurInit = new (S.Context) CXXStdInitializerListExpr(Step->Type, MTE);
// Bind the result, in case the library has given initializer_list a
// non-trivial destructor.
if (shouldBindAsTemporary(Entity))
- CurInit = S.MaybeBindToTemporary(CurInit.take());
+ CurInit = S.MaybeBindToTemporary(CurInit.get());
break;
}
@@ -6227,7 +6336,7 @@
assert(Step->Type->isEventT() &&
"Event initialization on non-event type.");
- CurInit = S.ImpCastExprToType(CurInit.take(), Step->Type,
+ CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type,
CK_ZeroToOCLEvent,
CurInit.get()->getValueKind());
break;
@@ -6543,7 +6652,8 @@
Args.back()->getLocEnd());
if (Failure == FK_ListConstructorOverloadFailed) {
- assert(Args.size() == 1 && "List construction from other than 1 argument.");
+ assert(Args.size() == 1 &&
+ "List construction from other than 1 argument.");
InitListExpr *InitList = cast<InitListExpr>(Args[0]);
Args = MultiExprArg(InitList->getInits(), InitList->getNumInits());
}
@@ -6588,7 +6698,8 @@
<< S.Context.getTypeDeclType(Constructor->getParent())
<< /*member=*/1
<< Entity.getName();
- S.Diag(Entity.getDecl()->getLocation(), diag::note_field_decl);
+ S.Diag(Entity.getDecl()->getLocation(),
+ diag::note_member_declared_at);
if (const RecordType *Record
= Entity.getType()->getAs<RecordType>())
@@ -7101,7 +7212,7 @@
EqualLoc,
AllowExplicit);
InitializationSequence Seq(*this, Entity, Kind, InitE, TopLevelOfInitList);
- Init.release();
+ Init.get();
ExprResult Result = Seq.Perform(*this, Entity, Kind, InitE);