#
b0d2a52c |
| 24-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Enable RemoveSemicolon for clang-format style (#82735)
Also insert separators for decimal integers longer than 4 digits.
|
#
04fbc461 |
| 21-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Fix RemoveSemicolon for empty functions (#82278)
Fixes #79833.
|
Revision tags: llvmorg-18.1.0-rc3 |
|
#
119a7286 |
| 20-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Remove redundant calls to guessIsObjC()
Running clang-format on the following input ``` int lambdas() { return [&] { return [&] { return [&] { return [&] { return [&] {
[clang-format][NFC] Remove redundant calls to guessIsObjC()
Running clang-format on the following input ``` int lambdas() { return [&] { return [&] { return [&] { return [&] { return [&] { return [&] { return [&] { return 3; } (); } (); } (); } (); } (); } (); } (); } ``` will finish instantly if you pass clang-format a .cpp input with this content, but hang for tens of seconds if you pass the same via stdin or a .h file.
Adding some debug statements showed that guessIsObjC was getting called tens of millions of times in a manner that scales very rapidly with the amount of nesting (if clang-format just takes a few seconds with that input passed on stdin, try adding a couple more levels of nesting).
This change moves the recursive guessIsObjC call one level of nesting out of an inner loop whose iterations don't affect the input to the recursive call. This resolves the performance issue.
Authored-by: davidvc1 and Uran198
Differential Revision: https://reviews.llvm.org/D114837 Differential Revision: https://reviews.llvm.org/D47515
show more ...
|
#
6087d7bc |
| 15-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Sort options in Format.cpp
|
#
d821650e |
| 15-Feb-2024 |
rmarker <37921131+rmarker@users.noreply.github.com> |
[clang-format][NFC] Drop "Always" in "AlwaysBreakAfterReturnType". (#81591)
Complete the switch from "AlwaysBreakAfterReturnType" to
"BreakAfterReturnType".
|
#
91dcf53a |
| 13-Feb-2024 |
rmarker <37921131+rmarker@users.noreply.github.com> |
[clang-format] Rename option AlwaysBreakAfterReturnType. (#80827)
Changes the option to BreakAfterReturnType option, with a more relevant
name, deprecating and replacing AlwaysBreakAfterReturnType.
[clang-format] Rename option AlwaysBreakAfterReturnType. (#80827)
Changes the option to BreakAfterReturnType option, with a more relevant
name, deprecating and replacing AlwaysBreakAfterReturnType.
Following up on #78010.
show more ...
|
#
3dc8ef67 |
| 11-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
Revert "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"
This reverts commit 03f571995b4f0c260254955afd16ec44d0764794.
We can't hide getFormattingLangOpts() as it's used by ot
Revert "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"
This reverts commit 03f571995b4f0c260254955afd16ec44d0764794.
We can't hide getFormattingLangOpts() as it's used by other tools.
show more ...
|
#
03f57199 |
| 11-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Make LangOpts global in namespace Format (#81390)
|
#
7664ddf8 |
| 10-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Drop "Always" in "AlwaysBreakTemplateDeclarations"
|
#
c5cbfc56 |
| 10-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Rename option AlwaysBreakTemplateDeclarations (#81093)
Drop the "Always" prefix to remove the self-contradiction.
|
#
d0337990 |
| 08-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Add Leave to AlwaysBreakTemplateDeclarations (#80569)
Closes #78067.
|
Revision tags: llvmorg-18.1.0-rc2 |
|
#
984dd15d |
| 06-Feb-2024 |
j-jorge <j-jorge@users.noreply.github.com> |
[clang-format] Add MainIncludeChar option. (#78752)
Resolves #27008, #39735, #53013, #63619.
Hello, this PR adds the MainIncludeChar option to clang-format, allowing
to select which include synt
[clang-format] Add MainIncludeChar option. (#78752)
Resolves #27008, #39735, #53013, #63619.
Hello, this PR adds the MainIncludeChar option to clang-format, allowing
to select which include syntax must be considered when searching for the
main header: quotes (`#include "foo.hpp"`, the default), brackets
(`#include <foo.hpp>`), or both.
The lack of support for brackets has been reported many times, see the
linked issues, so I am pretty sure there is a need for it :)
A short note about why I did not implement a regex approach as discussed
in #53013: while a regex would have allowed many extra ways to describe
the main header, the bug descriptions listed above suggest a very simple
need: support brackets for the main header. This PR answers this needs
in a quite simple way, with a very simple style option. IMHO the feature
space covered by the regex (again, for which there is no demand :)) can
be implemented latter, in addition to the proposed option.
The PR also includes tests for the option with and without grouped
includes.
show more ...
|
#
25620073 |
| 04-Feb-2024 |
rmarker <37921131+rmarker@users.noreply.github.com> |
[clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (#78011)
The RTBS_None option in Clang-format avoids breaking after a short
return type.
However, there was
[clang-format] Add Automatic and ExceptShortType options for 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
show more ...
|
#
908fd09a |
| 01-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Simplify the AfterPlacementOperator option (#79796)
Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/del
[clang-format] Simplify the AfterPlacementOperator option (#79796)
Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/delete.
Fixes #78892.
show more ...
|
Revision tags: llvmorg-18.1.0-rc1, llvmorg-19-init |
|
#
a7d7da6e |
| 20-Jan-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Add SkipMacroDefinitionBody option (#78682)
Closes #67991.
See also: #70338
Co-authored-by: @tomekpaszek
|
#
5723fce0 |
| 15-Jan-2024 |
Ilya Biryukov <ibiryukov@google.com> |
[Format] Fix isStartOfName to recognize attributes (#76804)
This addresses a problem with formatting attributes. Some context:
- eaff083035c8 changed `isStartOfName` to fix problems inside
`#pragm
[Format] Fix isStartOfName to recognize attributes (#76804)
This addresses a problem with formatting attributes. Some context:
- eaff083035c8 changed `isStartOfName` to fix problems inside
`#pragma`s, but this behavior changed formatting of attribute macros in
an undesirable way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style
to fix some widely used attributes.
Instead of changing the format style, this commit specializes behavior
introduced in eaff083035c8 to `#pragma`s. This seems to work well in
both cases.
Also update the test with two `GUARDED_BY` directives. While the
formatting after efeb546865c233dfa7706ee0316c676de9f69897 seems better,
this case is rare enough to not warrant the extra complexity. We are
reverting it back to the state it had before
efeb546865c233dfa7706ee0316c676de9f69897.
---------
Co-authored-by: Owen Pan <owenpiano@gmail.com>
show more ...
|
#
60a9874f |
| 14-Jan-2024 |
rmarker <37921131+rmarker@users.noreply.github.com> |
[clang-format] Add PenaltyBreakScopeResolution option. (#78015)
Resolves #78014
|
#
b2c0c6f3 |
| 11-Jan-2024 |
Gedare Bloom <gedare@rtems.org> |
[clang-format]: Split alignment of declarations around assignment (#69340)
Function pointers are detected as a type of declaration using
FunctionTypeLParen. They are aligned based on rules for
Ali
[clang-format]: Split alignment of declarations around assignment (#69340)
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.
show more ...
|
#
efeb5468 |
| 22-Dec-2023 |
Ilya Biryukov <ibiryukov@google.com> |
[clang-format] Add common attribute macros to Google style (#76239)
We have found that 199fc973ced20016b04ba540cf63a1d4914fa513 regresses
formatting of our codebases because we do not properly conf
[clang-format] Add common attribute macros to Google style (#76239)
We have found that 199fc973ced20016b04ba540cf63a1d4914fa513 regresses
formatting of our codebases because we do not properly configure the
names of attribute macros.
`GUARDED_BY` and `ABSL_GUARDED_BY` are very commoon in Google codebases
so it is reasonable to include them by default to avoid the need for
extra configuration in every Google repository.
show more ...
|
#
401f0396 |
| 17-Dec-2023 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Fix a bug in `IndentExternBlock: NoIndent` (#75731)
Fixes #36620.
Fixes #75719.
|
#
f3dcc235 |
| 13-Dec-2023 |
Kazu Hirata <kazu@google.com> |
[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}:
[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.
I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
show more ...
|
#
3791b3fc |
| 08-Dec-2023 |
Owen Pan <owenpiano@gmail.com> |
[clang-format][NFC] Clean up the driver and getStyle() in Format.cpp (#74794)
|
#
c45a66ec |
| 02-Dec-2023 |
Jared Grubb <jgrubb@apple.com> |
[clang-format] ObjCPropertyAttributeOrder to sort ObjC property attributes
Add a style option to specify the order that property attributes should appear in ObjC property declarations (property attr
[clang-format] ObjCPropertyAttributeOrder to sort ObjC property attributes
Add a style option to specify the order that property attributes should appear in ObjC property declarations (property attributes are things like `nonatomic, strong, nullable`).
Closes #71323.
Differential Revision: https://reviews.llvm.org/D150083
show more ...
|
Revision tags: llvmorg-17.0.6 |
|
#
39faf13d |
| 27-Nov-2023 |
Owen Pan <owenpiano@gmail.com> |
[clang-format] Add BreakAdjacentStringLiterals option (#73432)
Closes #70451.
|
Revision tags: llvmorg-17.0.5, llvmorg-17.0.4 |
|
#
497b2ebb |
| 28-Oct-2023 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang-format] Change LLVM style to BreakAfterAttributes == ABS_Leave (#70360)
This patch addresses some examples of bad formatting in Clang. The following commit contains only changes suggested by
[clang-format] Change LLVM style to BreakAfterAttributes == ABS_Leave (#70360)
This patch addresses some examples of bad formatting in Clang. The following commit contains only changes suggested by clang-format: https://github.com/llvm/llvm-project/pull/70349/commits/21689b56d1fc1db0b2263e8049ff656d3757ad36.
I believe it's a net negative on readability, with a couple of particularly bad cases. Highlights:
```diff
- [[clang::preferred_type(bool)]]
- mutable unsigned CachedLocalOrUnnamed : 1;
+ [[clang::preferred_type(bool)]] mutable unsigned CachedLocalOrUnnamed : 1;
```
```diff
- [[clang::preferred_type(TypeDependence)]]
- unsigned Dependence : llvm::BitWidth<TypeDependence>;
+ [[clang::preferred_type(TypeDependence)]] unsigned Dependence
+ : llvm::BitWidth<TypeDependence>;
```
```diff
- [[clang::preferred_type(ExceptionSpecificationType)]]
- unsigned ExceptionSpecType : 4;
+ [[clang::preferred_type(
+ ExceptionSpecificationType)]] unsigned ExceptionSpecType : 4;
```
Style guides doesn't appear to have an opinion on this matter.
show more ...
|