objc++: some minor cleanup and a test case
for atomic setters which requires assignment operator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141415 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 28e0fab..368bdc3 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -505,7 +505,7 @@
   "synthesized, or both be user defined,or the property must be nonatomic">;
 def warn_atomic_property_nontrivial_assign_op : Warning<
   "atomic property of type %0 synthesizing setter using non-trivial assignment"
-  "operator">, InGroup<DiagGroup<"objc-property-atomic-setter-synthesis">>;
+  " operator">, InGroup<DiagGroup<"objc-property-atomic-setter-synthesis">>;
 def warn_ownin_getter_rule : Warning<
   "property's synthesized getter follows Cocoa naming"
   " convention for returning 'owned' objects">,
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 13ccf82..7eb552c 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -805,15 +805,12 @@
           ObjCPropertyDecl::OBJC_PR_atomic) {
         Expr *callExpr = Res.takeAs<Expr>();
         if (const CXXOperatorCallExpr *CXXCE = 
-              dyn_cast_or_null<CXXOperatorCallExpr>(callExpr)) {
-          const CallExpr *CE = cast<CallExpr>(CXXCE);
-          if (const FunctionDecl *FuncDecl = CE->getDirectCallee()) {
+              dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
+          if (const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
             if (!FuncDecl->isTrivial())
               Diag(PropertyLoc, 
                    diag::warn_atomic_property_nontrivial_assign_op) 
                     << property->getType();
-          }
-        }
       }
       PIDecl->setSetterCXXAssignment(Res.takeAs<Expr>());
     }
diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm
index 98bc727..236dba6 100644
--- a/test/SemaObjCXX/property-reference.mm
+++ b/test/SemaObjCXX/property-reference.mm
@@ -29,7 +29,7 @@
 @implementation TNSObject
 
 @synthesize cppObjectNonAtomic;
-@synthesize cppObjectAtomic; // expected-warning{{atomic property of type 'CREF_TCPPObject' (aka 'const TCPPObject &') synthesizing setter using non-trivial assignmentoperator}}
+@synthesize cppObjectAtomic; // expected-warning{{atomic property of type 'CREF_TCPPObject' (aka 'const TCPPObject &') synthesizing setter using non-trivial assignment operator}}
 @dynamic cppObjectDynamic;
 
 - (const TCPPObject&) cppObjectNonAtomic
diff --git a/test/SemaObjCXX/property-synthesis-error.mm b/test/SemaObjCXX/property-synthesis-error.mm
index f79a56d..5ba4b70 100644
--- a/test/SemaObjCXX/property-synthesis-error.mm
+++ b/test/SemaObjCXX/property-synthesis-error.mm
@@ -43,19 +43,32 @@
  void* fData;
 };
 
+class Trivial
+{
+public:
+ Trivial(const Trivial& inObj);
+ Trivial();
+ ~Trivial();
+private:
+ void* fData;
+};
+
 @interface MyDocument
 {
 @private
  TCPPObject _cppObject;
  TCPPObject _ncppObject;
+ Trivial _tcppObject;
 }
 @property (assign, readwrite) const TCPPObject& cppObject;
 @property (assign, readwrite, nonatomic) const TCPPObject& ncppObject;
+@property (assign, readwrite) const Trivial& tcppObject;
 @end
 
 @implementation MyDocument
 
-@synthesize cppObject = _cppObject; // expected-warning {{atomic property of type 'const TCPPObject &' synthesizing setter using non-trivial assignmentoperator}}
+@synthesize cppObject = _cppObject; // expected-warning {{atomic property of type 'const TCPPObject &' synthesizing setter using non-trivial assignment operator}}
 @synthesize ncppObject = _ncppObject;
 
+@synthesize tcppObject = _tcppObject;
 @end