History log of /llvm-project/clang/unittests/Format/FormatTest.cpp (Results 226 – 250 of 2034)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-15.0.5
# 617277e7 11-Nov-2022 Björn Schäpers <bjoern@hazardy.de>

[clang-format][NFC] Moved configuration parsing tests in own file

I want to reduce the size of ForatTest.cpp with its still wopping 25k
lines it is a burden on the compiler and editor (mine is clang

[clang-format][NFC] Moved configuration parsing tests in own file

I want to reduce the size of ForatTest.cpp with its still wopping 25k
lines it is a burden on the compiler and editor (mine is clangd
powered).

This are tests which are really serving a different purpose than
formatting.

I've copied the code and made the following changes:
- Dropped the ; at the end of some macros, all macro "invocations"
already have their own ;.
- Dropped the _F, we don't need a fxiture here.

Differential Revisison: https://reviews.llvm.org/D137823

show more ...


# e864ac69 12-Nov-2022 Micah Weston <micahsweston@gmail.com>

[clang-format] Treats &/&& as reference when followed by ',' or ')'

Ran into an issue where function declarations inside function
scopes or uses of sizeof inside a function would treat the && in
'si

[clang-format] Treats &/&& as reference when followed by ',' or ')'

Ran into an issue where function declarations inside function
scopes or uses of sizeof inside a function would treat the && in
'sizeof(Type &&)' as a binary operator.

Attempt to fix this by assuming reference when followed by ',' or
')'. Also adds tests for these.

Also hit an edge case in another test that treated "and" the same
as "&&" since it parses as C++. Changed the "and" to "also" so it
is no longer a keyword.

Fixes #58923.

Differential Revision: https://reviews.llvm.org/D137755

show more ...


# f6b25297 10-Nov-2022 Anastasiia Lukianenko <vicooodin@gmail.com>

[clang-format] Add BreakBeforeInlineASMColon configuration

If true, colons in ASM parameters will be placed after line breaks.

true:
asm volatile("string",
:

[clang-format] Add BreakBeforeInlineASMColon configuration

If true, colons in ASM parameters will be placed after line breaks.

true:
asm volatile("string",
:
: val);

false:
asm volatile("string", : : val);

Differential Revision: https://reviews.llvm.org/D91950

show more ...


# 41a09a07 04-Nov-2022 Björn Schäpers <bjoern@hazardy.de>

[clang-format][NFCish] Alphabetical sort Format.(h|pp)

I've:
- Sorted the members of FormatStyle alphabetical. The enums and structs
are kept close to the member.
- Sorted the yaml io functions, b

[clang-format][NFCish] Alphabetical sort Format.(h|pp)

I've:
- Sorted the members of FormatStyle alphabetical. The enums and structs
are kept close to the member.
- Sorted the yaml io functions, based on the type they operate on.
- Sorted the initializers in getLLVMStyle(), except that penalities are
kept at the end.
- Sorted the io of FormatStyle, this changes the --dump-config behavior.
- Moved the deprecated options into the only input case, this also
changes --dump-config, it does not put the not directly used options
in the .clang-format anymore.
- Sorted the comparisons in operator==.
- Added WhiteSpaceMacros in operator==, I've not actively looked if all
other members are compared.
- This showed flawed tests (or in my opinion a flawed io operation, but
that is another discussion and change).

Differential Revision: https://reviews.llvm.org/D137409

show more ...


Revision tags: llvmorg-15.0.4, llvmorg-15.0.3
# cdbe2968 13-Oct-2022 Björn Schäpers <bjoern@hazardy.de>

[clang-format] Fix lambda formatting in conditional

Without the patch UnwrappedLineFormatter::analyzeSolutionSpace just ran
out of possible formattings and would put everything just on one line.
The

[clang-format] Fix lambda formatting in conditional

Without the patch UnwrappedLineFormatter::analyzeSolutionSpace just ran
out of possible formattings and would put everything just on one line.
The problem was that the the line break was forbidden, but putting the
conditional colon on the same line is also forbidden.

Differential Revision: https://reviews.llvm.org/D135918

show more ...


# 117d792f 30-Oct-2022 Owen Pan <owenpiano@gmail.com>

[clang-format] Don't skip #else/#elif of #if 0

Fixes #58188.

Differential Revision: https://reviews.llvm.org/D137052


# 3edc1210 30-Oct-2022 Yusuke Kadowaki <yusuke.kadowaki.1231@gmail.com>

[clang-format] Adds a formatter for aligning trailing comments over empty lines

This patch addresses https://github.com/llvm/llvm-project/issues/19756

Reviewed By: MyDeveloperDay, HazardyKnusperkek

[clang-format] Adds a formatter for aligning trailing comments over empty lines

This patch addresses https://github.com/llvm/llvm-project/issues/19756

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D132131

show more ...


# d5be1550 30-Oct-2022 sstwcw <f0gukp2nk@protonmail.com>

[clang-format] Don't crash on malformed preprocessor conditions

Previously the program would crash on this input:

```
#else
#if X
```

The problem was that in `parsePPElse`, `PPBranchLevel` would b

[clang-format] Don't crash on malformed preprocessor conditions

Previously the program would crash on this input:

```
#else
#if X
```

The problem was that in `parsePPElse`, `PPBranchLevel` would be
incremented when the first `#else` gets parsed, but `PPLevelBranchCount`
and `PPLevelBranchIndex` would not be updated together.

I found the problem when working on D135740.

Differential Revision: https://reviews.llvm.org/D135972

show more ...


# 30ea3fcc 27-Oct-2022 owenca <owenpiano@gmail.com>

[clang-format][NFC] Move BracesRemover tests out of FormatTest.cpp

Differential Revision: https://reviews.llvm.org/D136830


# 17059753 25-Oct-2022 owenca <owenpiano@gmail.com>

[clang-format] Move InsertBraces unit tests out of FormatTest.cpp

Also add line range examples from #58161.

Differential Revision: https://reviews.llvm.org/D136658


Revision tags: working, llvmorg-15.0.2
# dce5bb9a 29-Sep-2022 Emilia Dreamer <emilia@rymiel.space>

[clang-format] Correctly annotate UDLs as OverloadedOperator

While the opening parenthesis of an user-defined literal operator was
correctly annotated as OverloadedOperatorLParen, the "" and its suf

[clang-format] Correctly annotate UDLs as OverloadedOperator

While the opening parenthesis of an user-defined literal operator was
correctly annotated as OverloadedOperatorLParen, the "" and its suffix
wasn't annotated as OverloadedOperator.

Fixes https://github.com/llvm/llvm-project/issues/58035

Differential Revision: https://reviews.llvm.org/D134853

show more ...


# fd1d93db 25-Oct-2022 Tobias Hieta <tobias@hieta.se>

[clang-format] Mark pragma region lines as StringLiterals

In our code-base we auto-generate pragma regions the regions
look like method signatures like:

`#pragma region MYREGION(Foo: bar)`

The pro

[clang-format] Mark pragma region lines as StringLiterals

In our code-base we auto-generate pragma regions the regions
look like method signatures like:

`#pragma region MYREGION(Foo: bar)`

The problem here was that the rest of the line after region
was not marked as stringliteral as in the case of pragma mark
so clang-format tried to change the formatting based on the
method signature.

Added test and mark it similar as pragma mark.

Reviewed By: owenpan

Differential Revision: https://reviews.llvm.org/D136336

show more ...


# 9c422ab7 29-Sep-2022 Danil Sidoruk <patriotrossii2019@mail.ru>

[clang-format] Add option for aligning requires clause body

Adds an option whether requires clause body should be aligned with
the `requires` keyword.
This option is now the default, both without co

[clang-format] Add option for aligning requires clause body

Adds an option whether requires clause body should be aligned with
the `requires` keyword.
This option is now the default, both without configuration and in LLVM
style.

Fixes https://github.com/llvm/llvm-project/issues/56283

Differential Revision: https://reviews.llvm.org/D129443

Co-authored-by: Emilia Dreamer <emilia@rymiel.space>

show more ...


# 037669de 14-Oct-2022 Joseph Huber <jhuber6@vols.utk.edu>

[clang-format] Do not parse certain characters in pragma directives

Currently, we parse lines inside of a compiler `#pragma` the same way we
parse any other line. This is fine for some cases, like s

[clang-format] Do not parse certain characters in pragma directives

Currently, we parse lines inside of a compiler `#pragma` the same way we
parse any other line. This is fine for some cases, like separating
expressions and adding proper spacing, but in others it causes some poor
results from miscategorizing some tokens.

For example, the OpenMP offloading uses certain clauses that contain
special characters like `map(tofrom : A[0:N])`. This will be formatted
poorly as it will be split between lines on the first colon.
Additionally the subscript notation will lead to poor spacing. This can
be seen in the OpenMP tests as the automatic clang formatting with
inevitably ruin the formatting.

For example, the following contrived example will be formatted poorly.
```
#pragma omp target teams distribute collapse(2) map(to: A[0 : M * K]) \
map(to: B[0:K * N]) map(tofrom:C[0:M*N]) firstprivate(Alpha) \
firstprivate(Beta) firstprivate(X) firstprivate(D) firstprivate(Y) \
firstprivate(E) firstprivate(Z) firstprivate(F)
```
This results in this when formatted, which is far from ideal.
```
#pragma omp target teams distribute collapse(2) map(to \
: A [0:M * K]) \
map(to \
: B [0:K * N]) map(tofrom \
: C [0:M * N]) firstprivate(Alpha) \
firstprivate(Beta) firstprivate(X) firstprivate(D) firstprivate(Y) \
firstprivate(E) firstprivate(Z) firstprivate(F)
```

This patch seeks to improve this by adding extra logic where the parsing goes
awry. This is primarily caused by the colon being parsed as an inline-asm
directive and the brackes an objective-C expressions. Also the line gets
indented every single time the line is dropped.

This doesn't implement true parsing handling for OpenMP statements.

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D136100

show more ...


# 94215d2b 11-Oct-2022 Emilia Dreamer <emilia@rymiel.space>

[clang-format] Correctly annotate star/amp in function pointer params

Inside the arguments part of a function pointer declaration,
`determineStarAmpUsage` results in a binary operator rather than
po

[clang-format] Correctly annotate star/amp in function pointer params

Inside the arguments part of a function pointer declaration,
`determineStarAmpUsage` results in a binary operator rather than
pointers, because said parens are assumed to be an expression.

This patch correctly marks the argument parens of a function
pointer type as not an expression. Note that this fix already
existed for Objective-C blocks as part of f1f267b447f60528440d2c066b29ab014ae7f90f.
As Objective-C blocks and C/C++ function pointers share a lot
of the same logic, that fix also makes sense here.

Fixes https://github.com/llvm/llvm-project/issues/31659

Differential Revision: https://reviews.llvm.org/D135707

show more ...


# b0758f62 11-Oct-2022 Jacob Abraham <jacob.r.abraham@gmail.com>

[clang-format] Fix mis-attributing preprocessor directives to macros

This solves the issue where a case statement inside a macro greedily
adds preprocessor lines such as #include to the macro even i

[clang-format] Fix mis-attributing preprocessor directives to macros

This solves the issue where a case statement inside a macro greedily
adds preprocessor lines such as #include to the macro even if they
are not a part of the macro to begin with.

Fixes #58214.

Differential Revision: https://reviews.llvm.org/D135422

show more ...


# 69e77276 09-Oct-2022 mydeveloperday <mydeveloperday@gmail.com>

[clang-format] Add support to remove unnecessary semicolons after function definition

Fixes: https://github.com/llvm/llvm-project/issues/58217

This change is to remove extraneous and unnecessary ';

[clang-format] Add support to remove unnecessary semicolons after function definition

Fixes: https://github.com/llvm/llvm-project/issues/58217

This change is to remove extraneous and unnecessary ';' from after a function definition, its off by default and carries the same "code modification" warning as some of our other code manipulating changes.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D135466

show more ...


# 1fa115b5 01-Oct-2022 Emilia Dreamer <emilia@rymiel.space>

[clang-format] Correctly indent closing brace of compound requires

When a compound requirement is too long to fit onto a single line, the
braces are split apart onto separate lines, and the containe

[clang-format] Correctly indent closing brace of compound requires

When a compound requirement is too long to fit onto a single line, the
braces are split apart onto separate lines, and the contained expression
is indented. However, this indentation would also apply to the closing
brace and the trailing return type requirement thereof.
This was because the indentation level was being restored after all
trailing things were already read

With this change, the initial level of the opening brace is set before
attempting to read any trailing return type requirements

Fixes https://github.com/llvm/llvm-project/issues/57108

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D134626

show more ...


# 2d23175f 27-Sep-2022 owenca <owenpiano@gmail.com>

[clang-format] Fix a bug with C++ `export import <Foo/Bar>`

Fixes #57798.

Differential Revision: https://reviews.llvm.org/D134700


# c0779756 27-Sep-2022 mitchell <56368743+mitchell-stellar@users.noreply.github.com>

[clang-format] Fix alignment in #else preprocessor blocks
Summary:
clang-format makes multiple passes when #if/#else preprocessor blocks are found. It will make
one pass for normal code and code in

[clang-format] Fix alignment in #else preprocessor blocks
Summary:
clang-format makes multiple passes when #if/#else preprocessor blocks are found. It will make
one pass for normal code and code in the #if block, and then it will make another pass for just
the code in #else blocks. This often results in invalid alignment inside the else blocks because
they do not have any scope or indentAndNestingLevel context from their surrounding tokens/lines.

This patch remedies that by caching any initial indentAndNestingLevel from a second pass and
not breaking/returning early when a scope change is detected.

Fixes #36070

Reviewers: HazardyKnusperkeks, MyDeveloperDay

Tags: clang, clang-format

Differential Revision: https://reviews.llvm.org/D134042

show more ...


Revision tags: llvmorg-15.0.1
# 6257832b 19-Sep-2022 owenca <owenpiano@gmail.com>

[clang-format] Wrap inserted braces only if preceded by comments

Fixes #57805.

Differential Revision: https://reviews.llvm.org/D134233


# 7349084e 18-Sep-2022 owenca <owenpiano@gmail.com>

[clang-format] Update removed brace's next token's WhitespaceRange

Fixes #57803.

Differential Revision: https://reviews.llvm.org/D134146


# e5964223 16-Sep-2022 sstwcw <f0gukp2nk@protonmail.com>

[clang-format] Fix template arguments in macros

Fixes https://github.com/llvm/llvm-project/issues/57738

old
```
#define FOO(typeName, realClass) \
{

[clang-format] Fix template arguments in macros

Fixes https://github.com/llvm/llvm-project/issues/57738

old
```
#define FOO(typeName, realClass) \
{ \
#typeName, foo < FooType>(new foo <realClass>(#typeName)) \
}
```
new
```
#define FOO(typeName, realClass) \
{ #typeName, foo<FooType>(new foo<realClass>(#typeName)) }
```

Previously, when an UnwrappedLine began with a hash in a macro
definition, the program incorrectly assumed the line was a preprocessor
directive. It should be stringification.

The rule in spaceRequiredBefore was added in 8b5297117b. Its purpose is
to add a space in an include directive. It also added a space to a
template opener when the line began with a stringification hash. So we
changed it.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D133954

show more ...


# 2183fe21 10-Sep-2022 sstwcw <f0gukp2nk@protonmail.com>

[clang-format] Parse the else part of `#if 0`

Fixes https://github.com/llvm/llvm-project/issues/57539

Previously things outside of `#if` blocks were parsed as if only the
first branch of the condit

[clang-format] Parse the else part of `#if 0`

Fixes https://github.com/llvm/llvm-project/issues/57539

Previously things outside of `#if` blocks were parsed as if only the
first branch of the conditional compilation branch existed, unless the
first condition is 0. In that case the outer parts would be parsed as
if nothing inside the conditional parts existed. Now we use the second
conditional branch if the first condition is 0.

Reviewed By: owenpan

Differential Revision: https://reviews.llvm.org/D133647

show more ...


# 5889ed83 10-Sep-2022 owenca <owenpiano@gmail.com>

[clang-format] Don't insert braces for loops with a null statement

This is a workaround for #57539.

Fixes #57509.

Differential Revision: https://reviews.llvm.org/D133635


12345678910>>...82