summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-294-54/+101
| | | | | | | | | | | | | | | 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: Extend #include sorting functionalityDaniel Jasper2015-09-291-10/+42
| | | | | | | | | Recognize the main module header as well as different #include categories. This should now mimic the behavior of llvm/utils/sort_includes.py as well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very closely. llvm-svn: 248782
* clang-format: [JS] Support pseudo-keywordsDaniel Jasper2015-09-282-1/+6
| | | | | | | | | JavaScript allows keywords to appear in IdenfierName positions, e.g. fields, or object literal members, but not as plain identifiers. Patch by Martin Probst. Thank you! llvm-svn: 248714
* clang-format: [JS] handle let (ES6)Daniel Jasper2015-09-283-4/+7
| | | | | | Patch by Martin Probst. Thank you! llvm-svn: 248713
* clang-format: Add initial #include sorting capabilities.Daniel Jasper2015-09-232-3/+103
| | | | | | | | | To implement this nicely, add a function that merges two sets of replacements that are meant to be done in sequence. This functionality will also be useful for other applications, e.g. formatting the result of clang-tidy fixes. llvm-svn: 248367
* clang-format: Fix alignConsecutiveAssignments.Daniel Jasper2015-09-221-34/+44
| | | | | | | | | | | | | It wasn't correctly handling this case: int oneTwoThree = 123; int oneTwo = 12; method(); Review: http://reviews.llvm.org/D12369 Patch by Beren Minor. Thank you! llvm-svn: 248254
* clang-format: Remove ChromiumStyle.MacroBlockBegin.Nico Weber2015-09-211-2/+0
| | | | | | | | We prefer setting these in our .clang-format file as the macros change over time. (Also, the code was setting MacroBlockBegin twice and didn't set MacroBlockEnd, so it wasn't doing what it tried to do anyways.) llvm-svn: 248205
* 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
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-152-1/+3
| | | | | | Before: assert a&& b; Now: assert a && b; llvm-svn: 247750
* 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: Don't let a leading "template <..>" lead to wrapped initializers.Daniel Jasper2015-08-271-0/+3
| | | | | | | | | | | | | | | | | Before: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} After: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} llvm-svn: 246146
* clang-format: Add space before member function reference qualifiers.Daniel Jasper2015-08-251-6/+6
| | | | | | | | | | | | Before: SomeType MemberFunction(const Deleted &)&; After: SomeType MemberFunction(const Deleted &) &; Seems to be much more common. llvm-svn: 245934
* clang-format: Always allow break after leading annotations.Daniel Jasper2015-08-241-1/+1
| | | | | | | | | | | Before: DEPRECATED("Use NewClass::NewFunction instead.") int OldFunction( const string &parameter) {} Could not be formatted at all, as clang-format would both require and disallow the break before "int". llvm-svn: 245846
* clang-format: Make formatting of member function reference qualifiersDaniel Jasper2015-08-242-5/+11
| | | | | | | | | | | | | | more consistent. Before: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &) && { ... } After: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &)&& { ... } llvm-svn: 245843
* clang-format: Properly handle braced lists in macros.Daniel Jasper2015-08-241-0/+2
| | | | | | | | | | | | Before: #define A \ { a, a } \ , After: #define A {a, a}, llvm-svn: 245837
* clang-format: Be more conservative about specially indenting blocks in C++.Daniel Jasper2015-08-212-1/+2
| | | | | | | | | | | | | | | | | | | | | | This is a bit of a step back of what we did in r222531, as there are some corner cases in C++, where this kind of formatting is really bad. Example: Before: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); After: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); The block formatting logic in JavaScript will probably go some other changes, too, and we'll potentially be able to make the rules more consistent again. For now, this seems to be the best approach for C++. llvm-svn: 245694
* clang-format: Don't remove space between #elif and parentheses.Daniel Jasper2015-08-142-1/+5
| | | | | | | | | | Before: #elif(AAAA && BBBB) After: #elif (AAAA && BBBB) llvm-svn: 245043
* clang-format: Inside decltype(), there is an expression.Daniel Jasper2015-08-131-2/+3
| | | | | | | | | | Before: decltype(a* b) F(); After: decltype(a * b) F(); llvm-svn: 244891
* clang-format: Fix incorrect lambda-detection.Daniel Jasper2015-08-131-0/+1
| | | | | | | | | | Before: [ a, a ]() -> a<1>{}; After: [a, a]() -> a<1> {}; llvm-svn: 244890
* clang-format: Make SpaceBeforeParens work with overloaded operators.Daniel Jasper2015-08-111-1/+1
| | | | | | Patch by Jon Chesterfield, thank you! llvm-svn: 244660
* Add WebKit brace style configuration option.Roman Kashitsyn2015-08-101-1/+2
| | | | | | | | | | | | | | | | | | Summary: Add brace style `BS_WebKit` as described on https://www.webkit.org/coding/coding-style.html: * Function definitions: place each brace on its own line. * Other braces: place the open brace on the line preceding the code block; place the close brace on its own line. Set brace style used in `getWebKitStyle()` to the newly added `BS_WebKit`. Reviewers: djasper, klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D11837 llvm-svn: 244446
* Do not force linebreaks when MaxEmptyLinesToKeep is 0.Manuel Klimek2015-07-281-1/+1
| | | | | | | | | | | | | | | | Previously we would format call( p); as call( p); with MaxEmptyLinesToKeep == 0. Now we format it as: call(p); llvm-svn: 243429
* clang-format: Fix unary operator detection in for loops.Daniel Jasper2015-07-211-1/+2
| | | | | | | | | | Before: for (;; * a = b) {} After: for (;; *a = b) {} llvm-svn: 242849
* clang-format: Fix crasher when a UTF8 character is found in an escapeDaniel Jasper2015-07-201-1/+1
| | | | | | sequence. Discovered by the fuzzer. llvm-svn: 242738
* clang-format: Take nested lines into account when detection C++03Daniel Jasper2015-07-181-32/+46
| | | | | | compatibility and variable alignment. llvm-svn: 242611
* clang-format: Respect IndentWrappedFunctionNames when aligning colonsDaniel Jasper2015-07-161-1/+6
| | | | | | | | | | | | | | | | Before: - (void)shortf:(GTMFoo *)theFoo dontAlignNamef:(NSRect)theRect { } After: - (void)shortf:(GTMFoo *)theFoo dontAlignNamef:(NSRect)theRect { } Patch by Kwasi Mensah, thank you! llvm-svn: 242484
* clang-format: [Proto] Handle enum bodies differently.Daniel Jasper2015-07-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | In proto, enum constants can contain complex options and should be handled more like individual declarations. Before: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; After: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; llvm-svn: 242404
* clang-format: Fix return type breaking with overloaded operator functionsBirunthan Mohanathas2015-07-152-15/+60
| | | | | | Differential Revision: http://reviews.llvm.org/D11177 llvm-svn: 242316
* clang-format: Fix column layout with a comment in the last line.Daniel Jasper2015-07-151-1/+2
| | | | | | | | | | | | | | | | | | Before: int aaaaa[] = { 1, 2, 3, // comment 4, 5, 6 // comment }; After: int aaaaa[] = { 1, 2, 3, // comment 4, 5, 6 // comment }; llvm-svn: 242299
* clang-format: Fix formatting of multiple lambdas in initializers.Daniel Jasper2015-07-141-2/+4
| | | | | | | | | | | | | | | | | | | | Before: SomeFunction({[&] { // comment }, [&] { // comment }}); After: SomeFunction({[&] { // comment }, [&] { // comment }}); llvm-svn: 242138
* clang-format: Print token type name instead of number in -debug outputBirunthan Mohanathas2015-07-133-60/+84
| | | | | | Differential Revision: http://reviews.llvm.org/D11125 llvm-svn: 242039
* clang-format: Add Mozilla brace breaking styleBirunthan Mohanathas2015-07-123-1/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D10883 llvm-svn: 241986
* clang-format: [JS] Assign proper penalties when breaking a type annotationDaniel Jasper2015-07-101-0/+2
| | | | | | | | | | | | | | | | Before: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } After: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } llvm-svn: 241908
* clang-format: Break after "for (" less eagerly.Daniel Jasper2015-07-071-1/+2
| | | | | | | | | | | | | | | | Before: for ( auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { After: for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { llvm-svn: 241601
* clang-format: Don't wrap before the ] of a lambda introducer.Daniel Jasper2015-07-071-0/+3
| | | | | | | | | | | | | | | | Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([= ](int iiiiiiiiiiii) { return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa; }); After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([=]( int iiiiiiiiiiii) { return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa; }); llvm-svn: 241583
* clang-format: [JS] Properly reset parse state after parsing interface.Daniel Jasper2015-07-061-1/+1
| | | | llvm-svn: 241446
* clang-format: [JS] Prevent confusing TypeScript parameters wraps.Daniel Jasper2015-07-061-1/+1
| | | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} After: aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} llvm-svn: 241444
* clang-format: Fix __attribute__ being treated as decl name.Daniel Jasper2015-07-061-1/+2
| | | | | | | | | | | __attribute__ was treated as the name of a function definition, with the tokens in parentheses being the parameter list. This formats incorrectly with AlwaysBreakAfterDefinitionReturnType. Fix it by treating __attribute__ like decltype. Patch by Strager Neds, thank you. llvm-svn: 241439
* clang-format: Add MacroBlock{Begin,End} optionsBirunthan Mohanathas2015-07-033-10/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MacroBlockBegin and MacroBlockEnd options make matching macro identifiers behave like '{' and '}', respectively, in terms of indentation. Mozilla code, for example, uses several macros that begin and end a scope. Previously, Clang-Format removed the indentation resulting in: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Now, using the options MacroBlockBegin: "^[A-Z_]+_BEGIN$" MacroBlockEnd: "^[A-Z_]+_END$" will yield the expected result: MACRO_BEGIN(...) MACRO_ENTRY(...) MACRO_ENTRY(...) MACRO_END Differential Revision: http://reviews.llvm.org/D10840 llvm-svn: 241363
* clang-format: [JS] Allow line breaks after TypeScript type colons.Daniel Jasper2015-07-031-0/+2
| | | | llvm-svn: 241339
* clang-format: [Java/JS] Properly support instanceof and its precedence.Daniel Jasper2015-07-031-2/+7
| | | | llvm-svn: 241337
* clang-format: [JS] Treat regex literals like string literals.Daniel Jasper2015-07-021-0/+2
| | | | | | | Using the token type "unknown" can interfere badly with WhitespaceManager's way of handling multiline comments. llvm-svn: 241273
* clang-format: [JS] Skip comments when applying the regex-literal heuristicDaniel Jasper2015-07-021-5/+9
| | | | llvm-svn: 241264
* clang-format: [JS] Fix bug in regex literal parsing.Daniel Jasper2015-07-021-0/+1
| | | | | | The lexer wasn't properly reset leading to unexpected deletions. llvm-svn: 241262
* clang-format: [JS] Support regex literals at the start of a file.Daniel Jasper2015-07-021-5/+6
| | | | llvm-svn: 241259
* clang-format: [JS] Fix character counting in template strings.Daniel Jasper2015-07-021-5/+6
| | | | | | | Some counts were off, we don't need to take the leading newlines of the first ` into account and some tests were just wrong. llvm-svn: 241257
* clang-format: Support member function reference qualifiers withDaniel Jasper2015-07-011-1/+1
| | | | | | | | | | | | | | trailing return types. Before: template <typename T> auto x() & -> int {} After: template <typename T> auto x() & -> int {} llvm-svn: 241188
* clang-format: Properly parse parenthesis in braced lists.Daniel Jasper2015-06-301-3/+2
| | | | | | | | | | | Among other things, this makes clang-format understand arbitrary blocks embedded in them, such as: SomeFunction({MACRO({ return output; }), b}); where MACRO could e.g. expand to a lambda. llvm-svn: 241059
OpenPOWER on IntegriCloud