]> granicus.if.org Git - clang/commit
clang-format: Fix namespace end comments for namespaces with attributes and macros.
authorNico Weber <nicolasweber@gmx.de>
Tue, 23 Jul 2019 17:49:45 +0000 (17:49 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 23 Jul 2019 17:49:45 +0000 (17:49 +0000)
commita25d062264efe6f7af3c8ad18e73989ae20909c5
tree61cf901de81b1826c103933bd8f8b144e25a0d64
parenta91ff7ca87533c4853e2e69faa5c9788a06b14c9
clang-format: Fix namespace end comments for namespaces with attributes and macros.

Fixes PR39247.

While here, also make C++20 `namespace A::inline B::inline C` nested
inline namespaced definitions work.

Before:
    #define DEPRECATE_WOOF [[deprecated("meow")]]

    namespace DEPRECATE_WOOF woof {
    void f() {}
    } // namespace DEPRECATE_WOOFwoof

    namespace [[deprecated("meow")]] woof {
      void f() {}
    } // namespace [[deprecated("meow")]]woof

    namespace woof::inline bark {
      void f() {}
    } // namespace woof::inlinebark

Now:
    #define DEPRECATE_WOOF [[deprecated("meow")]]

    namespace DEPRECATE_WOOF woof {
    void f() {}
    } // namespace woof

    namespace [[deprecated("meow")]] woof {
    void f() {}
    } // namespace woof

    namespace woof::inline bark {
    void f() {}
    } // namespace woof::inline bark

(In addition to the fixed namespace end comments, also note the correct
indent of the namespace contents.)

Differential Revision: https://reviews.llvm.org/D65125

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366831 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/NamespaceEndCommentsFixer.cpp
lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp
unittests/Format/NamespaceEndCommentsFixerTest.cpp