History log of /external/clang/lib/Format/TokenAnnotator.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef8225444452a1486bd721f3285301fe84643b00 21-Jul-2014 Stephen Hines <srhines@google.com> Update Clang for rebase to r212749.

This also fixes a small issue with arm_neon.h not being generated always.

Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android

Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
/external/clang/lib/Format/TokenAnnotator.cpp
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
/external/clang/lib/Format/TokenAnnotator.cpp
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
/external/clang/lib/Format/TokenAnnotator.cpp
deb61c5169531895a3cfa02d77b4d8f315f5e64b 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve linebreaking and indentation for ObjC calls.

Before:
popup_wdow_.reset([[RenderWidgetPopupWindow alloc]
iniithContentRect:
NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height())
syeMask:NSBorderlessWindowMask
bking:NSBackingStoreBuffered
der:NO]);
[self param:function( //
parameter)]

After:
popup_wdow_.reset([[RenderWidgetPopupWindow alloc]
iniithContentRect:NSMakRet(origin_global.x, origin_global.y, pos.width(),
pos.height())
syeMask:NSBorderlessWindowMask
bking:NSBackingStoreBuffered
der:NO]);
[self param:function( //
parameter)]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194267 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1a896a5a72d9af0259afe636535254c95dc6b355 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Make breaking before ternary operators configurable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194229 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f9504aa0c3fc7169d137b32d311f6c8102471cb1 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve binary operator detection in macros.

Before:
#define M(NAME) assert(!Context.Verifying &&#NAME);

After:
#define M(NAME) assert(!Context.Verifying && #NAME);

This fixes llvm.org/PR16156.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194216 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
966e6d3a174856ff3fe3d6cfe294ebae832f6c09 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve ObjC variadic and binary expression parameters.

Before:
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];

After:
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];

This addresses llvm.org/PR15349 and llvm.org/PR16185.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194214 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
dbfb5f37f4d003ae6935b87a103b7827d5069690 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of constructor initializers.

Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa,
aaaa)) {}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194210 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
59875ac81b97de87ac6c4c7cb256ab71b75114f2 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Remove old hack that mainly made incorrect tests pass.

As a side-effect, constructors definitions will correctly be recognized
and formatted as function declarations. Tests will be added in a
follow-up patch actually using the correct recognition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194209 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2a80ad6fe7aa506b1df2bb638bc367d9e760f707 05-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Allow line merging and partial formatting of nested blocks

Before, clang-format would always format entire nested blocks, which
can be unwanted e.g. for long DEBUG({...}) statements. Also
clang-format would not allow to merge lines in nested blocks (e.g. to
put "if (a) return;" on one line in Google style).

This is the first step of several refactorings mostly focussing on the
additional functionality (by reusing the "format many lines" code to
format the children of a nested block). The next steps are:
* Pull out the line merging into its own class.
* Seperate the formatting of many lines from the formatting of a single
line (and the analysis of the solution space).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194090 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8437957c9da906c24d4e385869c05d8e601c664d 30-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix whitespaces in include directives.

Before (clang-format wouldn't change):
#include "a.h"
#include<a>

After:
#include "a.h"
#include <a>

This fixes llvm.org/PR16151.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193683 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d8ee5c1c8709c5fc060a48b598112f6eadb35d96 29-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Option to control spacing in template argument lists.

Same as SpacesInParentheses, this option allows adding a space inside
the '<' and '>' of a template parameter list.

Patch by Christopher Olsen.

This fixes llvm.org/PR17301.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193614 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
52af94453e30d2e9d0f4b6a208c8d4c3ff7c85a9 29-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix overloaded operator for global-scoped conversions.

Before:
operator::A();

After:
operator ::A();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193605 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8f54d881723ca7058807eee871913c812618bfda 26-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix ObjC method exprs with variadic parameters.

Before:
_versionLabel.text = [
NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]
];

After:
_versionLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]];

This fixed llvm.org/PR17695.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193475 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
47066e46b9ce4f830ead3c7b9a4cb5bf0ac2c857 25-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Adapt line break penalties for LLVM style.

Specifically make clang-format less eager to break after the opening
parenthesis of a function call.

Before:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Apparently that is preferable. This penalties are adapted
conservatively, we might have to increase them a little bit further.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193410 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3c6aea7ac63265c769b5fe09e213ab1c4cee111e 24-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Cleanup array initializer and dict initializer formatting.

Significant changes:
- Also recognize these literals with missing "@" for robustness.
- Reorganize tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193325 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
a07aa665a12ab23bef7aa4aedfe113dd8b13da57 22-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of ObjC array literals.

Before:
NSArray *arguments =
@[ kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets", @"--productid", @"com.google.Chrome" ];
After:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];

This fixes llvm.org/PR15231.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193167 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
363193b1bd4d9e0f07d361113157b9d4f229f212 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Better understand Lambda poarameters.

Before:
auto PointerBinding = [](const char * S) {};

After:
auto PointerBinding = [](const char *S) {};

This fixes llvm.org/PR17618.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b3c887dcb70220eced72935725cd94d7e8325912 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Support case ranges.

Before (note the missing space before "..." which can lead to compile
errors):
switch (x) {
case 'A'... 'Z':
case 1... 5:
break;
}

