summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Improve binary operator detection.Daniel Jasper2014-04-281-1/+1
| | | | | | | | | | | | Before: *(int *)(p &~3UL) = 0; After: *(int *)(p & ~3UL) = 0; This fixes llvm.org/PR19464. llvm-svn: 207405
* clang-format: Fixes spaces in case statements.Daniel Jasper2014-04-281-2/+3
| | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19482. Before: switch (a) { case(B) : return; } After: switch (a) { case (B): return; } llvm-svn: 207402
* clang-format: Don't wrap after @interface.Daniel Jasper2014-04-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19450. Before: @interface BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate, BookmarkFolderCollectionViewDelegate, BookmarkMenuViewControllerDelegate, BookmarkSearchViewControllerDelegate> { } After: @interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> { } llvm-svn: 207400
* [Modules] Update Clang's two files that use DEBUG(...) without definingChandler Carruth2014-04-211-0/+2
| | | | | | DEBUG_TYPE to do so. LLVM's Debug.h requires this as of r206822. llvm-svn: 206823
* clang-format: Add special case to reduce indentaiton in streams.Daniel Jasper2014-04-161-2/+6
| | | | | | | | | | | | | | | | This is similar to how we treat assignments and seems to be generally desirable. Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 206384
* clang-format: Understand proto text format without commas.Daniel Jasper2014-04-151-1/+6
| | | | | | | | | | | | | | | | Also removed spaces before colons as they don't seem to be used frequently. Before: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb : "baz"}]; After: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123, bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}]; llvm-svn: 206269
* clang-format: Fix regression caused by r206165.Daniel Jasper2014-04-141-1/+3
| | | | llvm-svn: 206173
* clang-format: Fix incorrect &&-detection in macros.Daniel Jasper2014-04-141-0/+3
| | | | | | | | | | | | Before: #define A(a, b) (a &&b) After: #define A(a, b) (a && b) This fixes llvm.org/PR19343. llvm-svn: 206165
* clang-format: Don't allow hanging indentation for operators on new linesDaniel Jasper2014-04-141-1/+5
| | | | | | | | | | | | | | | | Before: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... After: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... The same rule has already be implemented for BreakBeforeBinaryOperators set to false in r205527. llvm-svn: 206159
* clang-format: Improve formatting of annotated variables.Daniel Jasper2014-04-141-0/+1
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 206155
* Correctly handle escaped newlines when the next token starts without a space.Manuel Klimek2014-04-111-1/+1
| | | | | | | We will need this to correctly handle conflict markers inside macro definitions. llvm-svn: 206029
* clang-format: Treat a trailing comment like a trailing comma in braced lists.Daniel Jasper2014-04-091-5/+7
| | | | | | | | | | | | | | | | | Before: static StructInitInfo module = {MODULE_BUILTIN, /* type */ "streams" /* name */ }; After: static StructInitInfo module = { MODULE_BUILTIN, /* type */ "streams" /* name */ }; This fixes llvm.org/PR19378. llvm-svn: 205851
* clang-format: Allow breaking between trailing annotations in more cases.Daniel Jasper2014-04-091-5/+5
| | | | | | | | | | | | Before: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA( aaaaaaaaaaaaaaa); After: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa); llvm-svn: 205846
* clang-format: Keep more trailing annotations on the same line.Daniel Jasper2014-04-091-4/+2
| | | | | | | | | | | | | | | | | | | | More precisely keep all short annotations (<10 characters) on the same line if possible. Previously, clang-format would only prefer to do so for "const", "override" and "final". However, it seems to be generally preferable, especially because some codebases have to wrap those in macros for backwards compatibility. Before: void someLongFunction(int someLongParameter) OVERRIDE {} After: void someLongFunction( int someLongParameter) OVERRIDE {} This fixes llvm.org/PR19363. llvm-svn: 205845
* clang-format: Recognize lists ending in trailing commas correctly.Daniel Jasper2014-04-091-7/+11
| | | | | | | Previously, this did not look through trailing comments leading to a few formatting oddities. llvm-svn: 205843
* clang-format: Fix incorrect multi-block-parameter computation.Daniel Jasper2014-04-081-3/+2
| | | | llvm-svn: 205763
* clang-format: Correctly understand arrays of pointers.Daniel Jasper2014-04-081-1/+1
| | | | | | | | | | | | Before: A<int * []> a; After: A<int *[]> a; This fixes llvm.org/PR19360. llvm-svn: 205761
* 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-011-3/+11
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* Get rid of the adapted isLiteral method.Manuel Klimek2014-03-281-3/+6
| | | | | | We don't want to deviate from clang's standard terminology. llvm-svn: 204997
* Improve handling of bool expressions in template arguments.Manuel Klimek2014-03-271-3/+7
| | | | | | | Now correctly formats: foo<true && false>(); llvm-svn: 204950
* 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-271-4/+6
| | | | 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: 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
* Fix crasher bug.Manuel Klimek2014-03-181-13/+18
| | | | | | | | | | | | | | | 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: 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
* clang-format: Add spaces around trailing/lambda return types.Daniel Jasper2014-03-101-1/+2
| | | | | | | | | | Before: int c = []()->int { return 2; }(); After: int c = []() -> int { return 2; }(); llvm-svn: 203452
* 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: 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: More custom option fixes for protocol buffer files.Daniel Jasper2014-01-291-1/+2
| | | | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = { aaaaaaaaaaaaaaaa : AAAAAAAAAA, bbbbbbbbbbbbbbbb : BBBBBBBBBB }]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa : AAAAAAAAAA, bbbbbbbbbbbbbbbb : BBBBBBBBBB}]; llvm-svn: 200406
* clang-format: Fix formatting of custom proto options.Daniel Jasper2014-01-291-1/+1
| | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = { aaaaaaaaaaaaaaaaa : AAAAAAAA }]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}]; llvm-svn: 200405
* clang-format: Understand __attribute__s preceding parameter lists.Daniel Jasper2014-01-281-12/+13
| | | | | | | | | | | | | | Before: ReturnType __attribute__((unused)) function(int i); After: ReturnType __attribute__((unused)) function(int i); This fixes llvm.org/PR18632. llvm-svn: 200337
* clang-format: Fix option formatting in protocol buffer files.Daniel Jasper2014-01-281-0/+1
| | | | | | | | | | Before: optional int32 foo[ default = true, deprecated = true ]; After: optional int32 foo[default = true, deprecated = true]; llvm-svn: 200327
* clang-format: Add support for a space after @propertyDaniel Jasper2014-01-281-0/+3
| | | | | | | | | Mozilla and WebKit seem to use a space after @property (verified by grepping their codebases) so we turn this on there as well. Change by Christian Legnitto. Thank you! llvm-svn: 200320
* clang-format: Fix incorrect space removal.Daniel Jasper2014-01-251-1/+1
| | | | | | | | | | | | Before: Deleted &operator=(const Deleted &)&= default; Deleted &operator=(const Deleted &)&&= delete; After: Deleted &operator=(const Deleted &)& = default; Deleted &operator=(const Deleted &)&& = delete; llvm-svn: 200073
* clang-format: Treat "." in protos like namespace separators.Daniel Jasper2014-01-221-1/+2
| | | | | | | | | | | | | Before: optional really.really.long.and.qualified.type.aaaaaaa .aaaaaaaa another_fiiiiiiiiiiiiiiiiiiiiield = 2; After: optional really.really.long.and.qualified.type.aaaaaaa.aaaaaaaa another_fiiiiiiiiiiiiiiiiiiiiield = 2; llvm-svn: 199796
* clang-format: text following #if is likely an expression.Daniel Jasper2014-01-211-1/+2
| | | | | | | | | | Before: #if AAAA &&BBBB After: #if AAAA && BBBB llvm-svn: 199713
* clang-format: Properly format custom options in protocol buffer definitions.Daniel Jasper2014-01-201-1/+2
| | | | | | | | | | Before: option(my_option) = "abc"; After: option (my_option) = "abc"; llvm-svn: 199672
* clang-format: Better support and testing for protocol buffers.Daniel Jasper2014-01-191-3/+14
| | | | | | | | | With this patch, there is dedicated testing for protocol buffers (https://developers.google.com/protocol-buffers/). Also some minor tweaks formatting tweaks. llvm-svn: 199580
* clang-format: Fix ObjC block as first call parameter formatting.Daniel Jasper2014-01-191-0/+2
| | | | | | | | | Before: foo (^{ bar(); }); After: foo(^{ bar(); }); llvm-svn: 199573
* clang-format: Don't break lines starting with "import <string-literal>"Daniel Jasper2014-01-171-0/+9
| | | | | | | | | The author might be missing the "#" or these might be protocol buffer definitions. Either way, we should not break the line or the string. There don't seem to be other valid use cases. llvm-svn: 199501
* clang-format: Improve formatting of ObjC Blocks with return type.Daniel Jasper2014-01-161-4/+10
| | | | | | | | | | Before: int a = [operation block:^int(int * i) { return 1; }]; After: int a = [operation block:^int(int *i) { return 1; }]; llvm-svn: 199411
* clang-format: Enable formatting of lambdas with explicit return type.Daniel Jasper2014-01-161-32/+2
| | | | | | | | | So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector<int> { return { 2 }; }(); llvm-svn: 199368
* clang-format: Fixed formatting of JavaScript container literalsDaniel Jasper2014-01-151-5/+4
| | | | | | | | | | | | Before: var arr = [ 1, 2, 3 ]; var obj = {a : 1, b : 2, c : 3}; After: var arr = [1, 2, 3]; var obj = {a: 1, b: 2, c: 3}; llvm-svn: 199317
* clang-format: Fix corner case with comment in ctor initializer.Daniel Jasper2014-01-131-0/+1
| | | | | | | | | | | | | | | | | | | | Formatting: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} Before: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} After: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} llvm-svn: 199107
OpenPOWER on IntegriCloud