зеркало из https://github.com/microsoft/clang-1.git
Replace all comparisons between ObjCInterfaceDecl pointers with calls
to declaresSameEntity(), as a baby step toward tracking forward declarations of Objective-C classes precisely. Part of <rdar://problem/10583531>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146618 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
643d3ce93c
Коммит
60ef308e51
|
@ -742,7 +742,7 @@ public:
|
||||||
bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
|
bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
|
||||||
// If RHS is derived from LHS it is OK; else it is not OK.
|
// If RHS is derived from LHS it is OK; else it is not OK.
|
||||||
while (I != NULL) {
|
while (I != NULL) {
|
||||||
if (this == I)
|
if (declaresSameEntity(this, I))
|
||||||
return true;
|
return true;
|
||||||
I = I->getSuperClass();
|
I = I->getSuperClass();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5469,7 +5469,7 @@ QualType ASTContext::areCommonBaseCompatible(
|
||||||
const ObjCObjectType *RHS = Rptr->getObjectType();
|
const ObjCObjectType *RHS = Rptr->getObjectType();
|
||||||
const ObjCInterfaceDecl* LDecl = LHS->getInterface();
|
const ObjCInterfaceDecl* LDecl = LHS->getInterface();
|
||||||
const ObjCInterfaceDecl* RDecl = RHS->getInterface();
|
const ObjCInterfaceDecl* RDecl = RHS->getInterface();
|
||||||
if (!LDecl || !RDecl || (LDecl == RDecl))
|
if (!LDecl || !RDecl || (declaresSameEntity(LDecl, RDecl)))
|
||||||
return QualType();
|
return QualType();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -3373,7 +3373,7 @@ Decl *ASTNodeImporter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
|
||||||
if ((Super && !Impl->getSuperClass()) ||
|
if ((Super && !Impl->getSuperClass()) ||
|
||||||
(!Super && Impl->getSuperClass()) ||
|
(!Super && Impl->getSuperClass()) ||
|
||||||
(Super && Impl->getSuperClass() &&
|
(Super && Impl->getSuperClass() &&
|
||||||
Super->getCanonicalDecl() != Impl->getSuperClass())) {
|
!declaresSameEntity(Super->getCanonicalDecl(), Impl->getSuperClass()))) {
|
||||||
Importer.ToDiag(Impl->getLocation(),
|
Importer.ToDiag(Impl->getLocation(),
|
||||||
diag::err_odr_objc_superclass_inconsistent)
|
diag::err_odr_objc_superclass_inconsistent)
|
||||||
<< Iface->getDeclName();
|
<< Iface->getDeclName();
|
||||||
|
|
|
@ -41,7 +41,7 @@ static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM,
|
||||||
// If we know have an implementation (and the ivar is in it) then
|
// If we know have an implementation (and the ivar is in it) then
|
||||||
// look up in the implementation layout.
|
// look up in the implementation layout.
|
||||||
const ASTRecordLayout *RL;
|
const ASTRecordLayout *RL;
|
||||||
if (ID && ID->getClassInterface() == Container)
|
if (ID && declaresSameEntity(ID->getClassInterface(), Container))
|
||||||
RL = &CGM.getContext().getASTObjCImplementationLayout(ID);
|
RL = &CGM.getContext().getASTObjCImplementationLayout(ID);
|
||||||
else
|
else
|
||||||
RL = &CGM.getContext().getASTObjCInterfaceLayout(Container);
|
RL = &CGM.getContext().getASTObjCInterfaceLayout(Container);
|
||||||
|
|
|
@ -205,7 +205,7 @@ public:
|
||||||
assert(MsgD);
|
assert(MsgD);
|
||||||
|
|
||||||
// Same interface ? We have a winner!
|
// Same interface ? We have a winner!
|
||||||
if (MsgD == IFace)
|
if (declaresSameEntity(MsgD, IFace))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If the message interface is a superclass of the original interface,
|
// If the message interface is a superclass of the original interface,
|
||||||
|
@ -220,7 +220,7 @@ public:
|
||||||
if (IFace) {
|
if (IFace) {
|
||||||
Selector Sel = Msg->getSelector();
|
Selector Sel = Msg->getSelector();
|
||||||
for (ObjCInterfaceDecl *Cls = MsgD; Cls; Cls = Cls->getSuperClass()) {
|
for (ObjCInterfaceDecl *Cls = MsgD; Cls; Cls = Cls->getSuperClass()) {
|
||||||
if (Cls == IFace)
|
if (declaresSameEntity(Cls, IFace))
|
||||||
return true;
|
return true;
|
||||||
if (Cls->getMethod(Sel, IsInstanceMethod))
|
if (Cls->getMethod(Sel, IsInstanceMethod))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5938,7 +5938,7 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||||
OldRange.getEnd(),
|
OldRange.getEnd(),
|
||||||
castExpr);
|
castExpr);
|
||||||
if (IV->isFreeIvar() &&
|
if (IV->isFreeIvar() &&
|
||||||
CurMethodDef->getClassInterface() == iFaceDecl->getDecl()) {
|
declaresSameEntity(CurMethodDef->getClassInterface(), iFaceDecl->getDecl())) {
|
||||||
MemberExpr *ME = new (Context) MemberExpr(PE, true, D,
|
MemberExpr *ME = new (Context) MemberExpr(PE, true, D,
|
||||||
IV->getLocation(),
|
IV->getLocation(),
|
||||||
D->getType(),
|
D->getType(),
|
||||||
|
|
|
@ -1701,7 +1701,7 @@ bool Sema::IsSimplyAccessible(NamedDecl *Decl, DeclContext *Ctx) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we're inside the same interface that owns the ivar, we're fine.
|
// If we're inside the same interface that owns the ivar, we're fine.
|
||||||
if (ClassOfMethodDecl == Ivar->getContainingInterface())
|
if (declaresSameEntity(ClassOfMethodDecl, Ivar->getContainingInterface()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If the ivar is private, it's inaccessible.
|
// If the ivar is private, it's inaccessible.
|
||||||
|
|
|
@ -417,7 +417,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
||||||
DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope,
|
DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope,
|
||||||
NULL, NULL, false, CTC_NoKeywords);
|
NULL, NULL, false, CTC_NoKeywords);
|
||||||
if ((PrevDecl = Corrected.getCorrectionDeclAs<ObjCInterfaceDecl>())) {
|
if ((PrevDecl = Corrected.getCorrectionDeclAs<ObjCInterfaceDecl>())) {
|
||||||
if (PrevDecl == IDecl) {
|
if (declaresSameEntity(PrevDecl, IDecl)) {
|
||||||
// Don't correct to the class we're defining.
|
// Don't correct to the class we're defining.
|
||||||
PrevDecl = 0;
|
PrevDecl = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,7 +429,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrevDecl == IDecl) {
|
if (declaresSameEntity(PrevDecl, IDecl)) {
|
||||||
Diag(SuperLoc, diag::err_recursive_superclass)
|
Diag(SuperLoc, diag::err_recursive_superclass)
|
||||||
<< SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
|
<< SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
|
||||||
IDecl->setLocEnd(ClassLoc);
|
IDecl->setLocEnd(ClassLoc);
|
||||||
|
@ -924,7 +924,7 @@ Decl *Sema::ActOnStartClassImplementation(
|
||||||
if (!SDecl)
|
if (!SDecl)
|
||||||
Diag(SuperClassLoc, diag::err_undef_superclass)
|
Diag(SuperClassLoc, diag::err_undef_superclass)
|
||||||
<< SuperClassname << ClassName;
|
<< SuperClassname << ClassName;
|
||||||
else if (IDecl && IDecl->getSuperClass() != SDecl) {
|
else if (IDecl && !declaresSameEntity(IDecl->getSuperClass(), SDecl)) {
|
||||||
// This implementation and its interface do not have the same
|
// This implementation and its interface do not have the same
|
||||||
// super class.
|
// super class.
|
||||||
Diag(SuperClassLoc, diag::err_conflicting_super_class)
|
Diag(SuperClassLoc, diag::err_conflicting_super_class)
|
||||||
|
@ -2439,7 +2439,7 @@ CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method,
|
||||||
if (ObjCInterfaceDecl *ResultClass
|
if (ObjCInterfaceDecl *ResultClass
|
||||||
= ResultObjectType->getInterfaceDecl()) {
|
= ResultObjectType->getInterfaceDecl()) {
|
||||||
// - it is the same as the method's class type, or
|
// - it is the same as the method's class type, or
|
||||||
if (CurrentClass == ResultClass)
|
if (declaresSameEntity(CurrentClass, ResultClass))
|
||||||
return RTC_Compatible;
|
return RTC_Compatible;
|
||||||
|
|
||||||
// - it is a superclass of the method's class type
|
// - it is a superclass of the method's class type
|
||||||
|
|
|
@ -1975,7 +1975,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
|
||||||
|
|
||||||
// Diagnose the use of an ivar outside of the declaring class.
|
// Diagnose the use of an ivar outside of the declaring class.
|
||||||
if (IV->getAccessControl() == ObjCIvarDecl::Private &&
|
if (IV->getAccessControl() == ObjCIvarDecl::Private &&
|
||||||
ClassDeclared != IFace)
|
!declaresSameEntity(ClassDeclared, IFace))
|
||||||
Diag(Loc, diag::error_private_ivar_access) << IV->getDeclName();
|
Diag(Loc, diag::error_private_ivar_access) << IV->getDeclName();
|
||||||
|
|
||||||
// FIXME: This should use a new expr for a direct reference, don't
|
// FIXME: This should use a new expr for a direct reference, don't
|
||||||
|
@ -2005,7 +2005,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
|
||||||
ObjCInterfaceDecl *ClassDeclared;
|
ObjCInterfaceDecl *ClassDeclared;
|
||||||
if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
|
if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
|
||||||
if (IV->getAccessControl() != ObjCIvarDecl::Private ||
|
if (IV->getAccessControl() != ObjCIvarDecl::Private ||
|
||||||
IFace == ClassDeclared)
|
declaresSameEntity(IFace, ClassDeclared))
|
||||||
Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
|
Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1150,8 +1150,8 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IV->getAccessControl() == ObjCIvarDecl::Private) {
|
if (IV->getAccessControl() == ObjCIvarDecl::Private) {
|
||||||
if (ClassDeclared != IDecl ||
|
if (!declaresSameEntity(ClassDeclared, IDecl) ||
|
||||||
ClassOfMethodDecl != ClassDeclared)
|
!declaresSameEntity(ClassOfMethodDecl, ClassDeclared))
|
||||||
Diag(MemberLoc, diag::error_private_ivar_access)
|
Diag(MemberLoc, diag::error_private_ivar_access)
|
||||||
<< IV->getDeclName();
|
<< IV->getDeclName();
|
||||||
} else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
|
} else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
|
||||||
|
|
|
@ -690,7 +690,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
|
||||||
// Note! I deliberately want it to fall thru so, we have a
|
// Note! I deliberately want it to fall thru so, we have a
|
||||||
// a property implementation and to avoid future warnings.
|
// a property implementation and to avoid future warnings.
|
||||||
} else if (getLangOptions().ObjCNonFragileABI &&
|
} else if (getLangOptions().ObjCNonFragileABI &&
|
||||||
ClassDeclared != IDecl) {
|
!declaresSameEntity(ClassDeclared, IDecl)) {
|
||||||
Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
|
Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
|
||||||
<< property->getDeclName() << Ivar->getDeclName()
|
<< property->getDeclName() << Ivar->getDeclName()
|
||||||
<< ClassDeclared->getDeclName();
|
<< ClassDeclared->getDeclName();
|
||||||
|
@ -870,7 +870,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
|
||||||
}
|
}
|
||||||
// Issue diagnostics only if Ivar belongs to current class.
|
// Issue diagnostics only if Ivar belongs to current class.
|
||||||
if (Ivar && Ivar->getSynthesize() &&
|
if (Ivar && Ivar->getSynthesize() &&
|
||||||
IC->getClassInterface() == ClassDeclared) {
|
declaresSameEntity(IC->getClassInterface(), ClassDeclared)) {
|
||||||
Diag(Ivar->getLocation(), diag::err_undeclared_var_use)
|
Diag(Ivar->getLocation(), diag::err_undeclared_var_use)
|
||||||
<< PropertyId;
|
<< PropertyId;
|
||||||
Ivar->setInvalidDecl();
|
Ivar->setInvalidDecl();
|
||||||
|
|
|
@ -2300,7 +2300,8 @@ bool Sema::FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
|
||||||
ToType->getAs<ObjCObjectPointerType>()) {
|
ToType->getAs<ObjCObjectPointerType>()) {
|
||||||
if (const ObjCObjectPointerType *PTFr =
|
if (const ObjCObjectPointerType *PTFr =
|
||||||
FromType->getAs<ObjCObjectPointerType>())
|
FromType->getAs<ObjCObjectPointerType>())
|
||||||
if (PTTo->getInterfaceDecl() == PTFr->getInterfaceDecl())
|
if (declaresSameEntity(PTTo->getInterfaceDecl(),
|
||||||
|
PTFr->getInterfaceDecl()))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ArgPos) *ArgPos = O - OldType->arg_type_begin();
|
if (ArgPos) *ArgPos = O - OldType->arg_type_begin();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче