| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we find an unexpected closing brace, we must not stop parsing, as
we'd otherwise not layout anything beyond that point.
If we find a structural error on the highest level we'll not re-indent
anyway, but we'll still want to format within unwrapped lines.
Needed to introduce a differentiation between an expected and unexpected
closing brace.
llvm-svn: 171666
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
Uses indent 0 for macros for now and resets the indent state to the
level prior to the preprocessor directive.
llvm-svn: 171639
|
|
|
|
|
|
| |
A preprocessor directive cannot be started while we're parsing one.
llvm-svn: 171635
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
Before: InvalidRegions[ &R] = 0;
After: InvalidRegions[&R] = 0;
This fixes llvm.org/PR14793
llvm-svn: 171522
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This prevents code like:
namespace {
class Foo {
Foo(
};
} // comment
from causing segfaults (see llvm.org/PR14774).
llvm-svn: 171495
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR14747.
Before: Type *A = (Type * ) P;
After: Type *A = (Type *) P;
llvm-svn: 171390
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR14746.
Before: return - 1;
After: return -1;
llvm-svn: 171389
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 171386
|
|
|
|
|
|
|
| |
Removes a duplicate #include as well as cleaning up some sort order
regressions since I last ran the script over Clang.
llvm-svn: 171364
|
|
|
|
|
|
| |
Before: "int a = b ? *c : * d;"
After: "int a = b ? *c : *d;
llvm-svn: 171358
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changes formatting from:
inline namespace X {
class A {
};
}
to:
inline namespace X {
class A {
};
}
llvm-svn: 171266
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
"return a*b;" was formatted as "return a *b;" and is now formatted as "return a * b;".
Fixes PR14687 partially.
llvm-svn: 170993
|
|
|
|
| |
llvm-svn: 170914
|
|
|
|
|
|
|
|
|
|
| |
This fixes PR14683. We used to format like this:
#include <a / b>
And this patch changes this to:
#include <a/b>
llvm-svn: 170910
|
|
|
|
| |
llvm-svn: 170904
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to not really format them. Now we do:
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
SE = BB->succ_end();
SI != SE; ++SI) {
This is just one example and I am sure we still mess some of them up, but it
is a step forward.
llvm-svn: 170899
|
|
|
|
|
|
|
| |
No indented functional changes other than handling more operators
correctly.
llvm-svn: 170875
|
|
|
|
|
|
| |
Also, some (automated) formatting fixes and slight cleanups.
llvm-svn: 170873
|
|
|
|
|
|
|
| |
use it to format xml declaration tags.
// rdar://12378714
llvm-svn: 170727
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to format initializers like this (with a sort of hacky implementation):
Constructor()
: Val1(A),
Val2(B) {
and now format like this (with a somewhat better solution):
Constructor()
: Val1(A), Val2(B) {
assuming this would not fit on a single line. Also added tests.
As a side effect we now first analyze whether an UnwrappedLine needs to be
split at all. If not, not splitting it is the best solution by definition. As
this should be a very common case in normal code, not exploring the entire
solution space can provide significant speedup.
llvm-svn: 170457
|
|
|
|
|
|
|
|
|
|
|
|
| |
avoided.
This required a minor modification of the memoization as now the
"CurrentPenalty" depends on whether or not we break before the current
token. Therefore, the CurrentPenalty should not be memoized but added
after retrieving a value from memory. This should not affect the runtime
behavior.
llvm-svn: 170337
|
|
|
|
|
|
|
|
|
| |
More specifically:
- Improve formatting of static initializers.
- Fix formatting of lines comments in enums.
- Fix formmating of trailing line comments.
llvm-svn: 170316
|
|
|
|
|
|
| |
Fix spacing before ",".
llvm-svn: 169746
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D198
llvm-svn: 169738
|
|
|
|
| |
llvm-svn: 169648
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: FormatTokenLexer is here, FormatTokenBuffer is on the way. This will allow to re-parse unwrapped lines when needed.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D186
llvm-svn: 169605
|
|
|
|
|
|
|
| |
Now not joining keywords with '::' and not putting a space between
a pointer pointer.
llvm-svn: 169594
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: + tests arranged in groups, as their number is already quite large.
Reviewers: djasper, klimek
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D185
llvm-svn: 169520
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits, silvas
Differential Revision: http://llvm-reviews.chandlerc.com/D176
llvm-svn: 169518
|
|
|
|
| |
llvm-svn: 169500
|
|
|
|
|
|
|
| |
Also, small fix for handling the first token correctly.
Review: http://llvm-reviews.chandlerc.com/D177
llvm-svn: 169488
|
|
|
|
| |
llvm-svn: 169390
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Adds support for formatting for and while loops.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D174
llvm-svn: 169387
|