[PATCH] D139113: [clang-tidy] Fix a couple additional cases in misc-use-anonymous-namespace

Kim Viggedal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 12 05:01:53 PST 2022


vingeldal accepted this revision.
vingeldal added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp:46-48
+// OK
+static const int v8{123};
+static constexpr int v9{123};
----------------
Is it really the best behavior to allow these? If I got the rationale right we don't warn about this because const and constexpr have implicit internal linkage anyway, so static doesn't make a difference, right?
Reading the documentation for this check I gather static would probably have been deprecated if it wasn't for the fact that deprecation would have broken compatibility with C. So, if we drop the static keyword here we still get the behavior we want, without a confusing keyword we would rather get rid of if we could, while keeping compatibility with C.

I'm thinking it could be better to just discourage from using static for cases like this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139113/new/

https://reviews.llvm.org/D139113



More information about the cfe-commits mailing list