After:
switch (x) {
case 'A' ... 'Z':
case 1 ... 5:
break;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193050 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
53eb05ac6a00b95baf5680d9378ae8819dd09471 18-Oct-2013 Daniel Jasper <djasper@google.com> Make clang-format slightly more willing to break before trailing annotations.

Specifically, prefer breaking before trailing annotations over breaking
before the first parameter.

Before:
void ffffffffffffffffffffffff(
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;

After:
void ffffffffffffffffffffffff(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192983 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
78a4e619e775b0dbaa10c9feaea0adf1d3dfe507 12-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: No space in "<::" in C++11 mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192524 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b18c258390f794d8803ef5ebbb56fb77bfea7ba4 11-Oct-2013 Alexander Kornienko <alexfh@google.com> Don't break string literals inside preprocessor directives.

Summary:
This way we avoid breaking code which uses unknown preprocessor
directives with long string literals. The specific use case in
http://llvm.org/PR17035 isn't very common, but it seems to be a good idea to
avoid this kind of problem anyway.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1813

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192507 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ae76f7f850a9101a20191b10241ca72c23dc40dd 11-Oct-2013 Manuel Klimek <klimek@google.com> Support formatting of preprocessor branches.

We now correctly format:
void SomeFunction(int param1,
#ifdef X
NoTemplate param2,
#else
template <
#ifdef A
MyType<Some> >
#else
Type1, Type2>
#endif
param2,
#endif
param3) {
f();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192503 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1d82b1a33bcfe85f4834fb6920517ed07e9355d3 11-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Don't remove 'unknown' tokens.

In certain macros or incorrect string literals, the token stream can
contain 'unknown' tokens, e.g. a single backslash or a set of empty
ticks. clang-format simply treated them as whitespace and removed them
prior to this patch.

This fixes llvm.org/PR17215

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192490 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
01fe9f9f320dd4342664376f24eb1a0d004d03c8 10-Oct-2013 Alexander Kornienko <alexfh@google.com> Correctly detect colon in bit fields. Fixes PR17333.

Summary: Colon was incorrectly detected as a start of inheritance list. Fixed.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1884

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192349 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
cea014bd8d280070caeb27e4e6e33e5723b4226f 08-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve indentation when deriving from templated classes.

Before:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa<
aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa> {};

After:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa
: public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa> {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192187 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
19ccb1227f5dc338d4b2d9dbbaeaa973c293f8d0 08-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve constructor initializer linewrapping.

Specifically make ConstructorInitializerAllOnOneLineOrOnePerLine work
nicely with BreakConstructorInitializersBeforeComma.

This fixes llvm.org/PR17395.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192168 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f78bf4a0132a3ea366ba3baadd9d6af26c617d11 30-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve alignment after 'return'.

Previously, comments, could totally confuse it.

Before:
return
// true if code is one of a or b.
code == a ||
code == b;

After:
return
// true if code is one of a or b.
code == a || code == b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191654 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
20376989402fb187c0bc48209f46560b9e402ea2 29-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix assertion on incomplete string literals.

Before, this could would lead to an assert:
llvm::errs() << "
<< a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191639 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6b3ff8c4caaa6782289a780e096fe56ad6434bb7 27-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of functions with multiple trailing tokens.

Before:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override
final;

After:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191494 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9b4de85e2f47a01974f451d21fed0276ff912e32 25-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Option to removing the space before assignment operators.

Patch contributed by Aaron Wishnick. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
65da8e952da32730202356290bb889c8839bbef5 21-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve address-of-operator detection

Before:
size = sizeof * a;

After:
size = sizeof *a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191139 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ebaa1719fdd180e6dd9b4e6471e83500471a2f16 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Don't accidentally move tokens into preprocessor directive.

This fixes llvm.org/PR17265.

Before:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif {
}

After:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif
{
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e63a48a21cb3416edc6bc75d4d24f3bcf23532d4 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix line breaking bug after empty ifs.

Before:
if () {
}
else {
}

After:
if () {
} else {
}

This fixed llvm.org/PR17262.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190855 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
26356ccf00f813cf358d420b55939fc737eb2cfa 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Don't split a >>-operator.

Before (with column limit 60):
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
> aaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);

(Not sure how that could have stayed in that long without being
detected..)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190854 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d3d9e0f4a107e97b493e1d4c7c5b5dc15e7e137a 14-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in style option AlwaysBreakTemplateDeclarations.

Before:
template <template <typename>
class Fooooooo, template <typename>
class Baaaaaaar>
struct C {};

After:
template <template <typename> class Fooooooo,
template <typename> class Baaaaaaar>
struct C {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190747 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5798120bc015360951d13a06e17501b909ecd21d 13-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix incorrect enum parsing / layouting.

Before:
enum {
Bar = Foo < int,
int > ::value
};

After:
enum {
Bar = Foo<int, int>::value
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190674 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
7e27400c90e9e295bcf5857eebf2d60c4b32106e 11-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in pointer detection

Before:
for (int i = 0; i* 2 < z; i *= 2) {}
After:
for (int i = 0; i * 2 < z; i *= 2) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190546 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
daa07e9ee76d438efa3c7e2c54b4d3d3ed19ea27 10-Sep-2013 Alexander Kornienko <alexfh@google.com> Don't divide L and #x in macro definitions. Fixes http://llvm.org/PR17144

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1639

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190408 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
db8afe424991b34884afb13ecf97ac458e41da9e 10-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Understand function type typedefs with typeof.

Before:
typedef typeof(int(int, int)) * MyFunc;
After:
typedef typeof(int(int, int)) *MyFunc;

This fixes llvm.org/PR17178.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190401 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
83a7dcdf5fce1bdf74ce985419d77a41a51abfa2 10-Sep-2013 Alexander Kornienko <alexfh@google.com> Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.

Summary:
This fixes various issues with mixed tabs and spaces handling, e.g.
when realigning block comments.

Reviewers: klimek, djasper

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1608

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190395 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2f0a020d29286805e48b74b127fbf153af2c4ce7 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix regression introduced by r189353.

Before:
FirstToken->WhitespaceRange.getBegin()
.getLocWithOffset(First->LastNewlineOffset);

After:
FirstToken->WhitespaceRange.getBegin().getLocWithOffset(
First->LastNewlineOffset);

Re-add logic to prevent breaking after an empty set of parentheses.
Basically it seems that calling a function without parameters is more
like navigating along the same object than it is a separate step of a
builder-type call.

We might need to extends this in future to allow "short" parameters that
e.g. are an index accessing a specific element.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190126 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
db4813a3997fcf3864d1190f8021ef68e42cc057 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix regression introduced by r189337.

Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) ...

After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
== 5) ...

Also precompute startsBinaryExpression() to improve performance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190124 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b77d741691a2775b5c31e29f021203cc659c26df 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix comment formatting bugs in nested blocks.

This fixes two issues:
1) The indent of a line comment was not adapted to the subsequent
statement as it would be outside of a nested block.
2) A missing DryRun flag caused actualy breaks to be inserted in
overly long comments while trying to come up with the best line
breaking decisions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190123 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ac2c974bc64d3767ad5e39451a874c50b3004b3a 05-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix parsing and indenting lambdas.

Before:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}

After:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190039 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
567dcf95424d69657f75e4bfd028967ca1f9eb8d 05-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Enable formatting of nested blocks.

Among other things, this enables (better) formatting lambdas and
constructs like:
MACRO({
long_statement();
long_statement_2();
},
{
long_statement();
long_statement_2();
},
{ short_statement(); }, "");

This fixes llvm.org/PR15381.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190038 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
31e44f7a5d50ab8f7f623a7d2e18d5d877ef400d 04-Sep-2013 Manuel Klimek <klimek@google.com> Fix layout of lambda captures.

Before:
int c = [ &, &a, a]{
[ =, c, &d]{
return b++;
}();
}();

After:
int c = [&, &a, a] {
[=, c, &d] {
return b++;
}();
}();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189924 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4b762a91faac0473fa380ea9731992b24867e2e6 02-Sep-2013 Alexander Kornienko <alexfh@google.com> Store first and last newline position in the token text for string literals and comments.

Summary:
Store first and last newline position in the token text for string literals and
comments to avoid doing .find('\n') for each possible solution.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1556

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189758 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
174f60f005167984d00682d1d38a2927b9c04684 02-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix segfault in overloaded operator parsing.

Before, constructs like:
using A::operator+;

caused a segfault. This fixes llvm.org/PR17050.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189749 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ec17226e82979592c16c7815d2368240201d18fe 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Enable formatting of protocol buffer definitions.

Almost by accident, clang-format seems to be able to format protocol
buffer definitions (https://code.google.com/p/protobuf/).

The only change is that a space is required between numeric constants
and opening square brackets (for default values). While this might in
theory be used for array subscripts (int val = 4[MyArray]), I have not
seen this pattern in practice much. If this is wrong, we can make this
smarter in the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189663 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
dcc0c5bb7ce9a731ecbc0b8e8477979cd9e730c0 29-Aug-2013 Alexander Kornienko <alexfh@google.com> Better support for multiline string literals (including C++11 raw string literals).

Summary:
Calculate characters in the first and the last line correctly so that
we only break before the literal when needed.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1544

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189595 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
a4dd982805e89a37a080350bf8de9069135c5a60 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Don't insert space in __has_include

Before:
#if __has_include( <strstream>)
#include <strstream>
#endif

After:
#if __has_include(<strstream>)
#include <strstream>
#endif

This fixes llvm.org/PR16516.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189455 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c476ea976badd316e3afd0f34afe1f030a710117 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in overloaded operator definitions.

Before:
SomeLoooooooooooooooooooooooooogType operator>
>(const SomeLooooooooooooooooooooooooogType &other);
SomeLoooooooooooooooooooooooooogType // break
operator>>(const SomeLooooooooooooooooooooooooogType &other);

After:
SomeLoooooooooooooooooooooooooogType
operator>>(const SomeLooooooooooooooooooooooooogType &other);
SomeLoooooooooooooooooooooooooogType // break
operator>>(const SomeLooooooooooooooooooooooooogType &other);

This fixes llvm.org/PR16328.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189450 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
081fc17374baf55cc6a6069a9f5a1596fb378ef3 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix space in decltype-constexprs.

Before:
static constexpr bool Bar = decltype(bar()) ::value;

After:
static constexpr bool Bar = decltype(bar())::value;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189449 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d3fef0fe26da19685bdec6a1bd844505f604d593 27-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Format segments of builder-type calls one per line.

This fixes llvm.org/PR14818.

Before:
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:
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189353 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d489f8ceb735458b0e1f814e3f952b154f49c025 27-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Revamp builder-type call formatting.

Previously builder-type calls were only correctly recognized in
top-level calls.

This fixes llvm.org/PR16981.
Before:
someobj->Add((new util::filetools::Handler(dir))->OnEvent1(
NewPermanentCallback(this, &HandlerHolderClass::EventHandlerCBA))
->OnEvent2(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBB))
->OnEvent3(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBC))
->OnEvent5(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBD))
->OnEvent6(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBE)));

After:
someobj->Add((new util::filetools::Handler(dir))
->OnEvent1(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBA))
->OnEvent2(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBB))
->OnEvent3(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBC))
->OnEvent5(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBD))
->OnEvent6(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBE)));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189337 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3618e6fae8b734ad94221d941417c12d4bd1e3a8 23-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix indentation relative to unary expressions.

This should be done, only if we are still in the unary expression's
scope.

Before:
bool aaaa = !aaaaaaaa( // break
aaaaaaaaaaa);
*aaaaaa = aaaaaaa( // break
aaaaaaaaaaaaaaaa);

After:
bool aaaa = !aaaaaaaa( // break
aaaaaaaaaaa); // <- (unchanged)
*aaaaaa = aaaaaaa( // break
aaaaaaaaaaaaaaaa); // <- (no longer indented relative to "*")

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189108 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d4a03dbb0bdbd4908375306283cb61813bd8f454 22-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Add column layout formatting for braced lists

With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:

static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};

Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).

Review: http://llvm-reviews.chandlerc.com/D1457

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189018 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
34f3d05d0ee625dfcac951e2851f212c4c1a8b83 21-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Indent relative to unary operators.

Before:
if (!aaaaaaaaaa( // break
aaaaa)) {
}

After:
if (!aaaaaaaaaa( // break
aaaaa)) {
}

Also cleaned up formatting using clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188891 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
7df56bfcf7186f73c99564cd54216f07a8db7352 20-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Additional options for spaces around parentheses.

This patch adds four new options to control:
- Spaces after control keyworks (if(..) vs if (..))
- Spaces in empty parentheses (f( ) vs f())
- Spaces in c-style casts (( int )1.0 vs (int)1.0)
- Spaces in other parentheses (f(a) vs f( a ))

Patch by Joe Hermaszewski. Thank you for working on this!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
92495a8032d8624495a0ce769d5a6cdeba2dc8d8 19-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix return type line break decision.

This accidentally introduced by r186077, as function names were not
correctly recognized in templated declarations.

Before:
template <class TemplateIt>
SomeReturnType
SomeFunction(TemplateIt begin, TemplateIt end, TemplateIt* stop) {}

After:
template <class TemplateIt>
SomeReturnType SomeFunction(TemplateIt begin, TemplateIt end,
TemplateIt* stop) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188665 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b644dd68d3d7261ceb8823595290439dc65530b1 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve boolean expression formatting in macros.

