summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Improve formatting of operator<< chains.Daniel Jasper2013-07-151-0/+3
| | | | | | | | | | | | | Before: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa; After: llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa; llvm-svn: 186320
* clang-format: Improve <<-formatting.Daniel Jasper2013-07-121-0/+5
| | | | | | | | | | | | | | | | This fixes a regression caused by r186115. Before: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 186164
* clang-format: Fix string literal breaking.Daniel Jasper2013-07-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Before this patch, it did not cooperate with Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); into: aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); and only a second format step would lead to the desired (with that option): aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa"); This could even lead to clang-format breaking the string at a different character and thus leading to a completely different end result. llvm-svn: 186154
* clang-format: Break before/between array subscript expressions.Daniel Jasper2013-07-121-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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; llvm-svn: 186153
* clang-format: Fix bug concerning the alignment of "}".Daniel Jasper2013-07-111-0/+7
| | | | | | | | | | | | | | | | Before: int i; // indented 2 space more than clang-format would use. SomeReturnType // clang-format invoked on this line. SomeFunctionMakingLBraceEndInColumn80() { } // This is the indent clang-format would prefer. After: int i; // indented 2 space more than clang-format would use. SomeReturnType // clang-format invoked on this line. SomeFunctionMakingLBraceEndInColumn80() { } llvm-svn: 186120
* clang-format: Break before trailing annotations.Daniel Jasper2013-07-111-0/+8
| | | | | | | | | | | | | | (if they are not function-like). Before: SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE; After: SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE; llvm-svn: 186117
* clang-format: Avoid line breaks before the first <<.Daniel Jasper2013-07-111-0/+16
| | | | | | | | | | | | | | | | | This puts a slight penalty on the linebreak before the first "<<", so that clang-format generally tries to keep things on the first line. User feedback has shown that this is generally desirable. Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa; After: llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 186115
* Improve detection of trailing return types.Daniel Jasper2013-07-111-0/+3
| | | | | | | | | | | | Trailing return types can only occur in declaration contexts. Before: void f() { auto a = b -> c(); } After: void f() { auto a = b->c(); } llvm-svn: 186087
* Fix indentation problem for comments in call chainsDaniel Jasper2013-07-111-0/+3
| | | | | | | | | | | | | | Before: SomeObject // Calling someFunction on SomeObject .someFunction(); After: SomeObject // Calling someFunction on SomeObject .someFunction(); llvm-svn: 186085
* Keep trailing annotations close to their argument.Daniel Jasper2013-07-111-0/+4
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa); After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa); llvm-svn: 186077
* Add experimental flag for adaptive parameter bin-packing.Daniel Jasper2013-07-101-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 186003
* Initial support for formatting trailing return types.Daniel Jasper2013-07-091-0/+10
| | | | | | | | | | | | 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. llvm-svn: 185938
* Avoid confusing indentations for chained function calls.Daniel Jasper2013-07-091-1/+10
| | | | | | | | | | | | | | | | | | | Basically treat a function with a trailing call similar to a function with multiple parameters. Before: aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); Also fix typo. llvm-svn: 185930
* Fix alignment of closing brace in braced initializers.Daniel Jasper2013-07-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | Before: someFunction(OtherParam, BracedList{ // comment 1 (Forcing intersting break) param1, param2, // comment 2 param3, param4 }); After: someFunction(OtherParam, BracedList{ // comment 1 (Forcing intersting break) param1, param2, // comment 2 param3, param4 }); To do so, the UnwrappedLineParser now stores the information about the kind of brace in the FormatToken. llvm-svn: 185914
* Format overloaded operators like other functions.Daniel Jasper2013-07-091-0/+7
| | | | | | | | | | | | | | 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); llvm-svn: 185908
* Fix incorrect incorrect cast identification in clang-format.Daniel Jasper2013-07-081-0/+1
| | | | | | | | | | | This fixes llvm.org/PR16534. Before: aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION; After: aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION; llvm-svn: 185828
* Prefer similar line breaks.Daniel Jasper2013-07-081-11/+18
| | | | | | | | | | | | | | | | | | | | | | | This adds a penalty for clang-format for each break that occurs in a set of parentheses (including fake parenthesis that determine the range of certain operator precendences) that have not yet been broken. Thereby, clang-format prefers similar line breaks. This fixes llvm.org/PR15506. Before: const int kTrackingOptions = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways; After: const int kTrackingOptions = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways; Also removed ParenState::ForFakeParenthesis which has become unused. llvm-svn: 185822
* Fix for corner cases in code handling leading "* " decorations in block commentsAlexander Kornienko2013-07-081-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixes problems that lead to incorrect formatting of these and similar snippets: /* ** */ /* **/ /* * */ /* *test */ Clang-format used to think that all the cases above use "* " decoration, and failed to calculate insertion position properly. It also used to remove leading "* " in the last line. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1113 llvm-svn: 185818
* Fix formatting for allocation of new pointer variables.Daniel Jasper2013-07-051-0/+4
| | | | | | | | | | | | Before: T **t = new T * ; T **q = new T * (); After: T **t = new T *; T **q = new T *(); llvm-svn: 185699
* Improve detection for preventing certain kind of formatting patterns.Daniel Jasper2013-07-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a better implementation of r183097. The main purpose is to prevent certain constructs to be formatted "like a block of text". Before: aaaaaaaaaaaaa< aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa< aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(bbbbbbbbbbbbbbbbbbbbbbbb); aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[ dddddddddddddddddddddddddddddddddddddddddddddddddddddddd]; After: aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>( bbbbbbbbbbbbbbbbbbbbbbbb); aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[ dddddddddddddddddddddddddddddddddddddddddddddddddddddddd]; llvm-svn: 185687
* Don't break after a "(" following a binary operator.Daniel Jasper2013-07-051-0/+3
| | | | | | | | | | | | | | | | 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. llvm-svn: 185685
* Added AlwaysBreakBeforeMultilineStrings option.Alexander Kornienko2013-07-041-0/+28
| | | | | | | | | | | | | | | | | 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 llvm-svn: 185622
* Don't insert confusing line breaks in comparisons.Daniel Jasper2013-07-031-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In general, clang-format breaks after an operator if the LHS spans multiple lines. Otherwise, this can lead to confusing effects and effectively hide the operator precendence, e.g. in if (aaaaaaaaaaaaaa == bbbbbbbbbbbbbb && c) { ... This patch removes this rule for comparisons, if the LHS is not a binary expression itself as many users were wondering why clang-format inserts an unnecessary linebreak. Before: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ... After: if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ... In the long run, we might: - Want to do this for other binary expressions as well. - Do this only if the RHS is short or even only if it is a literal. llvm-svn: 185530
* Fix formatting of long declarations with const type.Daniel Jasper2013-07-021-0/+5
| | | | | | | | | | | Before (exceeding the column limit): LoooooooooooooooooooooooooooooooooooooooongType const LoooooooooooooooooooooooooooooooooooooooongVariable; After: LoooooooooooooooooooooooooooooooooooooooongType const LoooooooooooooooooooooooooooooooooooooooongVariable; llvm-svn: 185418
* Fix incorrect token counting introduced by r185319.Daniel Jasper2013-07-011-0/+1
| | | | | | | | | | | | This lead to weird formatting. Before: DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } }); After: DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } }); llvm-svn: 185346
* Avoid column limit violation in block comments in certain cases.Alexander Kornienko2013-07-011-0/+17
| | | | | | | | | | | | | | | | | Summary: Add penalty when an excessively long line in a block comment can not be broken on a leading whitespace. Lack of this addition can lead to severe column width violations when they can be easily avoided. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1071 llvm-svn: 185337
* Don't align "} // namespace" comments.Daniel Jasper2013-07-011-5/+24
| | | | | | | | | | | | | | | | This is not all bad, but people are often surprised by it. Before: namespace { int SomeVariable = 0; // comment } // namespace After: namespace { int SomeVariable = 0; // comment } // namespace llvm-svn: 185327
* Don't add an extra space before ellipsis after pointers.Daniel Jasper2013-07-011-0/+5
| | | | | | | | | | | 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) {} llvm-svn: 185321
* Keep space between pointer and block comment.Daniel Jasper2013-07-011-0/+2
| | | | | | | | | | Before: void f(int */* unused */) {} After: void f(int * /* unused */) {} The previous version seems to be valid C++ code but confuses many syntax highlighters. llvm-svn: 185320
* Fix braced-list detection in lieu of trailing comments.Daniel Jasper2013-07-011-0/+1
| | | | | | | | | | Before: DoSomethingWithVector({ } /* No data */); After: DoSomethingWithVector({} /* No data */); llvm-svn: 185319
* Use lexing mode based on FormatStyle.Standard.Alexander Kornienko2013-06-281-12/+18
| | | | | | | | | | | | | | | | | | | | | Summary: Some valid pre-C++11 constructs change meaning when lexed in C++11 mode, e.g. #define x(_a) printf("foo"_a); (example from http://llvm.org/bugs/show_bug.cgi?id=16342). "foo"_a is treated as a user-defined string literal when parsed in C++11 mode. In order to deal with this correctly, we need to set lexing mode according to which standard the code conforms to. We already have a configuration value for this (FormatStyle.Standard), which seems to be appropriate to use in this case as well. Reviewers: klimek CC: cfe-commits, gribozavr Differential Revision: http://llvm-reviews.chandlerc.com/D1028 llvm-svn: 185149
* Formatter: Don't put a space after parameter-naming block comments.Nico Weber2013-06-261-1/+1
| | | | | | | | | | | | | 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 llvm-svn: 184894
* Formatter/ObjC: Correctly format casts in objc message send expressions.Nico Weber2013-06-251-0/+4
| | | | llvm-svn: 184804
* Formatter/Objc: Add a test that checks that @import is formatted correctly.Nico Weber2013-06-251-0/+3
| | | | llvm-svn: 184796
* Fixed typo.Alexander Kornienko2013-06-221-1/+1
| | | | llvm-svn: 184625
* Add an option to not indent declarations when breaking after the type.Manuel Klimek2013-06-211-18/+35
| | | | | | Make that option the default for LLVM style. llvm-svn: 184563
* Use the same set of whitespace characters for all operations in BreakableToken.Alexander Kornienko2013-06-201-0/+3
| | | | | | | | | | | | | | | | | Summary: Fixes a problem where \t,\v or \f could lead to a crash when placed as a first character in a line comment. The cause is that rtrim and ltrim handle these characters, but our code didn't, so some invariants could be broken. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1013 llvm-svn: 184425
* Fixed long-standing issue with incorrect length calculation of multi-line ↵Alexander Kornienko2013-06-191-14/+16
| | | | | | | | | | | | | | | | | | | | | comments. Summary: A trailing block comment having multiple lines would cause extremely high penalties if the summary length of its lines is more than the column limit. Fixed by always considering only the last line of a multi-line block comment. Removed a long-standing FIXME from relevant tests and added a motivating test modelled after problem cases from real code. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1010 llvm-svn: 184340
* Split long strings on word boundaries.Alexander Kornienko2013-06-191-0/+20
| | | | | | | | | | | | Summary: Split strings at word boundaries, when there are no spaces and slashes. Reviewers: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1003 llvm-svn: 184304
* Fix a problem in ExpressionParser leading to trailing comments affecting ↵Alexander Kornienko2013-06-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 184078
* Fixes incorrect indentation of line comments after break and re-alignment.Alexander Kornienko2013-06-171-0/+30
| | | | | | | | | | | | | | | | | | | Summary: Selectively propagate the information about token kind in WhitespaceManager::replaceWhitespaceInToken.For correct alignment of new segments of line comments in order to align them correctly. Don't set BreakBeforeParameter in breakProtrudingToken for line comments, as it introduces a break after the _next_ parameter. Added tests for related functions. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D980 llvm-svn: 184076
* [Driver] Refactor clang driver to use LLVM's Option libraryReid Kleckner2013-06-141-1/+1
| | | | | | | | | | | | | | | | | | The big changes are: - Deleting Driver/(Arg|Opt)* - Rewriting includes to llvm/Option/ and re-sorting - 'using namespace llvm::opt' in clang::driver - Fixing the autoconf build by adding option everywhere As discussed in the review, this change includes using directives in header files. I'll make follow up changes to remove those in favor of name specifiers. Reviewers: espindola Differential Revision: http://llvm-reviews.chandlerc.com/D975 llvm-svn: 183989
* Don't remove backslashes from block comments.Alexander Kornienko2013-06-141-0/+17
| | | | | | | | | | | | | | | | | | | | | | | Summary: Don't remove backslashes from block comments. Previously this /* \ \ \ \ \ \ */ would be turned to this: /* */ which spoils some kinds of ASCII-art, people use in their comments. The behavior was related to handling escaped newlines in block comments inside preprocessor directives. This patch makes handling it in a more civilized way. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D979 llvm-svn: 183978
* Preserve newlines before block comments in static initializers.Alexander Kornienko2013-06-121-11/+22
| | | | | | | | | | | | | | | | 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 llvm-svn: 183851
* Insert a space at the start of a line comment in case it starts with an ↵Alexander Kornienko2013-06-111-4/+9
| | | | | | | | | | | | | | | | | | | | alphanumeric character. Summary: "//Test" becomes "// Test". This change is aimed to improve code readability and conformance to certain coding styles. If a comment starts with a non-alphanumeric character, the space isn't added, e.g. "//-*-c++-*-" stays unchanged. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D949 llvm-svn: 183750
* Improved handling of escaped newlines at the token start.Alexander Kornienko2013-06-071-1/+2
| | | | | | | | | | | | | | Summary: Remove them from the TokenText as well. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D935 llvm-svn: 183536
* Fixed calculation of penalty when breaking tokens.Alexander Kornienko2013-06-071-31/+62
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 183530
* Fix incorrect line breaking before trailing block comments.Daniel Jasper2013-06-061-0/+9
| | | | | | | | | | | | | | | | | 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 */ ... } llvm-svn: 183420
* Fix clang-format's expression parser for leading }s.Daniel Jasper2013-06-061-0/+4
| | | | | | | | 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. llvm-svn: 183393
* Improve c-style cast detection.Daniel Jasper2013-06-061-0/+3
| | | | | | | | | | | | | | 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"); llvm-svn: 183389
OpenPOWER on IntegriCloud