[all-commits] [llvm/llvm-project] 083f09: [clang-format] Support BraceWrapping.AfterNamespac...

Galen Elias via All-commits all-commits at lists.llvm.org
Thu Feb 13 20:15:01 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 083f099a345f02390d00a8196d4ffa36ae71c82f
      https://github.com/llvm/llvm-project/commit/083f099a345f02390d00a8196d4ffa36ae71c82f
  Author: Galen Elias <gelias at gmail.com>
  Date:   2025-02-13 (Thu, 13 Feb 2025)

  Changed paths:
    M clang/lib/Format/UnwrappedLineFormatter.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (#123010)

AllowShortNamespacesOnASingleLine assumes that there is no newline
before the namespace brace, however, there is no actual reason this
shouldn't be compatible with BraceWrapping.AfterNamespace = true.

This is a little tricky in the implementation because
UnwrappedLineFormatter works on lines, so being flexible about the
offsets is awkward.

Not sure if there is a better pattern for combining the 'AllowShort'
options with the various configurations of BraceWrapping, but this
seemed mostly reasonable. Really, it would almost be preferable to just
pattern match on the direct token stream, rather than the
AnnotatedLines, but I'm not seeing a straightforward way to do that.

---------

Co-authored-by: Owen Pan <owenpiano at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list