History log of /llvm-project/clang/lib/Format/Format.cpp (Results 901 – 925 of 1154)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 97b89484 13-Mar-2013 Daniel Jasper <djasper@google.com>

Fix formatting of new arrays of pointers.

Before:
A = new SomeType * [Length];
A = new SomeType *[Length]();

After:
A = new SomeType *[Length];
A = new SomeType *[Length]();

Small formatting clean

Fix formatting of new arrays of pointers.

Before:
A = new SomeType * [Length];
A = new SomeType *[Length]();

After:
A = new SomeType *[Length];
A = new SomeType *[Length]();

Small formatting cleanups with clang-format.

llvm-svn: 176936

show more ...


# 5085d9b2 08-Mar-2013 Manuel Klimek <klimek@google.com>

Fixes breaking of string literals.

1. We now ignore all non-default string literals, including raw
literals.
2. We do not break inside escape sequences any more.

FIXME: We still break in trigraphs.

Fixes breaking of string literals.

1. We now ignore all non-default string literals, including raw
literals.
2. We do not break inside escape sequences any more.

FIXME: We still break in trigraphs.
llvm-svn: 176710

show more ...


# f71cf3bd 07-Mar-2013 Daniel Jasper <djasper@google.com>

Remove unncessary whitespace when triggered on empty line.

With the cursor located at "I", clang-format would not do anything to:

int a;

I

int b;

With this patch, it reduces the number of e

Remove unncessary whitespace when triggered on empty line.

With the cursor located at "I", clang-format would not do anything to:

int a;

I

int b;

With this patch, it reduces the number of empty lines as necessary, and
removes unnecessary whitespace. It does not change/reformat "int a;" or
"int b;".

llvm-svn: 176650

show more ...


# abf6e03b 04-Mar-2013 Manuel Klimek <klimek@google.com>

Make sure to not split string literals at the first character.

llvm-svn: 176447


# 973c9420 04-Mar-2013 Daniel Jasper <djasper@google.com>

Format a line if a range in its leading whitespace was selected.

With [] marking the selected range, clang-format invoked on

[ ] int a;

Would so far not reformat anything. With this patch,

Format a line if a range in its leading whitespace was selected.

With [] marking the selected range, clang-format invoked on

[ ] int a;

Would so far not reformat anything. With this patch, it formats a
line if its leading whitespace is touched.

llvm-svn: 176435

show more ...


# a79064a8 01-Mar-2013 Daniel Jasper <djasper@google.com>

Remove whitespace at end of file.

This fixes the rest of llvm.org/PR15062.

llvm-svn: 176361


# f9a84b5f 01-Mar-2013 Daniel Jasper <djasper@google.com>

Normal indent for last element of builder-type call.

In builder type call, we indent to the laster function calls.
However, for the last element of such a call, we don't need to do
so, as that norma

Normal indent for last element of builder-type call.

In builder type call, we indent to the laster function calls.
However, for the last element of such a call, we don't need to do
so, as that normally just wastes space and does not increase
readability.

Before:
aaaaaa->aaaaaa->aaaaaa( // break
aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa
->aaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaa->aaaaaa->aaaaaa( // break
aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 176352

show more ...


# 3324cbef 01-Mar-2013 Daniel Jasper <djasper@google.com>

Remove trailing whitespace of line comments.

This fixed llvm.org/PR15378.

llvm-svn: 176351


# e317d1b1 01-Mar-2013 Manuel Klimek <klimek@google.com>

Implements breaking string literals at slashes.

We now break at a slash if we do not find a space to break on.

Also fixes a bug where we would go over the limit when breaking the
second line.

llvm

Implements breaking string literals at slashes.

We now break at a slash if we do not find a space to break on.

Also fixes a bug where we would go over the limit when breaking the
second line.

llvm-svn: 176350

show more ...


# b176cff8 01-Mar-2013 Manuel Klimek <klimek@google.com>

Implement fallback split point for string literals.

If we don't find a natural split point (currently space) in a string
literal protruding over the line, we just split at the last possible
point.

Implement fallback split point for string literals.

If we don't find a natural split point (currently space) in a string
literal protruding over the line, we just split at the last possible
point.

llvm-svn: 176349

show more ...


# c22f5b4a 28-Feb-2013 Daniel Jasper <djasper@google.com>

Improve formatting of #defines.

Two improvements:
1) Always leave at least one space before "\". Otherwise is can look bad
and there is a risk of unwillingly joining to characters to a different

Improve formatting of #defines.

Two improvements:
1) Always leave at least one space before "\". Otherwise is can look bad
and there is a risk of unwillingly joining to characters to a different
token.
2) Use the full column limit for single-line #defines.
Fixes llvm.org/PR15148

