History log of /llvm-project/clang/unittests/Format/FormatTest.cpp (Results 1876 – 1900 of 2034)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# d3b92fa6 18-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes problems with line merging in the face of preprocessor directives.

This patch prepares being able to test for and fix more problems (see
FIXME in the test for example).

Previously we would ou

Fixes problems with line merging in the face of preprocessor directives.

This patch prepares being able to test for and fix more problems (see
FIXME in the test for example).

Previously we would output unwrapped lines for preprocessor directives
at the point where we also parsed the hash token. Since often
projections only terminate (and thus output their own unwrapped line)
after peeking at the next token, this would lead to the formatter seeing
the preprocessor directives out-of-order (slightly earlier). To be able
to correctly identify lines to merge, the formatter needs a well-defined
order of unwrapped lines, which this patch introduces.

llvm-svn: 172819

show more ...


# 04468962 18-Jan-2013 Daniel Jasper <djasper@google.com>

Reduce penalty for splitting between ")" and ".".

').' is likely part of a builder pattern statement.
This is based upon a patch developed by Nico Weber. Thank you!

Before:
int foo() {
return llv

Reduce penalty for splitting between ")" and ".".

').' is likely part of a builder pattern statement.
This is based upon a patch developed by Nico Weber. Thank you!

Before:
int foo() {
return llvm::StringSwitch<Reference::Kind>(name).StartsWith(
".eh_frame_hdr", ORDER_EH_FRAMEHDR).StartsWith(
".eh_frame", ORDER_EH_FRAME).StartsWith(".init", ORDER_INIT).StartsWith(
".fini", ORDER_FINI).StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

After:
int foo() {
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

Probably not ideal, but makes many cases much more readable.

The changes to overriding-ftemplate-comments.cpp don't seem better or
worse. We should address those soon.

llvm-svn: 172804

show more ...


# 997b08ce 18-Jan-2013 Daniel Jasper <djasper@google.com>

Also align trailing line comments in include directives.

Before:
#include <a> // for x
#include <a/b/c> // for yz
After:
#include <a> // for x
#include <a/b/c> // for yz

llvm-svn: 172799


# aa701fa3 18-Jan-2013 Daniel Jasper <djasper@google.com>

Let the formatter align trailing line comments where possible.

Before:
int a; // comment
int bbbbb; // comment

After:
int a; // comment
int bbbbb; // comment

llvm-svn: 172798


# a5510af5 18-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: After case blocks, "break" goes on the same line as the "}", PR14907.

Before:
switch (foo) {
case a: {
int a = g();
h(a);
}
break;
}

Now:
switch (foo) {
case a: {
int a = g();

Formatter: After case blocks, "break" goes on the same line as the "}", PR14907.

Before:
switch (foo) {
case a: {
int a = g();
h(a);
}
break;
}

Now:
switch (foo) {
case a: {
int a = g();
h(a);
} break;
}

llvm-svn: 172789

show more ...


# e3025672 18-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Enable @encode test.

This doesn't work right with pointers to pointers, but that's likely just a
dupe of PR14884.

llvm-svn: 172785


# 250fe713 18-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: The contents of @selector() should be formatted as a selector.

Before: @selector(foo: )
Now: @selector(foo:)
llvm-svn: 172781


# 80a82761 17-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Get bit tests in ifs right.

It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter c

Formatter: Get bit tests in ifs right.

It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.

Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.

Before:
if (a& b)
if (int* b = f())

Now:
if (a & b)
if (int* b = f())

llvm-svn: 172731

show more ...


# fefb1e62 17-Jan-2013 Daniel Jasper <djasper@google.com>

Allow breaking after the trailing const after a function declaration.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(i

Allow breaking after the trailing const after a function declaration.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const
GUARDED_BY(aaaaaaaaaaaaa);

llvm-svn: 172718

show more ...


# 11cb81cd 17-Jan-2013 Daniel Jasper <djasper@google.com>

Improve handling of comments in static initializers.

Also adding more tests.

We can now keep the formatting of something like:

static SomeType type = { aaaaaaaaaaaaaaaaaaaa, /* comment */

Improve handling of comments in static initializers.

Also adding more tests.

We can now keep the formatting of something like:

static SomeType type = { aaaaaaaaaaaaaaaaaaaa, /* comment */
aaaaaaaaaaaaaaaaaaaa /* comment */,
/* comment */ aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa, // comment
aaaaaaaaaaaaaaaaaaaa };

Note that the comment in the first line is handled like a trailing line comment
as that is likely what the user intended.

llvm-svn: 172711

show more ...


# 772fbfda 17-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Revert most of r172140.

r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Me

Revert most of r172140.

r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions
as reference. But now that I look at that link again, it seems I didn't
read it very carefully the first time round.

llvm-svn: 172703

show more ...


# 69987d54 16-Jan-2013 Daniel Jasper <djasper@google.com>

Fix a bug where we would move a following line into a comment.

Before: Constructor() : a(a), // comment a(a) {}
After: Constructor() : a(a), // comment
a(a) {}

Needed this

Fix a bug where we would move a following line into a comment.

Before: Constructor() : a(a), // comment a(a) {}
After: Constructor() : a(a), // comment
a(a) {}

Needed this as a quick fix. Will add more tests for this in a future
commit.

llvm-svn: 172624

show more ...


# 8c5fba9f 16-Jan-2013 Daniel Jasper <djasper@google.com>

Fix parsing error in conditional expressions.

We used to incorrectly parse

aaaaaa ? aaaaaa(aaaaaa) : aaaaaaaa;

Due to an l_paren being followed by a colon, we assumed it to be part of
a constructo

Fix parsing error in conditional expressions.

We used to incorrectly parse

aaaaaa ? aaaaaa(aaaaaa) : aaaaaaaa;

Due to an l_paren being followed by a colon, we assumed it to be part of
a constructor initializer. Thus, we never found the colon belonging to
the conditional expression, marked the line as bing incorrect and did
not format it.

llvm-svn: 172621

show more ...


# a1dc93a5 16-Jan-2013 Daniel Jasper <djasper@google.com>

Improve understanding of unary operators.

Before: int x = ** a;
After: int x = **a;
llvm-svn: 172619


# ced17f8c 16-Jan-2013 Daniel Jasper <djasper@google.com>

Disable inlining of short ifs in Google style.

Various reasons seem to speak against it, so I am disabling this for
now.

Changed tests to still test this option.

llvm-svn: 172618


# 9278eb95 16-Jan-2013 Daniel Jasper <djasper@google.com>

Add option to avoid "bin-packing" of parameters.

"Bin-packing" here means allowing multiple parameters on one line, if a
function call/declaration is spread over multiple lines.

This is required by

Add option to avoid "bin-packing" of parameters.

"Bin-packing" here means allowing multiple parameters on one line, if a
function call/declaration is spread over multiple lines.

This is required by the Chromium style guide and probably desired for
the Google style guide. Not making changes to LLVM style as I don't have
enough data.

With this enabled, we format stuff like:
aaaaaaaaaaaaaaa(aaaaaaaaaa,
aaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaa();

llvm-svn: 172617

show more ...


# 24998104 16-Jan-2013 Manuel Klimek <klimek@google.com>

Add debugging support for split penalties.

llvm-svn: 172616


# ae6e53c1 16-Jan-2013 Alexander Kornienko <alexfh@google.com>

Clang Format: A couple of tests for the trailing stuff case

llvm-svn: 172607


# 1231e066 16-Jan-2013 Alexander Kornienko <alexfh@google.com>

Clang Format: Handle missing semicolon

llvm-svn: 172606


# 736c14fa 16-Jan-2013 Daniel Jasper <djasper@google.com>

Never merge < and ::, as it produces different tokens.

Before: vector<::Type> t;
After: vector< ::Type> t;
llvm-svn: 172601


# c36492b5 16-Jan-2013 Daniel Jasper <djasper@google.com>

Remove errors were if statements were incorrectly put on a single line.

Before: if (a) // This comment confused clang-format f();
After: if (a) // No more confusion
f();
llvm-svn: 172600


# 99c7baa3 15-Jan-2013 Manuel Klimek <klimek@google.com>

Fix formatting of preprocessor directives (incluces, warnings & errors).

Treat tokens inside <> for includes and everything from the second token
of a warning / error on as an implicit string litera

Fix formatting of preprocessor directives (incluces, warnings & errors).

Treat tokens inside <> for includes and everything from the second token
of a warning / error on as an implicit string literal, e.g. do not
change its whitespace at all.

Now correctly formats:
#include < path with space >
#error Leave all white!!!!! space* alone!

Note that for #error and #warning we still format the space up to the
first token of the text, so:
# error Text
will become
#error Text

llvm-svn: 172536

show more ...


# 7194527d 15-Jan-2013 Daniel Jasper <djasper@google.com>

Improve operator kind detection in presence of comments.

We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.

Example:
Before: int a = /**/ - 1;
Aft

Improve operator kind detection in presence of comments.

We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.

Example:
Before: int a = /**/ - 1;
After: int a = /**/ -1;

llvm-svn: 172533

show more ...


# e01bab58 15-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes various bugs around the keywords class, struct and union.

This switches to parsing record definitions only if we can clearly
identify them. We're specifically allowing common patterns for
visi

Fixes various bugs around the keywords class, struct and union.

This switches to parsing record definitions only if we can clearly
identify them. We're specifically allowing common patterns for
visibility control through macros and attributes, but we cannot
currently fix all instances. This fixes all known bugs we have though.

Before:
static class A f() {
return g();
} int x;

After:
static class A f() {
return g();
}
int x;

llvm-svn: 172530

show more ...


# a54d1a99 14-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes formatting of nested brace initializers.

We now format this correctly:
Status::Rep Status::global_reps[3] = {
{ kGlobalRef, OK_CODE, NULL, NULL, NULL },
{ kGlobalRef, CANCELLED_CODE, NULL,

Fixes formatting of nested brace initializers.

We now format this correctly:
Status::Rep Status::global_reps[3] = {
{ kGlobalRef, OK_CODE, NULL, NULL, NULL },
{ kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL },
{ kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL }
};

- fixed a bug where BreakBeforeClosingBrace would be set on the wrong
state
- added penalties for breaking between = and {, and between { and any
other non-{ token

llvm-svn: 172433

show more ...


1...<<71727374757677787980>>...82