Before:
#define IF(a, b, c) if (a&&(b == c))

After:
#define IF(a, b, c) if (a && (b == c))

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188256 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e60084d1e8a62716b80872f10e9828fbbb3cadfc 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Slightly adapt line break penalties.

Before:
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaa());
After:
aaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaaa());

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188253 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
53352600b7370b1d33b9fde1adda207fd9d7dcd1 12-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Correctly format alias declarations.

Before:
template <class CallbackClass>
using MyCallback = void(CallbackClass::*)(SomeObject * Data);");

After:
template <class CallbackClass>
using MyCallback = void (CallbackClass::*)(SomeObject *Data);");

Also fix three wrong indentations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188172 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2530fd5a235c1e57f8ebef2eae9b365042501009 12-Aug-2013 Manuel Klimek <klimek@google.com> This change fixes the formatting of statements such as catch (E& e).

Previously these were formatting as catch (E & e) because the inner parenthesis
was being marked as an expression.

Patch by Thomas Gibson-Robinson.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188153 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1dc6f745eb19c94527503012d798dc9b9b5ba6da 07-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in OpenMP pragma formatting.

Before:
#pragma omp reduction( | : var)
After:
#pragma omp reduction(| : var)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187892 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
efed68700e6352f50d120b246041054e76b0c6b9 07-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of builder-type calls.

This removes a formatting choice that was added at one point, but is
not generally liked by users. Specifically, in builder-type calls, do
(easily) break if the object before the ./-> is either a field or a
parameter-less function call. I.e., don't break after "aa.aa.aa" or
"aa.aa.aa()". In general, these sequences in builder-type calls are
seen as a single entity and thus breaking them up is a bad idea.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187865 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1eaa99779a254411600d77a715c761d9d84ec8bd 02-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Operator precendence in ObjC method exprs.

Patch (mostly) by Adam Strzelecki. Thanks!

Before:
[self aaaaaa:bbbbbbbbbbbbb
aaaaaaaaaa:bbbbbbbbbbbbbbbbb
aaaaa:bbbbbbbbbbb +
bbbbbbbbbbbb aaaa:bbb];

After:
[self aaaaaa:bbbbbbbbbbbbb
aaaaaaaaaa:bbbbbbbbbbbbbbbbb
aaaaa:bbbbbbbbbbb + bbbbbbbbbbbb
aaaa:bbb];

This fixes llvm.org/PR16150.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187631 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ab3ce592d027e3a10fb21e703cab1507f8d9bb03 02-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Don't break empty 2nd operand of ternary expr.

Before:
some_quite_long_variable_name_ptr
?
: argv[9] ? ptr : argv[8] ? : argv[7] ? ptr : argv[6];
After:
some_quite_long_variable_name_ptr
?: argv[9] ? ptr : argv[8] ?: argv[7] ? ptr : argv[6];

Patch by Adam Strzelecki, thank you!!

This fixed llvm.org/PR16758.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187622 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b7000ca629da16164f0073f5a7f9459ddf5ba281 01-Aug-2013 Daniel Jasper <djasper@google.com> Teach clang-format to understand static_asserts better.

Before:
template <bool B, bool C>
class A {
static_assert(B &&C, "Something is wrong");
};

After:
template <bool B, bool C>
class A {
static_assert(B && C, "Something is wrong");
};

(Note the spacing around '&&'). Also change the identifier table to always
understand all C++11 keywords (which seems like the right thing to do).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187589 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
aa9e7b18a88d715b63e7b65d1b26a1759decc177 01-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve line breaks in @property.

Before:
@property(nonatomic, assign,
readonly) NSString *looooooooooooooooooooooooooooongName;

After:
@property(nonatomic, assign, readonly)
NSString *looooooooooooooooooooooooooooongName;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187577 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
0236dd09c040f2e6124654d620dde94a595c5ab0 31-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve detection of templates.

Before:
template <typename... Types>
typename enable_if < 0<sizeof...(Types)>::type Foo() {}
After:
template <typename... Types>
typename enable_if<0 < sizeof...(Types)>::type Foo() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187458 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e8b10d3d5b90efaf60ad89e96f6500f971ceec41 26-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Add two new style options to support WebKit style.

New options:
* Break before the commas of constructor initializers and align
the commas with the colon.
* Break before binary operators

Additionally, for styles without column limit, don't just accept
linebreaks done by the user, but instead remove 'invalid' (according
to the current style) linebreaks and add 'required' ones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187210 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5e2169f94fca20bbfda317c222b156751a431c13 18-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bad line break with pointers to members.

