summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatToken.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Enable formatting of lambdas with explicit return type.Daniel Jasper2014-01-161-0/+30
| | | | | | | | | So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector<int> { return { 2 }; }(); llvm-svn: 199368
* clang-format: Some tweaks to braces list formatting:Daniel Jasper2014-01-091-13/+20
| | | | | | | | | - Format a braced list with one element per line if it has nested braced lists. - Use a column layout only when the list has 6+ elements (instead of the current 4+ elements). llvm-svn: 198869
* clang-format: Be more conservative about braced list column layout.Daniel Jasper2013-12-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically disable it for nested braced lists as it commonly can look really weird. Eventually, we'll want to become smarter and format some of the nested lists better. Before: SomeStruct my_struct_array = { { aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa, aaaaaaaaaa, aaaaaaaaaa, aaaaaaa, aaa }, { aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa }, { aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, a, aaaaaaaaaa, aaaaaaaaa, aaa }, }; After: SomeStruct my_struct_array = { { aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaaa, aaaaaaa, aaa }, { aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa }, { aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, a, aaaaaaaaaa, aaaaaaaaa, aaa }, }; llvm-svn: 196783
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* clang-format: Prefer column layout if possible.Daniel Jasper2013-11-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Add a severe penalty for not using column layout for braced lists. If there are solutions with column layout, these are generally preferable over bin-packed solutions. Before: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a }; After: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a }; llvm-svn: 195546
* clang-format: Be more conservative about column layout formatting.Daniel Jasper2013-10-241-1/+9
| | | | | | | | | | | Specifically, if a braced list has at least one nested braced list, format it either all on one line or in one column (i.e. one item per line). This seems in general to be an improvement as the structure of nested braced lists can make a tightly packed outer braced list hard to read. llvm-svn: 193345
* clang-format: Cleanup array initializer and dict initializer formatting.Daniel Jasper2013-10-241-0/+1
| | | | | | | | Significant changes: - Also recognize these literals with missing "@" for robustness. - Reorganize tests. llvm-svn: 193325
* Support formatting of preprocessor branches.Manuel Klimek2013-10-111-0/+1
| | | | | | | | | | | | | | | | | | | | | 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
* clang-format: Fix incorrect enum parsing / layouting.Daniel Jasper2013-09-131-0/+1
| | | | | | | | | | | | | | | Before: enum { Bar = Foo < int, int > ::value }; After: enum { Bar = Foo<int, int>::value }; llvm-svn: 190674
* Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.Alexander Kornienko2013-09-101-2/+2
| | | | | | | | | | | | | | | | Summary: This fixes various issues with mixed tabs and spaces handling, e.g. when realigning block comments. Reviewers: klimek, djasper Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1608 llvm-svn: 190395
* clang-format: Fix bug in column layout.Daniel Jasper2013-08-271-2/+6
| | | | | | | | | | | | Before (with 60 character limit in Google style): return { {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}}; After: return {{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}}; llvm-svn: 189327
* clang-format: Fix bug in column-layout formatting.Daniel Jasper2013-08-261-8/+8
| | | | | | | | | | Specific arrangements of comments after trailing commas could confuse the column width calculation, e.g. in: vector<int> x = { a, b, /* some */ /* comment */ }; llvm-svn: 189211
* clang-format: Handle trailing commas in column layout of braced list.Daniel Jasper2013-08-231-0/+5
| | | | | | | | | | Before, this was causing errors. Also exit early in breakProtrudingToken() (before the expensive call to SourceManager::getSpellingColumnNumber()). This makes formatting huge (100k+-item) braced lists possible. llvm-svn: 189094
* clang-format: Add column layout formatting for braced listsDaniel Jasper2013-08-221-0/+184
With this patch, braced lists (with more than 3 elements are formatted in a column layout if possible). E.g.: static const uint16_t CallerSavedRegs64Bit[] = { X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI, X86::R8, X86::R9, X86::R10, X86::R11, 0 }; Required other changes: - FormatTokens can now have a special role that contains extra data and can do special formattings. A comma separated list is currently the only implementation. - Move penalty calculation entirely into ContinuationIndenter (there was a last piece still in UnwrappedLineFormatter). Review: http://llvm-reviews.chandlerc.com/D1457 llvm-svn: 189018
OpenPOWER on IntegriCloud