Age | Commit message (Collapse) | Author | Files | Lines |
|
Closes #149971
|
|
Sorting by stem gives nicer results when various header file names are
substrings of other header file names. For example, a CLI application
with a main header named analyze.h and an analyze-xxx.h header for each
subcommand currently will always put analyze.h last after all the
analyze-xxx.h headers, but putting analyze.h first instead is arguably
nicer to read.
TLDR; Instead of
```
#include "analyze-blame.h"
#include "analyze.h"
```
You'd get
```
#include "analyze.h"
#include "analyze-blame.h"
```
Let's allow sorting by stem instead of full path by adding
IgnoreExtension to SortIncludes.
|
|
This allows RemoveParentheses to skip the invocations of function-like
macros.
Fixes #68354.
Fixes #147780.
|
|
Fix #137792
|
|
This allows adding other suboptions e.g. IgnoreExtension in #137840.
|
|
Add SpaceAfterOperatorKeyword option to clang-format
|
|
|
|
This reverts commit b8bb1ccb4f9126d1bc9817be24e17f186a75a08b which triggered
an assertion failure in CodeGenTest.TestNonAlterTest.
|
|
Close #54334
|
|
Also refactor the code that removes/replaces a token.
|
|
Fix #132832
|
|
Add support for formatting w/ absl nullability macros
(https://github.com/abseil/abseil-cpp/blob/c52afac4f87ef76e6293b84874e5126a62be1f15/absl/base/nullability.h#L237).
Example at https://godbolt.org/z/PYv19M1Gj
input:
```
std::vector<int* _Nonnull> x;
std::vector<int* absl_nonnull> y;
```
orig output:
```
std::vector<int* _Nonnull> x;
std::vector<int * absl_nonnull> y;
```
new output:
```
std::vector<int* _Nonnull> x;
std::vector<int* absl_nonnull> y;
```
credit to @ymand for the original patch
|
|
Fixes #108526
|
|
The use of Cpp11BracedListStyle with BinPackArguments=False avoids bin
packing until reaching a hard-coded limit of 20 items. This is an
arbitrary choice. Introduce a new style option to allow disabling this
limit.
|
|
In clang-format, multiline templates have the `>` on the same line as
the last parameter:
```c++
template <
typename Foo,
typename Bar>
void foo() {
```
I would like to add an option to put the `>` on the next line, like
this:
```c++
template <
typename Foo,
typename Bar
>
void foo() {
```
An example of a large project that uses this style is NVIDIA's CUTLASS,
here is an example:
https://github.com/NVIDIA/cutlass/blob/main/include/cutlass/epilogue/dispatch_policy.hpp#L149-L156
My reasoning is that it reminds me of this style of braces:
```c++
if (foo()) {
bar();
baz();}
```
Most people agree this is better:
```c++
if (foo()) {
bar();
baz();
}
```
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
|
|
Also add a number of missing tests for unsigned options.
|
|
The penalty for breaking before a member access is hard-coded to 150.
Add a configuration option to allow setting it.
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
|
|
This renames the `ExportBlockIndentation` option and adds a config parse
test, as requested in #110381.
|
|
Also, simplify the existing test for NamespaceMacros. Like the options
tested by the added tests, it's also a list of arbitrary strings and
initialized to an empty list. (The other existing tests for list of
strings either are initialized to a list of one or more strings or
require specific strings.)
|
|
It wraps the body of namespace with additional newlines, turning this code:
```
namespace N {
int function();
}
```
into the following:
```
namespace N {
int function();
}
```
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
|
|
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.
|
|
Closes #113170.
|
|
Fixes #111340.
|
|
without breaking internal structure (think Doxygen). (#96804)
* Convert `ReflowComments` from boolean into a new `enum` which can take
on the value `RCS_Never`, `RCS_IndentOnly`, or `RCS_Always`. The first
one is equivalent to the old `false`, the third one is `true`, and the
middle one means that multiline comments should only have their
indentation corrected, which is what Doxygen users will want.
* Preserve backward compatibility while parsing `ReflowComments`.
|
|
- Add a `CHECK_PARSE` for `AcrossComments`.
- Add a `CHECK_PARSE_NESTED_BOOL` for `AlignFunctionPointers`.
- Remove redundant statements.
- Clean up documentation.
|
|
(#108241)
Enabling AlignConsecutiveDeclarations also aligns function prototypes
or declarations. This is often unexpected as typically function
prototypes, especially in public headers, don't use any padding.
Setting AlignFunctionDeclarations to false will skip this alignment.
It is by default set to true to keep compatibility with prior
versions to not make unexpected changes.
Fixes #74320
|
|
(#101882)
Related issues that have requested this feature:
#51833
#23796
#53190 Partially solves - this issue requests is for both arguments and
parameters
|
|
By default, clang-format packs binary operations, but it may be
desirable to have compound operations be on individual lines instead of
being packed.
This PR adds the option `BreakBinaryOperations` to break up large
compound binary operations to be on one line each.
This applies to all logical and arithmetic/bitwise binary operations
Maybe partially addresses #79487 ?
Closes #58014
Closes #57280
|
|
The __attribute((specifier-list)) currently is formatted based on the
SpacesInParensOptions.Other (previously, SpacesInParentheses). This
change allows finer control over addition of spaces between the
consecutive parens, and between the inner parens and the list of
attribute specifiers.
Differential Revision: https://reviews.llvm.org/D155529
This is migrated from Phabricator, see more discussion there.
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
|
|
The options regarding which blank lines are kept are also aggregated.
The new option is `KeepEmptyLines`.
This patch was initially part of 9267f8f19a2e502e. I neglected to check
the server builds before I added it. It broke clangd. Jie Fu fixed the
problem in 4c91b49bab0728d4. I was unaware of it. I thought the main
branch was still broken. I reverted the first patch in
70cfece24d6cbb57. It broke his fix. He reverted it in
c69ea04fb9738db2. Now the feature is added again including the fix.
|
|
This reverts commit 9267f8f19a2e502ef5a216c0d52b352b3699d399.
I changed a formatter option. I forgot to update other components that
depend on the formatter when the option name changed.
|
|
The options regarding which blank lines are kept are also aggregated.
The new option is `KeepEmptyLines`.
|
|
|
|
It allows to control of error output for the function.
Closes #94205.
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
|
|
Closes #92999.
|
|
Also adds AllowShortCaseExpressionOnASingleLine option and
AlignCaseArrows suboption of AlignConsecutiveShortCaseStatements.
Fixes #55903.
|
|
Complete the switch from "AlwaysBreakAfterReturnType" to
"BreakAfterReturnType".
|
|
Changes the option to BreakAfterReturnType option, with a more relevant
name, deprecating and replacing AlwaysBreakAfterReturnType.
Following up on #78010.
|
|
|
|
Drop the "Always" prefix to remove the self-contradiction.
|
|
Closes #78067.
|
|
AlwaysBreakAfterReturnType. (#78011)
The RTBS_None option in Clang-format avoids breaking after a short
return type.
However, there was an issue with the behaviour in that it wouldn't take
the leading indentation of the line into account.
This meant that the behaviour wasn't applying when intended.
In order to address this situation without breaking the existing
formatting, RTBS_None has been deprecated.
In its place are two new options for AlwaysBreakAfterReturnType.
The option RTBS_Automatic will break after the return type based on
PenaltyReturnTypeOnItsOwnLine.
The option RTBS_ExceptShortType will take the leading indentation into
account and prevent breaking after short return types.
This allows the inconsistent behaviour of RTBS_None to be avoided and
users to decide whether they want to allow breaking after short return
types or not.
Resolves #78010
|
|
Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/delete.
Fixes #78892.
|
|
Closes #67991.
See also: #70338
Co-authored-by: @tomekpaszek
|
|
Add config parse tests for SeparateDefinitionBlocks option.
|
|
Resolves #78014
|
|
Function pointers are detected as a type of declaration using
FunctionTypeLParen. They are aligned based on rules for
AlignConsecutiveDeclarations. When a function pointer is on the
right-hand side of an assignment, the alignment of the function pointer
can result in excessive whitespace padding due to the ordering of
alignment, as the alignment processes a line from left-to-right and
first aligns the declarations before and after the assignment operator,
and then aligns the assignment operator. Injection of whitespace by
alignment of declarations after the equal sign followed by alignment of
the equal sign results in the excessive whitespace.
Fixes #68079.
|
|
Closes #70451.
|
|
|
|
clang-format brace wrapping did not take requires into consideration,
compound requirements will be affected by BraceWrapping.AfterFunction.
Closes #59412.
Differential Revision: https://reviews.llvm.org/D139834
|