Before:
void f() {
(a->*
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(aaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
}

After:
void f() {
(a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
}

Also add missing test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186583 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e0fa4c55a4bc6d2bbe0d9d657287c037158d5357 17-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Add space in corner case.

Before:
SomeType s __attribute__((unused))(InitValue);
After:
SomeType s __attribute__((unused)) (InitValue);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
215c57ff4a75388913dc392d03d84ec8c4c3ee1e 17-Jul-2013 Daniel Jasper <djasper@google.com> Improve line breaking before multi-line strings.

The AlwaysBreakBeforeMultilineStrings rule does not really make sense
if it does not a column gain.

Before (in Google style):
f(
"aaaa"
"bbbb");

After:
f("aaaa"
"bbbb");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186515 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
10c26b2e974f97c75fc3aaa302ca750f422cbce1 16-Jul-2013 Alexander Kornienko <alexfh@google.com> Don't break line comments with escaped newlines.

Summary:
These can appear when comments contain command lines with quoted line
breaks. As the text (including escaped newlines and '//' from consecutive lines)
is a single line comment, we used to break it even when it didn't exceed column
limit. This is a temporary solution, in the future we may want to support this
case completely - at least adjust leading whitespace when changing indentation
of the first line.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1146

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186456 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
561211d35b5a2825fba6d0c017044f6896b204fd 16-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve handling of unterminated string literals.

Before, clang-format would simply eat these as they were recognized as
whitespace. With this patch, they are mostly left alone.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186454 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b5dc3f4f53981b681a565cdf1d49f18e817541ff 16-Jul-2013 Daniel Jasper <djasper@google.com> Revamp the formatting of C++11 braced init lists.

The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.

This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186433 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e7d3bff31e3ef4fea1e2a5a7cd5441b6b0752e3f 16-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve detection of function types.

This fixes an incorrect detection that led to a formatting error.
Before:
some_var = function (*some_pointer_var)[0];
After:
some_var = function(*some_pointer_var)[0];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186402 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
0c368787d9d1f92a3408b71b3f074a06edaa6bde 15-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve c-style cast detection.

Before:
#define x ((int) - 1)
#define p(q) ((int *) & q)
After:
#define x ((int)-1)
#define p(q) ((int *)&q)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186324 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9637dda705e39110bfff66742542a58dd2470ad2 15-Jul-2013 Daniel Jasper <djasper@google.com> Improvement of change r186320.

Fixed a test that by now passed for the wrong reason.

Before:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Also reformatted Format.cpp with the latest changes (1 formatting fix
and 1 layout change of a <<-chain).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186322 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3e12e87f98538c55c1eab79df79e5a00df6de8ec 15-Jul-2013 Daniel Jasper <djasper@google.com> Improve formatting of operator<< chains.

Before:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

After:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186320 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
011c35dabb4c8abcb7389d8fbc6316f8f23576ab 12-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Break before/between array subscript expressions.

clang-format used to treat array subscript expressions much like
function call (just replacing () with []). However, this is not really
appropriate especially for expressions with multiple subscripts.

Although it might seem counter-intuitive, the most consistent solution
seems to be to always (if necessary) break before a square bracket,
never after it. Also, multiple subscripts of the same expression should
be aligned if they are on subsequent lines.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

After:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186153 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
20a0f8cff96505abb65233a2eaf3af3cd8536cd2 11-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Break before trailing annotations.

(if they are not function-like).

Before:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;

After:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3262f4c10520cf11acea4cf590cfbf055924a41e 11-Jul-2013 Daniel Jasper <djasper@google.com> Improve detection of trailing return types.

Trailing return types can only occur in declaration contexts.

Before:
void f() { auto a = b -> c(); }

After:
void f() { auto a = b->c(); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186087 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c18cff311118fc6a30929468fc82b2b35cbd7fbf 11-Jul-2013 Daniel Jasper <djasper@google.com> Keep trailing annotations close to their argument.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa);

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GUARDED_BY(aaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186077 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c7bd68f9edcbca95e882d0ab18d09371f0bdb82c 10-Jul-2013 Daniel Jasper <djasper@google.com> Add experimental flag for adaptive parameter bin-packing.

This is not activated for any style, might change or go away
completely.

For those that want to play around with it, set
ExperimentalAutoDetectBinPacking to true.

clang-format will then:
Look at whether function calls/declarations/definitions are currently
formatted with one parameter per line (on a case-by-case basis). If so,
clang-format will avoid bin-packing the parameters. If all parameters
are on one line (thus that line is "inconclusive"), clang-format will
make the choice dependent on whether there are other bin-packed
calls/declarations in the same file.

The reason for this change is that bin-packing in some situations can be
really bad and an author might opt to put one parameter on each line. If
the author does that, he might want clang-format not to mess with that.
If the author is unhappy with the one-per-line formatting, clang-format
can easily be convinced to bin-pack by putting any two parameters on the
same line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186003 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2ca3741a962ded08866596577aaee2f4ab74c955 09-Jul-2013 Daniel Jasper <djasper@google.com> Initial support for formatting trailing return types.

This fixes llvm.org/PR15170.

For now, the basic formatting rules are (based on the C++11 standard):
* Surround the "->" with spaces.
* Break before "->".

Also fix typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185938 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6561f6a13b79ed752748ede590792191edf78ce8 09-Jul-2013 Daniel Jasper <djasper@google.com> Format overloaded operators like other functions.

This fixes llvm.org/PR16328 (at least partially).

Before:
SomeLoooooooooooooooooooooooooooooogType operator<<(
const SomeLooooooooogType &a, const SomeLooooooooogType &b);

After:
SomeLoooooooooooooooooooooooooooooogType
operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185908 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
526df0f3a8d436e9084bd12118a2e119aa0bd724 08-Jul-2013 Daniel Jasper <djasper@google.com> Fix incorrect incorrect cast identification in clang-format.

This fixes llvm.org/PR16534.

Before:
aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION;
After:
aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185828 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2a409b62126d8f0b8f5749d5ed435ad2b394b526 08-Jul-2013 Daniel Jasper <djasper@google.com> Reformat clang-format's source files after r185822 and others.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185823 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d6104f6c34639ebe66f83d955c5f32ea4a50c266 05-Jul-2013 Daniel Jasper <djasper@google.com> Fix formatting for allocation of new pointer variables.

Before:
T **t = new T * ;
T **q = new T * ();

After:
T **t = new T *;
T **q = new T *();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185699 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
198c8bfee0b33ab0ed0c54224f460868f1c18e95 05-Jul-2013 Daniel Jasper <djasper@google.com> Don't break after a "(" following a binary operator.

Additionally, allow breaking after c-style casts, but with a high
penalty.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (
aaaaaaaaaaaaaaaaa *)bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (aaaaaaaaaaaaaaaaa *)
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

This fixes llvm.org/PR16049.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185685 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
0bdc6434fa0fea933b6ab566eff751afdba40a2a 04-Jul-2013 Alexander Kornienko <alexfh@google.com> Fixed typo: NoneComment -> NonComment, no other changes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185640 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
56312023bf62cb40d2e33ea5e14d55c1e42303a7 04-Jul-2013 Alexander Kornienko <alexfh@google.com> Added AlwaysBreakBeforeMultilineStrings option.

Summary:
Always breaking before multiline strings can help format complex
expressions containing multiline strings more consistently, and avoid consuming
too much horizontal space.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1097

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185622 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6ac431c7bae27a42351d2c2ad03dddd5b005ffd5 02-Jul-2013 Daniel Jasper <djasper@google.com> Fix formatting of long declarations with const type.

Before (exceeding the column limit):
LoooooooooooooooooooooooooooooooooooooooongType const LoooooooooooooooooooooooooooooooooooooooongVariable;

After:
LoooooooooooooooooooooooooooooooooooooooongType const
LoooooooooooooooooooooooooooooooooooooooongVariable;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185418 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c47d7f1237b022eabbbdcebf77506e8a81aa54bd 01-Jul-2013 Daniel Jasper <djasper@google.com> Don't add an extra space before ellipsis after pointers.

Before (for styles where the pointer binds to the type):
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts* ... ts) {}
After:
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts*... ts) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185321 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3a1847e0a1810a0b1b963182abc59114cc5ff53d 01-Jul-2013 Daniel Jasper <djasper@google.com> Keep space between pointer and block comment.

Before: void f(int */* unused */) {}
After: void f(int * /* unused */) {}

The previous version seems to be valid C++ code but confuses many syntax
highlighters.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185320 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
14e66498781b7d81639bdc48716e09700552ac21 01-Jul-2013 Craig Topper <craig.topper@gmail.com> Put helper classes in an anonymous namespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185301 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2726877196b41b922f10f794801b313980e1a8ad 26-Jun-2013 Nico Weber <nicolasweber@gmx.de> Run clang-format on lib/Format code after r184894. No other changes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184896 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
861576b8019392f15c803ac14a4bc31fbd93aab2 26-Jun-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Don't put a space after parameter-naming block comments.

Before: f(a, b, /*doFoo=*/ false);
Now: f(a, b, /*doFoo=*/false);

This style is a lot more common:
$ ack -H '=\*\/\w' lib | wc -l
1281
$ ack -H '=\*\/ \w' lib | wc -l
70



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184894 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
465e8615a153ebd70eb27785af79f7e82e4a81d4 25-Jun-2013 Nico Weber <nicolasweber@gmx.de> Formatter/ObjC: Correctly format casts in objc message send expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184804 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d71b15badeecdc049440103ef044f9cdf5e1359c 17-Jun-2013 Alexander Kornienko <alexfh@google.com> Fix a problem in ExpressionParser leading to trailing comments affecting indentation of an expression after a line break.

Summary:
E.g. the second line in

return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b; //

is indented 4 characters more than in

return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b;

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D984

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184078 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e3f1197cad5cda243093e8b39caa43f13111de89 12-Jun-2013 Alexander Kornienko <alexfh@google.com> Preserve newlines before block comments in static initializers.

Summary:
Basically, don't special-case line comments in this regard. And fixed
an incorrect test, that relied on the wrong behavior.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D962

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183851 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2785b9aabcb2c3fd6f7dd8b63d3cd3d4b9bca284 07-Jun-2013 Alexander Kornienko <alexfh@google.com> Fixed calculation of penalty when breaking tokens.

Summary:
Introduced two new style parameters: PenaltyBreakComment and
PenaltyBreakString. Add penalty for each character of a breakable token beyond
the column limit (this relates mainly to comments, as they are broken only on
whitespace). Tuned PenaltyBreakComment to prefer comment breaking over breaking
inside most binary expressions.
Fixed a bug that prevented *, & and && from being considered TT_BinaryOperator
in the presense of adjacent comments.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D933

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183530 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
65d2c3829494d254039683c73f95843c29c661b4 06-Jun-2013 Daniel Jasper <djasper@google.com> Fix incorrect line breaking before trailing block comments.

Before, clang-format would happily move a trailing block comment to a
new line, which normally changes the perceived binding of that comment.

E.g., it would move:
void f() { /* comment */
...
}
to:
void f() {
/* comment */
...
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183420 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9acb8b4355028887e8cc4aa8f683aceee021a62b 06-Jun-2013 Daniel Jasper <djasper@google.com> Fix clang-format's expression parser for leading }s.

The leading "}" in the construct "} else if (..) {" was confusing the
expression parser. Thus, no fake parentheses were generated and the
indentation was broken in some cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183393 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ff1a2e519ebcd6d7a060eac7ba8aca37b2bf89d0 06-Jun-2013 Daniel Jasper <djasper@google.com> Improve c-style cast detection.

Before:
return (my_int) aaaa;
template <> void f<int>(int i)SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa)"aaaa");

After:
return (my_int)aaaa;
template <> void f<int>(int i) SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa) "aaaa");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183389 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
00895106f9ed602af67984ec4d225a0cdc8c12af 05-Jun-2013 Alexander Kornienko <alexfh@google.com> UTF-8 support for clang-format.

Summary:
Detect if the file is valid UTF-8, and if this is the case, count code
points instead of just using number of bytes in all (hopefully) places, where
number of columns is needed. In particular, use the new
FormatToken.CodePointCount instead of TokenLength where appropriate.
Changed BreakableToken implementations to respect utf-8 character boundaries
when in utf-8 mode.

Reviewers: klimek, djasper

Reviewed By: djasper

CC: cfe-commits, rsmith, gribozavr

Differential Revision: http://llvm-reviews.chandlerc.com/D918

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183312 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
15f33f03e742fb6567e4789996fa0391a8e18068 03-Jun-2013 Daniel Jasper <djasper@google.com> Let clang-format remove empty lines before "}".

These lines almost never aid readability.

Before:
void f() {
int i; // some variable

}

