зеркало из https://github.com/microsoft/clang-1.git
Patch to diagnose inconsistancies between properties declared in current and
its super class. This patch is incomplete. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
77d7ef8d8a
Коммит
b5e0224173
|
@ -718,8 +718,14 @@ public:
|
||||||
llvm::SmallVector<DeclTy *, 8> &
|
llvm::SmallVector<DeclTy *, 8> &
|
||||||
Protocols) {
|
Protocols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ComparePropertiesInBaseAndSuper - This routine compares property
|
||||||
|
/// declarations in base and its super class, if any, and issues
|
||||||
|
/// diagnostics in a variety of inconsistant situations.
|
||||||
|
///
|
||||||
|
virtual void ComparePropertiesInBaseAndSuper(SourceLocation *PropertyLoc,
|
||||||
|
DeclTy *ClassInterface) {
|
||||||
|
}
|
||||||
//===----------------------- Obj-C Expressions --------------------------===//
|
//===----------------------- Obj-C Expressions --------------------------===//
|
||||||
|
|
||||||
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
||||||
|
|
|
@ -652,6 +652,9 @@ public:
|
||||||
llvm::SmallVector<DeclTy *, 8> &
|
llvm::SmallVector<DeclTy *, 8> &
|
||||||
Protocols);
|
Protocols);
|
||||||
|
|
||||||
|
virtual void ComparePropertiesInBaseAndSuper(SourceLocation *PropertyLoc,
|
||||||
|
DeclTy *ClassInterface);
|
||||||
|
|
||||||
virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
|
virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
|
||||||
DeclTy **allMethods = 0, unsigned allNum = 0,
|
DeclTy **allMethods = 0, unsigned allNum = 0,
|
||||||
DeclTy **allProperties = 0, unsigned pNum = 0);
|
DeclTy **allProperties = 0, unsigned pNum = 0);
|
||||||
|
|
|
@ -246,6 +246,74 @@ Sema::FindProtocolDeclaration(SourceLocation TypeLoc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DiagnosePropertyMismatch - Compares two properties for their
|
||||||
|
/// attributes and types and warns on a variety of inconsistancies.
|
||||||
|
///
|
||||||
|
// TODO: Incomplete.
|
||||||
|
//
|
||||||
|
static void
|
||||||
|
DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
|
||||||
|
ObjCPropertyDecl *SuperProperty) {
|
||||||
|
ObjCPropertyDecl::PropertyAttributeKind CAttr =
|
||||||
|
Property->getPropertyAttributes();
|
||||||
|
ObjCPropertyDecl::PropertyAttributeKind SAttr =
|
||||||
|
SuperProperty->getPropertyAttributes();
|
||||||
|
if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly)
|
||||||
|
&& (SAttr & ObjCPropertyDecl::OBJC_PR_readwrite))
|
||||||
|
; // ???
|
||||||
|
|
||||||
|
if ((CAttr & ObjCPropertyDecl::OBJC_PR_copy)
|
||||||
|
!= (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
|
||||||
|
; //
|
||||||
|
else if ((CAttr & ObjCPropertyDecl::OBJC_PR_retain)
|
||||||
|
!= (SAttr & ObjCPropertyDecl::OBJC_PR_retain))
|
||||||
|
; // ???
|
||||||
|
|
||||||
|
if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
|
||||||
|
!= (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic))
|
||||||
|
; //
|
||||||
|
|
||||||
|
if (Property->getSetterName() != SuperProperty->getSetterName())
|
||||||
|
; //
|
||||||
|
if (Property->getGetterName() != SuperProperty->getGetterName())
|
||||||
|
; //
|
||||||
|
|
||||||
|
if (Property->getCanonicalType() != SuperProperty->getCanonicalType()) {
|
||||||
|
if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly)
|
||||||
|
&& (SAttr & ObjCPropertyDecl::OBJC_PR_readonly))
|
||||||
|
// && objc_compare_types(...))
|
||||||
|
;
|
||||||
|
else
|
||||||
|
; //
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ComparePropertiesInBaseAndSuper - This routine compares property
|
||||||
|
/// declarations in base and its super class, if any, and issues
|
||||||
|
/// diagnostics in a variety of inconsistant situations.
|
||||||
|
///
|
||||||
|
void
|
||||||
|
Sema::ComparePropertiesInBaseAndSuper(SourceLocation *PropertyLoc,
|
||||||
|
DeclTy *D) {
|
||||||
|
ObjCInterfaceDecl *IDecl =
|
||||||
|
dyn_cast<ObjCInterfaceDecl>(static_cast<Decl *>(D));
|
||||||
|
ObjCInterfaceDecl *SDecl = IDecl->getSuperClass();
|
||||||
|
if (!SDecl)
|
||||||
|
return;
|
||||||
|
for (ObjCInterfaceDecl::classprop_iterator I = SDecl->classprop_begin(),
|
||||||
|
E = SDecl->classprop_end(); I != E; ++I) {
|
||||||
|
ObjCPropertyDecl *SuperPDecl = (*I);
|
||||||
|
// Does property in super class has declaration in current class?
|
||||||
|
for (ObjCInterfaceDecl::classprop_iterator I = IDecl->classprop_begin(),
|
||||||
|
E = IDecl->classprop_end(); I != E; ++I) {
|
||||||
|
ObjCPropertyDecl *PDecl = (*I);
|
||||||
|
if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
|
||||||
|
DiagnosePropertyMismatch(PDecl, SuperPDecl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// ActOnForwardProtocolDeclaration -
|
/// ActOnForwardProtocolDeclaration -
|
||||||
Action::DeclTy *
|
Action::DeclTy *
|
||||||
Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче