summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatToken.h
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Add column layout formatting for braced listsDaniel Jasper2013-08-221-0/+83
| | | | | | | | | | | | | | | | | | | | 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
* clang-format: Add two new style options to support WebKit style.Daniel Jasper2013-07-261-0/+1
| | | | | | | | | | | | | New options: * Break before the commas of constructor initializers and align the commas with the colon. * Break before binary operators Additionally, for styles without column limit, don't just accept linebreaks done by the user, but instead remove 'invalid' (according to the current style) linebreaks and add 'required' ones. llvm-svn: 187210
* clang-format: Improve handling of unterminated string literals.Daniel Jasper2013-07-161-5/+9
| | | | | | | Before, clang-format would simply eat these as they were recognized as whitespace. With this patch, they are mostly left alone. llvm-svn: 186454
* Add experimental flag for adaptive parameter bin-packing.Daniel Jasper2013-07-101-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | 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
* Fix alignment of closing brace in braced initializers.Daniel Jasper2013-07-091-4/+15
| | | | | | | | | | | | | | | | | | | | | | 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
* Reformat clang-format's source files after r185822 and others.Daniel Jasper2013-07-081-1/+0
| | | | llvm-svn: 185823
* Fixed typo: NoneComment -> NonComment, no other changes.Alexander Kornienko2013-07-041-2/+2
| | | | llvm-svn: 185640
* Use LLVM_DELETED_FUNCTION on unimplemented copy constructor and assignment ↵Craig Topper2013-07-011-2/+2
| | | | | | operator. llvm-svn: 185302
* Fix a comment.Nico Weber2013-06-251-1/+1
| | | | llvm-svn: 184873
* Improved handling of escaped newlines at the token start.Alexander Kornienko2013-06-071-11/+5
| | | | | | | | | | | | | | 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
* UTF-8 support for clang-format.Alexander Kornienko2013-06-051-8/+13
| | | | | | | | | | | | | | | | | | | | Summary: Detect if the file is valid UTF-8, and if this is the case, count code points instead of just using number of bytes in all (hopefully) places, where number of columns is needed. In particular, use the new FormatToken.CodePointCount instead of TokenLength where appropriate. Changed BreakableToken implementations to respect utf-8 character boundaries when in utf-8 mode. Reviewers: klimek, djasper Reviewed By: djasper CC: cfe-commits, rsmith, gribozavr Differential Revision: http://llvm-reviews.chandlerc.com/D918 llvm-svn: 183312
* Moved FormatToken to a separate header.Alexander Kornienko2013-06-031-0/+281
llvm-svn: 183115
OpenPOWER on IntegriCloud