| Age | Commit message (Collapse) | Author |
|
normal lines and PP directives.
Handling PP directives differently can be desired, like in #161848.
Changing the default is not an option, there are tests for exactly the
current behaviour.
|
|
- Replace verifyFormat(Foo, Bar, ...) with verifyFormat(Foo, ...) or
verifyNoChange(Foo, ...) if Foo = Bar.
- Other minor cleanups
|
|
And reduce the number of getLLVMStyleWithColumnLimit calls.
|
|
Line comments in preprocessor directives were incorrectly marked as
continuing the directive, causing clang-format to add backslashes after
them on repeated runs. Backslashes appended after line comments in this
way do not continue the PP directive because the following line would
also become part of the comment.
Fix by unsetting `InPPDirective` in
`WhitespaceManager::replaceWhitespace` for line comments in two places:
when breaking lines and when formatting tokens on the same line. This
stops the spurious backslash insertion for both standalone line comments
after PP directives and trailing line comments after macro bodies.
Fixes https://github.com/llvm/llvm-project/issues/164282.
Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
|
|
Fixes http://llvm.org/PR55487 (#55487)
The code did not match the documentation about Cpp11BracedListStyle.
Changed handling of comments after opening braces, which are supposedly
function call like to behave exactly like their parenthesis counter
part.
|
|
Consistently use `constexpr StringRef Code("string literal");`.
|
|
Fixes #147341
|
|
Fixes #39150
|
|
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`.
|
|
(#101882)
Related issues that have requested this feature:
#51833
#23796
#53190 Partially solves - this issue requests is for both arguments and
parameters
|
|
Fixes #92530.
|
|
Fixes #45002.
|
|
Commit d06b92391513 caused a regression that breaks after a block
comment adjacent to a function paramter that follows.
Fixes #86573.
|
|
Fixes llvm/llvm-project#63241
Doxygen commands can start with `@` or `\`.
|
|
Fixed #41854.
|
|
Fixed #72785.
|
|
|
|
We now stop aligning trailing comments on all closing braces, for
classes etc. we even check for the semicolon between the comment and the
brace.
Fixes #67906.
|
|
Fixes #67116.
|
|
Fixes https://github.com/llvm/llvm-project/issues/57504.
Differential Revision: https://reviews.llvm.org/D138263
|
|
Insert missing namespace comments with SpacesBeforeTrailingComments
leading spaces.
Fixes #64051.
Differential Revision: https://reviews.llvm.org/D156065
|
|
It worked only correct for a tab as the first char.
Fixes https://github.com/llvm/llvm-project/issues/56769
Differential Revision: https://reviews.llvm.org/D138402
|
|
|
|
This patch adds a verifyNoChange macro to verify code that won't
change after being formatted. (The code will not be messed up before
being formatted.) It then replaces EXPECT_EQ with verifyFormat
wherever applicable so that the code will be messed up before being
formatted. When the replacement fails the unit test, verifyFormat is
replaced with verifyNoChange.
Differential Revision: https://reviews.llvm.org/D153109
|
|
Put an intentional "trailing" space back in
FormatTestComments.SplitCommentIntroducers. It was removed in
a4c87f8ccacc by mistake.
|
|
Since 3.8 or earlier, clang-format has been lumping all #else, #elif,
etc blocks together when doing whitespace replacements and causing
consecutive alignments across #else blocks.
Commit c077975 partially addressed the problem but also triggered
"regressions".
This patch fixes the root cause of the problem and "reverts" c077975
(except for the unit tests).
Fixes #36070.
Fixes #55265.
Fixes #60721.
Fixes #61498.
Differential Revision: https://reviews.llvm.org/D150057
|
|
Fixes #62107.
Differential Revision: https://reviews.llvm.org/D148200
|
|
Pull out common base class for formatting unit tests, removing duplicate
code that accumulated over the years.
Pull out macro expansion test into its own test file.
|
|
For comments that start after a new line, currently, the comments are
being indented. This happens because the OriginalWhitespaceRange
considers newlines on the range. Therefore, when AlignTrailingComments:
Kind: Leave, deduct the number of newlines before the token to calculate
the number of spaces for trailing comments.
Fixes #59203.
Differential Revision: https://reviews.llvm.org/D139029
|
|
|
|
This patch addresses https://github.com/llvm/llvm-project/issues/19756
Reviewed By: MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D132131
|
|
Fixes https://github.com/llvm/llvm-project/issues/35116.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D121451
|
|
Fixes https://github.com/llvm/llvm-project/issues/53844.
I believe this regression was caused by not accounting for clang-format directives in https://reviews.llvm.org/D92257.
Reviewed By: HazardyKnusperkeks, curdeius
Differential Revision: https://reviews.llvm.org/D120188
|
|
Fixes https://github.com/llvm/llvm-project/issues/52649.
This was already fixed in commit https://github.com/llvm/llvm-project/commit/e967d97a35a93c883528a9672159edff05f5addb.
|
|
Fixes https://github.com/llvm/llvm-project/issues/53799.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D119680
|
|
|
|
This commit changes the condition of requiring comment to start with
alphanumeric characters to make no change only for a certain set of
characters, currently horizontal whitespace and punctuation characters,
to support wider set of leading characters unrelated to documentation
generation directives.
Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D118869
|
|
block comment.
Fixes https://github.com/llvm/llvm-project/issues/53441.
Expected code:
```
/**/ //
int a; //
```
was before misformatted to:
```
/**/ //
int a; //
```
Because the "remaining length" (after the starting `/*`) of an empty block comment `/**/` was computed to be 0 instead of 2.
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D118475
|
|
Make sure we do not try to change line comments that are non-regular, i.e. do
not start with "//" or "#". This can for example happen when "//" is
broken into two lines with an escaped newline.
|
|
... without an active column limit.
Before line comments were not touched at all with ColumnLimit == 0.
Differential Revision: https://reviews.llvm.org/D96896
|
|
Differential Revision: https://reviews.llvm.org/D92257
|
|
This reverts commit 078f30e04d1fcb5a05d8e340f3178f3478075541.
|
|
Differential Revision: https://reviews.llvm.org/D92257
|
|
https://bugs.llvm.org/show_bug.cgi?id=48539
Add support for Qt Translator Comments to reflow
When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.
Reviewed By: curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D93490
|
|
In C++ with -Werror=comment, multiline comments are not allowed.
clang-format could accidentally introduce multiline comments when reflowing.
This adapts clang-format to not introduce multiline comments by not allowing a
break after `\`. Note that this does not apply to comment lines that already are
multiline comments, such as comments in macros.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D90949
|
|
This allows building the clang-format unit tests in only 657 ninja steps
rather than 1257 which allows for much faster incremental builds after a
git pull.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D89709
|
|
This reverts commit b2eb439317576ce718193763c12bff9fccdfc166.
Caused the regression:
https://bugs.llvm.org/show_bug.cgi?id=47589
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D89464
|
|
Summary:
Currently the 'AlignConsecutive*' options incorrectly align across
elif and else statements, even if they are very far away and across
unrelated preprocessor macros.
This failed since on preprocessor run 2+, there is not enough context
about the #ifdefs to actually differentiate one block from another,
causing them to align across different blocks or even large sections of
the file.
Eg, with AlignConsecutiveAssignments:
```
\#if FOO // Run 1
\#else // Run 1
int a = 1; // Run 2, wrong
\#endif // Run 1
\#if FOO // Run 1
\#else // Run 1
int bar = 1; // Run 2
\#endif // Run 1
```
is read as
```
int a = 1; // Run 2, wrong
int bar = 1; // Run 2
```
The approach taken to fix this was to add a new flag to Token that
forces breaking alignment across groups of lines (MustBreakAlignBefore)
in a similar manner to the existing flag that forces a line break
(MustBreakBefore). This flag is set for the first Token after a
preprocessor statement or diff conflict marker.
Fixes #25167,#31281
Patch By: JakeMerdichAMD
Reviewed By: MyDeveloperDay
Tags: #clang, #clang-format
Differential Revision: https://reviews.llvm.org/D79388
|
|
Summary:
Ensure the clang-format unit tests are themselves clang-formatted
Having areas of the llvm code which are clang-format clean, give us more areas to run new clang-format binaries on ensuring we haven't broken anything.
It seems to me we SHOULD have this clang-formatted at a minimum, otherwise how can we expect others to use clang-format if we "don't eat our own dogfood", also if the tests are dependent on the formatting of the code then that would also be bad!
Reviewed By: sammccall
Subscribers: cfe-commits
Tags: #clang, #clang-format
Differential Revision: https://reviews.llvm.org/D79204
|
|
to reflect the new license.
We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.
Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.
llvm-svn: 351636
|