History log of /llvm-project/clang/lib/Format/Format.cpp (Results 1051 – 1075 of 1154)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# a7252d83 12-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Initial support for formatting Objective-C method expressions.

This follows the approach suggested

Formatter: Initial support for formatting Objective-C method expressions.

This follows the approach suggested by djasper in PR14911: When a '[' is
seen that's at the start of a line, follows a binary operator, or follows one
of : [ ( return throw, that '[' and its closing ']' are marked as
TT_ObjCMethodExpr and every ':' in that range that isn't part of a ternary
?: is marked as TT_ObjCMethodExpr as well.

Update the layout routines to not output spaces around ':' tokens that are
marked TT_ObjCMethodExpr, and only allow breaking after such tokens, not
before.

Before:
[self adjustButton : closeButton_ ofKind : NSWindowCloseButton];

Now:
[self adjustButton:closeButton_ ofKind:NSWindowCloseButton];

llvm-svn: 172304

show more ...


# eee7b81a 12-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: * and & are binary operators before ( and [.

llvm-svn: 172303


# 5dafd4a7 12-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: * and & are binary operators after ) and ].

llvm-svn: 172302


# 63a54eb7 12-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: + and - after { are unary operators.

llvm-svn: 172301


# a21aaae7 11-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Format ObjC static and instance methods consistently, add a test for that.

llvm-svn: 172254


# 2acb7b7b 11-Jan-2013 Manuel Klimek <klimek@google.com>

Fix single-line optimization for ObjC.

Puts blocks always into multiple lines when they start with an ObjC
keyword or minus.

llvm-svn: 172238


# f4ab9ef3 11-Jan-2013 Manuel Klimek <klimek@google.com>

Implements pulling simple blocks into a single line.

void f() { return 42; }

The final change that implements the feature.

llvm-svn: 172225


# d6a947f7 11-Jan-2013 Daniel Jasper <djasper@google.com>

Correct spacing around new and delete.

This fixes llvm.org/PR14913.

Before: A *a = new(placement) A;
After: A *a = new (placement) A;
llvm-svn: 172212


# fd8c4b13 11-Jan-2013 Daniel Jasper <djasper@google.com>

Improve handling of trailing declaration annotations.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaa

Improve handling of trailing declaration annotations.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
GUARDED_BY(aaaaaaaaaaaaa);

Also did some formatting cleanups with clang-format on the way.

llvm-svn: 172200

show more ...


# 2408a8c7 11-Jan-2013 Daniel Jasper <djasper@google.com>

Improved formatting of constructor initializers

Added option to put each constructor initializer on its own line
if not all initializers fit on a single line. Enabling this for
Google style now as t

Improved formatting of constructor initializers

Added option to put each constructor initializer on its own line
if not all initializers fit on a single line. Enabling this for
Google style now as the style guide (arguable) suggests it. Not
sure whether we also want it for LLVM.

llvm-svn: 172196

show more ...


# 337816e4 11-Jan-2013 Daniel Jasper <djasper@google.com>

Refactor IndentState into two classes.

As we keep adding more stuff to it, this structure is easier to
maintain. At one point we might think about making it an actual
class with specific accessors,

Refactor IndentState into two classes.

As we keep adding more stuff to it, this structure is easier to
maintain. At one point we might think about making it an actual
class with specific accessors, etc.

llvm-svn: 172188

show more ...


# 9efe291f 10-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Put spaces in ObjC method decls in the right place for Google style.

Objective-C method declarations look like this:

- (returntype)name:(type)argname anothername:(type)arg2name;

In goog

Formatter: Put spaces in ObjC method decls in the right place for Google style.

Objective-C method declarations look like this:

- (returntype)name:(type)argname anothername:(type)arg2name;

In google style, there's no space after the leading '-' but one after
"(returntype)" instead (but none after the argument types), see
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions

Not inserting the space after '-' is easy, but to insert the space after the
return type, the formatter needs to know that a closing parenthesis ends the
return type. To do this, I tweaked the code in parse() to check for this, which
in turn required moving detection of TT_ObjCMethodSpecifier from annotate() to
parse(), because parse() runs before annotate().

(To keep things interesting, the return type is optional, but it's almost
always there in practice.)

http://llvm-reviews.chandlerc.com/D280

llvm-svn: 172140

show more ...


# a2a8495e 10-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: No spaces around '=' in @property lines.

Before:
@property(assign, getter = isEditable) BOOL editable;

Now:
@property(assign, getter=isEditable) BOOL editable;

It'd be nice if some Appl

Formatter: No spaces around '=' in @property lines.

Before:
@property(assign, getter = isEditable) BOOL editable;

Now:
@property(assign, getter=isEditable) BOOL editable;

It'd be nice if some Apple person could let me know if spaces are preferred
around '=' in @synthesize lines (see FIXME in the test).

llvm-svn: 172110

show more ...


# a608775b 10-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatting: In @implementation etc lines, put a space before protocol lists.

Don't do this in Google style though:
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Protocols

Most oth

Formatting: In @implementation etc lines, put a space before protocol lists.

Don't do this in Google style though:
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Protocols

Most other places (function declarations, variable declarations) still get
this wrong, and since this looks very similiar to template instantiations to
the lexer (`id <MyProtocol> a = ...`), it's going to be hard to fix in some
places.

llvm-svn: 172099

show more ...


# 51bd6ec1 10-Jan-2013 Manuel Klimek <klimek@google.com>

Refactoring the outermost structure of the formatter.

This is the last step of pure shuffling stuff around, the next step will
be the actual feature.

llvm-svn: 172098


# a1a5abd5 10-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Don't put a space in ObjC number literals like @+50

Before:
@ -4.5

Now:
@-4.5

llvm-svn: 172095


# 2bb00742 10-Jan-2013 Nico Weber <nicolasweber@gmx.de>

Formatter: Add space before '(' in @implemenation, @interface, @protocol lines

The first token in @implementation, @interface, and @protocol lines is now
marked TT_ObjCDecl, and lines starting with

Formatter: Add space before '(' in @implemenation, @interface, @protocol lines

The first token in @implementation, @interface, and @protocol lines is now
marked TT_ObjCDecl, and lines starting with a TT_ObjCDecl token are now marked
LT_ObjCMethodDecl.

llvm-svn: 172093

show more ...


# b2c6dbec 10-Jan-2013 Manuel Klimek <klimek@google.com>

Pull calculation whether a line fits one level up.

This is the next step towards being able to configure multiple unwrapped
lines into one.

llvm-svn: 172092


# 0b689fd6 10-Jan-2013 Manuel Klimek <klimek@google.com>

Pulling formatFirstToken one level up.

This prepares the code for single line optimizations and changes the
dependencies between single-line-formats to the indent of the first
token.

Conceptually,

Pulling formatFirstToken one level up.

This prepares the code for single line optimizations and changes the
dependencies between single-line-formats to the indent of the first
token.

Conceptually, the first token is "between" the lines anyway, as the
whitespace for the first token includes the previous end-of-line, which
needs to be escaped when inside a preprocessor directive.

llvm-svn: 172083

show more ...


# 0ddd57a1 10-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes layout of right braces.

We now decide whether a newline should go before the closing brace
depending on whether a newline was inserted after the opening brace.

For example, we now insert a ne

Fixes layout of right braces.

We now decide whether a newline should go before the closing brace
depending on whether a newline was inserted after the opening brace.

For example, we now insert a newline before '};' in:
static SomeClass WithALoooooooooooooooooooongName = {
100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
};
... while not inserting a newline here:
static SomeClass = { a, b, c, d, e, f, g, h, i, j,
looooooooooooooooooooooooooooooooooongname,
looooooooooooooooooooooooooooooong };

Also fixes the formating of (column limit 25):
int x = {
avariable,
b(alongervariable)
};

llvm-svn: 172076

show more ...


# 5b7157ac 10-Jan-2013 Alexander Kornienko <alexfh@google.com>

Basic support for diagnostics.

Summary: Uses DiagnosticsEngine to output diagnostics.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.c

Basic support for diagnostics.

Summary: Uses DiagnosticsEngine to output diagnostics.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 172071

show more ...


# 73a2fdf2 10-Jan-2013 Manuel Klimek <klimek@google.com>

Fixes formatting of function calls etc inside an initializer list.

We're now formatting (column limit 25):
int x = {
avariable,
b(alongervariable) };

This also fixes:
Aaa({
int i;
}, aaaaaaaa

Fixes formatting of function calls etc inside an initializer list.

We're now formatting (column limit 25):
int x = {
avariable,
b(alongervariable) };

This also fixes:
Aaa({
int i;
}, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccc));
... where we would previously break after the '},'.

Putting the closing curly into an extra line when there's a break
directly after the first curly will be done in a subsequent patch.

Paired with djasper.

llvm-svn: 172070

show more ...


# e7d10a1f 10-Jan-2013 Manuel Klimek <klimek@google.com>

Do not add newline in empty blocks.

void f() {}
now gets formatted in one line.

llvm-svn: 172067


# c1fa2813 10-Jan-2013 Daniel Jasper <djasper@google.com>

Improvements to function type and ObjC block formatting.

Before: int (^myBlock) (int) = ^(int num) {}
A<void ()>;
int (*b)(int);

After: int (^myBlock)(int) = ^(int num) {}
A<void(

Improvements to function type and ObjC block formatting.

Before: int (^myBlock) (int) = ^(int num) {}
A<void ()>;
int (*b)(int);

After: int (^myBlock)(int) = ^(int num) {}
A<void()>;
int(*b)(int);

For function types and function pointer types, this patch only makes
the behavior consistent (for types that are keywords and other types).
For the latter function pointer type declarations, we'll probably
want to add a space after "int".

Also added LangOpts.Bool = 1, so we handle "A<bool()>" appropriately
Moved the LangOpts-settings to a public place for use by tests
and clang-format binary.

llvm-svn: 172065

show more ...


# 8e07a1b6 10-Jan-2013 Manuel Klimek <klimek@google.com>

Fix layout of blocks inside statements.

Previously, we would not indent:
SOME_MACRO({
int i;
});
correctly. This is fixed by adding the trailing }); to the unwrapped
line starting with SOME_MACRO(

Fix layout of blocks inside statements.

Previously, we would not indent:
SOME_MACRO({
int i;
});
correctly. This is fixed by adding the trailing }); to the unwrapped
line starting with SOME_MACRO({, so the formatter can correctly match
the braces and indent accordingly.

Also fixes incorrect parsing of initializer lists, like:
int a[] = { 1 };

llvm-svn: 172058

show more ...


1...<<41424344454647