diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-05-08 20:20:55 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-05-08 20:20:55 +0000 |
commit | fe9e3940ebac6ef90afa7e1a3af307366c120983 (patch) | |
tree | 2d52da7530449e7823ec83f6cea9736212a2d3b5 /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | c3a3cb47d23c776a41699435c657b68fe781445d (diff) | |
download | bcm5719-llvm-fe9e3940ebac6ef90afa7e1a3af307366c120983.tar.gz bcm5719-llvm-fe9e3940ebac6ef90afa7e1a3af307366c120983.zip |
Refactoring of my last patch.
llvm-svn: 71248
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 34afdedba7d..981d13c15e4 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -19,6 +19,26 @@ #include "clang/Parse/DeclSpec.h" using namespace clang; +bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property, + ObjCMethodDecl *GetterMethod, + SourceLocation Loc) { + if (GetterMethod && + GetterMethod->getResultType() != property->getType()) { + AssignConvertType result = Incompatible; + if (Context.isObjCObjectPointerType(property->getType())) + result = CheckAssignmentConstraints(property->getType(), + GetterMethod->getResultType()); + if (result != Compatible) { + Diag(Loc, diag::warn_accessor_property_type_mismatch) + << property->getDeclName() + << GetterMethod->getSelector(); + Diag(GetterMethod->getLocation(), diag::note_declared_at); + return true; + } + } + return false; +} + /// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible /// and user declared, in the method definition's AST. void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) { @@ -1312,22 +1332,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, GetterMethod = CD->getInstanceMethod(Context, property->getGetterName()); SetterMethod = CD->getInstanceMethod(Context, property->getSetterName()); - - if (GetterMethod && - GetterMethod->getResultType() != property->getType()) { - AssignConvertType result = Incompatible; - if (Context.isObjCObjectPointerType(property->getType())) - result = CheckAssignmentConstraints(property->getType(), - GetterMethod->getResultType()); - if (result != Compatible) { - Diag(property->getLocation(), - diag::warn_accessor_property_type_mismatch) - << property->getDeclName() - << GetterMethod->getSelector(); - Diag(GetterMethod->getLocation(), diag::note_declared_at); - } - } - + DiagnosePropertyAccessorMismatch(property, GetterMethod, + property->getLocation()); + if (SetterMethod) { if (Context.getCanonicalType(SetterMethod->getResultType()) != Context.VoidTy) |