summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix crasher bug in clang-format.Manuel Klimek2014-08-131-1/+4
| | | | llvm-svn: 215549
* clang-format: Format long lists in columns if without bin-packing.Daniel Jasper2014-08-131-3/+5
| | | | | | | | | | | | | | | | After (even with BinPacking = false): const Aaaaaa aaaaa = { aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk, aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk, }; Before: <each element on its own line> This fixes http://llvm.org/PR20623. llvm-svn: 215529
* clang-format: Understand #defines defining system includes.Daniel Jasper2014-08-131-2/+12
| | | | | | | | | | Before: #define MY_IMPORT < a / b > After: #define MY_IMPORT <a/b> llvm-svn: 215527
* clang-format: Avoid bad line break.Daniel Jasper2014-08-121-2/+3
| | | | | | | | | | | | | Before: int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa); After: int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa); llvm-svn: 215442
* Fixes bug 20587 - Add K&R break before braces styleRoman Kashitsyn2014-08-111-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: http://llvm.org/bugs/show_bug.cgi?id=20587 Added K&R style. It could be enabled by the following option: ``` BreakBeforeBraces: KernighanRitchie ``` This style is like `Attach`, but break *only* before function declarations. As I can see, no additional logic required to support this style, any style different from other styles automagically satisfies K&R. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D4837 llvm-svn: 215354
* Use std::unique_ptr to handle transient ownership of UnwrappedLine in ↵David Blaikie2014-08-091-6/+5
| | | | | | ScopedLineState llvm-svn: 215294
* clang-format: Prefer not to put lambdas on a single line.Daniel Jasper2014-08-081-0/+2
| | | | | | | | | | | | | | Before: string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() { SomeOtherFunctioooooooooooooooooooooooooon(); }); After: string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() { SomeOtherFunctioooooooooooooooooooooooooon(); }); llvm-svn: 215197
* FormatTokenLexer: Avoid non-static member initializer.NAKAMURA Takumi2014-08-061-2/+2
| | | | llvm-svn: 214976
* clang-format: Correct SBPO_Always-behavior after function-like keywordsDaniel Jasper2014-08-062-1/+21
| | | | | | | | | | | | | | | | | Before: auto f (int x) -> decltype(x) { return sizeof(x); } int g () noexcept(someCall ()); static_assert(sizeof(char) == 1, "Your compiler is broken"); After: auto f (int x) -> decltype (x) { return sizeof (x); } int g () noexcept (someCall ()); static_assert (sizeof (char) == 1, "Your compiler is broken"); This fixes llvm.org/PR20559. Patch by Roman Kashitsyn, thank you! llvm-svn: 214969
* clang-format: Add special comments to disable formatting.Daniel Jasper2014-08-061-0/+7
| | | | | | | | | | | | | | | | With this patch: int ThisWillBeFormatted; // clang-format off int ThisWontBeFormatted; // clang-format on int Formatted; This is for regions where a significantly nicer code layout can be found knowing the content of the code. This fixes llvm.org/PR20463. llvm-svn: 214966
* clang-format: Fix indentation in multi-line placement new.Daniel Jasper2014-08-061-0/+3
| | | | | | | | | | | | | | Before: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214964
* [PR19983] SBPO_Always not covering all the cases.Chad Rosier2014-08-051-1/+1
| | | | | | | Patch by "Roman Kashitsyn" <romankashicin@gmail.com>. Phabricator revision: http://reviews.llvm.org/D4788 llvm-svn: 214904
* clang-format: Add option to always break after a function's return type.Daniel Jasper2014-08-052-0/+9
| | | | | | | | | | This is required for GNU coding style, among others. Also update the configuration documentation. Modified from an original patch by Jarkko Hietaniemi, thank you! llvm-svn: 214858
* clang-format: Break before 'else' in Stroustrup style.Daniel Jasper2014-08-051-0/+2
| | | | | | | | | Seems to be the desired thing to do according to: http://www.stroustrup.com/Programming/PPP-style-rev3.pdf Patch by Jarkko Hietaniemi, thank you! llvm-svn: 214857
* clang-format: Understand parameter pack initialization.Daniel Jasper2014-08-041-1/+1
| | | | | | | | | | Before: Constructor(A... a) : a_(X<A> { std::forward<A>(a) }...) {} After: Constructor(A... a) : a_(X<A>{std::forward<A>(a)}...) {} llvm-svn: 214720
* clang-format: Add a space in ObjC protocols.Daniel Jasper2014-08-011-4/+5
| | | | | | | | | | Before: @interface Foo (HackStuff)<MyProtocol> After: @interface Foo (HackStuff) <MyProtocol> llvm-svn: 214508
* Fix parsing of classes where the class name is an absolute nested name ↵Manuel Klimek2014-07-311-4/+2
| | | | | | specifier. llvm-svn: 214393
* clang-format: Understand 'typename' in placement new.Daniel Jasper2014-07-301-1/+2
| | | | | | | | | | | | Before: new (aaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214300
* clang-format: [proto] Improve formatting of text-proto options.Daniel Jasper2014-07-282-3/+6
| | | | | | Initial patch and tests by Kaushik Sridharan, thank you! llvm-svn: 214084
* clang-format: Improve operator and template recognition.Daniel Jasper2014-07-281-7/+3
| | | | | | | | | | Before: static_assert(is_convertible < A &&, B > ::value, "AAA"); After: static_assert(is_convertible<A &&, B>::value, "AAA"); llvm-svn: 214075
* clang-format: Improve pointer/reference detection.Daniel Jasper2014-07-281-1/+2
| | | | | | | | | | Before (with left pointer alignment): void f(int i = 0, SomeType* *temps = NULL); After: void f(int i = 0, SomeType** temps = NULL); llvm-svn: 214071
* clang-format: Fix unary operator recognition.Daniel Jasper2014-07-281-1/+1
| | | | | | | | | | Before: int x = ~ * p; After: int x = ~*p; llvm-svn: 214070
* clang-format: Fix formatting of lock annotations in lambda definitions.Daniel Jasper2014-07-281-0/+4
| | | | | | | | | | Before: SomeFunction([](int i)LOCKS_EXCLUDED(a) {}); After: SomeFunction([](int i) LOCKS_EXCLUDED(a) {}); llvm-svn: 214069
* Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ↵David Blaikie2014-07-191-2/+1
| | | | | | | | | | | ".reset()" It's also possible to just write "= nullptr", but there's some question of whether that's as readable, so I leave it up to authors to pick which they prefer for now. If we want to discuss standardizing on one or the other, we can do that at some point in the future. llvm-svn: 213439
* clang-format: Fix parsing of conditional expressions.Daniel Jasper2014-07-171-1/+1
| | | | | | | | | | | | | | | Before: aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 213258
* clang-format: Improve heuristic around avoiding bad line breaks.Daniel Jasper2014-07-151-1/+2
| | | | | | | | | | | Now, this can be properly formatted: static_cast<A< // B> *>( // ); Before, clang-format could end up, not formatting the code at all. llvm-svn: 213055
* Fix typosAlp Toker2014-07-141-1/+1
| | | | | | Also consolidate 'backward compatibility' llvm-svn: 212974
* clang-format: Improve cast detection (fix false positive).Daniel Jasper2014-07-141-0/+2
| | | | | | | | | | Before: fn(a)(b)+1; After: fn(a)(b) + 1; llvm-svn: 212935
* clang-format: Fix behavior around pointer-to-member invocations.Daniel Jasper2014-07-092-4/+5
| | | | | | | | | | | | Before: (aaaaaaaaaa->* bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); After: (aaaaaaaaaa->*bbbbbbb)( aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); llvm-svn: 212617
* clang-format: Add new option to indent wrapped function declarations.Daniel Jasper2014-07-092-2/+8
| | | | | | | | | Though not completely identical, make former IndentFunctionDeclarationAfterType change this flag for backwards compatibility (it is somewhat close in meaning and better the err'ing on an unknown config flag). llvm-svn: 212597
* clang-format: Revamp function declaration/definition indentation.Daniel Jasper2014-07-095-19/+53
| | | | | | | | | | | | | | Key changes: - Correctly (well ...) distinguish function declarations and variable declarations with ()-initialization. - Don't indent when breaking function declarations/definitions after the return type. - Indent variable declarations and typedefs when breaking after the type. This fixes llvm.org/PR17999. llvm-svn: 212591
* Update for llvm api change.Rafael Espindola2014-07-061-5/+6
| | | | llvm-svn: 212408
* clang-format: Support member function reference qualifiers.Daniel Jasper2014-06-301-1/+1
| | | | | | | | | | | | | Before: string // break operator()() & {} After: string // break operator()() & {} llvm-svn: 212041
* clang-format: Improve expression heuristics.Daniel Jasper2014-06-301-0/+2
| | | | | | | | | | | | | Upon encountering a binary operator inside parentheses, assume that the parentheses contain an expression. Before: MACRO('0' <= c&& c <= '9'); After: MACRO('0' <= c && c <= '9'); llvm-svn: 212040
* clang-format: [JS] support free-standing functions again.Daniel Jasper2014-06-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | This worked initially but was broken by r210887. Before: function outer1(a, b) { function inner1(a, b) { return a; } inner1(a, b); } function outer2(a, b) { function inner2(a, b) { return a; } inner2(a, b); } After: function outer1(a, b) { function inner1(a, b) { return a; } inner1(a, b); } function outer2(a, b) { function inner2(a, b) { return a; } inner2(a, b); } Thanks to Adam Strzelecki for working on this. llvm-svn: 212038
* clang-format: Understand that breaking before lambdas is fine.Daniel Jasper2014-06-241-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([]( const aaaaaaaaaa &a) { return a; }); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( [](const aaaaaaaaaa &a) { return a; }); llvm-svn: 211575
* clang-format: [proto] Add required space before absolute references.Daniel Jasper2014-06-231-0/+4
| | | | llvm-svn: 211488
* clang-format: Fix corner case in pointer/reference detection.Daniel Jasper2014-06-231-0/+2
| | | | llvm-svn: 211487
* clang-format: Introduce style with spaces on both sides of */&.Daniel Jasper2014-06-172-16/+32
| | | | | | | Patch by Janusz Sobczak (slightly extended). This fixes llvm.org/19929. llvm-svn: 211098
* clang-format: [JS] Understand named function literals.Daniel Jasper2014-06-131-0/+5
| | | | | | | | | | | | | | | | | | | Before: return {a: function SomeFunction(){// ... return 1; } } ; After: return { a: function SomeFunction() { // ... return 1; } }; llvm-svn: 210887
* Permit -Wswitch coverage for enumerations.Saleem Abdulrasool2014-06-121-1/+1
| | | | | | | | Thanks to David Blakie and Richard Smith for pointing out that we can retain the -Wswitch coverage while avoiding the warning from GCC by pushing the unreachable outside of the switch! llvm-svn: 210812
* Basic: fix warnings from GCCSaleem Abdulrasool2014-06-121-0/+1
| | | | | | | | | | | | tools/clang/lib/Basic/DiagnosticIDs.cpp: In function ‘clang::DiagnosticIDs::Level toLevel(clang::diag::Severity)’: tools/clang/lib/Basic/DiagnosticIDs.cpp:382:1: warning: control reaches end of non-void function [-Wreturn-type] tools/clang/lib/Format/Format.cpp: In member function ‘virtual std::string clang::format::ParseErrorCategory::message(int) const’: tools/clang/lib/Format/Format.cpp:282:1: warning: control reaches end of non-void function [-Wreturn-type] Add a default cases that asserts that we handle the severity, parse error. llvm-svn: 210804
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-4/+4
| | | | llvm-svn: 210780
* Fix typo.Rafael Espindola2014-06-121-2/+2
| | | | | | Thanks to Alp Toker for noticing. llvm-svn: 210744
* Give clang-format its own error category.Rafael Espindola2014-06-121-6/+29
| | | | | | | | | The posix errno values are probably to the best thing to use for describing parse errors. This should also fix the mingw build. llvm-svn: 210739
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-111-5/+5
| | | | | | This is an update for a llvm api change. llvm-svn: 210688
* clang-format: Fix pointer/reference detection after decltype.Daniel Jasper2014-06-111-1/+2
| | | | | | | | | | Before: [](const decltype(*a) & value) {} After: [](const decltype(*a)& value) {} llvm-svn: 210643
* clang-format: [JS] Treat dict literals similar to objc method exprs.Daniel Jasper2014-06-103-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } } After: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } }; llvm-svn: 210537
* clang-format: Increase penalty for wrapping array subscript expressionsDaniel Jasper2014-06-101-1/+1
| | | | | | | | | | | | | Before: aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0].aaaaaaa [0].aaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0] .aaaaaaa[0] .aaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 210529
* clang-format: Fix enum formatting with specific comment.Daniel Jasper2014-06-101-1/+3
| | | | | | | | | | | | | | | Before: enum Fruit { // APPLE, PEAR }; After: enum Fruit { // APPLE, PEAR }; llvm-svn: 210522
OpenPOWER on IntegriCloud