After:
void f() {
int i; // some variable
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183112 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
0348be0c78781c5ddb8c271976812705410c731a 01-Jun-2013 Daniel Jasper <djasper@google.com> Improve recognition of template parameters.

Before: return a<b &&c> d;
After: return a < b && c > d;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183077 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b8b4295b4ee161bfb76ff7b0ec1007bfd959553b 31-May-2013 Daniel Jasper <djasper@google.com> Improve clang-format's c-style cast detection.

Before:
x[(uint8) y];
x = (uint8) y;
void f() { x = (uint8) y; }
#define AA(X) sizeof(((X *) NULL)->a)

After:
x[(uint8)y];
x = (uint8)y;
void f() { x = (uint8)y; }
#define AA(X) sizeof(((X *)NULL)->a)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183014 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c01897c3f6139304ed25e3f673bef77be209617f 31-May-2013 Daniel Jasper <djasper@google.com> Properly format nested conditional operators.

Before:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;

After:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183007 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b398701e4cbb9a55d90a60e3f4f4bc577446d098 29-May-2013 Manuel Klimek <klimek@google.com> The second step in the token refactoring.

Gets rid of AnnotatedToken, putting everything into FormatToken.
FormatTokens are created once, and only referenced by pointer. This
enables multiple future features, like having tokens shared between
multiple UnwrappedLines (while there's still work to do to fully enable
that).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
bbc8776493fc0176d925a5b528e61ee400895047 29-May-2013 Daniel Jasper <djasper@google.com> Add option to always break template declarations.

With option enabled (e.g. in Google-style):
template <typename T>
void f() {}

With option disabled:
template <typename T> void f() {}

Enabling this for Google-style and Chromium-style, not sure which other
styles would prefer that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182849 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3ff4a2fea4aa6e5182b7799ccb4352e56961a212 28-May-2013 Daniel Jasper <djasper@google.com> Fix formatting regression regarding pointers to arrays.

Before: f( (*PointerToArray)[10]);
After: f((*PointerToArray)[10]);

This fixes llvm.org/PR16163

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182777 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
dcb3f2aab329c80e97a44312d15299df4dc059be 28-May-2013 Manuel Klimek <klimek@google.com> Make UnwrappedLines and AnnotatedToken contain pointers to FormatToken.

The FormatToken is now not copyable any more.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182772 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5ad390d27f8f7cb6628bc2c32beba4d25bc2718b 28-May-2013 Daniel Jasper <djasper@google.com> Initial support for designated initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182767 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
431f5918281dd1f178bf838b7a47ab1d11c52961 28-May-2013 Daniel Jasper <djasper@google.com> Clean up formatting of function types.

Before:
int (*func)(void*);
void f() { int(*func)(void*); }

After (consistent space after "int"):
int (*func)(void*);
void f() { int (*func)(void*); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182756 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
131884a4bd9b72f8ced8c9f6d2b284f40fde1ea5 27-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of templates.

Before: A < int&& > a;
After: A<int &&> a;

Also remove obsolete FIXMEs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182741 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f2ff8126e9e9df368f31b1f968d8fc80f99809b3 26-May-2013 Nico Weber <nicolasweber@gmx.de> Formatter/ObjC: In dictionary literals, break after ':', not before it.

Before:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
: regularFont, };

Now:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
regularFont, };

':'s in dictionary literals (and the corresponding {}s) are now marked as
TT_ObjCDictLiteral too, which makes further improvements to dict literal
layout possible.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182716 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ce93356e2719d2992763ea747b65beada99f4c9b 23-May-2013 Daniel Jasper <djasper@google.com> More tests and a fix for braced init lists.

Before: f(new vector<int> { 1, 2, 3 });
After: f(new vector<int>{ 1, 2, 3 });

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182614 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1bee0738b67b784f08d5e2f8351920260c9cfb1d 23-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of braced lists.

Before: vector<int> v{ -1};
After: vector<int> v{-1};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182597 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2424eefa6936ec2dc35188e19c99e2f85428b52e 23-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of braced lists.

Before:
vector<int> x { 1, 2, 3 };
After:
vector<int> x{ 1, 2, 3 };

Also add a style option to remove the spaces inside braced lists,
so that the above becomes:
std::vector<int> v{1, 2, 3};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182570 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e573c3f7fc40e813559ab4ff1e7eec4f66f1a50f 22-May-2013 Manuel Klimek <klimek@google.com> Makes whitespace management more consistent.

Instead of selectively storing some changes and directly generating
replacements for others, we now notify the WhitespaceManager of the
whitespace before every token (and optionally with more changes inside
tokens).

Then, we run over all whitespace in the very end in original source
order, where we have all information available to correctly align
comments and escaped newlines.

The future direction is to pull more of the comment alignment
implementation that is now in the BreakableToken into the
WhitespaceManager.

This fixes a bug when aligning comments or escaped newlines in unwrapped
lines that are handled out of order:
#define A \
f({ \
g(); \
});
... now gets correctly layouted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6e6efa7ec880559b7dd3096423b2345c0ff21c4c 22-May-2013 Daniel Jasper <djasper@google.com> Improve clang-format's stream formatting.

clang-format was a bit too aggressive when trying to keep labels and
values on the same line.

Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182458 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5ad72bb8eb8e5cc4c061ccd28632295213d319db 22-May-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing 'const'.

Reduce the preference for breaking before a trailing 'const' according
to review comments on r182362.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182455 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
54b4e4468ec2bcd381ede70e1391bcdb59b8fd1a 22-May-2013 Daniel Jasper <djasper@google.com> Cut-off clang-format analysis.

If clang-format is confronted with long and deeply nested lines (e.g.
complex static initializers or function calls), it can currently try too
hard to find the optimal solution and never finish. The reason is that
the memoization does not work effectively for deeply nested lines.

This patch removes an earlier workaround and instead opts for
accepting a non-optimal solution in rare cases. However, it only does
so only in cases where it would have to analyze an excessive number of
states (currently set to 10000 - the most complex line in Format.cpp
requires ~800 states) so this should not change the behavior in a
relevant way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182449 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e033e87cbe77341777100093f8066167888d4440 21-May-2013 Daniel Jasper <djasper@google.com> Allow breaking before a trailing const.

Before:
void someLongFunction(
int someLongParameter) const;

After:
void someLongFunction(int someLongParameter)
const;

Also slightly cleanup tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182362 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5d823e3a00a3e21a0823288e6dee26a93758332b 15-May-2013 Daniel Jasper <djasper@google.com> Improve recognition of template definitions.

In the long run, this will probably be better fixed by a proper
expression parser..

Before:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c < is_base_of<F, T>::value &&
!is_same<F, T>::value > ::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}

After:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c<is_base_of<F, T>::value &&
!is_same<F, T>::value>::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181884 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
a8fda85af8ddc91366b5522aee3a78a1fed206f7 15-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types.

The function type detection in r181438 and r181764 detected function
types too eagerly. This led to inconsistent formatting of inline
assembly and (together with r181687) to an incorrect formatting of calls
in macros.

Before: #define DEREF_AND_CALL_F(parameter) f (*parameter)
After: #define DEREF_AND_CALL_F(parameter) f(*parameter)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181870 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
089f78d9cc1192244c9884e0e60dd82d415d8138 14-May-2013 Daniel Jasper <djasper@google.com> Fix uninitialized value bug found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181779 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
7424d79613a67ba200b6801468f2b59cde7ab087 14-May-2013 Daniel Jasper <djasper@google.com> Don't format sizeof/alignof as function types.

Before: A<sizeof (*x)> a;
After: A<sizeof(*x)> a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
378d93dcf7ec80661efc65642dc6266c9e13780a 13-May-2013 Daniel Jasper <djasper@google.com> Assume macros to contain declarations.

This seems to be the vastly more common case. If we find enough
examples to the contrary, we can make it smarter.

Before: #define MACRO void f(int * a)
After: #define MACRO void f(int *a)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181687 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6ea933c7e8f6988d5647af4a0eafd393a4c3685a 10-May-2013 Daniel Jasper <djasper@google.com> Fix bug when formatting overloaded operators.

Before, the actual operator of an overloaded operator declaration was
handled as a binary operator an thus, clang-format could not find valid
formattings for many examples, e.g.:

template <typename AAAAAAA, typename BBBBBBB>
AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181585 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4b7b104c2c66550ecc4ebfe39225fe067858b9aa 08-May-2013 Daniel Jasper <djasper@google.com> Further fix to pointer to member formatting.

With style where the *s go with the type:
Before: typedef bool* (Class:: *Member)() const;
After: typedef bool* (Class::*Member)() const;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
395228fdc343df39c2507e414dc1406a185c6d37 08-May-2013 Daniel Jasper <djasper@google.com> Fix formatting of pointers to members.

Before: int(S::*func)(void *);
After: int (S::*func)(void *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181438 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
11e13801d8a25cea011c2a154380c371b6ddaaf6 08-May-2013 Daniel Jasper <djasper@google.com> Improve line breaking in binary expressions.

If the LHS of a binary expression is broken, clang-format should also
break after the operator as otherwise:
- The RHS can be easy to miss
- It can look as if clang-format doesn't understand operator precedence

Before:
bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !=
bbbbbbbbbbbbbbbbbb && ccccccccc == ddddddddddd;
After:
bool aaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb &&
ccccccccc == ddddddddddd;

As an additional note, clang-format would also be ok with the following
formatting, it just has a higher penalty (IMO correctly so).
bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !=
bbbbbbbbbbbbbbbbbb &&
ccccccccc == ddddddddddd;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181430 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
dbef71ebc66fe5553db01eb8e95b696c3223e737 07-May-2013 Daniel Jasper <djasper@google.com> Correctly recognize dereference after 'delete'.

With certain styles:
Before: delete* x;
After: delete *x;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
53e72cdcc0bc217cab33fa56858a0fe5b94ca453 06-May-2013 Daniel Jasper <djasper@google.com> Change indentation when breaking after a type.

clang-format did not indent any declarations/definitions when breaking
after the type. With this change, it indents for all declarations but
does not indent for function definitions, i.e.:

Before:
const SomeLongTypeName&
some_long_variable_name;
typedef SomeLongTypeName
SomeLongTypeAlias;
const SomeLongReturnType*
SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

After:
const SomeLongTypeName&
some_long_variable_name;
typedef SomeLongTypeName
SomeLongTypeAlias;
const SomeLongReturnType*
SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

While it might seem inconsistent to indent function declarations, but
not definitions, there are two reasons for that:
- Function declarations are very similar to declarations of function
type variables, so there is another side to consistency to consider.
- There can be many function declarations on subsequent lines and not
indenting can make them harder to identify. Function definitions
are already separated by their body and not indenting
makes the function name slighly easier to find.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181187 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c194c95036b7bf1281a6f2ed683f7c85ee5d2c20 06-May-2013 Daniel Jasper <djasper@google.com> Break the class-inheritance ":" to the new line.

This seems to be more common in LLVM, Google and Chromium.

Before:
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :
public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {
};

After:
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
: public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181183 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f022018698ced7e538b338d4f7befef9f81051ea 06-May-2013 Daniel Jasper <djasper@google.com> Don't put a space before ellipsis.

Before: template <class ... Ts> void Foo(Ts ... ts) { Foo(ts ...); }
After: template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181182 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
454cb70f9470dc37d0c0646012877d64fb1e73d7 03-May-2013 Daniel Jasper <djasper@google.com> Add space between ; and (.

Before: for (int i = 0;(i < 10); ++i) {}
After: for (int i = 0; (i < 10); ++i) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181020 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
16a69ef481f4580c571b6c693a5d3dd64ea56b53 03-May-2013 Daniel Jasper <djasper@google.com> Fix expression recognition in for-loops.

Before: for (; a&& b;) {}
After: for (; a && b;) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181017 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
fca24bc45192c254ca92ef1d7cef71a290392f31 25-Apr-2013 Daniel Jasper <djasper@google.com> Improve clang-format's memoization behavior.

Deeply nested expressions basically break clang-format's memoization.
This patch slightly improves the situations and makes expressions like

aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa())))))))))))))))))))))))))))))))))))))));

