[PATCH] D87587: [clang-format] Make one-line namespaces resistant to FixNamespaceComments, update documentation

Krystian Kuzniarek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 13 04:00:26 PDT 2020


kuzkry created this revision.
kuzkry added reviewers: krasimir, JakeMerdichAMD, jmerdich, rsmith.
kuzkry added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
kuzkry requested review of this revision.

clang-format documentation states that having enabled
FixNamespaceComments one may expect below code:

  c++
  namespace a {
  foo();
  }

to be turned into:

  c++
  namespace a {
  foo();
  } // namespace a

In reality, no "// namespace a" was added. The problem was too high
value of kShortNamespaceMaxLines, which is used while deciding whether
a namespace is long enough to be formatted.

As with 9163fe2, it remains to ensure clang-format is idempotent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87587

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87587.291453.patch
Type: text/x-patch
Size: 5538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200913/3c6e3706/attachment-0001.bin>


More information about the cfe-commits mailing list