diff options
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 34 | 
1 files changed, 30 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 88ad4d7527c..2f5be478065 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -1081,7 +1081,32 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl,         E = IDecl->prop_end();         I != E; ++I) {      ObjCPropertyDecl *Property = (*I); +    ObjCMethodDecl *GetterMethod = 0; +    ObjCMethodDecl *SetterMethod = 0; +    bool LookedUpGetterSetter = false; +      unsigned Attributes = Property->getPropertyAttributes(); +    unsigned AttributesAsWrittern = Property->getPropertyAttributesAsWritten(); + +    if (!(AttributesAsWrittern & ObjCPropertyDecl::OBJC_PR_atomic) && +        !(AttributesAsWrittern & ObjCPropertyDecl::OBJC_PR_nonatomic)) { +      GetterMethod = IMPDecl->getInstanceMethod(Property->getGetterName()); +      SetterMethod = IMPDecl->getInstanceMethod(Property->getSetterName()); +      LookedUpGetterSetter = true; +      if (GetterMethod) { +        Diag(GetterMethod->getLocation(), +             diag::warn_default_atomic_custom_getter_setter) +          << Property->getIdentifier(); +        Diag(Property->getLocation(), diag::note_property_declare); +      } +      if (SetterMethod) { +        Diag(SetterMethod->getLocation(), +             diag::warn_default_atomic_custom_getter_setter) +          << Property->getIdentifier(); +        Diag(Property->getLocation(), diag::note_property_declare); +      } +    } +      // We only care about readwrite atomic property.      if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||          !(Attributes & ObjCPropertyDecl::OBJC_PR_readwrite)) @@ -1090,10 +1115,11 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl,           = IMPDecl->FindPropertyImplDecl(Property->getIdentifier())) {        if (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)          continue; -      ObjCMethodDecl *GetterMethod = -        IMPDecl->getInstanceMethod(Property->getGetterName()); -      ObjCMethodDecl *SetterMethod = -        IMPDecl->getInstanceMethod(Property->getSetterName()); +      if (!LookedUpGetterSetter) { +        GetterMethod = IMPDecl->getInstanceMethod(Property->getGetterName()); +        SetterMethod = IMPDecl->getInstanceMethod(Property->getSetterName()); +        LookedUpGetterSetter = true; +      }        if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {          SourceLocation MethodLoc =            (GetterMethod ? GetterMethod->getLocation()  | 

