[clang] Add clang atomic control options and attribute (PR #114841)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 24 06:31:05 PST 2025


================
@@ -625,6 +625,41 @@ static Attr *handleHLSLControlFlowHint(Sema &S, Stmt *St, const ParsedAttr &A,
   return ::new (S.Context) HLSLControlFlowHintAttr(S.Context, A);
 }
 
+static Attr *handleAtomicAttr(Sema &S, Stmt *St, const ParsedAttr &AL,
+                              SourceRange Range) {
+  if (!AL.checkAtLeastNumArgs(S, 1))
+    return nullptr;
+
+  if (!isa<CompoundStmt>(St)) {
+    S.Diag(St->getBeginLoc(), diag::err_attribute_wrong_decl_type)
+        << AL << "compound statement";
+    return nullptr;
+  }
+
+  SmallVector<AtomicAttr::ConsumedOption, 6> Options;
+  for (unsigned ArgIndex = 0; ArgIndex < AL.getNumArgs(); ++ArgIndex) {
+    AtomicAttr::ConsumedOption Option;
+    StringRef OptionString;
+    SourceLocation Loc;
+    if (AL.isArgIdent(ArgIndex)) {
+      IdentifierLoc *Ident = AL.getArgAsIdent(ArgIndex);
+      OptionString = Ident->Ident->getName();
+      Loc = Ident->Loc;
+    } else {
+      if (!S.checkStringLiteralArgumentAttr(AL, ArgIndex, OptionString, &Loc))
----------------
erichkeane wrote:

Do we allow string arguments anymore?  I THINK the point of this else-branch is we would permit:

` [[clang::atomic("no_remote_memory")]]`

Which we aren't documenting anywhere.

https://github.com/llvm/llvm-project/pull/114841


More information about the cfe-commits mailing list