work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180264 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
aae7bad5cdd804cb88e918e9defbf5faf69f4cfd 23-Apr-2013 Daniel Jasper <djasper@google.com> Fix formatting of complex #if expressions.

Before:
#if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC || \
defined DDDDDDDD) && defined(BBBBBBBB)

After:
#if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC || defined DDDDDDDD) && \
defined(BBBBBBBB)

This fixes llvm.org/PR15828.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180105 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1407bee187d7b964d5293ac8bf4f7a490c78cec6 11-Apr-2013 Daniel Jasper <djasper@google.com> Change clang-format's affinity for breaking after return types.

Function declarations are now broken with the following preferences:
1) break amongst arguments.
2) break after return type.
3) break after (.
4) break before after nested name specifiers.

Options #2 or #3 are preferred over #1 only if a substantial number of
lines can be saved by that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179287 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2eb23b73f001e475c604652732f1a156f252352d 11-Apr-2013 Daniel Jasper <djasper@google.com> Fix formatting of overloaded assignment operators.

Before: SomeType &operator=(const SomeType & S);
After: SomeType &operator=(const SomeType &S);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179270 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ac3223e45e7d17c65b143439313800eef4fdf71d 10-Apr-2013 Daniel Jasper <djasper@google.com> Fix labels with trailing comments and cleanup.

Before:
class A {
public : // test
};

After:
class A {
public: // test
};

Also remove duplicate methods calculating properties of AnnotatedTokens
and make them members of AnnotatedTokens so that they are in a common
place.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179167 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
bf71ba2988b34c45af968f0965e28ac952e4a15f 08-Apr-2013 Daniel Jasper <djasper@google.com> Revamp indentation behavior for complex binary expressions.

The idea is to indent according to operator precedence and pretty much
identical to how stuff would be indented with parenthesis.

Before:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;

After:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179049 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
65622aae92ff6e338abed83d31e512ee0e013dc7 08-Apr-2013 Daniel Jasper <djasper@google.com> Revert accidental commit r179015.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179016 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c4ff76913ada469a70ed4bd960aeff038b6c2e1b 08-Apr-2013 Daniel Jasper <djasper@google.com> x

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179015 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6b119d63f5036344acd4e00a6ff2b3c72f26966f 05-Apr-2013 Daniel Jasper <djasper@google.com> Allow breaking after 'class' for classes with looong names.

(Don't ask, this was a user request).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178888 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
27b91cc046f580fbe825f15b3e27f1b6407ee3e3 05-Apr-2013 Daniel Jasper <djasper@google.com> Fix bad formatting of overloaded operator definitions.

Before:
bool operator<
(const aaaaaaaaaaaaaaaaaaaaa &left, const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}

After:
bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,
const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178887 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8ed9f2b25f082a1643ab5310f9eec33cf31a7577 03-Apr-2013 Daniel Jasper <djasper@google.com> Improve formatting of for loops and multi-variable DeclStmts.

This combines several related changes:
a) Don't break before after the variable types in for loops with a
single variable.
b) Better indent DeclStmts defining multiple variables.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaa = aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa =
aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178641 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
81d2d38d2d774a2550fa0d2efffa707e7a53b39c 01-Apr-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types.

Before: void * (*a)(int *, SomeType *);
After: void *(*a)(int *, SomeType *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178474 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
627707b9360597b65a9a0953d0ead2a08c3a0d5d 22-Mar-2013 Daniel Jasper <djasper@google.com> Better fix for r177725.

It turns out that

-foo;

can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177740 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b5985420d5910e068b0c8b84b8af2223e6bdf130 22-Mar-2013 Daniel Jasper <djasper@google.com> More precisely recognize ObjC method declarations.

Otherwise, +/- and the beginning of constants can be recognized
incorrectly.

Before: #define A - 1
After: #define A -1

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177725 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
54a38bd5cf243310290f34b43fc940a498a00f90 20-Mar-2013 Alexander Kornienko <alexfh@google.com> Support for pointers-to-members usage via .*

Summary: Added support for pointers-to-members usage via .* and a few tests.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D556

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
64f092865c01c72ecb9e380432e241f3af55c249 20-Mar-2013 Daniel Jasper <djasper@google.com> Reduce penalty for breaks after "(" for functions with parameters.

Before:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177521 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f9955d309d3de328e65563baf2d34571249dccbb 20-Mar-2013 Daniel Jasper <djasper@google.com> Add extra indentation for multiline comparisons.

This seems to be generally more desired.

Before:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}
After:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}

Also: Some formatting cleanup on clang-format's files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177514 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9322aaee900b872c98f8fc10b38a231cb1e9b57a 20-Mar-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types in template parameters.

Before: A<int * (int)>;
After: A<int *(int)>;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177505 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
cf6d76af806f7e1ba97be7b72b31bc78b919e0f0 18-Mar-2013 Daniel Jasper <djasper@google.com> Fix clang-format segfault.

When annotating "lines" starting with ":", clang-format would segfault.
This could actually happen in valid code, e.g.
#define A :

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177283 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
bfa1edd8247b80e951a570ff2486fe5fa9898c41 14-Mar-2013 Daniel Jasper <djasper@google.com> Slightly improve formatting of longer pipe statements.

The stronger binding of a string ending in :/= does not really make
sense if it is the only character.

Before:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa
<< "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

After:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "="
<< bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177075 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
923ebef120a37122ce50722a85cbe42c0c2dab53 14-Mar-2013 Daniel Jasper <djasper@google.com> Basic support for formatting asm() statments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177073 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d3cf17b5f1fed43dbd0cd35c43d15139803c9c84 14-Mar-2013 Daniel Jasper <djasper@google.com> Fix dereference formatting in for-loops.

Before: for (char **a = b; * a; ++a) {}
After: for (char **a = b; *a; ++a) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177037 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8ef19a22956defa392df46c79e2d499ab7b16647 14-Mar-2013 Daniel Jasper <djasper@google.com> Improve formatting of trailing annotations.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((
unused));

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
__attribute__((unused));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177034 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6a365aaa057a8c445d25344c0433726c752b3e7d 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix incorrect cast identification.

Before: int a = sizeof(int *)+ b;"
After: int a = sizeof(int *) + b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176957 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8d0d19aa33751d89390e6a2bb2c2b19def287abe 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix formatting issue with builder-type calls.

Before:
->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() - aaaaaaaaa()->aaaaaa()
->aaaaa());

After:
a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() -
aaaaaaaaa()->aaaaaa()->aaaaa());

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176952 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e74de28ec3692986f3467a7f160a0e293277fa7e 13-Mar-2013 Alexander Kornienko <alexfh@google.com> Added AnnotatedToken::isOneOf + a few other refactorings

Summary: <subj>

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D536

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176951 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6f21a988990ff5872822dcb049bd8fc65ce3d236 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 cleanups with clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176936 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3fd9ccdd9f8d259bcf518e7056cfd419d992e984 12-Mar-2013 Alexander Kornienko <alexfh@google.com> Implemented formatting of rvalue references

Summary:
Handle "&&" usage as rvalue reference, added tests and fixed incorrect
tests that interfere with this feature.

http://llvm.org/bugs/show_bug.cgi?id=15051

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D531

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176874 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4ba9bfd89d0ceb4eae161a4a21dd8e50be752754 12-Mar-2013 Daniel Jasper <djasper@google.com> Remove bad space after "default".

Before:
switch (x) {
default : {}
}

