summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineFormatter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: treat Q_SIGNALS as an access modifierDaniel Jasper2015-12-011-2/+2
| | | | | | Patch by Alexander Richardson, thank you! llvm-svn: 254407
* clang-format: Simplify and improve stop condition for formattingDaniel Jasper2015-11-021-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | unaffected lines with incorrect initial indent. Starting from: namespace { int i; // There shouldn't be indentation here. int j; // <- call clang-format on this line. } Before: namespace { int i; int j; } After: namespace { int i; int j; } llvm-svn: 251824
* clang-format: Be slightly more cautious when formatting subsequent lines ↵Daniel Jasper2015-11-011-4/+19
| | | | | | | | | | | | | | | | | after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing brace, e.g. while writing code in an editor. Summary: With this change, clang-format stops formatting when either it leaves the current scope or when it comes back to the initial scope after going into a nested one. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14213 llvm-svn: 251760
* clang-format: When a line is formatted, also format subsequence lines if ↵Daniel Jasper2015-10-281-2/+5
| | | | | | | | | | | | | | their indent is off. Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14105 llvm-svn: 251474
* clang-format: Increase cut-off limit for number of analyzed states.Daniel Jasper2015-10-271-1/+1
| | | | | | | | | | | With more complex structures in C++ Lambdas and JavaScript function literals, the old value was simply to small. However, this is a temporary solution, I need to look at this more closely a) to find a fundamentally better approach and b) to look at whether the more recent usage of NoLineBreak makes us visit stuff in an unfortunate order where clang-format waste many states in dead ends. llvm-svn: 251463
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-4/+3
| | | | | | | | | | | | | | | control the individual braces. The existing choices for brace wrapping are now merely presets for the different flags that get expanded upon calling the reformat function. All presets have been chose to keep the existing formatting, so there shouldn't be any difference in formatting behavior. Also change the dump_format_style.py to properly document the nested structs that are used to keep these flags discoverable among all the configuration flags. llvm-svn: 248802
* clang-format: Fix merging short case labels with comments.Daniel Jasper2015-09-211-1/+2
| | | | | | | | This fixes llvm.org/PR24877. Patch by Benjamin Daly, thank you! llvm-svn: 248145
* Re-commit r247218: "Fix Clang-tidy misc-use-override warnings, other minor ↵Hans Wennborg2015-09-101-3/+3
| | | | | | | | fixes" This never broke the build; it was the LLVM side, r247216, that caused problems. llvm-svn: 247302
* Revert r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"Hans Wennborg2015-09-101-3/+3
| | | | | | | | | | | Seems it broke the Polly build. From http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3-polly-fast/builds/11687/steps/compile/logs/stdio: In file included from /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/lib/TableGen/Record.cpp:14:0: /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:369:3: error: looser throw specifier for 'virtual llvm::TypedInit::~TypedInit()' /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:270:11: error: overriding 'virtual llvm::Init::~Init() noexcept (true)' llvm-svn: 247222
* Fix Clang-tidy misc-use-override warnings, other minor fixesHans Wennborg2015-09-101-3/+3
| | | | | | | | Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D12741 llvm-svn: 247218
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-2/+2
| | | | llvm-svn: 239903
* clang-format: NFC. Add a function to test whether an annotated lineDaniel Jasper2015-06-171-7/+6
| | | | | | | starts with a given sequence of tokens. Only the one-token version is used yet, but other usages are coming up momentarily. llvm-svn: 239892
* clang-format: Make SFS_Inline imply SFS_Empty.Daniel Jasper2015-06-111-1/+1
| | | | | | | | | | In the long run, these two might be independent or we might to only allow specific combinations. Until we have a corresponding request, however, it is hard to do the right thing and choose the right configuration options. Thus, just don't touch the options yet and just modify the behavior slightly. llvm-svn: 239531
* Fix crash in clang-format.Manuel Klimek2015-06-111-2/+4
| | | | | | | | | | | The following example used to crash clang-format. #define a\ /**/} Adjusting the indentation level cache for the line starting with the comment would lead to an out-of-bounds array read. llvm-svn: 239521
* clang-format: Fix child-formatting in macros.Daniel Jasper2015-05-261-4/+8
| | | | | | | | | | | | | | | This fixes a case where the column limit was incorrectly calculated leading to a macro like this: #define A \ [] { \ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx( \ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx); \ } exceeding the column limit. llvm-svn: 238182
* clang-format: Make member introduced in r237108 const.Daniel Jasper2015-05-121-2/+1
| | | | llvm-svn: 237114
* clang-format: Fix hanging nested blocks in macros.Daniel Jasper2015-05-121-2/+4
| | | | | | | | | | | | | | | | | | | | Before: #define MACRO() \ Debug(aaa, /* force line break */ \ { \ int i; \ int j; \ }) After: #define MACRO() \ Debug(aaa, /* force line break */ \ { \ int i; \ int j; \ }) llvm-svn: 237108
* Refactor clang-format's formatter.Manuel Klimek2015-05-121-135/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: a) Pull out a class LevelIndentTracker whose responsibility is to keep track of the indent of levels across multiple annotated lines. b) Put all responsibility for merging lines into the LineJoiner; make the LineJoiner iterate over the lines so we never operate on a line that might be merged later; this makes the interface safer to use. c) Move formatting of the end-of-file whitespace into formatFirstToken. Fix bugs that became obvious after the refactoring: 1. We would not format lines with offsets correctly inside nested blocks if only the outer expression was affected: int x = s({ // clang-format only this line class X { public: // ^ this starts at the non-modified indnent level; previously we would // not fix this, now we correctly outdent it. void f(); }; }); 2. We would incorrectly align comments across lines that do not have comments for lines with nested blocks: int expression; // with comment int x = s({ int y; // comment int z; // we would incorrectly align this comment with the comment on // 'expression' }); llvm-svn: 237104
* Refactor the formatter of clang-format.Manuel Klimek2015-05-111-214/+336
| | | | | | | | | | | | Pull various parts of the UnwrappedLineFormatter into their own abstractions. NFC. There are two things left for subsequent changes (to keep this reasonably small) - the UnwrappedLineFormatter now has a bad name - the UnwrappedLineFormatter::format function is still too large llvm-svn: 236974
* Implements a way to retrieve information about whether some lines were not ↵Manuel Klimek2015-05-071-2/+4
| | | | | | formatted due to syntax errors. llvm-svn: 236722
* clang-format: [JS] Do not collapse short interfaces.Daniel Jasper2015-05-051-1/+2
| | | | | | Patch by Martin Probst. llvm-svn: 236485
* clang-format: Don't merge short else blocks.Daniel Jasper2015-04-301-1/+6
| | | | | | | | | | | | | | | | | | | | | Before (with the appropriate flags settings): if (a) { f(); } else { g(); } Before (with other appropriate flags settings): if (a) { f(); } else { g(); } After: if (a) { f(); } else { g(); } llvm-svn: 236217
* clang-format: Fix selective indentaiton in nested blocks.Daniel Jasper2015-04-291-1/+3
| | | | | | | | | | | | Buggy case: someFunction( [] { // comment int i; // invoke formatting here. }, // force line break aaa); llvm-svn: 236091
* clang-format: Support nested block formatting with ColumnLimit=0.Daniel Jasper2015-04-231-3/+7
| | | | llvm-svn: 235580
* clang-format: Don't corrupt macros with open braces.Daniel Jasper2015-03-131-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Formatting: #define A { { #define B } } Before: #define A \ { \ { #define B } \ } After: #define A \ { \ { #define B \ } \ } This fixes llvm.org/PR22884. llvm-svn: 232166
* clang-format: Don't remove newline if macro ends in access specifier.Daniel Jasper2015-03-091-1/+2
| | | | | | | | | | | I.e.: #define A public: // The new line before this line would be removed. int a; llvm-svn: 231636
* clang-format: Format Objective-C try blocks like all the other try blocks.Nico Weber2015-02-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: @try { // ... } @finally { // ... } Now: @try { // ... } @finally { // ... } This is consistent with how we format C++ try blocks and SEH try blocks. clang-format not doing this before was an implementation oversight. This is dependent on BraceBreakingStyle. The snippet above is with the Attach style. Style Stroustrip for example still results in the "Before:" snippet, which makes sense since other blocks (try, else) break after '}' too. llvm-svn: 228483
* clang-format: Add support for SEH __try / __except / __finally blocks.Nico Weber2015-02-041-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | This lets clang-format format __try { } __except(0) { } and __try { } __finally { } correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set, so this turns this on. This also enables a few other keywords, but it shouldn't overly perturb regular clang-format operation. __except is a context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to a few more places. Fixes PR22321. llvm-svn: 228148
* clang-format: Fix crasher caused by not properly setting dry-run.Daniel Jasper2015-01-291-2/+2
| | | | llvm-svn: 227427
* clang-format: Fix another crasher caused by incomplete macro code.Daniel Jasper2015-01-231-5/+11
| | | | | | | | We did't properly mark all of an AnnotatedLine's children as finalized and thus would reformat the same tokens in different branches of #if/#else sequences leading to invalid replacements. llvm-svn: 226930
* Exclude printLineState() in -Asserts. [-Wunused-function]NAKAMURA Takumi2014-12-171-0/+2
| | | | llvm-svn: 224430
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-7/+12
| | | | | | | | | | | | | | | | | | | | | | 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-101-0/+699
No functional changes intended. llvm-svn: 223936
OpenPOWER on IntegriCloud