This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add misc-use-anonymous-namespace check
ClosedPublic

Authored by carlosgalvezp on Nov 3 2022, 8:00 AM.

Diff Detail

Event Timeline

carlosgalvezp created this revision.Nov 3 2022, 8:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 8:00 AM
Herald added a subscriber: xazax.hun. · View Herald Transcript
carlosgalvezp requested review of this revision.Nov 3 2022, 8:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 8:00 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Fix release notes.

Add reference to undeprecation of static.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/modernize/UseAnonymousNamespaceCheck.cpp
31 ↗(On Diff #472948)

Please don't use auto unless type is explicitly spelled in same statement or iterator.

Address review comments.

carlosgalvezp marked an inline comment as done.Nov 3 2022, 11:51 AM

I'm not entirely sure why this belongs in the modernize module given anonymous namespaces have been in c++ forever, maybe its more of a misc check? Also the modernize checks are meant to actually emit fixes(ignore the c arrays check :) ), Right now, this only warn, it doesn't appear to act

I'm not entirely sure why this belongs in the modernize module given anonymous namespaces have been in c++ forever, maybe its more of a misc check? Also the modernize checks are meant to actually emit fixes(ignore the c arrays check :) ), Right now, this only warn, it doesn't appear to act

Don't have a strong opinion, if you want I can move it there! I put in modernize as in "modernize from C-style into C++ style". But I know there's diverse opinions about this (LLVM not following this, for example) so perhaps it should be misc. Let me know which one you'd prefer so I can apply the change!

I didn't add fix because it would add quite some complexity, e.g. figuring out if there's is already an anon namespace to move into, or create a new one, users might want configurable behavior, etc.

Move to misc

carlosgalvezp retitled this revision from [clang-tidy] Add modernize-use-anonymous-namespace check to [clang-tidy] Add misc-use-anonymous-namespace check.

Update commit message

Remove some code duplication

Fix typo in binding names

Simplify code for printing the type of the declaration.

@njames93 Ping again. Alternatively, could someone else review? @aaron.ballman maybe?

Another week, another ping @njames93 @aaron.ballman

I have addressed all comments since 3 weeks ago, and have not received any objections. I intend to land this patch next week (1st December) if I don't receive any further feedback.

Replace "the" anonymous namespace with "an" anonymous namespace
Rebase.

bigdavedev added inline comments.Nov 29 2022, 11:10 PM
clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
8–10

Would we want this to be a fix as well? Removing the static keyword automatically would be nice.

carlosgalvezp marked an inline comment as done.Nov 30 2022, 5:55 AM
carlosgalvezp added inline comments.
clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
8–10

Would make sense to fix, but unfortunately with my limited AST knowledge I don't know how to get the location of the static token to apply a removal. So unless someone wants to help out with that it will have to stay as is for now.

bigdavedev accepted this revision.Nov 30 2022, 11:11 PM

Looks good to me. All comments/suggestions/concerns addressed.

clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
8–10

Ack.

This revision is now accepted and ready to land.Nov 30 2022, 11:11 PM
This revision was automatically updated to reflect the committed changes.
carlosgalvezp marked an inline comment as done.