[PATCH] D65125: clang-format: Fix namespace end comments for namespaces with attributes and macros

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 22 16:26:23 PDT 2019


thakis created this revision.
thakis added reviewers: klimek, sammccall.

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.)


https://reviews.llvm.org/D65125

Files:
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65125.211228.patch
Type: text/x-patch
Size: 5525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190722/95e5a49c/attachment.bin>


More information about the cfe-commits mailing list