History log of /llvm-project/clang/unittests/Format/FormatTest.cpp (Results 726 – 750 of 2034)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 9b5a89b0 14-Aug-2017 Krasimir Georgiev <krasimir@google.com>

clang-format: Fix left pointer alignment after delctype/typeof

Change 272124* introduced a regression in spaceRequiredBetween for left aligned pointers to decltype and typeof expressions. This fix a

clang-format: Fix left pointer alignment after delctype/typeof

Change 272124* introduced a regression in spaceRequiredBetween for left aligned pointers to decltype and typeof expressions. This fix adds logic to fix this. The test added is based on a related test in determineStarAmpUsage. Also add test cases for the regression.

http://llvm.org/viewvc/llvm-project?view=revision&revision=272124
LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=30407

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

Fix contributed by euhlmann!

llvm-svn: 310831

show more ...


# 58933c5d 10-Aug-2017 Jacob Bandes-Storch <jacob@bandes-stor.ch>

[clang-format] let PointerAlignment dictate spacing of function ref qualifiers

Summary: The original changes for ref qualifiers in rL272537 and rL272548 allowed function const+ref qualifier spacing

[clang-format] let PointerAlignment dictate spacing of function ref qualifiers

Summary: The original changes for ref qualifiers in rL272537 and rL272548 allowed function const+ref qualifier spacing to diverge from the spacing used for variables. It seems more consistent for `T const& x;` to match `void foo() const&;`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 310544

show more ...


# d6a7e983 10-Aug-2017 Jacob Bandes-Storch <jacob@bandes-stor.ch>

clang-format: Fix bug with ENAS_DontAlign and empty lines

This fixes a bug in `ENAS_DontAlign` (introduced in D32733) where blank lines had an EscapedNewlineColumn of 0, causing a subtraction to ove

clang-format: Fix bug with ENAS_DontAlign and empty lines

This fixes a bug in `ENAS_DontAlign` (introduced in D32733) where blank lines had an EscapedNewlineColumn of 0, causing a subtraction to overflow when converted back to unsigned and leading to runaway memory allocation.

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

llvm-svn: 310539

show more ...


# a64ba701 28-Jul-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: merge short case labels with trailing comments

Summary:
Allow merging short case labels when they actually end with a comment
(like a comment after the ``break``) and when followed by

clang-format: merge short case labels with trailing comments

Summary:
Allow merging short case labels when they actually end with a comment
(like a comment after the ``break``) and when followed by switch-level
comments (e.g. aligned with next case):

switch(a) {
case 0: break; // comment at end of case
case 1: return value;
// comment related to next case
// comment related to next case
case 2:
}

Reviewers: krasimir, djasper

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

llvm-svn: 309370

show more ...


# 06b575ca 17-Jul-2017 Manuel Klimek <klimek@google.com>

Fix dereference of pointers in throw statements.

Before:
throw * x;

After:
throw *x;

Patch by Erik Uhlmann.

llvm-svn: 308185


# 90f981bc 14-Jul-2017 Olivier Goffart <ogoffart@woboq.com>

Keep the IdentifierInfo in the Token for alternative operator keyword

The goal of this commit is to fix clang-format so it does not merge tokens when
using the alternative spelling keywords. (eg: "n

Keep the IdentifierInfo in the Token for alternative operator keyword

The goal of this commit is to fix clang-format so it does not merge tokens when
using the alternative spelling keywords. (eg: "not foo" should not become "notfoo")

The problem is that Preprocessor::HandleIdentifier used to drop the identifier info
from the token for these keyword. This means the first condition of
TokenAnnotator::spaceRequiredBefore is not met. We could add explicit check for
the spelling in that condition, but I think it is better to keep the IdentifierInfo
and handle the operator keyword explicitly when needed. That actually leads to simpler
code, and probably slightly more efficient as well.

Another side effect of this change is that __identifier(and) will now work as
one would expect, removing a FIXME from the MicrosoftExtensions.cpp test

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

llvm-svn: 308008

show more ...


# e092634f 12-Jul-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Keep level of comment before an empty line

Summary:
This patch fixes bug https://bugs.llvm.org/show_bug.cgi?id=3313: a comment line
was aligned with the next #ifdef even in the presen

[clang-format] Keep level of comment before an empty line

Summary:
This patch fixes bug https://bugs.llvm.org/show_bug.cgi?id=3313: a comment line
was aligned with the next #ifdef even in the presence of an empty line between
them.

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 307795

show more ...


# ad72256d 30-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: add options to merge empty record body

Summary:
This patch introduces a few extra BraceWrapping options, similar to
`SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g.
c

clang-format: add options to merge empty record body

Summary:
This patch introduces a few extra BraceWrapping options, similar to
`SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g.
class, struct, union and namespace):
* SplitEmptyClass
* SplitEmptyStruct
* SplitEmptyUnion
* SplitEmptyNamespace

