summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/WhitespaceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Fix infinite loop in macro special case.Daniel Jasper2013-08-281-6/+4
| | | | | | | | | | | | | | If escaped newlines are aligned right (FormatStyle.AlignEscapedNewlinesLeft == false), and a line contained too many characters to fit into the column limit, this would result in a (virtually) endless loop creating a negative number of spaces. Instead, allow the escaped newlines to be pushed past the column limit in this case. This fixes llvm.org/PR16515. llvm-svn: 189459
* clang-format: Make alignment of trailing comments optional ..Daniel Jasper2013-07-311-3/+3
| | | | | | .. in order to support WebKit style properly. llvm-svn: 187549
* Reformat clang-format's source files after r185822 and others.Daniel Jasper2013-07-081-9/+8
| | | | llvm-svn: 185823
* Don't align "} // namespace" comments.Daniel Jasper2013-07-011-7/+17
| | | | | | | | | | | | | | | | This is not all bad, but people are often surprised by it. Before: namespace { int SomeVariable = 0; // comment } // namespace After: namespace { int SomeVariable = 0; // comment } // namespace llvm-svn: 185327
* Fixes incorrect indentation of line comments after break and re-alignment.Alexander Kornienko2013-06-171-4/+7
| | | | | | | | | | | | | | | | | | | Summary: Selectively propagate the information about token kind in WhitespaceManager::replaceWhitespaceInToken.For correct alignment of new segments of line comments in order to align them correctly. Don't set BreakBeforeParameter in breakProtrudingToken for line comments, as it introduces a break after the _next_ parameter. Added tests for related functions. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D980 llvm-svn: 184076
* Insert a space at the start of a line comment in case it starts with an ↵Alexander Kornienko2013-06-111-17/+16
| | | | | | | | | | | | | | | | | | | | alphanumeric character. Summary: "//Test" becomes "// Test". This change is aimed to improve code readability and conformance to certain coding styles. If a comment starts with a non-alphanumeric character, the space isn't added, e.g. "//-*-c++-*-" stays unchanged. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D949 llvm-svn: 183750
* The second step in the token refactoring.Manuel Klimek2013-05-291-4/+3
| | | | | | | | | | Gets rid of AnnotatedToken, putting everything into FormatToken. FormatTokens are created once, and only referenced by pointer. This enables multiple future features, like having tokens shared between multiple UnwrappedLines (while there's still work to do to fully enable that). llvm-svn: 182859
* Make UnwrappedLines and AnnotatedToken contain pointers to FormatToken.Manuel Klimek2013-05-281-4/+4
| | | | | | The FormatToken is now not copyable any more. llvm-svn: 182772
* Major refactoring of BreakableToken.Manuel Klimek2013-05-271-19/+0
| | | | | | | | | | | | | | | | | | | Unify handling of whitespace when breaking protruding tokens with other whitespace replacements. As a side effect, the BreakableToken structure changed significantly: - have a common base class for single-line breakable tokens, as they are much more similar - revamp handling of multi-line comments; we now calculate the information about lines in multi-line comments similar to normal tokens, and always issue replacements As a result, we were able to get rid of special casing of trailing whitespace deletion for comments in the whitespace manager and the BreakableToken and fixed bugs related to tab handling and escaped newlines. llvm-svn: 182738
* Fix aligning of comments.Manuel Klimek2013-05-231-4/+5
| | | | | | | | | | | | | | | | | Previously we started sequences to align for single line comments when the previous line had a trailing comment, but the sequence was broken for other reasons. Now we re-format: // a // b f(); // c to: // a // b f(); // c llvm-svn: 182608
* Fix aligning of comments that are at the start of the line.Manuel Klimek2013-05-231-3/+4
| | | | | | | | | | Now correctly leaves: f(); // comment // comment g(); // comment ... alone if the middle comment was aligned with g() before formatting. llvm-svn: 182605
* 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