summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-054-5/+5
| | | | llvm-svn: 196510
* Fix the regression caused by r196378Alexander Kornienko2013-12-041-3/+3
| | | | llvm-svn: 196380
* Leave constructor initializer lists on one line in styles with no column limit.Alexander Kornienko2013-12-041-6/+16
| | | | | | | | | | | | | | | | | Summary: Allow tryFitMultipleLinesInOne join unwrapped lines when ContinuationIndenter::mustBreak doesn't agree. But don't merge any lines, that are separate in the input. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2321 llvm-svn: 196378
* Added an option to specify fallback style.Alexander Kornienko2013-12-021-10/+12
| | | | | | | | | | | | | | | | Summary: Added -fallback-style option. Changed clang-format to stop searching for .clang-format when an invalid file is found. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2292 llvm-svn: 196108
* clang-format: Fix excessive formatting caused by r195954.Daniel Jasper2013-12-021-0/+1
| | | | | | | Due to a bug in the patch, clang-format would more or less simply format all multi-line comments. llvm-svn: 196080
* Added LanguageStandard::LS_JavaScript to gate all JS-specific parsing.Alexander Kornienko2013-11-291-19/+156
| | | | | | | | | | | | | | | | Summary: Use LS_JavaScript for files ending with ".js". Added support for ">>>=" operator. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2242 llvm-svn: 195961
* clang-format: Extends formatted ranges to subsequent lines comments.Daniel Jasper2013-11-291-8/+14
| | | | | | | | | | | | | | | | Before: int aaaa; // This line is formatted. // The comment continues .. // .. here. Before: int aaaa; // This line is formatted. // The comment continues .. // .. here. This fixes llvm.org/PR17914. llvm-svn: 195954
* clang-format: Correctly handle Qt's Q_SLOTS.Daniel Jasper2013-11-291-1/+2
| | | | | | This should fix llvm.org/PR17241. Maybe it sticks this time :-). llvm-svn: 195953
* clang-format: Fix bad indentation of nested blocks.Daniel Jasper2013-11-291-1/+2
| | | | | | | | | | | | | | | Before: DEBUG( // { f(); }); After: DEBUG( // { f(); }); Also add additional test to selected formatting of individual statements in nested blocks. llvm-svn: 195952
* clang-format: Improve selective formatting of nested statements.Daniel Jasper2013-11-282-24/+64
| | | | | | | | | | Previously, clang-format could create quite corrupt formattings if individual lines of nested blocks (e.g. in "DEBUG({})" or lambdas) were used. With this patch, it tries to extend the formatted regions to leave around some reasonable format without always formatting the entire surrounding statement. llvm-svn: 195925
* Fix crash in getStringSplit.Alexander Kornienko2013-11-262-7/+7
| | | | | | | | | | | | | | | | Summary: getStringSplit used to crash, when trying to split a long string literal containing both printable and unprintable multi-byte UTF-8 characters. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2268 llvm-svn: 195728
* clang-format: Fix formatting of empty files (fixes c-index-tests).Daniel Jasper2013-11-251-2/+3
| | | | llvm-svn: 195638
* clang-format: Refactor calculation of lines intersecting with -lines.Daniel Jasper2013-11-253-75/+122
| | | | | | | | No functional changes intended. However, it seems to have found a buggy behavior in one of the tests. I think this structure is generally desirable and it will make a planned bugfix significantly easier. llvm-svn: 195634
* clang-format: Support Qt's slot access specifiers.Daniel Jasper2013-11-231-0/+3
| | | | | | This fixes llvm.org/PR17241. llvm-svn: 195555
* clang-format: Fix incorrect space in parameters named by comment.Daniel Jasper2013-11-231-2/+2
| | | | | | | | | | | | This fixes llvm.org/PR17979. Before: void f() { g(/*aaa=*/x, /*bbb=*/ !y); } After: void f() { g(/*aaa=*/x, /*bbb=*/!y); } llvm-svn: 195553
* clang-format: The "<" of a template argument is not a binary operator.Daniel Jasper2013-11-231-1/+1
| | | | | | | | | | | | | | | With Style.BreakBeforeBinaryOperators, clang-format breaks incorrectly. This fixes llvm.org/PR17994. Before: return boost::fusion::at_c<0>(iiii).second == boost::fusion::at_c <1>(iiii).second; After: return boost::fusion::at_c<0>(iiii).second == boost::fusion::at_c<1>(iiii).second; llvm-svn: 195552
* clang-format: Fix bug in ObjC method declaration formatting.Daniel Jasper2013-11-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Also disallow breaking between "@" and "{" or "[". Before: - (NSAttributedString *)attributedStringForSegment:(NSUInteger)segment index:(NSUInteger)index attributes:(NSDictionary *)attributes nonDigitAttributes:(NSDictionary *) nonDigitAttributes; [mailComposeViewController setToRecipients:@ [ NSBundle.mainBundle.infoDictionary[@"ABBFeedbackEmail"] ]]; After: - (NSAttributedString *)attributedStringForSegment:(NSUInteger)segment index:(NSUInteger)index attributes:(NSDictionary *)attributes nonDigitAttributes: (NSDictionary *)nonDigitAttributes; [mailComposeViewController setToRecipients: @[ NSBundle.mainBundle.infoDictionary[@"ABBFeedbackEmail"] ]]; This fixes llvm.org/PR18030. llvm-svn: 195550
* clang-format: Prefer column layout if possible.Daniel Jasper2013-11-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Add a severe penalty for not using column layout for braced lists. If there are solutions with column layout, these are generally preferable over bin-packed solutions. Before: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a }; After: std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a, aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a }; llvm-svn: 195546
* clang-format: Fix bug in alignment of complex template parameters.Daniel Jasper2013-11-221-1/+2
| | | | | | | | | | | | | | | Before: template <typename aaaaaaaaaaa, typename bbbbbbbbbbbbb, template <typename> class cccccccccccccccccccccc, typename ddddddddddddd> class C {}; After: template <typename aaaaaaaaaaa, typename bbbbbbbbbbbbb, template <typename> class cccccccccccccccccccccc, typename ddddddddddddd> class C {}; llvm-svn: 195418
* clang-format: Recognize braced lists with trailing function call.Daniel Jasper2013-11-221-1/+1
| | | | | | | | | | | Before: int count = set<int> { f(), g(), h() } .size(); After: int count = set<int>{f(), g(), h()}.size(); llvm-svn: 195417
* Better implementation of JavaScript === and !== operators.Alexander Kornienko2013-11-212-14/+30
| | | | | | | | | | | | | | | | Summary: Now based on token merging. Now they are not only prevented from being split, but are actually formatted as comparison operators. Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2240 llvm-svn: 195354
* clang-format: Improve formatting of ObjC method expressions.Daniel Jasper2013-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In particular, make breaking after a parameter's ":" more of a last resort choice as it significantly affects the readability gained by aligning the parameters. Before (in Chromium style - which doesn't allow bin-packing): { popup_window_.reset([[RenderWidgetPopupWindow alloc] initWithContentRect: NSMakeRect( origin_global.x, origin_global.y, pos.width(), pos.height()) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); } After: { popup_window_.reset([[RenderWidgetPopupWindow alloc] initWithContentRect:NSMakeRect(origin_global.x, origin_global.y, pos.width(), pos.height()) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]); } llvm-svn: 195301
* Added an option to allow short function bodies be placed on a single line.Alexander Kornienko2013-11-204-24/+53
| | | | | | | | | | | | | | | | | | | Summary: The AllowShortFunctionsOnASingleLine option now controls short function body placement on a single line independent of the BreakBeforeBraces option. Updated tests using BreakBeforeBraces other than BS_Attach. Addresses http://llvm.org/PR17888 Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2230 llvm-svn: 195256
* Simplify fix proposed in r195240.Daniel Jasper2013-11-202-18/+10
| | | | llvm-svn: 195253
* Support for JavaScript === and !== operators.Alexander Kornienko2013-11-201-0/+7
| | | | | | | | | | | | Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2231 llvm-svn: 195251
* Fix bug where optimization would lead to strange line breaks.Manuel Klimek2013-11-202-8/+18
| | | | | | | | | | | | | | | | | Before: void f() { CHECK_EQ(aaaa, ( *bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } After: void f() { CHECK_EQ(aaaa, (*bbbbbbbbb)->cccccc) << "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"; } llvm-svn: 195240
* Refactoring: replaced (*(I + x)) with I[x].Alexander Kornienko2013-11-191-21/+18
| | | | | | | | | | | | | | Summary: Pure refactoring, no semantic changes intended. Reviewers: klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2220 llvm-svn: 195128
* Correctly mark first token in the presence of UTF-8 BOM.Alexander Kornienko2013-11-131-3/+4
| | | | | | | | | | | | | | Summary: Fixes http://llvm.org/PR17753 Reviewers: klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2159 llvm-svn: 194576
* Remove extra whitespace instead of breaking the line in comments when possible.Alexander Kornienko2013-11-123-2/+49
| | | | | | | | | | | | | | Summary: Solves the problem described in http://llvm.org/PR17756 Reviewers: klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2131 llvm-svn: 194493
* Do not insert backslashes, when breaking line comments after preprocessor ↵Alexander Kornienko2013-11-121-8/+9
| | | | | | | | | | | | | | | | directives. Summary: This solves http://llvm.org/PR17536 Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2142 llvm-svn: 194491
* clang-format: Fix alignment of ObjC string literals.Daniel Jasper2013-11-091-1/+1
| | | | | | | | This used to interfere with AlwaysBreakBeforeMultilineStrings. This fixes llvm.org/PR17856. llvm-svn: 194310
* clang-format: Improve clang-format's detection about comment binding.Daniel Jasper2013-11-081-13/+15
| | | | | | | | | | | | | | | | | | Before, existing code in the form of: int a; // this is a. // This is // b. int b; Got turned into: int a; // this is a. // This is // b. int b; llvm-svn: 194294
* clang-format: Improve formatting of operators forced to new lines.Daniel Jasper2013-11-081-4/+6
| | | | | | | | | | | | | | | | | | | | | | | Before: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) After: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) This fixes llvm.org/PR17687. llvm-svn: 194276
* clang-format: Don't auto-break short macros in WebKit style.Daniel Jasper2013-11-081-1/+3
| | | | | | This fixes llvm.org/PR17842. llvm-svn: 194268
* clang-format: Improve linebreaking and indentation for ObjC calls.Daniel Jasper2013-11-082-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Before: popup_wdow_.reset([[RenderWidgetPopupWindow alloc] iniithContentRect: NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height()) syeMask:NSBorderlessWindowMask bking:NSBackingStoreBuffered der:NO]); [self param:function( // parameter)] After: popup_wdow_.reset([[RenderWidgetPopupWindow alloc] iniithContentRect:NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height()) syeMask:NSBorderlessWindowMask bking:NSBackingStoreBuffered der:NO]); [self param:function( // parameter)] llvm-svn: 194267
* clang-format: Properly indent ObjC calls wrapped before first selectorDaniel Jasper2013-11-081-1/+5
| | | | | | | | | | | | | | | | Before: [self // break a:a aa:aa aaaaa:aaa]; After: [self // break a:a aa:aa aaaaa:aaa]; llvm-svn: 194241
* clang-format: Make breaking before ternary operators configurable.Daniel Jasper2013-11-083-16/+30
| | | | llvm-svn: 194229
* clang-format: Improve binary operator detection in macros.Daniel Jasper2013-11-071-1/+1
| | | | | | | | | | | | Before: #define M(NAME) assert(!Context.Verifying &&#NAME); After: #define M(NAME) assert(!Context.Verifying && #NAME); This fixes llvm.org/PR16156. llvm-svn: 194216
* clang-format: Improve ObjC variadic and binary expression parameters.Daniel Jasper2013-11-072-6/+9
| | | | | | | | | | | | | | | | | | | | | | Before: [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa]; [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa]; After: [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa]; [self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa]; This addresses llvm.org/PR15349 and llvm.org/PR16185. llvm-svn: 194214
* clang-format: Improve formatting of constructor initializers.Daniel Jasper2013-11-072-6/+13
| | | | | | | | | | | | | Before: Constructor() : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {} After: Constructor() : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {} llvm-svn: 194210
* clang-format: Remove old hack that mainly made incorrect tests pass.Daniel Jasper2013-11-071-5/+3
| | | | | | | | As a side-effect, constructors definitions will correctly be recognized and formatted as function declarations. Tests will be added in a follow-up patch actually using the correct recognition. llvm-svn: 194209
* clang-format: Fix corner case for brace alignment.Daniel Jasper2013-11-071-1/+3
| | | | | | | | | | | | | | | | Before: Constructor::Constructor() : some_value{ // aaaaaaa // } {} After: Constructor::Constructor() : some_value{ // aaaaaaa // } {} llvm-svn: 194204
* clang-format: Separate line-merging logic into its own class.Daniel Jasper2013-11-061-151/+164
| | | | | | No functional changes (intended). llvm-svn: 194179
* clang-format: Allow line merging and partial formatting of nested blocksDaniel Jasper2013-11-052-414/+419
| | | | | | | | | | | | | | | | Before, clang-format would always format entire nested blocks, which can be unwanted e.g. for long DEBUG({...}) statements. Also clang-format would not allow to merge lines in nested blocks (e.g. to put "if (a) return;" on one line in Google style). This is the first step of several refactorings mostly focussing on the additional functionality (by reusing the "format many lines" code to format the children of a nested block). The next steps are: * Pull out the line merging into its own class. * Seperate the formatting of many lines from the formatting of a single line (and the analysis of the solution space). llvm-svn: 194090
* clang-format: Fix indenting corner case with comment and else.Daniel Jasper2013-10-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | Before: if (a) { f(); } // or else .. else { g(); } After: if (a) { f(); } // or else .. else { g(); } llvm-svn: 193684
* clang-format: Fix whitespaces in include directives.Daniel Jasper2013-10-302-2/+11
| | | | | | | | | | | | | | Before (clang-format wouldn't change): #include "a.h" #include<a> After: #include "a.h" #include <a> This fixes llvm.org/PR16151. llvm-svn: 193683
* clang-format: fix for \r\r\n produced in multiline block commentsDaniel Jasper2013-10-301-1/+2
| | | | | | Patch by Christopher Olsen. Thank you! llvm-svn: 193678
* clang-format: Option to control spacing in template argument lists.Daniel Jasper2013-10-292-1/+7
| | | | | | | | | | | Same as SpacesInParentheses, this option allows adding a space inside the '<' and '>' of a template parameter list. Patch by Christopher Olsen. This fixes llvm.org/PR17301. llvm-svn: 193614
* clang-format: Fix overloaded operator for global-scoped conversions.Daniel Jasper2013-10-291-1/+1
| | | | | | | | | | Before: operator::A(); After: operator ::A(); llvm-svn: 193605
* clang-format: Fix ObjC method exprs with variadic parameters.Daniel Jasper2013-10-261-1/+4
| | | | | | | | | | | | | | | | | Before: _versionLabel.text = [ NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"), [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"] ]; After: _versionLabel.text = [NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"), [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]]; This fixed llvm.org/PR17695. llvm-svn: 193475
OpenPOWER on IntegriCloud