History log of /llvm-project/clang/lib/Format/Format.cpp (Results 276 – 300 of 1154)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# e8111502 13-Apr-2020 mydeveloperday <mydeveloperday@gmail.com>

[clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

Summary:
Use spaces instead of tabs for alignment with UT_ForContinuationAndIndentation to make the code aligned for any

[clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

Summary:
Use spaces instead of tabs for alignment with UT_ForContinuationAndIndentation to make the code aligned for any tab/indent width.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38381

Reviewed By: MyDeveloperDay

Patch By: fickert

Tags: #clang-format

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

show more ...


# c5c487f0 11-Mar-2020 Mitchell Balan <mitchell@stellarscience.com>

Revert "[clang-format] Add option to specify explicit config file"
There were a number of unexpected test failures.

This reverts commit 10b1a87ba35d386b718f0e83c1d750631705b220.


# 10b1a87b 11-Mar-2020 Mitchell Balan <mitchell@stellarscience.com>

[clang-format] Add option to specify explicit config file
Summary:
This diff extends the -style=file option to allow a config file to be specified explicitly. This is useful (for instance) when addin

[clang-format] Add option to specify explicit config file
Summary:
This diff extends the -style=file option to allow a config file to be specified explicitly. This is useful (for instance) when adding IDE commands to reformat code to a personal style.

Reviewers: djasper, ioeric, krasimir, MyDeveloperDay

Reviewed by: MyDeveloperDay

Contributed by: tnorth

Subscribers: cfe-commits, lebedev.ri, MyDeveloperDay, klimek, sammccall, mitchell-stellar

Tags: #clang, #clang-format

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

show more ...


# fa0118e6 13-Feb-2020 Wawha <fjean.wk@gmail.com>

[clang-format] Add new option BeforeLambdaBody in Allman style.

This option add a line break then a lambda is inside a function call.

Reviewers : djasper, klimek, krasimir, MyDeveloperDay

Reviewed

[clang-format] Add new option BeforeLambdaBody in Allman style.

This option add a line break then a lambda is inside a function call.

Reviewers : djasper, klimek, krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

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

show more ...


# 70c98671 01-Feb-2020 mydeveloperday <mydeveloperday@gmail.com>

[clang-format] Add option for not breaking line before ObjC params

Summary:
From `clang-format` version 3.7.0 and up, , there is no way to keep following format of ObjectiveC block:
```
- (void)_aMe

[clang-format] Add option for not breaking line before ObjC params

Summary:
From `clang-format` version 3.7.0 and up, , there is no way to keep following format of ObjectiveC block:
```
- (void)_aMethod
{
[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
u = c;
}]
}
```
Regardless of the change in `.clang-format` configuration file, all parameters will be lined up so that colons will be on the same column, like following:
```
- (void)_aMethod
{
[self.test1 t:self
w:self
callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
u = c;
}]
}
```

Considering with ObjectiveC, the first code style is cleaner & more readable for some people, I've added a config option: `ObjCDontBreakBeforeNestedBlockParam` (boolean) so that if it is enable, the first code style will be favored.

Reviewed By: MyDeveloperDay

Patch By: ghvg1313

Tags: #clang, #clang-format

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

show more ...


# a324fcf1 24-Jan-2020 Martin Probst <martin@probst.io>

clang-format: insert trailing commas into containers.

Summary:
This change adds an option to insert trailing commas into container
literals. For example, in JavaScript:

const x = [
a,

clang-format: insert trailing commas into containers.

Summary:
This change adds an option to insert trailing commas into container
literals. For example, in JavaScript:

const x = [
a,
b,
^~~~~ inserted if missing.
]

This is implemented as a seperate post-processing pass after formatting
(because formatting might change whether the container literal does or
does not wrap). This keeps the code relatively simple and orthogonal,
though it has the notable drawback that the newly inserted comma is not
taken into account for formatting decisions (e.g. it might exceed the 80
char limit). To avoid exceeding the ColumnLimit, a comma is only
inserted if it fits into the limit.

Trailing comma insertion conceptually conflicts with argument
bin-packing: inserting a comma disables bin-packing, so we cannot do
both. clang-format rejects FormatStyle configurations that do both with
this change.

Reviewers: krasimir, MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang

show more ...


# adcd0268 28-Jan-2020 Benjamin Kramer <benny.kra@googlemail.com>

Make llvm::StringRef to std::string conversions explicit.

This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly m

Make llvm::StringRef to std::string conversions explicit.

This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.

show more ...


# 02656f29 24-Jan-2020 Martin Probst <martin@probst.io>

clang-format: [JS] options for arrow functions.

Summary:
clang-format currently always wraps the body of non-empty arrow
functions:

const x = () => {
z();
};

This change implements s

clang-format: [JS] options for arrow functions.

Summary:
clang-format currently always wraps the body of non-empty arrow
functions:

const x = () => {
z();
};

This change implements support for the `AllowShortLambdasOnASingleLine`
style options, controlling the indent style for arrow function bodies
that have one or fewer statements. SLS_All puts all on a single line,
SLS_Inline only arrow functions used in an inline position.

const x = () => { z(); };

Multi-statement arrow functions continue to be wrapped. Function
expressions (`a = function() {}`) and function/method declarations are
unaffected as well.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

show more ...


# 14c04475 19-Jan-2020 mydeveloperday <mydeveloperday@gmail.com>

[clang-format] Add IndentCaseBlocks option

Summary:
The documentation for IndentCaseLabels claimed that the "Switch
statement body is always indented one level more than case labels". This
is techni

[clang-format] Add IndentCaseBlocks option

Summary:
The documentation for IndentCaseLabels claimed that the "Switch
statement body is always indented one level more than case labels". This
is technically false for the code block immediately following the label.
Its closing bracket aligns with the start of the label.

If the case label are not indented, it leads to a style where the
closing bracket of the block aligns with the closing bracket of the
switch statement, which can be hard to parse.

This change introduces a new option, IndentCaseBlocks, which when true
treats the block as a scope block (which it technically is).

(Note: regenerated ClangFormatStyleOptions.rst using tools/dump_style.py)

Reviewed By: MyDeveloperDay

Patch By: capn

Tags: #clang-format, #clang

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

show more ...


# 9835cf15 17-Jan-2020 Martin Probst <martin@probst.io>

clang-format: [JS] pragmas for tslint, tsc.

Summary:
tslint and tsc (the TypeScript compiler itself) use comment pragmas of
the style:

// tslint:disable-next-line:foo
// @ts-ignore

These must

clang-format: [JS] pragmas for tslint, tsc.

Summary:
tslint and tsc (the TypeScript compiler itself) use comment pragmas of
the style:

// tslint:disable-next-line:foo
// @ts-ignore

These must not be wrapped and must stay on their own line, in isolation.
For tslint, this required adding it to the pragma regexp. The comments
starting with `@` are already left alone, but this change adds test
coverage for them.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

show more ...


# 26748a32 03-Dec-2019 Mitchell Balan <mitchell@stellarscience.com>

[clang-format] Add new option to add spaces around conditions
Summary:
This diff adds a new option SpacesAroundConditions that inserts spaces inside the braces for conditional statements.

Reviewers:

[clang-format] Add new option to add spaces around conditions
Summary:
This diff adds a new option SpacesAroundConditions that inserts spaces inside the braces for conditional statements.

Reviewers: klimek, owenpan, mitchell-stellar, MyDeveloperDay

Patch by: timwoj

Subscribers: rsmmr, cfe-commits

Tags: clang, clang-format

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

show more ...


# d4819fe0 16-Nov-2019 Sylvestre Ledru <sylvestre@debian.org>

Remove +x permission on clang/lib/Format/Format.cpp


# a4a7c125 16-Nov-2019 mydeveloperday <mydeveloperday@gmail.com>

[clang-format] Add SpaceBeforeBrackets

Summary: Adds a new option SpaceBeforeBrackets to add spaces before brackets (i.e. int a[23]; -> int a [23];) This is present as an option in the Visual Studi

[clang-format] Add SpaceBeforeBrackets

Summary: Adds a new option SpaceBeforeBrackets to add spaces before brackets (i.e. int a[23]; -> int a [23];) This is present as an option in the Visual Studio C++ code formatting settings, but there was no matching setting in clang-format.

Reviewers: djasper, MyDeveloperDay, mitchell-stellar

Reviewed By: MyDeveloperDay

Subscribers: llvm-commits, cfe-commits, klimek

Patch by: Anteru

Tags: #clang, #clang-format, #llvm

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

show more ...


# 358eaa3d 15-Nov-2019 Cameron Desrochers <Cameron.Desrochers@octasic.com>

[clang-format] Flexible line endings

Line ending detection is now set with the `DeriveLineEnding` option.
CRLF can now be used as the default line ending by setting `UseCRLF`.
When line ending detec

[clang-format] Flexible line endings

Line ending detection is now set with the `DeriveLineEnding` option.
CRLF can now be used as the default line ending by setting `UseCRLF`.
When line ending detection is disabled, all line endings are converted
according to the `UseCRLF` option.

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

show more ...


# 335ac2eb 12-Nov-2019 mydeveloperday <mydeveloperday@gmail.com>

Allow additional file suffixes/extensions considered as source in main include grouping

Summary:
By additional regex match, grouping of main include can be enabled in files that are not normally con

Allow additional file suffixes/extensions considered as source in main include grouping

Summary:
By additional regex match, grouping of main include can be enabled in files that are not normally considered as a C/C++ source code.
For example, this might be useful in templated code, where template implementations are being held in *Impl.hpp files.
On the occassion, 'assume-filename' option description was reworded as it was misleading. It has nothing to do with `style=file` option and it does not influence sourced style filename.

Reviewers: rsmith, ioeric, krasimir, sylvestre.ledru, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Patch by: furdyna

Tags: #clang

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

show more ...


# 86825dbe 07-Nov-2019 Anders Waldenborg <anders@0x63.nu>

[clang-format] Make '.clang-format' variants finding a loop (NFC)

This simplifies logic making it trivial to add searching for other
files later.

Differential revision: https://reviews.llvm.org/D68

[clang-format] Make '.clang-format' variants finding a loop (NFC)

This simplifies logic making it trivial to add searching for other
files later.

Differential revision: https://reviews.llvm.org/D68568

show more ...


# a2f963bb 04-Oct-2019 Paul Hoad <mydeveloperday@gmail.com>

[clang-format] [PR43333] Fix C# breaking before function name when using Attributes

Summary:
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=43333

This comes with 3 main parts

- C# attr

[clang-format] [PR43333] Fix C# breaking before function name when using Attributes

Summary:
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=43333

This comes with 3 main parts

- C# attributes cause function names on a new line even when AlwaysBreakAfterReturnType is set to None
- Add AlwaysBreakAfterReturnType to None by default in the Microsoft style,
- C# unit tests are not using Microsoft style (which we created to define the default C# style to match a vanilla C# project).

Reviewers: owenpan, klimek, russellmcc, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-tools-extra, #clang, #clang-format

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

llvm-svn: 373707

show more ...


# fb13e65a 03-Oct-2019 Paul Hoad <mydeveloperday@gmail.com>

[clang-format] Add ability to wrap braces after multi-line control statements

Summary:
Change the BraceWrappingFlags' AfterControlStatement from a bool to an enum with three values:

* "Never": This

[clang-format] Add ability to wrap braces after multi-line control statements

Summary:
Change the BraceWrappingFlags' AfterControlStatement from a bool to an enum with three values:

* "Never": This is the default, and does not do any brace wrapping after control statements.
* "MultiLine": This only wraps braces after multi-line control statements (this really only happens when a ColumnLimit is specified).
* "Always": This always wraps braces after control statements.

The first and last options are backwards-compatible with "false" and "true", respectively.

The new "MultiLine" option is useful for when a wrapped control statement's indentation matches the subsequent block's indentation. It makes it easier to see at a glance where the control statement ends and where the block's code begins. For example:

```
if (
foo
&& bar )
{
baz();
}
```

vs.

```
if (
foo
&& bar ) {
baz();
}
```

Short control statements (1 line) do not wrap the brace to the next line, e.g.

```
if (foo) {
bar();
} else {
baz();
}
```

Reviewers: sammccall, owenpan, reuk, MyDeveloperDay, klimek

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Patch By: mitchell-stellar

Tags: #clang-format, #clang, #clang-tools-extra

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

llvm-svn: 373647

show more ...


# e5032567 02-Oct-2019 Sam McCall <sam.mccall@gmail.com>

[ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version

Summary:
The historical context:
- clang-format was written when C++11 was current,
and the main lan

[ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version

Summary:
The historical context:
- clang-format was written when C++11 was current,
and the main language-version concern was >> vs > > template-closers.
An option was added to allow selection of the 03/11 behavior, or auto-detection.
- there was no option to choose simply "latest standard" so anyone who didn't
ever want 03 behavior or auto-detection specified Cpp11.
- In r185149 this option started to affect lexer mode.
- no options were added to cover c++14, as parsing/formatting
didn't change that much. The usage of Cpp11 to mean "latest" became
codified e.g. in r206263
- c++17 added some new constructs. These were mostly backwards-compatible and so
not used in old programs, so having no way to turn them off was OK.
- c++20 added some new constructs and keywords (e.g. co_*) that changed the
meaning of existing programs, and people started to complain that
the c++20 parsing couldn't be turned off.

New plan:
- Default ('Auto') behavior remains unchanged: parse as latest, format
template-closers based on input.
- Add new 'Latest' option that more clearly expresses the intent "use
modern features" that many projects have chosen for their .clang-format files.
- Allow pinning to *any* language version, using the same name as clang -std:
c++03, c++11, c++14 etc. These set precise lexer options, and any
clang-format code depending on these can use a >= check.
- For backwards compatibility, `Cpp11` is an alias for `Latest`, not `c++11`.
This matches the historical documented semantics of this option.
This spelling (and `Cpp03`) are deprecated.

Reviewers: klimek, modocache

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373439

show more ...


# 60365021 01-Oct-2019 Paul Hoad <mydeveloperday@gmail.com>

[clang-format] [PR43372] - clang-format shows replacements in DOS files when no replacement is needed

Summary:
This is a patch to fix PR43372 (https://bugs.llvm.org/show_bug.cgi?id=43372) - clang-fo

[clang-format] [PR43372] - clang-format shows replacements in DOS files when no replacement is needed

Summary:
This is a patch to fix PR43372 (https://bugs.llvm.org/show_bug.cgi?id=43372) - clang-format can't format file with includes, ( which really keep providing replacements for already sorted headers.)

A similar issue was addressed by @krasimir in {D60199}, however, this seemingly only prevented the issue when the files being formatted did not contain windows line endings (\r\n)

It's possible this is related to https://twitter.com/StephanTLavavej/status/1176722938243895296 given who @STL_MSFT works for!

As people often used the existence of replacements to determine if a file needs clang-formatting, this is probably pretty important for windows users

There may be a better way of comparing 2 strings and ignoring \r (which appear in both Results and Code), I couldn't choose between this idiom or the copy_if approach, but I'm happy to change it to whatever people consider more performant.

Reviewers: krasimir, klimek, owenpan, ioeric

Reviewed By: krasimir

Subscribers: cfe-commits, STL_MSFT, krasimir

Tags: #clang-format, #clang, #clang-tools-extra

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

llvm-svn: 373388

show more ...


# f0458283 26-Sep-2019 Fangrui Song <maskray@google.com>

[clang-format] Add SortPriority fields to fix -Wmissing-field-initializers after D64695/r372919

llvm-svn: 372939


# 52e44b14 25-Sep-2019 Paul Hoad <mydeveloperday@gmail.com>

[clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.

Summary:
This new Style rule is made as a part of adding support for NetBSD KN

[clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.

Summary:
This new Style rule is made as a part of adding support for NetBSD KNF in clang-format. NetBSD have it's own priority of includes which should be followed while formatting NetBSD code. This style sorts the Cpp Includes according to the priorities of NetBSD, as mentioned in the [Style Guide](http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev=HEAD&content-type=text/x-cvsweb-markup)
The working of this Style rule shown below:

**Configuration:**
This revision introduces a new field under IncludeCategories named `SortPriority` which defines the priority of ordering the `#includes` and the `Priority` will define the categories for grouping the `#include blocks`.

