[llvm-branch-commits] [cfe-branch] r71293 - in /cfe/branches/Apple/Dib/lib/Sema: Sema.h SemaDeclObjC.cpp SemaExpr.cpp

Mike Stump mrs at apple.com
Fri May 8 16:38:15 PDT 2009


Author: mrs
Date: Fri May  8 18:38:15 2009
New Revision: 71293

URL: http://llvm.org/viewvc/llvm-project?rev=71293&view=rev
Log:
Merge in 71248:

Refactoring of my last patch.

Modified:
    cfe/branches/Apple/Dib/lib/Sema/Sema.h
    cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
    cfe/branches/Apple/Dib/lib/Sema/SemaExpr.cpp

Modified: cfe/branches/Apple/Dib/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/Sema.h?rev=71293&r1=71292&r2=71293&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/Sema.h (original)
+++ cfe/branches/Apple/Dib/lib/Sema/Sema.h Fri May  8 18:38:15 2009
@@ -1270,6 +1270,9 @@
   // Expression Parsing Callbacks: SemaExpr.cpp.
 
   bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
+  bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, 
+                                        ObjCMethodDecl *Getter,
+                                        SourceLocation Loc);
 
   // Primary Expressions.
   virtual SourceRange getExprRange(ExprTy *E) const;

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp?rev=71293&r1=71292&r2=71293&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaDeclObjC.cpp Fri May  8 18:38:15 2009
@@ -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 @@
   
   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)

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaExpr.cpp?rev=71293&r1=71292&r2=71293&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaExpr.cpp Fri May  8 18:38:15 2009
@@ -2099,17 +2099,8 @@
       QualType ResTy = PD->getType();
       Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
       ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Context, Sel);
-      if (Getter) {
-        AssignConvertType result =
-          CheckAssignmentConstraints(PD->getType(), Getter->getResultType());
-        if (result != Compatible) {
-          Diag(MemberLoc, diag::warn_accessor_property_type_mismatch) 
-            << PD->getDeclName() << Sel;
-          Diag(Getter->getLocation(), diag::note_declared_at);
-          ResTy = Getter->getResultType();
-        }
-      }
-      
+      if (DiagnosePropertyAccessorMismatch(PD, Getter, MemberLoc))
+        ResTy = Getter->getResultType();
       return Owned(new (Context) ObjCPropertyRefExpr(PD, ResTy,
                                                      MemberLoc, BaseExpr));
     }





More information about the llvm-branch-commits mailing list