================
@@ -1107,6 +1107,105 @@ bool SemaARM::CheckARMBuiltinFunctionCall(const 
TargetInfo &TI,
   }
 }
 
+static bool CheckAArch64AtomicStoreWithStshhCall(SemaARM &S,
+                                                 CallExpr *TheCall) {
+  Sema &SemaRef = S.SemaRef;
+  ASTContext &Context = S.getASTContext();
+  // Ensure we have the proper number of arguments.
+  if (SemaRef.checkArgCount(TheCall, 4))
+    return true;
+
+  // Normalize arg0/arg1 into value form, and check valid
+  ExprResult PtrRes =
+      SemaRef.DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
+  ExprResult ValRes =
+      SemaRef.DefaultFunctionArrayLvalueConversion(TheCall->getArg(1));
+
+  if (PtrRes.isInvalid() || ValRes.isInvalid())
+    return true;
+
+  Expr *OrderArg = TheCall->getArg(2);
+  TheCall->setArg(0, PtrRes.get());
+  TheCall->setArg(1, ValRes.get());
+
+  // Defer validation for dependent memory_order arguments.
+  if (OrderArg->isValueDependent())
+    return false;
+
+  Expr *PointerArg = PtrRes.get();
+  QualType PtrType = PointerArg->getType();
+
+  // Check arg 0 is a pointer type, err out if not
+  const PointerType *PointerTy = PtrType->getAs<PointerType>();
+  if (!PointerTy) {
+    SemaRef.Diag(PointerArg->getBeginLoc(),
+                 diag::err_atomic_builtin_must_be_pointer)
+        << PtrType << 0 << PointerArg->getSourceRange();
+    return true;
+  }
+
+  // Reject const-qualified pointee types
+  QualType ValType = PointerTy->getPointeeType();
+  if (ValType.isConstQualified()) {
+    SemaRef.Diag(PointerArg->getBeginLoc(),
+                 diag::err_atomic_builtin_cannot_be_const)
+        << PtrType << PointerArg->getSourceRange();
+    return true;
+  }
+
+  ValType = ValType.getUnqualifiedType();
+  unsigned Bits = 0;
+  if (!ValType->isIntegerType() ||
+      ((Bits = Context.getTypeSize(ValType)),
+       Bits != 8 && Bits != 16 && Bits != 32 && Bits != 64)) {
----------------
jthackray wrote:

Thanks, done.

https://github.com/llvm/llvm-project/pull/181386
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to