summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fixes issue with Allman BreakBeforeBraces for Objective C @interfaceDinesh Dwivedi2014-05-021-2/+5
| | | | | | | | | | | | | | | | | | | Before: @interface BSApplicationController () { @private id _extraIvar; } @end After: @interface BSApplicationController () { @private id _extraIvar; } @end llvm-svn: 207849
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | | | | definition below all of the header #include lines, clang edition. If you want more details about this, you can see some of the commits to Debug.h in LLVM recently. This is just the clang section of a cleanup I've done for all uses of DEBUG_TYPE in LLVM. llvm-svn: 206849
* Format code around VCS conflict markers.Manuel Klimek2014-04-141-25/+44
| | | | | | | | | | | | | | | | | | | | | Now correctly formats: { int a; void f() { callme(some(parameter1, <<<<<<< text by the vcs parameter2), ||||||| text by the vcs parameter2), parameter3, ======= text by the vcs parameter2, parameter3), >>>>>>> text by the vcs otherparameter); } } llvm-svn: 206157
* Correctly handle escaped newlines when the next token starts without a space.Manuel Klimek2014-04-111-4/+9
| | | | | | | We will need this to correctly handle conflict markers inside macro definitions. llvm-svn: 206029
* clang-format: Fix false positive in braced list detection in protos.Daniel Jasper2014-04-101-12/+19
| | | | llvm-svn: 205954
* clang-format: Support configurable list of foreach-macros.Daniel Jasper2014-04-011-2/+9
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* clang-format: Solve issues found and fixed by clang-tidy.Daniel Jasper2014-03-311-1/+1
| | | | llvm-svn: 205193
* clang-format: Recognize more ObjC blocks with parameters/return type.Daniel Jasper2014-03-281-2/+6
| | | | llvm-svn: 204990
* clang-format: Detect function-like macros only when upper case is used.Alexander Kornienko2014-03-181-1/+1
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3110 llvm-svn: 204156
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-151-6/+6
| | | | | | class. llvm-svn: 203999
* Remove an unnecessary check for FormatTok not being null.Alexander Kornienko2014-03-131-1/+2
| | | | | | | | | | | | | | | | | Summary: This check hints clang analyzer, that FormatTok may be null, and it reports a null pointer dereference error: http://buildd-clang.debian.net/scan-build/report-827c64.html#Path28 Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3040 llvm-svn: 203800
* clang-format: Prevent ObjC code from confusing the braced-init detectionDaniel Jasper2014-03-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This was leading to bad formatting, e.g.: Before: f(^{ @autoreleasepool { if (a) { g(); } } }); After: f(^{ @autoreleasepool { if (a) { g(); } } }); llvm-svn: 203777
* clang-format: Fix another false positive in the lambda detection.Daniel Jasper2014-03-111-2/+2
| | | | | | | | | | Before: int i = (*b)[a] -> f(); After: int i = (*b)[a]->f(); llvm-svn: 203557
* clang-format: Fix incorrect lambda recognition exposed by r203452.Daniel Jasper2014-03-111-1/+2
| | | | | | | | | | Before: int i = a[a][a] -> f(); After: int i = a[a][a]->f(); llvm-svn: 203556
* clang-format: Add spaces around trailing/lambda return types.Daniel Jasper2014-03-101-0/+3
| | | | | | | | | | Before: int c = []()->int { return 2; }(); After: int c = []() -> int { return 2; }(); llvm-svn: 203452
* Change OwningPtr::take() to OwningPtr::release().Ahmed Charles2014-03-071-1/+1
| | | | | | This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
* clang-format: Support lambdas with namespace-qualified return types.Daniel Jasper2014-02-111-0/+1
| | | | | | | E.g.: Foo([]()->std::vector<int> { return { 2 }; }()); llvm-svn: 201139
* clang-format: Support ObjC's NS_ENUMs.Daniel Jasper2014-01-301-1/+10
| | | | | | | | | | | | | | | | | | | | | | | Before: typedef NS_ENUM(NSInteger, MyType) { /// Information about someDecentlyLongValue. someDecentlyLongValue, /// Information about anotherDecentlyLongValue. anotherDecentlyLongValue, /// Information about aThirdDecentlyLongValue. aThirdDecentlyLongValue}; After: typedef NS_ENUM(NSInteger, MyType) { /// Information about someDecentlyLongValue. someDecentlyLongValue, /// Information about anotherDecentlyLongValue. anotherDecentlyLongValue, /// Information about aThirdDecentlyLongValue. aThirdDecentlyLongValue }; llvm-svn: 200469
* Fix crash on unmatched #endif's.Manuel Klimek2014-01-291-1/+3
| | | | | | | | The following snippet would crash: #endif #if A llvm-svn: 200381
* Get rid of special parsing for return statements.Manuel Klimek2014-01-241-37/+0
| | | | | | | | This was done when we were not able to parse lambdas to handle some edge cases for block formatting different in return statements, but is not necessary any more. llvm-svn: 199982
* clang-format: Fix incorrect lambda recognition.Daniel Jasper2014-01-221-1/+2
| | | | | | | | | | | | | Before: std::unique_ptr<int[]> foo() {} After: std::unique_ptr<int []> foo() {} Also, the formatting could go severely wrong after such a function before. llvm-svn: 199817
* clang-format: Enable formatting of lambdas with explicit return type.Daniel Jasper2014-01-161-2/+8
| | | | | | | | | So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector<int> { return { 2 }; }(); llvm-svn: 199368
* clang-format: Don't hang forever when encountering a stray "}" in an ↵Benjamin Kramer2014-01-081-0/+4
| | | | | | | | @implementation block. PR18406. llvm-svn: 198770
* clang-format: Recognize single-line macro usages inside macros.Daniel Jasper2014-01-031-1/+1
| | | | | | | | | | | | | | | | | Before: #define LIST(L) \ L(FirstElement) L(SecondElement) L(ThirdElement) L(FourthElement) \ L(FifthElement) After: #define LIST(L) \ L(FirstElement) \ L(SecondElement) \ L(ThirdElement) \ L(FourthElement) \ L(FifthElement) llvm-svn: 198407
* clang-format: Fix various problems in formatting ObjC blocks.Daniel Jasper2013-12-231-5/+43
| | | | | | Among other things, this fixes llvm.org/PR15269. llvm-svn: 197900
* Implemented GNU-style formatting for compound statements.Alexander Kornienko2013-12-121-22/+45
| | | | | | | | | | | | | | | | Summary: Added BraceBreakingStyle::BS_GNU. I'm not sure about the correctness of static initializer formatting, but compound statements should be fine. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2372 llvm-svn: 197138
* clang-format: Correctly handle Qt's Q_SLOTS.Daniel Jasper2013-11-291-1/+2
| | | | | | This should fix llvm.org/PR17241. Maybe it sticks this time :-). llvm-svn: 195953
* clang-format: Support Qt's slot access specifiers.Daniel Jasper2013-11-231-0/+3
| | | | | | This fixes llvm.org/PR17241. llvm-svn: 195555
* clang-format: Recognize braced lists with trailing function call.Daniel Jasper2013-11-221-1/+1
| | | | | | | | | | | Before: int count = set<int> { f(), g(), h() } .size(); After: int count = set<int>{f(), g(), h()}.size(); llvm-svn: 195417
* Added an option to allow short function bodies be placed on a single line.Alexander Kornienko2013-11-201-0/+1
| | | | | | | | | | | | | | | | | | | Summary: The AllowShortFunctionsOnASingleLine option now controls short function body placement on a single line independent of the BreakBeforeBraces option. Updated tests using BreakBeforeBraces other than BS_Attach. Addresses http://llvm.org/PR17888 Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2230 llvm-svn: 195256
* Remove incorrect assert.Manuel Klimek2013-10-221-1/+0
| | | | | | | | | | If we run into the second preprocessor branch chain, the first branch chain might have already set the maximum branch count on that level to something > 0. Fixes PR17645. llvm-svn: 193153
* Automatically munch semicolons after blocks.Manuel Klimek2013-10-121-2/+6
| | | | | | | | While it is mostly a user error to have the extra semicolon, formatting it graciously will correctly format in the cases where we do not fully understand the code (macros). llvm-svn: 192543
* clang-format: Fix assertion on unterminated #ifs.Daniel Jasper2013-10-121-1/+1
| | | | llvm-svn: 192535
* Support formatting of preprocessor branches.Manuel Klimek2013-10-111-26/+80
| | | | | | | | | | | | | | | | | | | | | 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(); } llvm-svn: 192503
* Fix incorrect detection of class definitions with alignas specification.Manuel Klimek2013-10-071-1/+2
| | | | llvm-svn: 192094
* clang-format: Detect braced lists in subscript expressions.Daniel Jasper2013-09-131-1/+1
| | | | | | | | | | Before (even with Style.Cpp11BracedListStyle): f(MyMap[{ composite, key }]); After: f(MyMap[{composite, key}]); llvm-svn: 190678
* clang-format: Fix incorrect enum parsing / layouting.Daniel Jasper2013-09-131-38/+15
| | | | | | | | | | | | | | | Before: enum { Bar = Foo < int, int > ::value }; After: enum { Bar = Foo<int, int>::value }; llvm-svn: 190674
* clang-format: Format typed enums with nested names.Daniel Jasper2013-09-061-1/+2
| | | | | | | | | The explicit type specified for an enum can actually have a nested name specifier. This fixes llvm.org/PR17125. llvm-svn: 190208
* clang-format: Don't confuse operator[] with lambdas.Daniel Jasper2013-09-061-1/+2
| | | | | | | | | | | | | Before: double &operator[](int i) { return 0; } int i; After: double &operator[](int i) { return 0; } int i; This fixes llvm.org/PR17134. llvm-svn: 190207
* Add ATTRIBUTE_UNUSED to silence unused-function warning in releaseDaniel Jasper2013-09-051-1/+2
| | | | | | builds. llvm-svn: 190061
* Fixes PR 17106 (explicitly typed enums are formatted differently).Manuel Klimek2013-09-051-3/+1
| | | | | | | | | | | | | | Before: enum X : int { A, B, C }; After: enum X : int { A, B, C }; llvm-svn: 190054
* clang-format: Quickfix for braced init lists detected as lambdas.Daniel Jasper2013-09-051-0/+6
| | | | | | | | | | Before: constexpr char hello [] { "hello" }; After: constexpr char hello[]{ "hello" }; llvm-svn: 190046
* clang-format: Fix parsing and indenting lambdas.Daniel Jasper2013-09-051-24/+32
| | | | | | | | | | | | | | | | Before: void f() { other(x.begin(), x.end(), // [&](int, int) { return 1; }); } After: void f() { other(x.begin(), x.end(), // [&](int, int) { return 1; }); } llvm-svn: 190039
* clang-format: Enable formatting of nested blocks.Daniel Jasper2013-09-051-18/+40
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 190038
* Remove code duplication in unwrapped line parser.Manuel Klimek2013-09-041-10/+1
| | | | llvm-svn: 189933
* Implement parsing of blocks (^{ ... }) in the unwrapped line parser.Manuel Klimek2013-09-041-14/+30
| | | | | | | | | | | | | | | | | | | | | | This patch makes sure we produce the right number of unwrapped lines, a follow-up patch will make the whitespace formatting consistent. Before: void f() { int i = {[operation setCompletionBlock : ^{ [self onOperationDone]; }] } ; } After: void f() { int i = {[operation setCompletionBlock : ^{ [self onOperationDone]; }] }; } llvm-svn: 189932
* Fix layout of lambda captures.Manuel Klimek2013-09-041-8/+11
| | | | | | | | | | | | | | | | | | Before: int c = [ &, &a, a]{ [ =, c, &d]{ return b++; }(); }(); After: int c = [&, &a, a] { [=, c, &d] { return b++; }(); }(); llvm-svn: 189924
* First step towards correctly formatting lambdas.Manuel Klimek2013-09-031-0/+80
| | | | | | | | | | Implements parsing of lambdas in the UnwrappedLineParser. This introduces the correct line breaks; the formatting of lambda captures are still incorrect, and the braces are also still formatted as if they were braced init lists instead of blocks. llvm-svn: 189818
* clang-format: Fix case-indentation in macros.Daniel Jasper2013-09-021-4/+3
| | | | | | | | | | | | | | Before: #define OPERATION_CASE(name) \ case OP_name: \ return operations::Operation##name After: #define OPERATION_CASE(name) \ case OP_name: \ return operations::Operation##name llvm-svn: 189743
* clang-format: Improve recovery from enums with errors.Daniel Jasper2013-08-301-0/+11
| | | | | | | | | | | | | | | | | | | | | | Before: namespace n { enum Type { One, Two, // missing }; int i; } void g() { } After: namespace n { enum Type { One, Two, // missing }; int i; } void g() {} llvm-svn: 189662
OpenPOWER on IntegriCloud