[PATCH] D77493: [clang-tidy] Add do-not-refer-atomic-twice check
JF Bastien via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 9 08:31:23 PDT 2020
jfb added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:10
+_Atomic int n2 = ATOMIC_VAR_INIT(0);
+_Atomic(int) n3 = ATOMIC_VAR_INIT(0);
+
----------------
Can you cover `std::atomic` as well?
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:10
+_Atomic int n2 = ATOMIC_VAR_INIT(0);
+_Atomic(int) n3 = ATOMIC_VAR_INIT(0);
+
----------------
jfb wrote:
> Can you cover `std::atomic` as well?
We deprecated `ATOMIC_VAR_INIT` in C++20 and C17, I wouldn't use it here (even if it's just your own macro).
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:77
+ n3++;
+}
----------------
Can you check that non-atomic-accesses to the variable also work, for example taking the atomic's address, using it in unevaluated `sizeof` / `offsetof`, etc.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77493/new/
https://reviews.llvm.org/D77493
More information about the cfe-commits
mailing list