Update Clang for 3.5 rebase (r209713).
Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index c53dba3..186a741 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -25,7 +25,7 @@
//===----------------------------------------------------------------------===//
void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
- List = 0;
+ List = nullptr;
if (Elts == 0) return; // Setting to an empty list is a noop.
@@ -60,7 +60,7 @@
if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
return ivar;
}
- return 0;
+ return nullptr;
}
// Get the local instance/class method declared in this interface.
@@ -72,7 +72,7 @@
if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
if (Def->isHidden() && !AllowHidden)
- return 0;
+ return nullptr;
}
// Since instance & class methods can have the same name, the loop below
@@ -90,7 +90,7 @@
if (MD && MD->isInstanceMethod() == isInstance)
return MD;
}
- return 0;
+ return nullptr;
}
/// HasUserDeclaredSetterMethod - This routine returns 'true' if a user declared setter
@@ -157,7 +157,7 @@
if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(DC)) {
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
if (Def->isHidden())
- return 0;
+ return nullptr;
}
DeclContext::lookup_const_result R = DC->lookup(propertyID);
@@ -166,7 +166,7 @@
if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I))
return PD;
- return 0;
+ return nullptr;
}
IdentifierInfo *
@@ -187,7 +187,7 @@
if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
if (Def->isHidden())
- return 0;
+ return nullptr;
}
if (ObjCPropertyDecl *PD =
@@ -233,7 +233,7 @@
break;
}
}
- return 0;
+ return nullptr;
}
void ObjCInterfaceDecl::anchor() { }
@@ -247,8 +247,8 @@
IdentifierInfo *PropertyId) const {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
-
+ return nullptr;
+
if (data().ExternallyCompleted)
LoadExternalDefinition();
@@ -261,7 +261,7 @@
if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId))
return P;
- return 0;
+ return nullptr;
}
void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap &PM,
@@ -294,7 +294,7 @@
return Class;
Class = Class->getSuperClass();
}
- return 0;
+ return nullptr;
}
void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
@@ -350,7 +350,7 @@
break;
IFace = IFace->getSuperClass();
}
- return 0;
+ return nullptr;
}
static bool isIntroducingInitializers(const ObjCInterfaceDecl *D) {
@@ -364,6 +364,12 @@
return true;
}
}
+ if (const auto *ImplD = D->getImplementation()) {
+ for (const auto *MD : ImplD->instance_methods()) {
+ if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
+ return true;
+ }
+ }
return false;
}
@@ -379,11 +385,21 @@
// misleading warnings.
if (isIntroducingInitializers(this)) {
data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
- return false;
} else {
- data().InheritedDesignatedInitializers = DefinitionData::IDI_Inherited;
- return true;
+ if (auto SuperD = getSuperClass()) {
+ data().InheritedDesignatedInitializers =
+ SuperD->declaresOrInheritsDesignatedInitializers() ?
+ DefinitionData::IDI_Inherited :
+ DefinitionData::IDI_NotInherited;
+ } else {
+ data().InheritedDesignatedInitializers =
+ DefinitionData::IDI_NotInherited;
+ }
}
+ assert(data().InheritedDesignatedInitializers
+ != DefinitionData::IDI_Unknown);
+ return data().InheritedDesignatedInitializers ==
+ DefinitionData::IDI_Inherited;
}
}
@@ -467,13 +483,13 @@
ObjCInterfaceDecl *&clsDeclared) {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
+ return nullptr;
if (data().ExternallyCompleted)
LoadExternalDefinition();
ObjCInterfaceDecl* ClassDecl = this;
- while (ClassDecl != NULL) {
+ while (ClassDecl != nullptr) {
if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) {
clsDeclared = ClassDecl;
return I;
@@ -488,7 +504,7 @@
ClassDecl = ClassDecl->getSuperClass();
}
- return NULL;
+ return nullptr;
}
/// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super
@@ -498,18 +514,18 @@
const IdentifierInfo*ICName) {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
+ return nullptr;
if (data().ExternallyCompleted)
LoadExternalDefinition();
ObjCInterfaceDecl* ClassDecl = this;
- while (ClassDecl != NULL) {
+ while (ClassDecl != nullptr) {
if (ClassDecl->getIdentifier() == ICName)
return ClassDecl;
ClassDecl = ClassDecl->getSuperClass();
}
- return NULL;
+ return nullptr;
}
ObjCProtocolDecl *
@@ -518,7 +534,7 @@
if (P->lookupProtocolNamed(Name))
return P;
ObjCInterfaceDecl *SuperClass = getSuperClass();
- return SuperClass ? SuperClass->lookupNestedProtocol(Name) : NULL;
+ return SuperClass ? SuperClass->lookupNestedProtocol(Name) : nullptr;
}
/// lookupMethod - This method returns an instance/class method by looking in
@@ -533,10 +549,10 @@
{
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
+ return nullptr;
const ObjCInterfaceDecl* ClassDecl = this;
- ObjCMethodDecl *MethodDecl = 0;
+ ObjCMethodDecl *MethodDecl = nullptr;
if (data().ExternallyCompleted)
LoadExternalDefinition();
@@ -569,12 +585,12 @@
}
if (!followSuper)
- return NULL;
+ return nullptr;
// Get the super class (if any).
ClassDecl = ClassDecl->getSuperClass();
}
- return NULL;
+ return nullptr;
}
// Will search "local" class/category implementations for a method decl.
@@ -585,12 +601,12 @@
bool Instance) const {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
+ return nullptr;
if (data().ExternallyCompleted)
LoadExternalDefinition();
- ObjCMethodDecl *Method = 0;
+ ObjCMethodDecl *Method = nullptr;
if (ObjCImplementationDecl *ImpDecl = getImplementation())
Method = Instance ? ImpDecl->getInstanceMethod(Sel)
: ImpDecl->getClassMethod(Sel);
@@ -634,7 +650,7 @@
ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) ObjCMethodDecl(SourceLocation(), SourceLocation(),
- Selector(), QualType(), 0, 0);
+ Selector(), QualType(), nullptr, nullptr);
}
bool ObjCMethodDecl::isThisDeclarationADesignatedInitializer() const {
@@ -668,7 +684,7 @@
void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
ArrayRef<ParmVarDecl*> Params,
ArrayRef<SourceLocation> SelLocs) {
- ParamsAndSelLocs = 0;
+ ParamsAndSelLocs = nullptr;
NumParams = Params.size();
if (Params.empty() && SelLocs.empty())
return;
@@ -705,9 +721,9 @@
/// \brief A definition will return its interface declaration.
/// An interface declaration will return its definition.
/// Otherwise it will return itself.
-ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
+ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
ASTContext &Ctx = getASTContext();
- ObjCMethodDecl *Redecl = 0;
+ ObjCMethodDecl *Redecl = nullptr;
if (HasRedeclaration)
Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
if (Redecl)
@@ -932,7 +948,7 @@
if (ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
return IMD->getClassInterface();
if (isa<ObjCProtocolDecl>(getDeclContext()))
- return 0;
+ return nullptr;
llvm_unreachable("unknown method context");
}
@@ -1067,11 +1083,11 @@
Selector Sel = getSelector();
unsigned NumArgs = Sel.getNumArgs();
if (NumArgs > 1)
- return 0;
+ return nullptr;
if (!isInstanceMethod() || getMethodFamily() != OMF_None)
- return 0;
-
+ return nullptr;
+
if (isPropertyAccessor()) {
const ObjCContainerDecl *Container = cast<ObjCContainerDecl>(getParent());
// If container is class extension, find its primary class.
@@ -1092,7 +1108,7 @@
}
if (!CheckOverrides)
- return 0;
+ return nullptr;
typedef SmallVector<const ObjCMethodDecl *, 8> OverridesTy;
OverridesTy Overrides;
@@ -1103,8 +1119,7 @@
return Prop;
}
- return 0;
-
+ return nullptr;
}
//===----------------------------------------------------------------------===//
@@ -1119,35 +1134,37 @@
SourceLocation ClassLoc,
bool isInternal){
ObjCInterfaceDecl *Result = new (C, DC)
- ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, PrevDecl, isInternal);
+ ObjCInterfaceDecl(C, DC, atLoc, Id, ClassLoc, PrevDecl, isInternal);
Result->Data.setInt(!C.getLangOpts().Modules);
C.getObjCInterfaceType(Result, PrevDecl);
return Result;
}
-ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C,
+ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(const ASTContext &C,
unsigned ID) {
- ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(0, SourceLocation(),
- 0, SourceLocation(),
- 0, false);
+ ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(C, nullptr,
+ SourceLocation(),
+ nullptr,
+ SourceLocation(),
+ nullptr, false);
Result->Data.setInt(!C.getLangOpts().Modules);
return Result;
}
-ObjCInterfaceDecl::
-ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
- SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl,
- bool isInternal)
- : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, atLoc),
- TypeForDecl(0), Data()
-{
+ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
+ SourceLocation AtLoc, IdentifierInfo *Id,
+ SourceLocation CLoc,
+ ObjCInterfaceDecl *PrevDecl,
+ bool IsInternal)
+ : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
+ redeclarable_base(C), TypeForDecl(nullptr), Data() {
setPreviousDecl(PrevDecl);
// Copy the 'data' pointer over.
if (PrevDecl)
Data = PrevDecl->Data;
- setImplicit(isInternal);
+ setImplicit(IsInternal);
}
void ObjCInterfaceDecl::LoadExternalDefinition() const {
@@ -1192,7 +1209,7 @@
}
// FIXME: Should make sure no callers ever do this.
- return 0;
+ return nullptr;
}
void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) {
@@ -1225,9 +1242,9 @@
ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
-
- ObjCIvarDecl *curIvar = 0;
+ return nullptr;
+
+ ObjCIvarDecl *curIvar = nullptr;
if (!data().IvarList) {
if (!ivar_empty()) {
ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
@@ -1297,7 +1314,7 @@
ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
- return 0;
+ return nullptr;
if (data().ExternallyCompleted)
LoadExternalDefinition();
@@ -1305,8 +1322,8 @@
for (auto *Cat : visible_categories())
if (Cat->getIdentifier() == CategoryId)
return Cat;
-
- return 0;
+
+ return nullptr;
}
ObjCMethodDecl *
@@ -1317,7 +1334,7 @@
return MD;
}
- return 0;
+ return nullptr;
}
ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const {
@@ -1326,8 +1343,8 @@
if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel))
return MD;
}
-
- return 0;
+
+ return nullptr;
}
/// ClassImplementsProtocol - Checks that 'lProto' protocol
@@ -1407,7 +1424,7 @@
else
ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
}
- ID->setIvarList(0);
+ ID->setIvarList(nullptr);
}
return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
@@ -1415,8 +1432,9 @@
}
ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0,
- QualType(), 0, ObjCIvarDecl::None, 0, false);
+ return new (C, ID) ObjCIvarDecl(nullptr, SourceLocation(), SourceLocation(),
+ nullptr, QualType(), nullptr,
+ ObjCIvarDecl::None, nullptr, false);
}
const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const {
@@ -1458,8 +1476,9 @@
ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(),
- 0, QualType(), 0);
+ return new (C, ID) ObjCAtDefsFieldDecl(nullptr, SourceLocation(),
+ SourceLocation(), nullptr, QualType(),
+ nullptr);
}
//===----------------------------------------------------------------------===//
@@ -1468,12 +1487,12 @@
void ObjCProtocolDecl::anchor() { }
-ObjCProtocolDecl::ObjCProtocolDecl(DeclContext *DC, IdentifierInfo *Id,
- SourceLocation nameLoc,
+ObjCProtocolDecl::ObjCProtocolDecl(ASTContext &C, DeclContext *DC,
+ IdentifierInfo *Id, SourceLocation nameLoc,
SourceLocation atStartLoc,
ObjCProtocolDecl *PrevDecl)
- : ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc), Data()
-{
+ : ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc),
+ redeclarable_base(C), Data() {
setPreviousDecl(PrevDecl);
if (PrevDecl)
Data = PrevDecl->Data;
@@ -1485,7 +1504,7 @@
SourceLocation atStartLoc,
ObjCProtocolDecl *PrevDecl) {
ObjCProtocolDecl *Result =
- new (C, DC) ObjCProtocolDecl(DC, Id, nameLoc, atStartLoc, PrevDecl);
+ new (C, DC) ObjCProtocolDecl(C, DC, Id, nameLoc, atStartLoc, PrevDecl);
Result->Data.setInt(!C.getLangOpts().Modules);
return Result;
}
@@ -1493,7 +1512,8 @@
ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
ObjCProtocolDecl *Result =
- new (C, ID) ObjCProtocolDecl(0, 0, SourceLocation(), SourceLocation(), 0);
+ new (C, ID) ObjCProtocolDecl(C, nullptr, nullptr, SourceLocation(),
+ SourceLocation(), nullptr);
Result->Data.setInt(!C.getLangOpts().Modules);
return Result;
}
@@ -1508,20 +1528,20 @@
if ((PDecl = I->lookupProtocolNamed(Name)))
return PDecl;
- return NULL;
+ return nullptr;
}
// lookupMethod - Lookup a instance/class method in the protocol and protocols
// it inherited.
ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
bool isInstance) const {
- ObjCMethodDecl *MethodDecl = NULL;
+ ObjCMethodDecl *MethodDecl = nullptr;
// If there is no definition or the definition is hidden, we don't find
// anything.
const ObjCProtocolDecl *Def = getDefinition();
if (!Def || Def->isHidden())
- return NULL;
+ return nullptr;
if ((MethodDecl = getMethod(Sel, isInstance)))
return MethodDecl;
@@ -1529,7 +1549,7 @@
for (const auto *I : protocols())
if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
return MethodDecl;
- return NULL;
+ return nullptr;
}
void ObjCProtocolDecl::allocateDefinitionData() {
@@ -1615,8 +1635,9 @@
ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(),
- SourceLocation(), 0, 0);
+ return new (C, ID) ObjCCategoryDecl(nullptr, SourceLocation(),
+ SourceLocation(), SourceLocation(),
+ nullptr, nullptr);
}
ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const {
@@ -1650,15 +1671,16 @@
ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(),
- SourceLocation(), SourceLocation());
+ return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr,
+ SourceLocation(), SourceLocation(),
+ SourceLocation());
}
ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
// The class interface might be NULL if we are working with invalid code.
if (const ObjCInterfaceDecl *ID = getClassInterface())
return ID->FindCategoryDeclaration(getIdentifier());
- return 0;
+ return nullptr;
}
@@ -1697,7 +1719,7 @@
if (PID->getPropertyIvarDecl() &&
PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
return PID;
- return 0;
+ return nullptr;
}
/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
@@ -1709,7 +1731,7 @@
for (auto *PID : property_impls())
if (PID->getPropertyDecl()->getIdentifier() == Id)
return PID;
- return 0;
+ return nullptr;
}
raw_ostream &clang::operator<<(raw_ostream &OS,
@@ -1742,8 +1764,8 @@
ObjCImplementationDecl *
ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) ObjCImplementationDecl(0, 0, 0, SourceLocation(),
- SourceLocation());
+ return new (C, ID) ObjCImplementationDecl(nullptr, nullptr, nullptr,
+ SourceLocation(), SourceLocation());
}
void ObjCImplementationDecl::setIvarInitializers(ASTContext &C,
@@ -1781,7 +1803,8 @@
ObjCCompatibleAliasDecl *
ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0);
+ return new (C, ID) ObjCCompatibleAliasDecl(nullptr, SourceLocation(),
+ nullptr, nullptr);
}
//===----------------------------------------------------------------------===//
@@ -1802,8 +1825,9 @@
ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(),
- SourceLocation(), 0);
+ return new (C, ID) ObjCPropertyDecl(nullptr, SourceLocation(), nullptr,
+ SourceLocation(), SourceLocation(),
+ nullptr);
}
//===----------------------------------------------------------------------===//
@@ -1824,8 +1848,9 @@
ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(),
- 0, Dynamic, 0, SourceLocation());
+ return new (C, ID) ObjCPropertyImplDecl(nullptr, SourceLocation(),
+ SourceLocation(), nullptr, Dynamic,
+ nullptr, SourceLocation());
}
SourceRange ObjCPropertyImplDecl::getSourceRange() const {