llvm-svn: 176245

show more ...


# 57d4a582 28-Feb-2013 Daniel Jasper <djasper@google.com>

Fix bug when formatting "A<A<A>>".

Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaa);
Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaa

Fix bug when formatting "A<A<A>>".

Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaa);
Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 176244

show more ...


# ead41b6b 28-Feb-2013 Daniel Jasper <djasper@google.com>

Fix incorrect recognition of bin-packing.

Before (in Google style):
Constructor()
: aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(
aaaaaa) {}

After:
Constructor()

Fix incorrect recognition of bin-packing.

Before (in Google style):
Constructor()
: aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(
aaaaaa) {}

After:
Constructor()
: aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa) {}

llvm-svn: 176242

show more ...


# 2cf17bfc 27-Feb-2013 Daniel Jasper <djasper@google.com>

Enable bin-packing in Google style.

After some discussions, it seems that this is the better path in
the long run. Does not change Chromium style, as there, bin packing
is forbidden by the style gui

Enable bin-packing in Google style.

After some discussions, it seems that this is the better path in
the long run. Does not change Chromium style, as there, bin packing
is forbidden by the style guide.

Also fix two minor bugs wrt. formatting:
1. If a call parameter is a function call itself and is split before
the "." or "->", split before the next parameter.
2. If a call parameter is string literal that has to be split onto
two lines, split before the next parameter.

llvm-svn: 176177

show more ...


# fb5e2411 26-Feb-2013 Daniel Jasper <djasper@google.com>

Only keep empty lines in unwrapped lines if they preceed a line comment.

Empty lines followed by line comments are often used to highlight the
comment. Empty lines somewhere else are usually left ov

Only keep empty lines in unwrapped lines if they preceed a line comment.

Empty lines followed by line comments are often used to highlight the
comment. Empty lines somewhere else are usually left over from manual or
automatic formatting and should probably be removed.

Before (clang-format would keep):
S s = {
a,

b
};

After:
S s = { a, b };

llvm-svn: 176086

show more ...


# 5497fce4 26-Feb-2013 Daniel Jasper <djasper@google.com>

Only break string literals as a last resort.

We might want to move towards doing this if the formatting can be
significantly improved, but we need to carefully evaluate the different
situations firs

Only break string literals as a last resort.

We might want to move towards doing this if the formatting can be
significantly improved, but we need to carefully evaluate the different
situations first.

Before (the string literal was split by clang-format here):
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa "
"aaaaa aaa aaa aaaaaa"));

After:
aaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaa,
aaaaaa("aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa"));

llvm-svn: 176084

show more ...


# 62e68174 25-Feb-2013 Daniel Jasper <djasper@google.com>

Re-add hack that caused regression.

This fixes llvm.org/PR15350.

Before:
Constructor(int Parameter = 0)
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
aaaaaaaaaaaa(aaa

Re-add hack that caused regression.

This fixes llvm.org/PR15350.

Before:
Constructor(int Parameter = 0)
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

After:
Constructor(int Parameter = 0)
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

I think the correct solution is to put the VariablePos into
ParenState, not LineState. Added FIXME.

llvm-svn: 176027

show more ...


# 26d1b1db 24-Feb-2013 Daniel Jasper <djasper@google.com>

Allow breaking between a type and name in variable declarations.

This fixes llvm.org/PR14967 and is generall necessary to avoid
situations where the column limit is exceeded. The challenge is
restri

Allow breaking between a type and name in variable declarations.

This fixes llvm.org/PR14967 and is generall necessary to avoid
situations where the column limit is exceeded. The challenge is
restricting such lines splits, otherwise clang-format suddenly starts
breaking at bad places.

Before:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string,
SomeOtherTemplateParameter> &ReallyReallyLongParameterName,
const SomeType<string,
SomeOtherTemplateParameter> &AnotherLongParameterName) {}

After:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string, SomeOtherTemplateParameter> &
ReallyReallyLongParameterName,
const SomeType<string, SomeOtherTemplateParameter> &
AnotherLongParameterName) {}

llvm-svn: 175999

show more ...


# cd8599e8 23-Feb-2013 Daniel Jasper <djasper@google.com>

Better formatting of conditional expressions.

In conditional expressions, if the condition is split over multiple
lines, also break before both operands.

This prevents formattings like:

aaaaaaaa

Better formatting of conditional expressions.

In conditional expressions, if the condition is split over multiple
lines, also break before both operands.

This prevents formattings like:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c;

Which are bad, because they suggestion incorrect operator precedence:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c);

This lead to the discovery that the expression parser incorrectly
handled conditional operators and that it could also handle semicolons
(which in turn reduced the amount of special casing for for-loops). As a
side-effect, we can now apply the bin-packing configuration to the
sections of for-loops.

llvm-svn: 175973

show more ...


# 12ef4e59 21-Feb-2013 Daniel Jasper <djasper@google.com>

Consistently put {} onto the same line for empty functions.

This fixes llvm.org/PR15167.

Before:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {
}
L

Consistently put {} onto the same line for empty functions.

This fixes llvm.org/PR15167.

Before:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {
}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}

After:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}

llvm-svn: 175800

show more ...


# 37905f71 21-Feb-2013 Daniel Jasper <djasper@google.com>

Allow breaking between type and name in for loops.

This fixes llvm.org/PR15033.

Also: Always break before a parameter, if the previous parameter was
split over multiple lines. This was necessary to

Allow breaking between type and name in for loops.

This fixes llvm.org/PR15033.

Also: Always break before a parameter, if the previous parameter was
split over multiple lines. This was necessary to make the right
decisions in for-loops, almost always makes the code more readable and
also fixes llvm.org/PR14873.

Before:
for (llvm::ArrayRef<NamedDecl *>::iterator I = FD->getDeclsInPrototypeScope()
.begin(), E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc), d, bar(e, f));

After:
for (llvm::ArrayRef<NamedDecl *>::iterator
I = FD->getDeclsInPrototypeScope().begin(),
E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc),
d, bar(e, f));

llvm-svn: 175741

show more ...


# 0c91571d 20-Feb-2013 Manuel Klimek <klimek@google.com>

Fix regression in string literal alignment.

Now correctly indents (again):
a = a + "a"
"a"
"a";

llvm-svn: 175630


# 02f640a3 20-Feb-2013 Manuel Klimek <klimek@google.com>

Fixes bug in string literal alignment.

We now indent the following correctly:
1. some + "literal" /* comment */
"literal";
2. breaking string literals after which we have another string li

Fixes bug in string literal alignment.

We now indent the following correctly:
1. some + "literal" /* comment */
"literal";
2. breaking string literals after which we have another string literal.

llvm-svn: 175628

show more ...


# dc7d5817 20-Feb-2013 Daniel Jasper <djasper@google.com>

Don't remove blank lines within unwrapped lines.

If the code author decides to put empty lines anywhere into the code we
should treat them equally, i.e. reduce them to the configured
MaxEmptyLinesTo

Don't remove blank lines within unwrapped lines.

If the code author decides to put empty lines anywhere into the code we
should treat them equally, i.e. reduce them to the configured
MaxEmptyLinesToKeep.

With this change, we e.g. keep the newline in:
SomeType ST = {
// First value
a,

// Second value
b
};

llvm-svn: 175620

show more ...


# 1998ea2c 20-Feb-2013 Manuel Klimek <klimek@google.com>

Implements breaking of string literals if they stick out.

An alternative strategy to calculating the break on demand when hitting
a token that would need to be broken would be to put all possible br

Implements breaking of string literals if they stick out.

An alternative strategy to calculating the break on demand when hitting
a token that would need to be broken would be to put all possible breaks
inside the token into the optimizer.

Currently only supports breaking at spaces; more break points to come.

llvm-svn: 175613

show more ...


1...<<31323334353637383940>>...47