summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [Java] Support try blocks with resources.Daniel Jasper2015-01-142-1/+6
| | | | | | | | | | | | | | | Before: try (SomeResource rs = someFunction()) { Something(); } After: try (SomeResource rs = someFunction()) { Something(); } llvm-svn: 225973
* clang-format: [Java] Prefer not to break in parameter annotations.Daniel Jasper2015-01-141-0/+2
| | | | | | | | | | | | | | Before: boolean someFunction(@Param(aaaaaaaaaaaaaaaa) String aaaaa, String bbbbbbbbbbbbbbb) {} After: boolean someFunction( @Param(aaaaaaaaaaaaaaaa) String aaaaa, String bbbbbbbbbbbbbbb) {} llvm-svn: 225971
* clang-format: [Java] Understand "import static".Daniel Jasper2015-01-141-1/+2
| | | | llvm-svn: 225965
* clang-format: [Java] Don't let annotations confuse return type analysis.Daniel Jasper2015-01-141-0/+3
| | | | | | | | | | | | | | Before: @Test ReturnType doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {} After: @Test ReturnType doSomething( String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {} llvm-svn: 225964
* clang-format: [Java] Don't line-wrap before annotations' l_parens.Daniel Jasper2015-01-141-1/+1
| | | | | | | | | | | | | | Before: @SomeAnnotation (aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa) int i; After: @SomeAnnotation( aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa) int i; llvm-svn: 225963
* clang-format: [Java] Don't get confused by leading annotations.Daniel Jasper2015-01-141-1/+2
| | | | | | | | | | | | | | Before: @Test(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa); After: @Test(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 225962
* clang-format: [Java] Detect `native` keyword.Nico Weber2015-01-132-1/+4
| | | | | | | | | | Before: public native<X> Foo foo(); After: public native <X> Foo foo(); llvm-svn: 225839
* Fix assertion in BreakableBlockComment (http://llvm.org/PR21916).Alexander Kornienko2015-01-122-1/+7
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6894 llvm-svn: 225628
* clang-format: Improve format of lambdas in ctor initializers.Daniel Jasper2015-01-121-0/+1
| | | | | | | | | | | | | | | | Before: Constructor() : Constructor([] { // comment int i; }) {} After: Constructor() : Constructor([] { // comment int i; }) {} llvm-svn: 225625
* clang-format: Fix formatting of inline asm.Daniel Jasper2015-01-121-2/+2
| | | | | | | | | Specifically, adjust the leading "__asm {" and trailing "}" while still leaving the assembly inside it alone. This fixes llvm.org/PR22190. llvm-svn: 225623
* clang-format: [Java] Support formatting qualified annotations.Nico Weber2015-01-092-23/+35
| | | | llvm-svn: 225559
* clang-format: Force line break between "endl" and "<<".Daniel Jasper2015-01-081-28/+26
| | | | | | | | | | | | | | | | This makes piped output easier to read in many instances. Before: llvm::errs() << aaaa << std::endl << bbbb << std::endl; After: llvm::errs() << aaaa << std::endl << bbbb << std::endl; Also fix a few instance of "don't use else after return" as per the coding standards. llvm-svn: 225444
* clang-format: Improve template parameter detection.Daniel Jasper2015-01-081-2/+5
| | | | | | | | | | Before: struct A < std::enable_if<sizeof(T2) <sizeof(int32)>::type>; After: struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>; llvm-svn: 225435
* clang-format: Let Chromium use the Google default for AlignTrailingComments.Nico Weber2015-01-071-1/+0
| | | | | | | | | | | r225141 changed the defaults of AllowShortIfStatementsOnASingleLine and AlignTrailingComments for Google style and added explicit overrides for Chromium style to undo these changes. For AllowShortIfStatementsOnASingleLine that's good as the Android style guide (which Chromium uses for Java) explicitly permits single-line ifs. But it's silent on trailing comments, to it makes sense for Chromium style to just follow Google style. llvm-svn: 225363
* clang-format: Understand single-line comments at the end of blocks.Daniel Jasper2015-01-071-4/+6
| | | | | | | | | | | This prevents clang-format from moving/aligning the comment in the snippet: void f() { int i; // some comment // some unrelated comment } llvm-svn: 225352
* clang-format: Fix unary operator detection.Daniel Jasper2015-01-071-4/+4
| | | | | | | | | | Before: ** outparam = 1; After: **outparam = 1; llvm-svn: 225349
* clang-format: [Java] Fix incorrect detection of cast.Daniel Jasper2015-01-051-0/+2
| | | | | | | | | | | | | | After: return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaaaaaaaaaaaaaaa; After: return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 225161
* clang-format: [Java] Fix incorrect recognition of annonymous classes.Daniel Jasper2015-01-041-2/+3
| | | | | | | | | | | | | | | | Before: someFunction(new Runnable() { public void run() { System.out.println(42); } }); After: someFunction(new Runnable() { public void run() { System.out.println(42); } }); llvm-svn: 225142
* clang-format: [Java] Change a few flags for Google's Java style.Daniel Jasper2015-01-041-0/+4
| | | | | | No tests added as all of these are already tested separately. llvm-svn: 225141
* clang-format: Re-enable comment re-indentation for Java/JS.Daniel Jasper2015-01-041-6/+6
| | | | | | This was broken by r224120. llvm-svn: 225130
* clang-format: Fix incorrect detection of ObjC "in" keyword.Daniel Jasper2014-12-181-1/+2
| | | | | | | | | | Before: for (auto v : in [1]) { .. After: for (auto v : in[1]) { .. llvm-svn: 224513
* Exclude printLineState() in -Asserts. [-Wunused-function]NAKAMURA Takumi2014-12-171-0/+2
| | | | llvm-svn: 224430
* clang-format: Fix incorrect calculation of token lenghts.Daniel Jasper2014-12-171-1/+0
| | | | | | This led, e.g. to break JavaScript regex literals too early. llvm-svn: 224419
* Don't break single-line raw string literals.Alexander Kornienko2014-12-141-20/+1
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6636 llvm-svn: 224223
* Don't break string literals in Java and JavaScript.Alexander Kornienko2014-12-121-0/+6
| | | | | | | | The proper way to break string literals in these languages is by inserting a "+" between parts which we don't support yet. So we disable string literal breaking until then. llvm-svn: 224120
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-124-84/+53
| | | | | | | | | | | | | | | | | | | | | | This fixed llvm.org/PR21804 and hopefully a few other strange cases. Before: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } After: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } llvm-svn: 224112
* clang-format: Factor out UnwrappedLineFormatter into a separate file.Daniel Jasper2014-12-104-773/+869
| | | | | | No functional changes intended. llvm-svn: 223936
* clang-format: Remove a few else after return statements.Daniel Jasper2014-12-101-19/+12
| | | | | | | They are against the LLVM coding conventions. No functional changes intended. llvm-svn: 223930
* clang-format: Indent correctly in conditional expressions after return.Daniel Jasper2014-12-081-1/+2
| | | | | | | | | | | | | | | | | | | This only applies when not aligning after the return itself (which is commonly done for C++. Before: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) // This is indented relative to aaaaaaaaaa. : b; After: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) : b; llvm-svn: 223694
* clang-format: [Java] Always break after annotations of multiline decls.Daniel Jasper2014-12-082-5/+6
| | | | | | | | | | | | | Before: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 223688
* clang-format: Support commas in lambda return types.Daniel Jasper2014-12-081-0/+1
| | | | | | | | | | Before: auto next_pair = [](A * a) -> pair<A*, A*>{}; After: auto next_pair = [](A* a) -> pair<A*, A*>{}; llvm-svn: 223652
* clang-format: Don't merge lines with comments.Daniel Jasper2014-12-071-0/+3
| | | | | | | | | | | | | | Before: int f() { // comment return 42; } After: int f() { // comment return 42; } This fixes llvm.org/PR21769. llvm-svn: 223609
* clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.Daniel Jasper2014-12-052-1/+8
| | | | | | This fixes llvm.org/PR21756. llvm-svn: 223458
* clang-format: [JS] Don't put top-level dict literals on a single line.Daniel Jasper2014-12-041-0/+3
| | | | | | | These are often used for enums which apparently are easier to read if formatted with one element per line. llvm-svn: 223367
* clang-format: More restrictively classify import declarations.Daniel Jasper2014-12-041-1/+2
| | | | | | | | | | | Before: import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 223345
* clang-format: Fix fake parentheses placement with comments.Daniel Jasper2014-12-031-1/+1
| | | | | | | | | | | | | | | | Before: return (a > b // comment1 // comment2 || c); After: return (a > b // comment1 // comment2 || c); llvm-svn: 223234
* clang-format: Fix expression parser not closing stuff at end of stmt.Daniel Jasper2014-12-031-10/+11
| | | | | | | | | | | | | | Uncovered by a Java test case: Before: public some.package.Type someFunction( // comment int parameter) {} After: public some.package.Type someFunction( // comment int parameter) {} llvm-svn: 223228
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-022-4/+12
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
* clang-format: precedence-based indentation when breaking before operators.Daniel Jasper2014-12-021-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; After: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; Not particularly pretty, but can probably help to uncover bugs. And if this bugs somebody, parentheses can help. llvm-svn: 223111
* clang-format: [JS] Contract fewer functions to a single line.Daniel Jasper2014-11-271-2/+3
| | | | | | | | | | | | | Before: var someVariable = function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); }; After: var someVariable = function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); }; llvm-svn: 222893
* clang-format: [JS] Try not to break in container literals.Daniel Jasper2014-11-271-0/+2
| | | | | | | | | | | | | | | | | Before: var obj = { fooooooooo: function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); } }; After: var obj = { fooooooooo: function(x) { return x.zIsTooLongForOneLineWithTheDeclarationLine(); } }; llvm-svn: 222892
* clang-format: [JS] new and delete are valid function names.Daniel Jasper2014-11-271-3/+2
| | | | | | | | | | | | Before: someObject.new (); someObject.delete (); After: someObject.new(); someObject.delete(); llvm-svn: 222890
* clang-format: [JS] Make Closure module detection more narrow.Daniel Jasper2014-11-271-1/+2
| | | | | | | | | | | Before: var MyLongClassName = goog.module.get('my.long.module.name.followedBy.MyLongClassName'); After: var MyLongClassName = goog.module.get('my.long.module.name.followedBy.MyLongClassName'); llvm-svn: 222888
* clang-format: Don't use column layout with AlignAfterOpenBrackets.Daniel Jasper2014-11-271-0/+4
| | | | | | This fixes llvm.org/PR21676. llvm-svn: 222886
* clang-format: [Java] Don't line-wrap package declarations.Daniel Jasper2014-11-262-2/+6
| | | | | | This fixes llvm.org/PR21677. llvm-svn: 222843
* clang-format: Tweak -style=Chromium for Java files.Nico Weber2014-11-261-6/+11
| | | | | | | | | | | For Java, don't do any of the deviations from Google Style that Chromium style does for C++. Chromium's Java follows Android Java style [1], which is roughly Google Java style with an indent of 4 and a continuation indent of 8. 1: https://source.android.com/source/code-style.html llvm-svn: 222839
* clang-format: [Java] Improve formatting of throws declarations.Daniel Jasper2014-11-261-2/+3
| | | | | | | | | | | | Before: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} After: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} llvm-svn: 222829
* clang-format: [Java] Improve cast detection.Daniel Jasper2014-11-261-3/+7
| | | | | | | | | | Before: a[b >> 1] = (byte)(c() << 4); After: a[b >> 1] = (byte) (c() << 4); llvm-svn: 222827
* clang-format: [Java] Fix breaking after annotations.Daniel Jasper2014-11-261-1/+2
| | | | | | | | | | | | | Before: @Annotation1 // comment @Annotation2 class C {} After: @Annotation1 // comment @Annotation2 class C {} llvm-svn: 222825
* clang-format: Add SFS_Empty to only empty functions on a single line.Daniel Jasper2014-11-261-2/+6
| | | | | | | | Activated for and tested by Google's Java style. This fixes llvm.org/PR21667. llvm-svn: 222819
OpenPOWER on IntegriCloud