The `SplitEmptyFunction` option name has also been simplified/
shortened (from `SplitEmptyFunctionBody`).

These options are helpful when the correspond AfterXXX option is
enabled, to allow merging the empty record:

class Foo
{};

In addition, this fixes an unexpected merging of short records, when
the AfterXXXX options are used, which caused to be formatted like
this:

class Foo
{ void Foo(); };

This is now properly formatted as:

class Foo
{
void Foo();
};

Reviewers: djasper, krasimir

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 306874

show more ...


# d2130f51 30-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: Do not binpack initialization lists

Summary:
This patch tries to avoid binpacking when initializing lists/arrays, to allow things like:

static int types[] = {
registerType1(),

clang-format: Do not binpack initialization lists

Summary:
This patch tries to avoid binpacking when initializing lists/arrays, to allow things like:

static int types[] = {
registerType1(),
registerType2(),
registerType3(),
};
std::map<int, std::string> x = {
{ 0, "foo fjakfjaklf kljj" },
{ 1, "bar fjakfjaklf kljj" },
{ 2, "stuff fjakfjaklf kljj" },
};

This is similar to how dictionnaries are formatted, and actually corresponds to the same conditions: when initializing a container (and not just 'calling' a constructor).

Such formatting involves 2 things:
* Line breaks around the content of the block. This can be forced by adding a comma or comment after the last element
* Elements should not be binpacked

This patch considers the block is an initializer list if it either ends with a comma, or follows an assignment, which seems to provide a sensible approximation.

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: malcolm.parsons, klimek, cfe-commits

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

llvm-svn: 306868

show more ...


# ac16a201 23-Jun-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Add a SortUsingDeclaration option and enable it by default

Summary:
This patch adds a `SortUsingDeclaration` style option and enables it for llvm
style.

Reviewers: klimek

Reviewed B

[clang-format] Add a SortUsingDeclaration option and enable it by default

Summary:
This patch adds a `SortUsingDeclaration` style option and enables it for llvm
style.

Reviewers: klimek

Reviewed By: klimek

Subscribers: klimek

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

llvm-svn: 306094

show more ...


# d3f0e3de 21-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: introduce InlineOnly short function style

Summary:
This is the same as Inline, except it does not imply all empty
functions are merged: with this style, empty functions are merged only

clang-format: introduce InlineOnly short function style

Summary:
This is the same as Inline, except it does not imply all empty
functions are merged: with this style, empty functions are merged only
if they also match the 'inline' criteria (i.e. defined in a class).

This is helpful to avoid inlining functions in implementations files.

Reviewers: djasper, krasimir

Reviewed By: djasper

Subscribers: klimek, rengolin, cfe-commits

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

llvm-svn: 305912

show more ...


# 5f07f443 19-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: Fix C99 designated initializers corner cases

Summary:
This fixes the missing space before the designated initializer when `Cpp11BracedListStyle=false` :

const struct A a = { .a = 1,

clang-format: Fix C99 designated initializers corner cases

Summary:
This fixes the missing space before the designated initializer when `Cpp11BracedListStyle=false` :

const struct A a = { .a = 1, .b = 2 };
^

Also, wrapping between opening brace and designated array initializers used to have an excessive penalty (like breaking between an expression and the subscript operator), leading to unexpected wrapping:

const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa =
{[1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
[2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

instead of:

const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = {
[1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
[2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

Finally, designated array initializers are not binpacked, just like designated member initializers.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, krasimir, klimek

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

llvm-svn: 305696

show more ...


# f92659e4 19-Jun-2017 Daniel Jasper <djasper@google.com>

clang-format: Improve understanding of combined typedef+record declarations

Fixes an issue where struct A { int X; }; would be broken onto multiple
lines, but typedef struct A { int X; } A2; was col

clang-format: Improve understanding of combined typedef+record declarations

Fixes an issue where struct A { int X; }; would be broken onto multiple
lines, but typedef struct A { int X; } A2; was collapsed onto a single
line.

Patch by Jacob Bandes-Storch. Thank you.

llvm-svn: 305667

show more ...


# 6a7d5a7a 19-Jun-2017 Daniel Jasper <djasper@google.com>

clang-format: Handle "if constexpr".

c++1z adds the following constructions to the language:

if constexpr (cond)
statement1;
else if constexpr (cond)
statement2;
else if constexpr (co

clang-format: Handle "if constexpr".

c++1z adds the following constructions to the language:

if constexpr (cond)
statement1;
else if constexpr (cond)
statement2;
else if constexpr (cond)
statement3;
else
statement4;

A first version of this was proposed in reviews.llvm.org/D26953 by
Francis Visoiu Mistrih, but never commited. This patch additionally
fixes the behavior when allowing short if statements on a single line
and was authored by Jacob Bandes-Storch. Thank you to both authors.

llvm-svn: 305666

show more ...


# e56a829e 14-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: Add CompactNamespaces option

Summary:
Add CompactNamespaces option, to pack namespace declarations on the
same line (somewhat similar to C++17 nested namespace definition).

With this

clang-format: Add CompactNamespaces option

Summary:
Add CompactNamespaces option, to pack namespace declarations on the
same line (somewhat similar to C++17 nested namespace definition).

With this option, consecutive namespace declarations are kept on the
same line:

namespace foo { namespace bar {
...
}} // namespace foo::bar

Reviewers: krasimir, djasper, klimek

Reviewed By: djasper

Subscribers: kimgr, cfe-commits, klimek

Tags: #clang-tools-extra

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

llvm-svn: 305384

show more ...


# 2a81ca8d 13-Jun-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: add option to merge empty function body

Summary:
This option supplements the AllowShortFunctionsOnASingleLine flag, to
merge empty function body at the beginning of the line: e.g. when

clang-format: add option to merge empty function body

Summary:
This option supplements the AllowShortFunctionsOnASingleLine flag, to
merge empty function body at the beginning of the line: e.g. when the
function is not short-enough and breaking braces after function.

int f()
{}

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 305272

show more ...


# a6b6d51b 24-May-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: Introduce BreakConstructorInitializers option

Summary:
This option replaces the BreakConstructorInitializersBeforeComma option with an enum, thus introducing a mode where the colon sta

clang-format: Introduce BreakConstructorInitializers option

Summary:
This option replaces the BreakConstructorInitializersBeforeComma option with an enum, thus introducing a mode where the colon stays on the same line as constructor declaration:

// When it fits on line:
Constructor() : initializer1(), initializer2() {}

// When it does not fit:
Constructor() :
initializer1(), initializer2()
{}

// When ConstructorInitializerAllOnOneLineOrOnePerLine = true:
Constructor() :
initializer1(),
initializer2()
{}

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303739

show more ...


# 9976efa8 22-May-2017 Francois Ferrand <thetypz@gmail.com>

clang-format: Allow customizing the penalty for breaking assignment

Summary:
Add option to customize the penalty for breaking assignment

This allows increasing the priority of the assignment, to pr

clang-format: Allow customizing the penalty for breaking assignment

Summary:
Add option to customize the penalty for breaking assignment

This allows increasing the priority of the assignment, to prefer spliting
an operation instead of splitting the assignment, e.g. :

int a = bbbbbbbbbbbbbbbb +
cccccccccccccccc;

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303534

show more ...


# 2c1cdae2 15-May-2017 Martin Probst <martin@probst.io>

JavaScript allows parameter lists to include trailing commas:

myFunction(param1, param2,);

For symmetry with other parenthesized lists ([...], {...}), clang-format should
wrap parenthesized lis

JavaScript allows parameter lists to include trailing commas:

myFunction(param1, param2,);

For symmetry with other parenthesized lists ([...], {...}), clang-format should
wrap parenthesized lists one-per-line if they contain a trailing comma:

myFunction(
param1,
param2,
);

This is particularly useful in function declarations or calls with many
arguments, e.g. commonly in constructors.

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

llvm-svn: 303049

show more ...


# 7fdbb3fe 08-May-2017 Daniel Jasper <djasper@google.com>

[clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding
DontAlign

This converts the clang-format option AlignEscapedNewlinesLeft from a
boolean to an enum, named AlignEscapedNewlines, wit

[clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding
DontAlign

This converts the clang-format option AlignEscapedNewlinesLeft from a
boolean to an enum, named AlignEscapedNewlines, with options Left (prev.
true), Right (prev. false), and a new option DontAlign.

When set to DontAlign, the backslashes are placed just after the last token in each line:
#define EXAMPLE \
do { \
int x = aaaaa; \
int b; \
int dddddddddd; \
} while (0)

Patch by jtbandes. Thank you!

llvm-svn: 302428

show more ...


# 988e7e4f 08-May-2017 Daniel Jasper <djasper@google.com>

[clang-format] Don’t propagate AvoidBinPacking into argument
subexpressions

This is an attempt to fix the issue described in a recent email:
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053632

[clang-format] Don’t propagate AvoidBinPacking into argument
subexpressions

This is an attempt to fix the issue described in a recent email:
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053632.html

Patch by jtbandes. Thank you!
Review: https://reviews.llvm.org/D32475

llvm-svn: 302427

show more ...


Revision tags: llvmorg-4.0.1-rc1
# cab46171 24-Apr-2017 Daniel Jasper <djasper@google.com>

clang-format: Fix bad corner case in formatting of function types.

Before:
std::function<
LoooooooooooongTemplatedType<SomeType>*(
LooooooooooooooooooooongType
type)>

clang-format: Fix bad corner case in formatting of function types.

Before:
std::function<
LoooooooooooongTemplatedType<SomeType>*(
LooooooooooooooooooooongType
type)>
function;

After:
std::function<
LoooooooooooongTemplatedType<
SomeType>*(
LooooooooooooooooongType type)>
function;

clang-format generally avoids having lines like "SomeType>*(" as they
lead to parameter lists that don't belong together to be aligned. However, in
case it is better than the alternative, which can even be violating the column
limit.

llvm-svn: 301182

show more ...


# bcda54b6 21-Apr-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Replace IncompleteFormat by a struct with Line

Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by

[clang-format] Replace IncompleteFormat by a struct with Line

Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by a struct that also contains a line number.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 300985

show more ...


# d4fa2e63 11-Apr-2017 Alexander Kornienko <alexfh@google.com>

[clang-format] Handle NSString literals by merging tokens.

Summary:
This fixes a few outstanding bugs:
* incorrect breaking of NSString literals containing double-width characters;
* inconsisten

[clang-format] Handle NSString literals by merging tokens.

Summary:
This fixes a few outstanding bugs:
* incorrect breaking of NSString literals containing double-width characters;
* inconsistent formatting of ObjC dictionary literals containing NSString
literals;
* AlwaysBreakBeforeMultilineStrings ignoring implicitly-concatenated NSString
literals.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 299927

show more ...


# dc06518f 05-Apr-2017 Nico Weber <nicolasweber@gmx.de>

clang-format: Support formatting utf-8 character literals in C++11+ mode.

clang-format <<END
auto c1 = u8'a';
auto c2 = u'a';
END

Before:
auto c1 = u8 'a';
auto c2 = u'a';

Now:
auto c1 = u8'

clang-format: Support formatting utf-8 character literals in C++11+ mode.

clang-format <<END
auto c1 = u8'a';
auto c2 = u'a';
END

Before:
auto c1 = u8 'a';
auto c2 = u'a';

Now:
auto c1 = u8'a';
auto c2 = u'a';

Patch from Denis Gladkikh <llvm@denis.gladkikh.email>!

llvm-svn: 299574

show more ...


1...<<21222324252627282930>>...82