Reviewers: cfe-commits, mgorny, christos, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: lebedev.ri, rdwampler, christos, mgorny, krytarowski

Patch By: Manikishan

Tags: #clang, #clang-format

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

llvm-svn: 372919

show more ...


# a506ed25 22-Sep-2019 Paul Hoad <mydeveloperday@gmail.com>

Clang-format: Add Whitesmiths indentation style

Summary:
This patch adds support for the Whitesmiths indentation style to clang-format. It’s an update to a patch submitted in 2015 (D6833), but rewor

Clang-format: Add Whitesmiths indentation style

Summary:
This patch adds support for the Whitesmiths indentation style to clang-format. It’s an update to a patch submitted in 2015 (D6833), but reworks it to use the newer API.

There are still some issues with this patch, primarily around `switch` and `case` support. The added unit test won’t currently pass because of the remaining issues.

Reviewers: mboehme, MyDeveloperDay, djasper

Reviewed By: MyDeveloperDay

Subscribers: krasimir, MyDeveloperDay, echristo, cfe-commits

Patch By: @timwoj (Tim Wojtulewicz)

Tags: #clang

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

llvm-svn: 372497

show more ...


# 45b6ca5c 17-Sep-2019 Yitzhak Mandelbaum <yitzhakm@google.com>

[clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

Summary:
AnnotatedLine has a tree structure, and things like the body of a lambda will be
a child of the lambda expression. F

[clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

Summary:
AnnotatedLine has a tree structure, and things like the body of a lambda will be
a child of the lambda expression. For example,

[&]() { foo(a); };

will have an AnnotatedLine with a child:

[&]() {};
'- foo(a);

Currently, when the `Cleaner` class analyzes the affected lines, it does not
cleanup the lines' children nodes, which results in missed cleanup
opportunities, like the lambda body in the example above.

This revision extends the algorithm to visit children, thereby fixing the above problem.

Patch by Eric Li.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 372129

show more ...


# 3867a2d5 12-Sep-2019 Paul Hoad <mydeveloperday@gmail.com>

[clang-format] Add new style option IndentGotoLabels

Summary:
This option determines whether goto labels are indented according to scope. Setting this option to false causes goto labels to be flushe

[clang-format] Add new style option IndentGotoLabels

Summary:
This option determines whether goto labels are indented according to scope. Setting this option to false causes goto labels to be flushed to the left.
This is mostly copied from [[ http://lists.llvm.org/pipermail/cfe-dev/2015-September/045014.html | this patch ]] submitted by Christian Neukirchen that didn't make its way into trunk.

```
true: false:
int f() { vs. int f() {
if (foo()) { if (foo()) {
label1: label1:
bar(); bar();
} }
label2: label2:
return 1; return 1;
} }
```

Reviewers: klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang, #clang-tools-extra

Patch by: tetsuo-cpp

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

llvm-svn: 371719

show more ...


1...<<11121314151617181920>>...47