[PATCH] D61989: [clang-tidy] enable modernize-concat-nested-namespaces on header files

Xiao Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 20:37:17 PDT 2019


shixiao created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

For header files that pass the -header-filter, the
modernize-concat-nested-namespaces check does not generate the expected
warning and fix for un-concatenated namespaces. This diff fixes it.

https://bugs.llvm.org/show_bug.cgi?id=41670

Test Plan:

a.h
---

namespace foo {
namespace bar {
namespace baz {
struct S {};
}
}

}
=

a.cpp
-----

namespace foo {
namespace bar {
namespace baz {
void foo(const S&) {}
}
}
}

int main () {

  return 0;

}
=

$ /clang-tidy -p sample/compile_commands.json -checks="modernize-concat-nested-namespaces" -header-filter="a.h" sample/a.cpp

  4 warnings generated.
  sample/a.h:5:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
  namespace foo {
  ^~~~~~~~~~~~~~~
  namespace foo::bar::baz
  sample/a.cpp:5:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
  namespace foo {
  ^~~~~~~~~~~~~~~
  namespace foo::bar::baz


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61989

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61989.199733.patch
Type: text/x-patch
Size: 4173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190516/5f3ab275/attachment.bin>


More information about the cfe-commits mailing list