History log of /llvm-project/clang/lib/Format/Format.cpp (Results 1001 – 1025 of 1154)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 304a986a 21-Jan-2013 Daniel Jasper <djasper@google.com>

Remove "incorrect" aligning of trailing comments.

We used to align trailing comments belong to different things.
Before:
void f() { // some function..
}
int a; // some variable..

After:
void f(

Remove "incorrect" aligning of trailing comments.

We used to align trailing comments belong to different things.
Before:
void f() { // some function..
}
int a; // some variable..

After:
void f() { // some function..
}
int a; // some variable..

llvm-svn: 173100

show more ...


# 767c8d35 21-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Set MatchingParen for [], to match <>, (), {}. No functionality change.

llvm-svn: 173078


# ed272de0 21-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Rename LSquare to Left to make parseSquare() more consistent with the other paren parsing methods.

llvm-svn: 173077


# a4fe1c13 21-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes formatting of empty blocks.

We now only put empty blocks into a single line, if all of:
- all tokens of the structural element fit into a single line
- we're not in a control flow statement

N

Fixes formatting of empty blocks.

We now only put empty blocks into a single line, if all of:
- all tokens of the structural element fit into a single line
- we're not in a control flow statement

Note that we usually don't put record definitions into a single line, as
there's usually at least one more token (the semicolon) after the
closing brace. This doesn't hold when we are in a context where there is
no semicolon, like "enum E {}".

There were some missing tests around joining lines around the corner
cases of the allowed number of columns, so this patch adds some.

llvm-svn: 173055

show more ...


# c228619b 21-Jan-2013 Daniel Jasper <djasper@google.com>

Fix parsing of templated declarations.

Before: template <template <typename T>, typename P > class X;
After: template <template <typename T>, typename P> class X;

More importantly, the token annot

Fix parsing of templated declarations.

Before: template <template <typename T>, typename P > class X;
After: template <template <typename T>, typename P> class X;

More importantly, the token annotations for the second ">" are now computed
correctly.

llvm-svn: 173047

show more ...


# d41ee2d2 21-Jan-2013 Daniel Jasper <djasper@google.com>

Fix bug discovered by valgrind.

When trying to merge lines, we should not touch lines that are invalid,
as we don't know how long they might be.

llvm-svn: 173043


# da08761b 18-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes issues around pulling in the next line in simple if statements.

llvm-svn: 172822


# 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 ...


# 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


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

Calculate the total length of a line up to each token up front.

This makes the tedious fitsIntoLimit() method unnecessary and I can
replace one hack (constructor initializers) by a slightly better h

Calculate the total length of a line up to each token up front.

This makes the tedious fitsIntoLimit() method unnecessary and I can
replace one hack (constructor initializers) by a slightly better hack.

Furthermore, this will enable calculating whether a certain part of a
line fits into the limit for future modifications.

llvm-svn: 172604

show more ...


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

Change the datastructure for UnwrappedLines.

It was quite convoluted leading to us accidentally introducing O(N^2)
complexity while copying from UnwrappedLine to AnnotatedLine. We might
still want t

Change the datastructure for UnwrappedLines.

It was quite convoluted leading to us accidentally introducing O(N^2)
complexity while copying from UnwrappedLine to AnnotatedLine. We might
still want to improve the datastructure in AnnotatedLine (most
importantly not put them in a vector where they need to be copied on
vector resizing but that will be done as a follow-up.

This fixes most of the regression in llvm.org/PR14959.

No formatting changes intended.

llvm-svn: 172602

show more ...


# 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


1...<<41424344454647