objc++: For atomic properties of c++ class objec typet, appropriate
operator= is called. Issue a warning for non-trivial case until
runtime support is provided. // rdar://6137845


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141302 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 880e9bf..5a54f57 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -16,6 +16,7 @@
 #include "clang/Sema/Initialization.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/ExprCXX.h"
 #include "llvm/ADT/DenseSet.h"
 
 using namespace clang;
@@ -800,6 +801,20 @@
                                             VK_LValue, SourceLocation());
       ExprResult Res = BuildBinOp(S, lhs->getLocEnd(), 
                                   BO_Assign, lhs, rhs);
+      if (property->getPropertyAttributes() & 
+          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()) {
+            if (!FuncDecl->isTrivial())
+              Diag(PropertyLoc, 
+                   diag::warn_atomic_property_nontrivial_assign_op) 
+                    << property->getType();
+          }
+        }
+      }
       PIDecl->setSetterCXXAssignment(Res.takeAs<Expr>());
     }
   }