[PATCH] D51084: Implement -Watomic-implicit-seq-cst

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 21 22:03:02 PDT 2018


jfb created this revision.
jfb added a reviewer: rjmccall.
Herald added subscribers: cfe-commits, dexonsmith.

_Atomic and __sync_* operations are implicitly sequentially-consistent. Some
codebases want to force explicit usage of memory order instead. This warning
allows them to know where implicit sequentially-consistent memory order is used.
The warning isn't on by default because _Atomic was purposefully designed to
have seq_cst as the default: the idea was that it's the right thing to use most
of the time. This warning allows developers who disagree to enforce explicit
usage instead.

A follow-up patch will take care of C++'s std::atomic. It'll be different enough
from this patch that I think it should be separate: for C++ the atomic
operations all have a memory order parameter (or two), but it's defaulted. I
believe this warning should trigger when the default is used, but not when
seq_cst is used explicitly (or implicitly as the failure order for cmpxchg).

rdar://problem/28172966


Repository:
  rC Clang

https://reviews.llvm.org/D51084

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-implicit-seq_cst.c
  test/Sema/sync-implicit-seq_cst.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51084.161884.patch
Type: text/x-patch
Size: 25336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180822/565553ea/attachment-0001.bin>


More information about the cfe-commits mailing list