summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/WhitespaceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Stop aligning trailing comments which are aligned with the next line.Manuel Klimek2013-05-231-1/+15
| | | | | | | | | | | | | | | | | | | | | | | Previously we would align: f(); // comment // other comment g(); Even if // other comment was at the start of the line. Now we do not align trailing comments if they have been already aligned correctly with the next line. Thus, f(); // comment // other comment g(); will not be changed, while: f(); // comment // other commment g(); will lead to the two trailing comments being aligned. llvm-svn: 182577
* Use a SourceRange for the whitespace location in FormatToken.Manuel Klimek2013-05-231-11/+6
| | | | | | | | | | | Replaces the use of WhitespaceStart + WhitspaceLength. This made a bug in the formatter obvous where we would incorrectly calculate the next column. FIXME: There's a similar bug left regarding TokenLength. We should probably also move to have a TokenRange instead. llvm-svn: 182572
* Fix uninitialized access error found by valgrind.Manuel Klimek2013-05-221-0/+3
| | | | llvm-svn: 182476
* Makes whitespace management more consistent.Manuel Klimek2013-05-221-142/+200
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of selectively storing some changes and directly generating replacements for others, we now notify the WhitespaceManager of the whitespace before every token (and optionally with more changes inside tokens). Then, we run over all whitespace in the very end in original source order, where we have all information available to correctly align comments and escaped newlines. The future direction is to pull more of the comment alignment implementation that is now in the BreakableToken into the WhitespaceManager. This fixes a bug when aligning comments or escaped newlines in unwrapped lines that are handled out of order: #define A \ f({ \ g(); \ }); ... now gets correctly layouted. llvm-svn: 182467
* Fix style according to post-commit review comments.Manuel Klimek2013-05-131-2/+2
| | | | llvm-svn: 181701
* Implements UseTab for clang-format.Manuel Klimek2013-05-131-2/+10
| | | | | | This is required for kernel linux kernel style formatting. llvm-svn: 181693
* Add option to align escaped newlines left.Daniel Jasper2013-04-251-38/+80
| | | | | | | | | | | | | | | This enables formattings like: #define A \ int aaaa; \ int b; \ int ccc; \ int dddddddddd; Enabling this for Google/Chromium styles only as I don't know whether it is desired for Clang/LLVM. llvm-svn: 180253
* Unified token breaking logic: support for line comments.Alexander Kornienko2013-04-171-63/+9
| | | | | | | | | | | | | | | | | | | Summary: Added BreakableLineComment, moved common code from BreakableBlockComment to newly added BreakableComment. As a side-effect of the rewrite, found another problem with escaped newlines and had to change code which removes trailing whitespace from line comments not to break after this patch. Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D682 llvm-svn: 179693
* Unified token breaking logic for strings and block comments.Alexander Kornienko2013-04-151-0/+223
Summary: Both strings and block comments are broken into lines in breakProtrudingToken. Logic specific for strings or block comments is abstracted in implementations of the BreakToken interface. Among other goodness, this change fixes placement of backslashes after a block comment inside a preprocessor directive (see removed FIXMEs in unit tests). The code is far from being polished, and some parts of it will be changed for line comments support. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D665 llvm-svn: 179526
OpenPOWER on IntegriCloud