summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Fix bad multi-variable for-loop formatting.Daniel Jasper2016-10-041-1/+3
| | | | | | | | | | Before: for (int*p, *q; p != q; p = p->next) { After: for (int *p, *q; p != q; p = p->next) { llvm-svn: 283246
* Move UTF functions into namespace llvm.Justin Lebar2016-09-301-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This lets people link against LLVM and their own version of the UTF library. I determined this only affects llvm, clang, lld, and lldb by running $ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq clang lld lldb llvm Tested with ninja lldb ninja check-clang check-llvm check-lld (ninja check-lldb doesn't complete for me with or without this patch.) Reviewers: rnk Subscribers: klimek, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D24996 llvm-svn: 282822
* [clang-format] Don't allow newline after uppercase Obj-C block return typesDaniel Jasper2016-09-261-6/+11
| | | | | | | | | | | | | | Fixes the following: BOOL (^aaa)(void) = ^BOOL { }; The first BOOL's token was getting set to TT_FunctionAnnotationRParen incorrectly, which was causing an unexpected newline after (^aaa). This was introduced in r245846. Patch by Kent Sutherland, thank you! llvm-svn: 282448
* clang-format: Only special-case top-level */& in multivar-declstmts.Daniel Jasper2016-09-261-1/+1
| | | | | | | | | | Before (even with PointerAlignment: Left): vector<int *> a, b; After: vector<int*> a, b; llvm-svn: 282410
* [clang-format] support header deletion in cleanupAroundReplacemnts.Eric Liu2016-09-231-2/+29
| | | | | | | | | | | | | | | | | | Summary: - If a replacement has offset UINT_MAX, length 0, and a replacement text that is an #include directive, this will insert the #include into the correct block in the \p Code. - If a replacement has offset UINT_MAX, length 1, and a replacement text that is the name of the header to be removed, the header will be removed from \p Code if it exists. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24829 llvm-svn: 282253
* clang-format: [JS] reserved words in method names.Martin Probst2016-09-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before: class X { delete () { ... } } After: class X { delete() { ... } } Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24804 llvm-svn: 282138
* clang-format: [JS] do not wrapp @returns tags.Martin Probst2016-09-211-1/+2
| | | | | | | | | | | | Summary: @returns is incorrect code, the standard is @return. However wrapping it can still confuse users. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24767 llvm-svn: 282056
* clang-format: [JS] Fix line breaks before comments when sorting imports.Martin Probst2016-09-191-3/+8
| | | | | | | | | | | | | | | Summary: Previously, clang-format would always insert an additional line break after the import block if the main body started with a comment, due to loosing track of the first non-import line. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24708 llvm-svn: 281888
* clang-format: [JS] Do not wrap taze annotation comments.Martin Probst2016-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: `// taze: ... from ...` comments are used help tools where a specific global symbol comes from. Before: // taze: many, different, symbols from // 'some_long_location_here' After: // taze: many, different, symbols from 'some_long_location_here' Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24477 llvm-svn: 281857
* clang-format: [JS] ASI insertion after boolean literals.Martin Probst2016-09-181-1/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Before when a semicolon was missing after a boolean literal: a = true return 1; clang-format would parse this as one line and format as: a = true return 1; It turns out that C++ does not consider `true` and `false` to be literals, we have to check for that explicitly. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24574 llvm-svn: 281856
* clang-format: [JS] Fix a crash in handledTemplateStrings.Daniel Jasper2016-09-171-0/+2
| | | | llvm-svn: 281816
* 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
OpenPOWER on IntegriCloud