aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
AgeCommit message (Collapse)Author
2013-03-01Implement fallback split point for string literals.Manuel Klimek
If we don't find a natural split point (currently space) in a string literal protruding over the line, we just split at the last possible point. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176349 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28Improve formatting of #defines.Daniel Jasper
Two improvements: 1) Always leave at least one space before "\". Otherwise is can look bad and there is a risk of unwillingly joining to characters to a different token. 2) Use the full column limit for single-line #defines. Fixes llvm.org/PR15148 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176245 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28Fix bug when formatting "A<A<A>>".Daniel Jasper
Before: A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaaaaa); Before: A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176244 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28Fix incorrect recognition of bin-packing.Daniel Jasper
Before (in Google style): Constructor() : aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa( aaaaaa) {} After: Constructor() : aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176242 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-27Enable bin-packing in Google style.Daniel Jasper
After some discussions, it seems that this is the better path in the long run. Does not change Chromium style, as there, bin packing is forbidden by the style guide. Also fix two minor bugs wrt. formatting: 1. If a call parameter is a function call itself and is split before the "." or "->", split before the next parameter. 2. If a call parameter is string literal that has to be split onto two lines, split before the next parameter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176177 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-26Only keep empty lines in unwrapped lines if they preceed a line comment.Daniel Jasper
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
2013-02-26Only break string literals as a last resort.Daniel Jasper
We might want to move towards doing this if the formatting can be significantly improved, but we need to carefully evaluate the different situations first. Before (the string literal was split by clang-format here): aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa " "aaaaa aaa aaa aaaaaa")); After: aaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa")); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176084 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-25Re-add hack that caused regression.Daniel Jasper
This fixes llvm.org/PR15350. Before: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {} After: Constructor(int Parameter = 0) : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa), aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {} I think the correct solution is to put the VariablePos into ParenState, not LineState. Added FIXME. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176027 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-24Allow breaking between a type and name in variable declarations.Daniel Jasper
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
2013-02-23Better formatting of conditional expressions.Daniel Jasper
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
2013-02-21Consistently put {} onto the same line for empty functions.Daniel Jasper
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
2013-02-21Allow breaking between type and name in for loops.Daniel Jasper
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
2013-02-20Fix regression in string literal alignment.Manuel Klimek
Now correctly indents (again): a = a + "a" "a" "a"; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175630 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20Fixes bug in string literal alignment.Manuel Klimek
We now indent the following correctly: 1. some + "literal" /* comment */ "literal"; 2. breaking string literals after which we have another string literal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175628 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20Don't remove blank lines within unwrapped lines.Daniel Jasper
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
2013-02-20Implements breaking of string literals if they stick out.Manuel Klimek
An alternative strategy to calculating the break on demand when hitting a token that would need to be broken would be to put all possible breaks inside the token into the optimizer. Currently only supports breaking at spaces; more break points to come. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175613 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-19Fix bug in LineState comparison function.Daniel Jasper
The key bug was if (Other.StartOfLineLevel < StartOfLineLevel) .. instead of if (Other.StartOfLineLevel != StartOfLineLevel) .. Also cleaned up the function to be more consistent in the comparisons. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175500 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-18Improve indentation of builder type calls.Daniel Jasper
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
2013-02-18Reformat lines if they were "moved around".Daniel Jasper
An unwrapped line can get moved around if there is no newline before it and the previous line was formatted. Example: template<typename T> // Cursor is on this line when hitting "format" T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); } "return .." is the second unwrapped line in this scenario. I does not touch any reformatted region. Thus, the result of formatting is: template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); } After second format (and arguably desired end-result): template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); } This fixes: llvm.org/PR15060. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175440 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-18Always break after multi-line string literals.Daniel Jasper
Otherwise, other parameters can be quite hidden. Reformatted unittests/Format/FormatTest.cpp after this. Before: someFunction("Always break between multi-line" " string literals", and, other, parameters); After: someFunction("Always break between multi-line" " string literals", and, other, parameters); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175436 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-18Prevent line breaks that make stuff hard to read.Daniel Jasper
Before: aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175432 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-15Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.Daniel Jasper
This got lost and was untested as the same effect is achieved by avoiding bin packing, which is active in Google style by default. However, moving forward, we want more control over the bin packing option(s) and thus, this flag should work as expected. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175277 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-15Prevent only breaking before "?" in conditional expressions.Daniel Jasper
This is almost always more readable. Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa; After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175262 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14Reduce penalty for breaking before ./-> after complex calls.Daniel Jasper
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
2013-02-14Remove the trailing whitespace of formatted lines.Daniel Jasper
So far, clang-format has always assumed the whitespace belonging to the subsequent token. This has the negative side-effect that when clang-format formats a line, it does not remove its trailing whitespace, as it belongs to the next token. Thus, this patch fixes most of llvm.org/PR15062. We are not zapping a file's trailing whitespace so far, as this does not belong to any token we see during formatting. We need to fix this in a subsequent patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175152 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14Get less confused by trailing comma in Google style.Daniel Jasper
The formatter can now format: void aaaaaaaaaaaaaaaaaa(int level, double *min_x, double *max_x, double *min_y, double *max_y, double *min_z, double *max_z, ) { } Although this is invalid code, it frequently happens during development and clang-format should be nicer :-). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175151 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14Align superclasses for multiple inheritence.Daniel Jasper
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
2013-02-13Allow breaking after the return type in function declarations.Daniel Jasper
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
2013-02-13Fix comment alignment close to the column limit.Daniel Jasper
Due to an error in one of the expressions, we used to not align comments although it would have been possible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175068 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-13Pull search state out as class members.Manuel Klimek
Fix some comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175052 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-13An attempt to make the search algorithm easier to understand.Manuel Klimek
- clear ownership: the SpecificBumpPtrAllocator owns all StateNodes - this allows us to simplify the memoization data structure into a std::set (FIXME: figure out whether we want to use a hash based data structure). - introduces StateNode as recursive data structure, instead of using Edge and the Seen-map combined to drill through the graph - using a count to stabilize the penalty instead of relying on the container - pulled out a method to forward-apply states in the end This leads to a ~40% runtime decrease on Nico's benchmark. Main FiXME is that the parameter lists of some function get too long. I'd vote for either pulling the Queue etc into the Formatter proper, or creating an inner class just for the search algorithm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175051 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12Fix bug in the adjustment to existing lines.Daniel Jasper
Before (if only the second line was reformatted): void f() {} void g() {} After: void f() {} void g() {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174978 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11Formatter: Detect ObjC message expressions after 'in' in loopNico Weber
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
2013-02-11Get rid of manual debug output, now that the test runner supports it.Manuel Klimek
You can run tests with -debug instead now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174880 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11Fix invalid formatting with spaces before trailing comments.Daniel Jasper
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
2013-02-11Fixes handling of empty lines in macros.Manuel Klimek
Now correctly formats: #define A \ \ b; to #define A b; Added the state whether an unwrapped line is a macro to the debug output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174878 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08Fix indentation-detection at indent level 0.Manuel Klimek
This correctly formats: { a; } where { is incorrectly indented by 2, but is at level 0, when reformatting only 'a;'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174737 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08Takes the context into account when re-indenting regions.Manuel Klimek
Fixes llvm.org/PR14916. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174720 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08Implement a tiny expression parser to improve formatting decisions.Daniel Jasper
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
2013-02-08Avoid unnecessary line breaks in nested ObjC calls.Daniel Jasper
Before: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType]; After: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174701 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Fix bug in the alignment of comments.Daniel Jasper
Before: const char *test[] = { // A "aaaa", // B "aaaaa", }; After: const char *test[] = { // A "aaaa", // B "aaaaa", }; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174549 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Align trailing block comments like trailing line comments.Daniel Jasper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174537 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Fix formatting of ObjC method calls.Daniel Jasper
This fixes llvm.org/PR15165. We now correctly align: [image_rep drawInRect:drawRect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0 ssssssssdd:NO hints:nil]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Fix a formatting bug caused by comments in expressions.Daniel Jasper
This fixes llvm.org/PR15162. Before: bool aaaaaaaaaaaaa = // comment aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaa = // comment aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174508 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Optionally derive formatting information from the input file.Daniel Jasper
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
2013-02-05Initial support for formatting ObjC method declarations/calls.Daniel Jasper
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
2013-02-05Fix some linebreak decisions in Google format.Daniel Jasper
Before: f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa); aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)); After: f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa); aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174363 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04Improve handling of trailing block commentsDaniel Jasper
This is a follow up to r174309 to actually make it work. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174314 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04Improve handling of trailing block comments.Daniel Jasper
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
2013-02-04Fix an error in formatting of for-loops.Daniel Jasper
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