#
38ba11e4 |
| 07-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Do not ever allow using the full line in preprocessor directives.
We would format: #define A \ int f(a); int i; as #define A \ int f(a);\ int i
The fix will break up macro definitio
Do not ever allow using the full line in preprocessor directives.
We would format: #define A \ int f(a); int i; as #define A \ int f(a);\ int i
The fix will break up macro definitions that could fit a line, but hit the last column; fixing that is more involved, though, as it requires looking at the following line.
llvm-svn: 171715
show more ...
|
#
c74d2922 |
| 07-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Fix layouting of single-line-comments preceded by an escaped newline.
Previously, we'd format int i;\ // comment as int i; // comment
The problem is that the escaped newline is part of the ne
Fix layouting of single-line-comments preceded by an escaped newline.
Previously, we'd format int i;\ // comment as int i; // comment
The problem is that the escaped newline is part of the next token, and thus the raw token text of the comment doesn't start with "//".
llvm-svn: 171713
show more ...
|
#
ef920699 |
| 07-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Fix layouting of tokens with a leading escaped newline.
If a token follows directly on an escaped newline, the escaped newline is stored with the token. Since we re-layout escaped newlines, we need
Fix layouting of tokens with a leading escaped newline.
If a token follows directly on an escaped newline, the escaped newline is stored with the token. Since we re-layout escaped newlines, we need to treat them just like normal whitespace - thus, we need to increase the whitespace-length of the token, while decreasing the token length (otherwise the token length contains the length of the escaped newline and we double-count it while indenting).
llvm-svn: 171706
show more ...
|
#
c7345ccc |
| 07-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Put a higher penalty on breaking before "." or "->".
This fixes llvm.org/PR14823.
Before: local_state->SetString(prefs::kApplicationLocale, parent_local_state ->
Put a higher penalty on breaking before "." or "->".
This fixes llvm.org/PR14823.
Before: local_state->SetString(prefs::kApplicationLocale, parent_local_state ->GetString(prefs::kApplicationLocale)); After: local_state->SetString( prefs::kApplicationLocale, parent_local_state->GetString(prefs::kApplicationLocale));
llvm-svn: 171705
show more ...
|
#
52d0fd89 |
| 05-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Fixes parsing of hash tokens in the middle of a line.
To parse # correctly, we need to know whether it is the first token in a line - we can deduct this either from the whitespace or seeing that the
Fixes parsing of hash tokens in the middle of a line.
To parse # correctly, we need to know whether it is the first token in a line - we can deduct this either from the whitespace or seeing that the token is the first in the file - we already calculate this information. This patch moves the identification of the first token into the getNextToken method and stores it inside the FormatToken, so the UnwrappedLineParser can stay independent of the SourceManager.
llvm-svn: 171640
show more ...
|
#
1abf789c |
| 04-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Various fixes to clang-format's macro handling.
Some of this is still pretty rough (note the load of FIXMEs), but it is strictly an improvement and fixes various bugs that were related to macro proc
Various fixes to clang-format's macro handling.
Some of this is still pretty rough (note the load of FIXMEs), but it is strictly an improvement and fixes various bugs that were related to macro processing but are also imporant in non-macro use cases.
Specific fixes: - correctly puts espaced newlines at the end of the line - fixes counting of white space before a token when escaped newlines are present - fixes parsing of "trailing" tokens when eof() is hit - puts macro parsing orthogonal to parsing other structure - general support for parsing of macro definitions
Due to the fix to format trailing tokens, this change also includes a bunch of fixes to the c-index tests.
llvm-svn: 171556
show more ...
|
#
3c2557d0 |
| 04-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Correctly format dereference and address of in array parameters.
Before: InvalidRegions[ &R] = 0; After: InvalidRegions[&R] = 0;
This fixes llvm.org/PR14793
llvm-svn: 171522
|
#
c0880a90 |
| 04-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Let the formatter ignore UnwrappedLines containing errors.
This prevents code like:
namespace { class Foo { Foo( }; } // comment
from causing segfaults (see llvm.org/PR14774).
llvm-svn: 1714
Let the formatter ignore UnwrappedLines containing errors.
This prevents code like:
namespace { class Foo { Foo( }; } // comment
from causing segfaults (see llvm.org/PR14774).
llvm-svn: 171495
show more ...
|
#
b69e3c62 |
| 02-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Fixes multiple formatting bugs.
Fixes: - incorrect handling of multiple consecutive preprocessor directives - crash when trying to right align the escpaed newline for a line that is longer than th
Fixes multiple formatting bugs.
Fixes: - incorrect handling of multiple consecutive preprocessor directives - crash when trying to right align the escpaed newline for a line that is longer than the column limit - using only ColumnLimit-1 columns when layouting with escaped newlines inside preprocessor directives
llvm-svn: 171401
show more ...
|
#
90e51fdb |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Don't allow line breaks after template parameters.
This fixes llvm.org/PR14786.
We will need to split there as a last resort, but that should be done consistently independent of whether the type is
Don't allow line breaks after template parameters.
This fixes llvm.org/PR14786.
We will need to split there as a last resort, but that should be done consistently independent of whether the type is a template type or not.
Before: template <typename T> aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T> ::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After: template <typename T> aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 171400
show more ...
|
#
3c0431c8 |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Format */& as binary operator if followed by a unary operator.
This fixes llvm.org/PR14687. Also fixes segfault for lines starting with * or &.
Before: a *~b; *a = 1; // <- this segfaulted
After:
Format */& as binary operator if followed by a unary operator.
This fixes llvm.org/PR14687. Also fixes segfault for lines starting with * or &.
Before: a *~b; *a = 1; // <- this segfaulted
After: a * ~b; *a = 1; // no segfault :-)
llvm-svn: 171396
show more ...
|
#
a71e5d81 |
| 02-Jan-2013 |
Manuel Klimek <klimek@google.com> |
Fixes use of unescaped newlines when formatting preprocessor directives.
This is the first step towards handling preprocessor directives. This patch only fixes the most pressing issue, namely correc
Fixes use of unescaped newlines when formatting preprocessor directives.
This is the first step towards handling preprocessor directives. This patch only fixes the most pressing issue, namely correctly escaping newlines for tokens within a sequence of a preprocessor directive.
The next step will be to fix incorrect format decisions on #define directives.
llvm-svn: 171393
show more ...
|
#
542de16e |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Correctly format pointers and references in casts.
This fixes llvm.org/PR14747.
Before: Type *A = (Type * ) P; After: Type *A = (Type *) P; llvm-svn: 171390
|
#
da1c68ab |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Understand unary operators after "return" and "case".
This fixes llvm.org/PR14746.
Before: return - 1; After: return -1; llvm-svn: 171389
|
#
ac5c1c28 |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Prefer splitting after "template <...>" and fix indentation.
This addresses llvm.org/PR14699
Before: template <typename T> void looooooooooooooooooooooongFunction(int Param1, int Param2); templ
Prefer splitting after "template <...>" and fix indentation.
This addresses llvm.org/PR14699
Before: template <typename T> void looooooooooooooooooooooongFunction(int Param1, int Param2); template <typename T> void looooooooooooooooooooongFunction( int Paaaaaaaaaaaaaaaaaaaaram1, int Paaaaaaaaaaaaaaaaaaaaram2);
After: template <typename T> void looooooooooooooooooooooongFunction(int Param1, int Param2); template <typename T> void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1, int Paaaaaaaaaaaaaaaaaaaaram2);
llvm-svn: 171388
show more ...
|
#
3d0c75cc |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Prefer to break after operators over breaking after "(".
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After: aaaaaaaaaaaa
Prefer to break after operators over breaking after "(".
Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 171386
show more ...
|
#
44eb4f66 |
| 02-Jan-2013 |
Chandler Carruth <chandlerc@gmail.com> |
Re-sort #include lines using the llvm/utils/sort_includes.py script.
Removes a duplicate #include as well as cleaning up some sort order regressions since I last ran the script over Clang.
llvm-svn
Re-sort #include lines using the llvm/utils/sort_includes.py script.
Removes a duplicate #include as well as cleaning up some sort order regressions since I last ran the script over Clang.
llvm-svn: 171364
show more ...
|
#
22bcf8a8 |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Understand * and & in ternary expressions.
Before: "int a = b ? *c : * d;" After: "int a = b ? *c : *d; llvm-svn: 171358
|
#
d1926a37 |
| 02-Jan-2013 |
Daniel Jasper <djasper@google.com> |
Don't break after pointer or reference specifier.
This fixes llvm.org/PR14717. Buggy format: TypeSpecDecl * TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
Don't break after pointer or reference specifier.
This fixes llvm.org/PR14717. Buggy format: TypeSpecDecl * TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *II, Type *T) {
Now changed to: TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *II, Type *T) {
llvm-svn: 171357
show more ...
|
#
8fbd9685 |
| 24-Dec-2012 |
Daniel Jasper <djasper@google.com> |
Let clang-format format itself.
Apply all formatting changes that clang-format would apply to its own source code. All choices seem to improve readability (or at least not make it worse). No functio
Let clang-format format itself.
Apply all formatting changes that clang-format would apply to its own source code. All choices seem to improve readability (or at least not make it worse). No functional changes.
llvm-svn: 171039
show more ...
|
#
6d822720 |
| 24-Dec-2012 |
Daniel Jasper <djasper@google.com> |
Penalize tokens with a lower parenthesis level than the start of the line.
This prevents formattings like this (assuming "parameter" doesn't fit the line): bool f = someFunction() && someFunctionW
Penalize tokens with a lower parenthesis level than the start of the line.
This prevents formattings like this (assuming "parameter" doesn't fit the line): bool f = someFunction() && someFunctionWithParam( parameter) && someOtherFunction();
Here, "parameter" - the start of line 2 - has a parenthesis level of 2, but there are subsequent tokens ("&&" and "someOtherFunction") with a lower level. This is bad for readability as "parameter" hides "someOtherFunction". With this patch, this changes to: bool f = someFunction() && someFunctionWithParam(parameter) && someOtherFunction();
llvm-svn: 171038
show more ...
|
#
2eda23e7 |
| 24-Dec-2012 |
Daniel Jasper <djasper@google.com> |
Align RHS after assignments and return statements.
This changes: int Result = a + // force break b; return Result + // force break 5;
To: int Result = a + // force break
Align RHS after assignments and return statements.
This changes: int Result = a + // force break b; return Result + // force break 5;
To: int Result = a + // force break b; return Result + // force break 5;
llvm-svn: 171032
show more ...
|
#
537a2963 |
| 24-Dec-2012 |
Daniel Jasper <djasper@google.com> |
Fix formatting over overloaded operators.
This fixes llvm.org/pr14686.
We used to add too many spaces for different versions of overloaded operator function declarations/definitions. This patch cha
Fix formatting over overloaded operators.
This fixes llvm.org/pr14686.
We used to add too many spaces for different versions of overloaded operator function declarations/definitions. This patch changes, e.g.
operator *() {} operator >() {} operator () () {}
to
operator*() {} operator>() {} operator()() {}
llvm-svn: 171028
show more ...
|
#
de5c2079 |
| 24-Dec-2012 |
Daniel Jasper <djasper@google.com> |
Take operator precedence into account when splitting lines.
With this patch, splitting after binary operators has a panelty corresponding to the operator's precedence. We used to ignore this and eag
Take operator precedence into account when splitting lines.
With this patch, splitting after binary operators has a panelty corresponding to the operator's precedence. We used to ignore this and eagerly format like:
if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) { .. }
With this patch, this becomes:
if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) { .. }
llvm-svn: 171007
show more ...
|
#
6f372e65 |
| 23-Dec-2012 |
Nico Weber <nicolasweber@gmx.de> |
libFormat: Teach the *& usage heuristic that "return" starts a rhs too.
"return a*b;" was formatted as "return a *b;" and is now formatted as "return a * b;".
Fixes PR14687 partially.
llvm-svn: 17
libFormat: Teach the *& usage heuristic that "return" starts a rhs too.
"return a*b;" was formatted as "return a *b;" and is now formatted as "return a * b;".
Fixes PR14687 partially.
llvm-svn: 170993
show more ...
|