summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Prefer an additional line-break over hanging indent.Daniel Jasper2014-04-031-0/+12
| | | | | | | | | | | | | | | | | | | | Don't allow the RHS of an operator to be split over multiple lines unless there is a line-break right after the operator. Before: if (aaaa && bbbbb || // break cccc) { } After: if (aaaa && bbbbb || // break cccc) { } In most cases, this seems to increase readability. llvm-svn: 205527
* xDaniel Jasper2014-04-031-1/+1
| | | | llvm-svn: 205526
* clang-format: Understand that "auto" is a type.Daniel Jasper2014-04-031-1/+1
| | | | | | | | | | Before: MACRO(auto * a); After: MACRO(auto *a); llvm-svn: 205517
* clang-format: Support configurable list of foreach-macros.Daniel Jasper2014-04-014-8/+41
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* clang-format: Solve issues found and fixed by clang-tidy.Daniel Jasper2014-03-312-2/+2
| | | | llvm-svn: 205193
* clang-format: Fix aligning of comments and escaped newlines in macros.Daniel Jasper2014-03-281-0/+4
| | | | | | | | | | | | | | Before: #define A \ int i; /*a*/ \ int jjj; /*b*/ After: #define A \ int i; /*a*/ \ int jjj; /*b*/ llvm-svn: 205011
* Get rid of the adapted isLiteral method.Manuel Klimek2014-03-282-7/+6
| | | | | | We don't want to deviate from clang's standard terminology. llvm-svn: 204997
* clang-format: Recognize more ObjC blocks with parameters/return type.Daniel Jasper2014-03-281-2/+6
| | | | llvm-svn: 204990
* Improve handling of bool expressions in template arguments.Manuel Klimek2014-03-272-3/+11
| | | | | | | Now correctly formats: foo<true && false>(); llvm-svn: 204950
* clang-format: Avoid line-breaks that increase the current column.Daniel Jasper2014-03-271-5/+9
| | | | | | | | | | | | | | | | | | While these might make sense for some rule (e.g. break after multi-line operand), they generally appear ugly and confusing. Before: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) After: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) llvm-svn: 204937
* clang-format: Extract getNewLineColumn out of addTokenOnNewLine.Daniel Jasper2014-03-272-74/+103
| | | | | | No functional changes intended. llvm-svn: 204930
* Fix bool expression special case.Manuel Klimek2014-03-271-4/+17
| | | | | | | | Clang-format now correctly formats: some_type<a * b> v; template <bool a, bool b> typename enabled_if<a && b>::type f() {} llvm-svn: 204913
* clang-format: Correctly identify ObjC Block with return type.Daniel Jasper2014-03-273-12/+10
| | | | llvm-svn: 204905
* clang-format: Fix incorrect &/* detection.Daniel Jasper2014-03-251-2/+4
| | | | | | | | | | Before: STATIC_ASSERT((a &b) == 0); After: STATIC_ASSERT((a & b) == 0); llvm-svn: 204709
* clang-format: Add flag for removing empty lines at the start of blocks.Daniel Jasper2014-03-211-1/+6
| | | | | | | This unbreaks polly-formatting-tests and we can make a decision for LLVM style independently. llvm-svn: 204467
* clang-format: Don't remove empty lines at the start of namespaces.Daniel Jasper2014-03-211-1/+2
| | | | llvm-svn: 204462
* clang-format: Remove empty lines at the beginning of blocks.Daniel Jasper2014-03-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | They very rarely aid readability. Formatting: void f() { if (a) { f(); } } Now leads to: void f() { if (a) { f(); } } llvm-svn: 204460
* clang-format: Let a trailing comma in braced lists enforce linebreaks.Daniel Jasper2014-03-211-0/+8
| | | | | | | | | | | | | | Before: vector<int> x{1, 2, 3, 4, }; After: vector<int> x{ 1, 2, 3, 4, }; This fixes llvm.org/PR18519. llvm-svn: 204458
* clang-format: Fix for r204456.Daniel Jasper2014-03-211-1/+1
| | | | llvm-svn: 204457
* clang-format: Preserve meaning of trailing comments on parameters.Daniel Jasper2014-03-211-0/+21
| | | | | | | | | | | | | | | | | | Formatting: SomeFunction(a, b, // comment c); Before: SomeFunction(a, b, // comment c); After: SomeFunction(a, b, // comment c); llvm-svn: 204456
* clang-format: Detect function-like macros only when upper case is used.Alexander Kornienko2014-03-181-1/+1
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3110 llvm-svn: 204156
* Fix crasher bug.Manuel Klimek2014-03-182-16/+32
| | | | | | | | | | | | | | | Due to not resetting the fake rparen data on the token when iterating over annotated lines, we would pop the last element of the paren stack. This patch fixes the underlying root cause, and makes the code more robust against similar problems in the future: - reset the first token when iterating on the same annotated lines due to preprocessor branches - never pop the last element from the paren stack, so we do not crash, but rather incorrectly format - add assert()s so we can figure out if our assumptions are violated llvm-svn: 204140
* clang-format: Indent from dict literal labels.Daniel Jasper2014-03-171-2/+3
| | | | | | | | | | | | | | | | Before: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; After: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; llvm-svn: 204041
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-154-48/+42
| | | | | | class. llvm-svn: 203999
* Remove an unnecessary check for FormatTok not being null.Alexander Kornienko2014-03-131-1/+2
| | | | | | | | | | | | | | | | | Summary: This check hints clang analyzer, that FormatTok may be null, and it reports a null pointer dereference error: http://buildd-clang.debian.net/scan-build/report-827c64.html#Path28 Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3040 llvm-svn: 203800
* clang-format: Prevent ObjC code from confusing the braced-init detectionDaniel Jasper2014-03-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This was leading to bad formatting, e.g.: Before: f(^{ @autoreleasepool { if (a) { g(); } } }); After: f(^{ @autoreleasepool { if (a) { g(); } } }); llvm-svn: 203777
* clang-format: Fix crasher.Daniel Jasper2014-03-121-3/+2
| | | | | | | | | | Caused by unknown tokens (e.g. "\n") not properly updating the state. Example: const char* c = STRINGIFY( \na : b); llvm-svn: 203645
* clang-format: Avoid unnecessary break before lambda return type.Daniel Jasper2014-03-111-1/+2
| | | | | | | | | | | | | | | | | Before: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; After: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; llvm-svn: 203562
* clang-format: Fix another false positive in the lambda detection.Daniel Jasper2014-03-111-2/+2
| | | | | | | | | | Before: int i = (*b)[a] -> f(); After: int i = (*b)[a]->f(); llvm-svn: 203557
* clang-format: Fix incorrect lambda recognition exposed by r203452.Daniel Jasper2014-03-111-1/+2
| | | | | | | | | | Before: int i = a[a][a] -> f(); After: int i = a[a][a]->f(); llvm-svn: 203556
* clang-format: Detect weird macro lambda usage.Daniel Jasper2014-03-111-1/+5
| | | | | | | | | | | | | | Before: void f() { MACRO((const AA & a) { return 1; }); } After: void f() { MACRO((const AA &a) { return 1; }); } llvm-svn: 203551
* clang-format: Add spaces between lambdas and comments.Daniel Jasper2014-03-101-1/+2
| | | | | | | | | | | | | | | | | | Before: void f() { bar([]() {}// Does not respect SpacesBeforeTrailingComments ); } After: void f() { bar([]() {} // Does not respect SpacesBeforeTrailingComments ); } This fixes llvm.org/PR19017. llvm-svn: 203466
* Preserve hanging indent when breaking line comments.Alexander Kornienko2014-03-101-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If we need to break the second line here: // something: aaaaa aaaaa aaaaaa aaaaa aaaaa // aaaaa aaaaa aaaaaa aaaaa aaaaa aaaaa with the patch it will be turned to // something: aaaaa aaaaa aaaaaa aaaaa aaaaa // aaaaa aaaaa aaaaaa aaaaa aaaaa // aaaaa instead of // something: aaaaa aaaaa aaaaaa aaaaa aaaaa // aaaaa aaaaa aaaaaa aaaaa aaaaa // aaaaa Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2988 llvm-svn: 203458
* clang-format: Add spaces around trailing/lambda return types.Daniel Jasper2014-03-102-1/+5
| | | | | | | | | | Before: int c = []()->int { return 2; }(); After: int c = []() -> int { return 2; }(); llvm-svn: 203452
* [C++11] Replace OwningPtr include with <memory>.Ahmed Charles2014-03-091-1/+1
| | | | llvm-svn: 203389
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-074-4/+4
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* Change OwningPtr::take() to OwningPtr::release().Ahmed Charles2014-03-071-1/+1
| | | | | | This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
* Fix operator<< recognition (PR19064).Alexander Kornienko2014-03-061-2/+4
| | | | llvm-svn: 203123
* [C++11] Switch the clang-format LLVM style to use C++11 style bracedChandler Carruth2014-03-021-3/+8
| | | | | | | | | init list formatting. This suggestion has now gone into the LLVM coding standards, and is particularly relevant now that we're using C++11. Updated a really ridiculous number of tests to reflect this change. llvm-svn: 202637
* [CMake] Use LINK_LIBS instead of target_link_libraries().NAKAMURA Takumi2014-02-261-2/+1
| | | | llvm-svn: 202238
* [CMake] Get rid of explicit dependencies to include/clang/*.inc and ↵NAKAMURA Takumi2014-02-211-9/+0
| | | | | | | | | | | | | | | | | | | introduce CLANG_TABLEGEN_TARGETS. This does; - clang_tablegen() adds each tblgen'd target to global property CLANG_TABLEGEN_TARGETS as list. - List of targets is added to LLVM_COMMON_DEPENDS. - all clang libraries and targets depend on generated headers. You might wonder this would be regression, but in fact, this is little loss. - Almost all of clang libraries depend on tblgen'd files and clang-tblgen. - clang-tblgen may cause short stall-out but doesn't cause unconditional rebuild. - Each library's dependencies to tblgen'd files might vary along headers' structure. It made hard to track and update *really optimal* dependencies. Each dependency to intrinsics_gen and ClangSACheckers is left as DEPENDS. llvm-svn: 201842
* clang-format: Don't wrap "const" etc. of function declarations.Daniel Jasper2014-02-171-2/+8
| | | | | | | | | | | | | | | | | Generally people seem to prefer wrapping the first function parameter over wrapping the trailing tokens "const", "override" and "final". This does not extend to function-like annotations and probably not to other non-standard annotations. Before: void someLongFunction(int SomeLongParameter) const { ... } After: void someLongFunction( int SomeLongParameter) const { ... } llvm-svn: 201504
* clang-format: Fix formatting of class template declaration.Daniel Jasper2014-02-141-0/+2
| | | | | | | | | | | | | | Before: template <class R, class C> struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const> : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {}; After: template <class R, class C> struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const> : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {}; llvm-svn: 201424
* clang-format: Support lambdas with namespace-qualified return types.Daniel Jasper2014-02-111-0/+1
| | | | | | | E.g.: Foo([]()->std::vector<int> { return { 2 }; }()); llvm-svn: 201139
* clang-format: Fix alignment of comments inside statements.Daniel Jasper2014-02-112-25/+32
| | | | | | | | | | | | | | Before: auto result = SomeObject // Calling someFunction on SomeObject .someFunction(); After: auto result = SomeObject // Calling someFunction on SomeObject .someFunction(); llvm-svn: 201138
* clang-format: Fix column limit violation for merged lines in macros.Daniel Jasper2014-02-071-0/+15
| | | | | | | | | | | | | | | | Before (81 columns): #define A \ void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() { return aaaaaaaa; } \ int i; After: #define A \ void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() { \ return aaaaaaaa; \ } \ int i; llvm-svn: 200974
* clang-format: Fix range-based for-loop formatting.Daniel Jasper2014-02-071-0/+2
| | | | | | | | | | | | | | | Before: for (aaaaaaaaa aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaa.aaaaaaaaaaaa() .aaaaaaaaa() .a()) { } After: for (aaaaaaaaa aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaa.aaaaaaaaaaaa().aaaaaaaaa().a()) { } llvm-svn: 200968
* clang-format: Don't indent relative to unary operators.Daniel Jasper2014-02-051-1/+0
| | | | | | | | | | | | | | It seems like most people see unary operators more like part of the subsequent identifier and find relative indentation odd. Before: aaaaaaaaaa(!aaaaaaaaaa( // break aaaaa)); After: aaaaaaaaaa(!aaaaaaaaaa( // break aaaaa)); llvm-svn: 200840
* clang-format: Let chromium style inherit google style's javascript tweaks.Nico Weber2014-02-021-30/+15
| | | | llvm-svn: 200652
* clang-format: (JavaScript) Don't crash on empty string literals.Daniel Jasper2014-01-311-4/+8
| | | | | | | Before, this would lead to a crash: f('', true); llvm-svn: 200540
OpenPOWER on IntegriCloud