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

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 11:46:01 PST 2022


njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp:44
+  const SourceManager &SM = MatchedDecl->getASTContext().getSourceManager();
+  if (!SM.isWrittenInMainFile(MatchedDecl->getLocation()))
+    return;
----------------
The logic would fall apart when run in clangd or unity builds. The safest way is generally to match the file extension, we have a class for it in `clang-tidy/utils`


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp:51
 struct Foo {
-  static void f();
-  static int x;
----------------
These changes just look like noise.


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