After:
switch (x) {
default: {}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8a5d7cd100ebfb8c6b353ee4ad5b14ab4105d32d 01-Mar-2013 Daniel Jasper <djasper@google.com> Correctly format arrays of pointers and function types.

Before:
void f(Type(*parameter)[10]) {}
int(*func)(void *);

After:
void f(Type (*parameter)[10]) {}
int (*func)(void *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176356 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
248497199bc56e86d1c089beb9529f3b3d77abb1 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 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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176352 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
25e81b255cea00fe633f2822c1d1d708ef871a59 28-Feb-2013 Daniel Jasper <djasper@google.com> Reduce penalty for splitting after "{" in static initializers.

This fixes llvm.org/PR15379.

Before:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = { 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};

After:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176262 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8ed4100410ea055a03be5ec4a92a947a0ee664cd 28-Feb-2013 Daniel Jasper <djasper@google.com> Dont break between (( in __attribute__((.

Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
(aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));

After:
void aaaaaaaaaaaaaaaaaa()
__attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176260 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9c3c7b3130bc72b3f50703c11b85152b1264fc90 28-Feb-2013 Daniel Jasper <djasper@google.com> No spaces around pointers to members.

Before: (a ->* f)()
After: (a->*f)()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176252 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
807809c421811509f488f3ebd249585025ad918a 28-Feb-2013 Daniel Jasper <djasper@google.com> Fix spacing after binary operator as macro parameter.

Before: COMPARE(a, == , b);
After: COMPARE(a, ==, b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176241 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9c65b069821b7de79427e291b006293a0f55ff8f 27-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting of multiplications in array subscripts.

Before:
a[a* a] = 1;

After:
a[a * a] = 1;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176180 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
518ee34467c0722e253a58efea20456e96aa5802 26-Feb-2013 Daniel Jasper <djasper@google.com> Fix bad line break decision.

Before:
if (Intervals[i].getRange().getFirst() < Intervals[i - 1]
.getRange().getLast()) {}

After:
if (Intervals[i].getRange().getFirst() <
Intervals[i - 1].getRange().getLast()) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176092 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
84a1a63b034744b68a27ec171dca5b1b7cf303f0 26-Feb-2013 Daniel Jasper <djasper@google.com> In range-based for-loops, prefer splitting after ":".

Before:
for (const aaaaaaaaaaaaaaaaaaaaa &
aaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

After:
for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa :
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176087 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1ef81d57fbcc26080c98e140e7c82db6d2aeba87 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 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 };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176086 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3c08a818a6ac9115fe8880af9bbf5a0a87bdffaa 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
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) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175999 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
237d4c1c785be13656bff6c09e5b7ccd066ff5ba 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:

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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175973 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
37eff83413a064c504c5a42097e4f5dd0b2962d2 23-Feb-2013 Daniel Jasper <djasper@google.com> Don't recognize unnamed pointer parameters as casts.

This fixes llvm.org/PR15061.

Before: virtual void f(int *)const;
After: virtual void f(int *) const;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175960 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
3a204418482c9ae70ad482e781132c54306c3aa6 23-Feb-2013 Daniel Jasper <djasper@google.com> Allow splitting between string literals and identifiers.

Also don't break in long include directives as that is not desired.

We can now format:

#include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
#define LL_FORMAT "ll"
printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT
"d, ddddddddd: %" LL_FORMAT "d\n");

Before, this led to weird results.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175959 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
1c1303b1fa988ffae7e269fbdbd5a50e4ba860a0 21-Feb-2013 Daniel Jasper <djasper@google.com> Remove accidentally introduced no-op line.

Was used during experiments, but another if-statements a few lines
before makes it (intentionally) useless.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175803 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f11a705c6075b12cbae5632ba4de433bc9bc105f 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) {
}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175800 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
7d81281fc39f6d40d86be6600adba13c05b4a639 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 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));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175741 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c4615b7aaf97e303a4fc675956f7f5572d492885 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
MaxEmptyLinesToKeep.

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

// Second value
b
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175620 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
03628b86a9c50e066412fb0e49908686ff117378 19-Feb-2013 Daniel Jasper <djasper@google.com> Add missing clang-format null pointer check..

.. and a test that triggers it in valid albeit questionable code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175554 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
34511fb79201ba9ed39c97f3a7ea0f157a79436d 19-Feb-2013 Daniel Jasper <djasper@google.com> Correctly format macro with unfinished template declaration.

We can now format:
#define A template <typename T>

Before this created a segfault :-/.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175533 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
82282dc907a04b1931f8f578693b035ad751fd3b 18-Feb-2013 Daniel Jasper <djasper@google.com> Improve indentation of builder type calls.

In builder-type calls, it can be very confusing to just indent
parameters from the start of the line. Instead, indent 4 from the
correct function call.

Before:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();

After:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()
->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175444 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
515f65df40624a767bc8763a0b6b678146b8e3c9 18-Feb-2013 Daniel Jasper <djasper@google.com> Improve formatting of builder-type calls.

Before:
aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);

After:
aaaaaaa->aaaaaaa
->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaa(aaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175441 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
d0f349be1422a123fdb28d6dd556f7300e6d51e9 18-Feb-2013 Daniel Jasper <djasper@google.com> Correctly determine */& usage in more cases.

This fixes llvm.org/PR15248.

Before:
Test::Test(int b) : a(b *b) {}
for (int i = 0; i < a *a; ++i) {}

After:
Test::Test(int b) : a(b * b) {}
for (int i = 0; i < a * a; ++i) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6ba52aab96c96b6d91ed7f5844f607b32f7f41c4 16-Feb-2013 Dmitri Gribenko <gribozavr@gmail.com> Use the correct type to hold enumeration values


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175374 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4a544e5856ceadef1c095c7d1ae5c8d760851d59 15-Feb-2013 Daniel Jasper <djasper@google.com> Recognize < and > as binary expressions in builder-type calls.

The current heuristic assumes that there can't be binary operators in
builder-type calls (excluding assigments). However, it also excluded
< and > in general, which is wrong. Now they are only excluded if they
are template parameters.

Before:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa()i
.aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();

After:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <
aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175291 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
dc2efa1c10c4646d692cc57db9fdbbebe3a48255 15-Feb-2013 Daniel Jasper <djasper@google.com> Done break between 'operator' and '<<'.

Before:
ostream &operator
<<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);

After:
ostream &operator<<(ostream &out,
some::ns::SomeReallyLongType WithSomeReallyLongValue);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
9fc56f2636137fcde8acb38865555ed6c7b84dfd 14-Feb-2013 Daniel Jasper <djasper@google.com> Fix counting of parameters so that r175162 works as expected.

Before:
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
.aaaaaaaaaaaaaaaaa());

After:
aaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa());

Not sure which of the formattings above is better, but we should not pick
one by accident.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175165 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
fc75908a7f58903a92c47e1ae02f9a05c36c9f59 14-Feb-2013 Daniel Jasper <djasper@google.com> Reduce penalty for breaking before ./-> after complex calls.

This gives a clearer separation of the context, e.g. in GMOCK
statements.

Before:
EXPECT_CALL(SomeObject,
SomeFunction(Parameter)).WillRepeatedly(Return(SomeValue));

After:
EXPECT_CALL(SomeObject, SomeFunction(Parameter))
.WillRepeatedly(Return(SomeValue));

Minor format cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175162 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6cabab48dacc1317821f8f078ed2d4c603b67aff 14-Feb-2013 Daniel Jasper <djasper@google.com> Align superclasses for multiple inheritence.

This fixes llvm.org/PR15179.

Before:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};

After:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175147 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
a03ab10f0e4d888139b3b694dd55d176982f72a4 13-Feb-2013 Daniel Jasper <djasper@google.com> Allow breaking after the return type in function declarations.

This has so far been disabled for Google style, but should be done
before breaking at nested name specifiers or in template parameters.

Before (in Google style):
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<
T>::aaaaaaa() {}

After:
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175074 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
37d693160eba22343e08d7bcf66cd132ace77e5c 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Refactor the cast detection code to be a bit more readable.

No functionality change. Also add another cast test.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175029 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4c2cc603f5239f3b2963ce3e5d25adcf4d0a028d 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC method expressions after casts.

Not all casts are correctly detected yet, but it helps in some cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175028 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
b0112e122650cbc9a1a0af42ad84b7178ba0a876 12-Feb-2013 Dmitri Gribenko <gribozavr@gmail.com> Replace 'signed' with 'int'. 'signed' is not typical for LLVM style


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175015 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
468e399cfa371a0b698e566d89ffa786b9696f94 12-Feb-2013 Aaron Ballman <aaron@aaronballman.com> Fixing the MSVC compiler warning a different way; removed use of static_cast and instead used a signed integer parameter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
be9f4208632ca301384a6f484bc88ef8c3331523 12-Feb-2013 Aaron Ballman <aaron@aaronballman.com> Removing a signed/unsigned mismatch warning triggered in MSVC 11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174986 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
95e8e468af284afb11ec1f994d0b5076fc7423d9 12-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Correctly format stars in `sizeof(int**)` and similar places.

This redoes how '*' and '&' are classified as pointer / reference markers when
followed by ')', '>', or ','.

Previously, determineStarAmpUsage() marked a single '*' and '&' followed by
')', '>', or ',' as pointer or reference marker. Now, all '*'s and '&'s
preceding ')', '>', or ',' are marked as pointer / reference markers. Fixes
PR14884.

