[all-commits] [llvm/llvm-project] 486ec4: [clang-format] Add `AllowShortNamespacesOnASingleL...
Galen Elias via All-commits
all-commits at lists.llvm.org
Mon Dec 30 01:28:26 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 486ec4bd7466cda444a7da6386a1bbb2db89a33f
https://github.com/llvm/llvm-project/commit/486ec4bd7466cda444a7da6386a1bbb2db89a33f
Author: Galen Elias <gelias at gmail.com>
Date: 2024-12-30 (Mon, 30 Dec 2024)
Changed paths:
M clang/docs/ClangFormatStyleOptions.rst
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Format/Format.h
M clang/lib/Format/Format.cpp
M clang/lib/Format/UnwrappedLineFormatter.cpp
M clang/unittests/Format/ConfigParseTest.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Add `AllowShortNamespacesOnASingleLine` option (#105597)
This fixes #101363 which is a resurrection of a previously opened but
never completed review: https://reviews.llvm.org/D11851
The feature is to allow code like the following not to be broken across
multiple lines:
```
namespace foo { class bar; }
namespace foo { namespace bar { class baz; } }
```
Code like this is commonly used for forward declarations, which are
ideally kept compact. This is also apparently the format that
include-what-you-use will insert for forward declarations.
Also, fix an off-by-one error in `CompactNamespaces` code. For nested
namespaces with 3 or more namespaces, it was incorrectly compacting
lines which were 1 or two spaces over the `ColumnLimit`, leading to
incorrect formatting results.
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