summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove redundant comma around parenthesis in parameter list.Eric Liu2016-09-131-0/+2
| | | | | | | | | | Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24501 llvm-svn: 281344
* Also cleanup comments around redundant colons/commas in format::cleanup.Eric Liu2016-09-091-0/+2
| | | | | | | | | | Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24400 llvm-svn: 281064
* clang-format: [JavaScript] Change default AllowShortFunctionsOnASingleLineDaniel Jasper2016-09-071-1/+1
| | | | | | for Google style to "empty". llvm-svn: 280878
* clang-format: [JavaScript] Do requoting in a separate passDaniel Jasper2016-09-071-44/+64
| | | | | | | | | | | | | | | | | | The attempt to fix requoting behavior in r280487 after changes to tooling::Replacements are incomplete. We essentially need to add to replacements at the same position, one to insert a line break and one to change the quoting and that's incompatible with the new tooling::Replacement API, which does not allow for order-dependent Replacements. To make the order clear, Replacements::merge() has to be used, but that requires the merged Replacement to actually refer to the changed text, which is hard to reproduce for the requoting. This change fixes the behavior by moving the requoting to a completely separate pass. The added benefit is that no weird ColumnWidth calculations are necessary anymore and this should just work even if we implement string literal splitting in the future. llvm-svn: 280874
* clang-format: [JS] whitespace required between ! and as.Martin Probst2016-09-061-0/+2
| | | | | | | | | | | | | | | | Summary: Before: x!as string After: x! as string Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24272 llvm-svn: 280731
* clang-format: [JS] ignore comments when wrapping returns.Martin Probst2016-09-061-1/+6
| | | | | | | | | | | | | | | | | | | Summary: When code contains a comment between `return` and the value: return /* lengthy comment here */ ( lengthyValueComesHere); Do not wrap before the comment, as that'd break the code through JS' automatic semicolon insertion. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24257 llvm-svn: 280730
* clang-format: [JS] merge requoting replacements.Martin Probst2016-09-024-9/+8
| | | | | | | | | | | | | | | | | Summary: When formatting source code that needs both requoting and reindentation, merge the replacements to avoid erroring out for conflicting replacements. Also removes the misleading Replacements parameter from the TokenAnalyzer API. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24155 llvm-svn: 280487
* clang-format: [JS] handle default bindings in imports.Martin Probst2016-09-021-8/+15
| | | | | | | | | | | | | | | | Summary: Default imports appear outside of named bindings in curly braces: import A from 'a'; import A, {symbol} from 'a'; Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23973 llvm-svn: 280486
* clang-format: [JS] Sort all JavaScript imports if any changed.Martin Probst2016-09-021-7/+5
| | | | | | | | | | | | | | | Summary: User feedback is that they expect *all* imports to be sorted if any import was affected by a change, not just imports up to the first non-affected line, as clang-format currently does. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23972 llvm-svn: 280485
* clang-format: Set default WebKit style to use C++11.Daniel Jasper2016-08-311-1/+0
| | | | | | | | | The WebKit style page says to use nullptr, so this should be fine: https://webkit.org/code-style-guidelines/ This fixes: llvm.org/PR30220 llvm-svn: 280245
* clang-format: Correctly calculate affected ranges when sorting #includes.Daniel Jasper2016-08-301-4/+4
| | | | | | affectedRanges takes a start and an end offset, not offset and length. llvm-svn: 280165
* clang-format: [JS] nested and tagged template strings.Martin Probst2016-08-253-23/+71
| | | | | | | | | | | | | | | | | | | JavaScript template strings can be nested arbitrarily: foo = `text ${es.map(e => { return `<${e}>`; })} text`; This change lexes nested template strings using a stack of lexer states to correctly switch back to template string lexing on closing braces. Also, reuse the same stack for the token-stashed logic. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D22431 llvm-svn: 279727
* clang-format: [JS] supports casts to types starting with punctuation ("{[(").Martin Probst2016-08-221-0/+3
| | | | | | | | | | | | | | | | | | Before: x as{x: number} After: x as {x: number} Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23761 llvm-svn: 279436
* clang-format: [JS] handle object literals with casts.Martin Probst2016-08-191-1/+2
| | | | | | | | | | | | Summary: E.g. `{a: 1} as b`. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D23714 llvm-svn: 279250
* Make clang-format remove duplicate headers when sorting #includes.Eric Liu2016-08-101-26/+63
| | | | | | | | | | | | Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D23274 llvm-svn: 278206
* clang-format: Add SpaceAfterTemplateSylvestre Ledru2016-08-092-2/+6
| | | | | | | | | | | | | | | | Summary: This is required for compliance with the Mozilla style guide. This is a rebase+minor change of Birunthan Mohanathas's patch Reviewers: djasper Subscribers: klimek, cfe-commits, opilarium Differential Revision: https://reviews.llvm.org/D23317 llvm-svn: 278121
* Implement tooling::Replacements as a class.Eric Liu2016-08-014-22/+63
| | | | | | | | | | | | | | | | | | | Summary: - Implement clang::tooling::Replacements as a class to provide interfaces to control how replacements for a single file are combined and provide guarantee on the order of replacements being applied. - tooling::Replacements only contains replacements for the same file now. Use std::map<std::string, tooling::Replacements> to represent multi-file replacements. - Error handling for the interface change will be improved in followup patches. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21748 llvm-svn: 277335
* clang-format: Fix incorrect detection of QT-signals access specifier.Daniel Jasper2016-07-271-1/+1
| | | | | | | | | | | | | | | | | Before: void f() { label: signals .baz(); } After: void f() { label: signals.baz(); } llvm-svn: 276854
* [NFC] Header cleanupMehdi Amini2016-07-186-7/+2
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* clang-format: [JS] Allow top-level conditionals again.Daniel Jasper2016-07-121-1/+1
| | | | | | | | I am not sure exactly which test breakage Martin was trying to fix in r273694. For now, fix the behavior for top-level conditionals, which (surprisingly) are actually used somewhat commonly. llvm-svn: 275183
* Make tooling::applyAllReplacements return llvm::Expected<string> instead of ↵Eric Liu2016-07-111-9/+13
| | | | | | | | | | | | | | | | empty string to indicate potential error. Summary: return llvm::Expected<> to carry error status and error information. This is the first step towards introducing "Error" into tooling::Replacements. Reviewers: djasper, klimek Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21601 llvm-svn: 275062
* clang-format: [JS] Sort imports case insensitive.Martin Probst2016-07-091-3/+3
| | | | | | | | | | | | Summary: ASCII case sorting does not help finding imported symbols quickly, and it is common to have e.g. class Foo and function fooFactory exported/imported from the same file. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D22146 llvm-svn: 274977
* clang-format: [JS] support trailing commas in imports.Martin Probst2016-07-091-0/+2
| | | | | | | | | | Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D22147 llvm-svn: 274976
* clang-format: [JS] Fix build breakage.Martin Probst2016-06-241-1/+1
| | | | | | Checking Line.MustBeDeclaration does actually break the field and param initializer use case. llvm-svn: 273694
* clang-format: [JS] handle conditionals in fields, default params.Martin Probst2016-06-231-2/+2
| | | | | | | | | | | | Summary: Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21658 llvm-svn: 273619
* clang-format: [JS] recognize more type locations.Martin Probst2016-06-232-0/+13
| | | | | | | | | | | | Summary: Includes parenthesized type expressions and type aliases. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21597 llvm-svn: 273603
* clang-format: [Proto] Use more compact format for text-formatted optionsDaniel Jasper2016-06-231-3/+0
| | | | | | | | | | | | | | | | | Before: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; After: enum Type { UNKNOWN = 0 [(some_options) = {a: aa, b: bb}]; }; llvm-svn: 273553
* clang-format: [JS] Do not break before 'as'.Martin Probst2016-06-221-0/+2
| | | | | | | | | | | | | | Summary: 'as' is a pseudo operator, so automatic semicolon insertion kicks in and the code fails to part. Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D21576 llvm-svn: 273422
* clang-format: [JS] Add a Closure Compiler JSDoc tags to the defaultDaniel Jasper2016-06-211-1/+1
| | | | | | Google configuration so that it isn't line-wrapped. llvm-svn: 273285
* clang-format: [Proto] Fix "import public" after r273179.Daniel Jasper2016-06-201-0/+2
| | | | llvm-svn: 273196
* clang-format: [Proto] Don't do bad things if imports are missing ;.Daniel Jasper2016-06-201-4/+15
| | | | llvm-svn: 273179
* [clang-format] do not add existing includes.Eric Liu2016-06-141-1/+7
| | | | | | | | | | | | Summary: do not add existing includes. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21323 llvm-svn: 272669
* clang-format: [JS] Fix failing format with TypeScript casts.Daniel Jasper2016-06-141-3/+3
| | | | | | | | | | | | Before, this could be formatted at all (with BracketAlignmentStyle AlwaysBreak): foo = <Bar[]>[ 1, /* */ 2 ]; llvm-svn: 272668
* clang-format: [JS] Support annotated classes.Daniel Jasper2016-06-141-1/+2
| | | | llvm-svn: 272654
* clang-format: [JS] Initialize new configuration value.Martin Probst2016-06-131-0/+2
| | | | llvm-svn: 272569
* clang-format: [JS] Indent namespaces in JavaScript/TS by default.Martin Probst2016-06-131-0/+1
| | | | | | | | | | | | Summary: There's no convention of avoiding the nested indentation. Reviewers: djasper Subscribers: klimek, alexeagle, cfe-commits Differential Revision: http://reviews.llvm.org/D21275 llvm-svn: 272559
* clang-format: [JS] Introduce JavaScriptWrapImports option.Martin Probst2016-06-133-5/+10
| | | | | | | | | | | | | | Summary: When turned on, clang-format wraps JavaScript imports (and importing exports), instead of forcing the entire import statement onto one line. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21273 llvm-svn: 272558
* clang-format: Restrict r272537 to function ref qualifiers.Daniel Jasper2016-06-131-1/+2
| | | | | | | | | | | | Seems this isn't generally desirable. Before: int const * a; After: int const* a; llvm-svn: 272548
* clang-format: Fix incorrect function type detection.Daniel Jasper2016-06-131-6/+7
| | | | | | | | | | Before: returnsFunction (&param1, &param2)(param); After: returnsFunction(&param1, &param2)(param); llvm-svn: 272538
* clang-format: Don't merge const and &, e.g. in function ref qualifiers.Daniel Jasper2016-06-131-1/+1
| | | | | | | | | | | | | | | | | Before (when aligning & to the right): SomeType MemberFunction(const Deleted &) const&; After: SomeType MemberFunction(const Deleted &) const &; This also applies to variable declarations, e.g.: int const * a; However, this form is very uncommon (most people would write "const int* a" instead) and contracting to "const*" might actually send the wrong signal of what the const binds to. llvm-svn: 272537
* clang-format: Fix incorrect cast detection.Daniel Jasper2016-06-131-2/+2
| | | | | | | | | | Before: auto s = sizeof...(Ts)-1; After: auto s = sizeof...(Ts) - 1; llvm-svn: 272536
* clang-format: Don't indent lambda body relative to its return type.Daniel Jasper2016-06-131-5/+7
| | | | | | | | | | | | | | | | Before: []() // -> int { return 1; // }; After: []() // -> int { return 1; // }; llvm-svn: 272535
* clang-format: [JS] post-fix non-null assertion operator.Martin Probst2016-06-131-0/+5
| | | | | | | | | | | | | | Summary: Do not insert whitespace preceding the "!" postfix operator. This is an incomplete fix, but should cover common usage. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D21204 llvm-svn: 272524
* [clang-format] pass Style by reference instead of value.Eric Liu2016-06-111-1/+1
| | | | llvm-svn: 272465
* clang-format: [JS] recognized named functions in AnnotatingParser.Martin Probst2016-06-091-1/+4
| | | | | | | | | | | | | | | Summary: This also fixes union type formatting in function parameter types. Before: function x(path: number| string) {} After: function x(path: number|string) {} Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21206 llvm-svn: 272330
* clang-format: [JS] fix a FIXME.Martin Probst2016-06-081-1/+1
| | | | llvm-svn: 272143
* clang-format: [JS] fix an assertion failure caused by shrinking sources.Martin Probst2016-06-081-2/+15
| | | | | | | | | | | | | | | | | | Summary: The JavaScript import sorter has a corner condition that can cause the overall source text length to shrink. This change circumvents the issue by appending trailing space in the line after the import blocks to match at least the previous source code length. This needs a better long term fix, but this fixes the immediate issue. Reviewers: alexeagle, djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D21108 llvm-svn: 272142
* clang-format: Fix incorrect calculation of "length" of /**/ comments.Daniel Jasper2016-06-081-3/+6
| | | | | | This could lead to column limit violations. llvm-svn: 272125
* clang-format: Fix bug in function ref qualifier identification.Daniel Jasper2016-06-081-4/+1
| | | | | | | | | | | | | | .. and simplify it. Before: void A::f()&& {} void f() && {} After: void A::f() && {} void f() && {} llvm-svn: 272124
* [clang-format] make header guard identification stricter (with Lexer).Eric Liu2016-06-061-23/+51
| | | | | | | | | | | | Summary: make header guard identification stricter with Lexer. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D20959 llvm-svn: 271883
OpenPOWER on IntegriCloud