Since only the last '*' in 'int ***' was marked as pointer before (the rest
were unary operators, which don't reach spaceRequiredBetween()),
spaceRequiredBetween() now had to be thought about handing multiple '*'s in
sequence.

Before:
return sizeof(int * *);
Type **A = static_cast<Type * *>(P);

Now:
return sizeof(int**);
Type **A = static_cast<Type **>(P);

While here, also make all methods of AnnotatingParser except parseLine()
private.

Review URL: http://llvm-reviews.chandlerc.com/D384



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174975 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
c2e6d2a4a7fe9dfa7d52a38c6048b7b18e6b591a 11-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC message expressions after 'in' in loop

Before:
for (id foo in[self getStuffFor : bla]) {
}

Now:
for (id foo in [self getStuffFor:bla]) {
}

"in" is treated as loop keyword if the line starts with "for", and as a
regular identifier else. To check for "in", its IdentifierInfo is handed
through a few layers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174889 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
729a743b317d877df3978e88a4a247d2edbf2090 11-Feb-2013 Daniel Jasper <djasper@google.com> Fix invalid formatting with spaces before trailing comments.

In google style, trailing comments are separated by two spaces. This
patch fixes the counting of these spaces and prevents clang-format from
creating a line with 81 columns.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174879 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2b4c924f85e156d66c01b3f16c850892c47dcc7a 11-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting of overloaded operator definitions.

Before:
operatorvoid*();
operator vector< A< A>>();

After:
operator void *();
operator vector<A<A> >();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174863 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8c7f38cb42b1d15b131af95aaa4f2b5a823ce580 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove now-unneeded code for formatting ':'s in ObjC method decls.

The more general code for formatting ObjC method exprs does this and more,
it's no longer necessary to special-case this. No behavior change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174843 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
051860ee770bf83c3e66ab893be3642bb8bc2680 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC array literals.

Use this to add a space after "@[" and before "]" for now.

Later, I want to use this to format multi-line array literals nicer, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174822 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
087387a1e9ce5abeb4f348e14f64e5c2273eaedb 08-Feb-2013 Daniel Jasper <djasper@google.com> Fix handling of fake parenthesis during formatting.

They are much easier to handle when attached to the previous token.

Before:
unsigned Indent =
formatFirstToken(TheLine.First, IndentForLevel[TheLine.Level] >=
0 ? IndentForLevel[TheLine.Level]
: TheLine.Level * 2, TheLine.InPPDirective, PreviousEndOfLineColumn);

After:
unsigned Indent = formatFirstToken(
TheLine.First, IndentForLevel[TheLine.Level] >= 0
? IndentForLevel[TheLine.Level] : TheLine.Level * 2,
TheLine.InPPDirective, PreviousEndOfLineColumn);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174718 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
29f123b2fa0435bb1962f0d9e9a2e660f35fbb2f 08-Feb-2013 Daniel Jasper <djasper@google.com> Implement a tiny expression parser to improve formatting decisions.

With this patch, the formatter introduces 'fake' parenthesis according
to the operator precedence of binary operators.

Before:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb &
BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

After:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ||
bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB ||
cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

Future improvements:
- Get rid of some of the hacky ways to nicely format certain constructs.
- Merge this parser and the AnnotatingParser as we now have several parsers
that analyze (), [], etc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174714 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
daf1a15d734d154f07d5a0328d3ef59cd9a68f13 07-Feb-2013 Daniel Jasper <djasper@google.com> clang-format: Don't put useless space in f( ::g()).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174662 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4e8a7b4a95962f63a938c0d21c9aca0a51b78345 06-Feb-2013 Daniel Jasper <djasper@google.com> Become a little smarter with formatting long chains of pipes.

Assign a high penalty to breaking before "<<" if the previous token is a
string literal ending in ":" or "=".

Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa << "bbbbbbbbbbbbbbbbb = "
<< bbbbbbbbbbbbbbbbb << "ccccccccccccccccc = " << ccccccccccccccccc
<< "ddddddddddddddddd = " << ddddddddddddddddd << "eeeeeeeeeeeeeeeee = "
<< eeeeeeeeeeeeeeeee;

After:
llvm::outs() << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa
<< "bbbbbbbbbbbbbbbbb = " << bbbbbbbbbbbbbbbbb
<< "ccccccccccccccccc = " << ccccccccccccccccc
<< "ddddddddddddddddd = " << ddddddddddddddddd
<< "eeeeeeeeeeeeeeeee = " << eeeeeeeeeeeeeeeee;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174545 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4ed7f3e003c906d9fdb92a9484feeb8ac6e28e2f 06-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Correctly detect ObjC message expressions preceded by a comment.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174521 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8ff690ab478b33e0d830a6203de12d191d94f8ff 06-Feb-2013 Daniel Jasper <djasper@google.com> Optionally derive formatting information from the input file.

With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.

With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174504 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
6b5ba8be528bf614d5f4477a4cdbd7c3b19714a6 06-Feb-2013 Daniel Jasper <djasper@google.com> Fix an issue with the formatting of stars in default values.

Before: void f(int *a = d *e, int b = 0);
After: void f(int *a = d * e, int b = 0);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174500 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
4e778091b0ff42895644ca8bef30f1a91ba6b32b 06-Feb-2013 Daniel Jasper <djasper@google.com> Handle nested ObjC calls.

Properly handle annotation contexts while calculating extra information
for each token. This enable nested ObjC calls and thus solves (most of)
llvm.org/PR15164. E.g., we can now format:

[contentsContainer replaceSubview:[subviews objectAtIndex:0]
with:contentsNativeView];

Also fix a problem with the formatting of types in casts as this was
trivial now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174498 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
e8a97985f72b4e11435ff2107c0f11e925fb6d96 06-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: No space after & and * in front of ObjC message expressions.

1. let determineStarAmp() check of unary operators before checking for
"is next '['". That check was added in r173150, and the test from that
revision passes either way.

2. change determineStarAmp() to categorize '*' and '&' after '=' as unary
operator.

3. don't let parseSquare() overwrite the type of a '*' or '&' before the start
of an objc message expression if has the role of unary operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174489 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
ee0feec7362053f22b6c01d12e1bfa06fb3ac93f 05-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC method expressions after unary operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174384 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
63d7cedca8616921c1908c88c2f23fcd67bbab99 05-Feb-2013 Daniel Jasper <djasper@google.com> Initial support for formatting ObjC method declarations/calls.

We can now format stuff like:
- (void)doSomethingWith:(GTMFoo *)theFoo
rect:(NSRect)theRect
interval:(float)theInterval {
[myObject doFooWith:arg1 //
name:arg2
error:arg3];

}

This seems to fix everything mentioned in llvm.org/PR14939.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174364 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
5b7e7b0ec77f49c1b24deffc9b7032ca16ca9f0d 05-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting regression introduced by r174307.

In preprocessor definitions, we would not parse all the tokens and thus
not annotate them anymore. This led to a wrong formatting of comments
in google style:

#endif // HEADER_GUARD -- requires two spaces

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174361 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
fa543accd8945c39d5128612c8822d0ab4ad594c 04-Feb-2013 Daniel Jasper <djasper@google.com> Improve formatting of stream operators.

If there are string literals on either side of a '<<', chances are
high that they represent logically separate concepts. Otherwise,
the author could just have just a single literal (possible split
over multiple lines).

So, we can now nicely format things like:
cout << "somepacket = {\n"
<< " val a = " << ValueA << "\n"
<< " val b = " << ValueB << "\n"
<< "}";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174310 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
2752ff35854b295837b8088e44d5a932be60e107 04-Feb-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing block comments.

We can now (even in non-bin-packing modes) format:
someFunction(1, /* comment 1 */
2, /* comment 2 */
3, /* comment 3 */
aaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174309 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
8159d2f271c9142b46a672ac2c45821911171a7d 04-Feb-2013 Daniel Jasper <djasper@google.com> Fix an error in formatting of for-loops.

Two minor changes:
* Slight penalty for breaking at "," as opposed to ";".
* Don't apply bin-packing rules to for-loops.

Before:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb; ++aaaaaa,
++ccccccccccccccc) {}

After:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb;
++aaaaaa, ++ccccccccccccccc) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174308 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
0178673f541685cf5067814dfeee2644078e39a9 04-Feb-2013 Daniel Jasper <djasper@google.com> Restructuring of token annotation for formatting.

This combines several changes:
* Calculation token type (e.g. for * and &) in the AnnotatingParser.
* Calculate the scope binding strength in the AnnotatingParser.
* Let <> and [] scopes bind stronger than () and {} scopes.
* Add minimal debugging output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
f343cabb68d495041706b8e2f1ed48fbac3cba06 31-Jan-2013 Daniel Jasper <djasper@google.com> Several improvements to the formatting of static initializers.

1. Never avoid bin packing in static initializers as this can
lead to terrible results.
2. If an element has to be broken over multiple lines, break after
the following comma.

This should be a step forward, but there are still many cases
especially with nested static initializers that we handle badly.
More patches will follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174061 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp
32d28ee6061930b2a9c170cbaaeea028c88a7b89 29-Jan-2013 Daniel Jasper <djasper@google.com> Move the token annotator into separate files.

No functional changes. Also removed experimental-warning from all of
clang-format's files, as it is no longer accurate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173830 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/lib/Format/TokenAnnotator.cpp