Daniel Jasper
66cb8c503f
clang-format: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.
...
llvm-svn: 236415
2015-05-04 09:22:29 +00:00
Daniel Jasper
3cea45d079
clang-format: NFC: Use default member initializers and other cleanups.
...
llvm-svn: 236413
2015-05-04 08:51:40 +00:00
Daniel Jasper
de7ca75ca0
clang-format: Force aligning different brackets relative to each other.
...
Before:
void SomeFunction(vector< // break
int> v);
After:
void SomeFunction(vector< // break
int> v);
llvm-svn: 236412
2015-05-04 07:39:00 +00:00
Daniel Jasper
ee4a8a140a
clang-format: Fix for #pragma option formatting.
...
Adapted patch from Sergey Razmetov. Thank you.
llvm-svn: 235492
2015-04-22 09:45:42 +00:00
Daniel Jasper
a74f5072e1
clang-format: [JS] support optionality markers in JS types.
...
Patch by Martin Probst. Thank you.
llvm-svn: 234753
2015-04-13 15:01:40 +00:00
Daniel Jasper
53395406da
clang-format: Fix regression formatting QT's "signals:" from r234318.
...
llvm-svn: 234320
2015-04-07 15:04:40 +00:00
Daniel Jasper
05cd92922d
clang-format: Force line break in trailing calls after multline exprs.
...
Before:
aaaaaaaa(aaaaaaaaaa,
bbbbbbbbbb).a();
After:
aaaaaaaa(aaaaaaaaaa,
bbbbbbbbbb)
.a();
llvm-svn: 233304
2015-03-26 18:46:28 +00:00
Daniel Jasper
a0ef4f36c8
clang-format: [js] Support template strings.
...
Merge template strings (marked by backticks ``).
Do not format any contents of template strings.
Patch by Martin Probst. Thank you.
llvm-svn: 230011
2015-02-20 13:47:38 +00:00
Daniel Jasper
354aa51587
clang-format: [js] Support ES6 module imports.
...
Patch by Martin Probst.
llvm-svn: 229863
2015-02-19 16:07:32 +00:00
Daniel Jasper
b10bdff337
clang-format: [JS] Support type annotations.
...
This patch adds support for type annotations that follow TypeScript's,
Flow's, and AtScript's syntax style.
Patch by Martin Probst, thank you.
Review: http://reviews.llvm.org/D7721
llvm-svn: 229700
2015-02-18 17:09:53 +00:00
Aaron Ballman
abc1892057
Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; Clang edition.
...
llvm-svn: 229339
2015-02-15 22:54:08 +00:00
Benjamin Kramer
c5bc3cd00b
Format: Make FormatToken's isOneOf a variadic template
...
llvm-svn: 229326
2015-02-15 20:11:14 +00:00
Nico Weber
fac2371be3
clang-format: Add support for SEH __try / __except / __finally blocks.
...
This lets clang-format format
__try {
} __except(0) {
}
and
__try {
} __finally {
}
correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set,
so this turns this on. This also enables a few other keywords, but it
shouldn't overly perturb regular clang-format operation. __except is a
context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to
a few more places.
Fixes PR22321.
llvm-svn: 228148
2015-02-04 15:26:27 +00:00
Nico Weber
ed50166b6b
clang-format: [Java] Detect `native` keyword.
...
Before:
public native<X> Foo foo();
After:
public native <X> Foo foo();
llvm-svn: 225839
2015-01-13 22:32:50 +00:00
Daniel Jasper
11a0ac66e1
clang-format: Revamp nested block formatting.
...
This fixed llvm.org/PR21804 and hopefully a few other strange cases.
Before:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
After:
if (blah_blah(whatever, whatever, [] {
doo_dah();
doo_dah();
})) {
}
}
llvm-svn: 224112
2014-12-12 09:40:58 +00:00
Daniel Jasper
31f6c54733
clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.
...
This fixes llvm.org/PR21756.
llvm-svn: 223458
2014-12-05 10:42:21 +00:00
Daniel Jasper
9b9e07608d
clang-format: [Java] Don't line-wrap package declarations.
...
This fixes llvm.org/PR21677.
llvm-svn: 222843
2014-11-26 18:03:42 +00:00
Daniel Jasper
a98b7b01be
clang-format: Refactoring.
...
Re-apply r222638 and r222641 without variadic templates.
llvm-svn: 222747
2014-11-25 10:05:17 +00:00
Aaron Ballman
484ee9b404
Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 does not support variadic templates. Also reverting r222641 because it was relying on 222638.
...
llvm-svn: 222656
2014-11-24 15:42:34 +00:00
Daniel Jasper
325e486f9b
clang-format: [Java] Treat 'instanceof' like other binary operators.
...
This fixes llvm.org/PR21436.
llvm-svn: 222641
2014-11-23 21:34:25 +00:00
Daniel Jasper
7198b0c778
clang-format: Refactoring.
...
Provide more overloads to simplify testing the type of a token. No
functional changes intended.
llvm-svn: 222638
2014-11-23 19:03:25 +00:00
Daniel Jasper
82c9275344
clang-format: [Java] Support more Java keywords.
...
Before:
public final<X> Foo foo() {
}
public abstract<X> Foo foo();
After:
public final <X> Foo foo() {
}
public abstract <X> Foo foo();
Patch by Harry Terkelsen. Thank you.
llvm-svn: 222527
2014-11-21 12:19:07 +00:00
Daniel Jasper
8354ea84dd
clang-format: [Java] Basic lambda support.
...
llvm-svn: 222524
2014-11-21 12:14:12 +00:00
Nico Weber
a644d7f39c
clang-format: [Java] Never treat @interface as annotation.
...
'@' followed by any keyword can't be an annotation, but @interface is currently
the only combination of '@' and a keyword that's allowed, so limit it to this
case. `@interface Foo` without a leading `public` was misformatted prior to
this patch.
llvm-svn: 221607
2014-11-10 16:30:02 +00:00
Daniel Jasper
d0ec0d62d6
clang-format: Use identifier table for keywords in other languages.
...
Slightly easier to write, more efficient and prevents bugs by
misspelling them.
No functional changes intended.
llvm-svn: 221259
2014-11-04 12:41:02 +00:00
Daniel Jasper
e9ab42df0c
clang-format: [Java] Improve line breaks around annotations.
...
Before:
@SomeAnnotation("With some really looooooooooooooong text") private static final
long something = 0L;
void SomeFunction(@Nullable
String something) {}
After:
@SomeAnnotation("With some really looooooooooooooong text")
private static final long something = 0L;
void SomeFunction(@Nullable String something) {}
llvm-svn: 220984
2014-10-31 18:23:49 +00:00
Daniel Jasper
fab69ff095
clang-format: [Java] Wrap after each function annotation.
...
Before:
@Override public String toString() { .. }
After:
@Override
public String toString() { .. }
llvm-svn: 220274
2014-10-21 08:24:18 +00:00
Daniel Jasper
da07a72928
clang-format: Prefer breaking before trailing return arrows.
...
Before:
auto SomeFunction(
A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}
After:
auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const
-> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}
llvm-svn: 220043
2014-10-17 14:37:40 +00:00
Daniel Jasper
610381ff07
clang-format: Improve handling of block comments in braced lists.
...
Before:
std::vector<int> v = {
1, 0 /* comment */
};
After:
std::vector<int> v = {1, 0 /* comment */};
llvm-svn: 216445
2014-08-26 09:37:52 +00:00
Benjamin Kramer
2f5db8b3db
Header guard canonicalization, clang part.
...
Modifications made by clang-tidy with minor tweaks.
llvm-svn: 215557
2014-08-13 16:25:19 +00:00
Daniel Jasper
78b1949950
clang-format: Correct SBPO_Always-behavior after function-like keywords
...
Before:
auto f (int x) -> decltype(x) { return sizeof(x); }
int g () noexcept(someCall ());
static_assert(sizeof(char) == 1, "Your compiler is broken");
After:
auto f (int x) -> decltype (x) { return sizeof (x); }
int g () noexcept (someCall ());
static_assert (sizeof (char) == 1, "Your compiler is broken");
This fixes llvm.org/PR20559.
Patch by Roman Kashitsyn, thank you!
llvm-svn: 214969
2014-08-06 14:15:41 +00:00
Daniel Jasper
85bcadcdc6
clang-format: Fix behavior around pointer-to-member invocations.
...
Before:
(aaaaaaaaaa->*
bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));
After:
(aaaaaaaaaa->*bbbbbbb)(
aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));
llvm-svn: 212617
2014-07-09 13:07:57 +00:00
Daniel Jasper
4355e7f0ef
clang-format: Revamp function declaration/definition indentation.
...
Key changes:
- Correctly (well ...) distinguish function declarations and variable
declarations with ()-initialization.
- Don't indent when breaking function declarations/definitions after the
return type.
- Indent variable declarations and typedefs when breaking after the
type.
This fixes llvm.org/PR17999.
llvm-svn: 212591
2014-07-09 07:50:33 +00:00
Daniel Jasper
17062ff550
clang-format: [JS] Treat dict literals similar to objc method exprs.
...
Before:
return {
link:
function() {
f(); //
}
};
return {
a: a,
link: function() {
f(); //
}
}
After:
return {
link: function() {
f(); //
}
};
return {
a: a,
link: function() {
f(); //
}
};
llvm-svn: 210537
2014-06-10 14:44:02 +00:00
Daniel Jasper
114a2bc9d2
clang-format: Refactor indentation behavior for multiple nested blocks.
...
This fixes a few oddities when formatting multiple nested JavaScript
blocks, e.g.:
Before:
promise.then(
function success() {
doFoo();
doBar();
},
[], function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
After:
promise.then(
function success() {
doFoo();
doBar();
},
[],
function error() {
doFoo();
doBaz();
});
promise.then([],
function success() {
doFoo();
doBar();
},
function error() {
doFoo();
doBaz();
});
llvm-svn: 210097
2014-06-03 12:02:45 +00:00
Daniel Jasper
b05a81debb
clang-format: Fix bug introduced by r208392.
...
Also run clang-format over clang-format's files.
llvm-svn: 208409
2014-05-09 13:11:16 +00:00
Craig Topper
2145bc0229
[C++11] Use 'nullptr'.
...
llvm-svn: 208392
2014-05-09 08:15:10 +00:00
Daniel Jasper
f9ae312fc0
clang-format: [JS] Initial support for regex literals.
...
llvm-svn: 208281
2014-05-08 07:01:45 +00:00
Daniel Jasper
0e61784ae5
clang-format: Add special case to reduce indentaiton in streams.
...
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
2014-04-16 12:26:54 +00:00
Manuel Klimek
68b03049e0
Format code around VCS conflict markers.
...
Now correctly formats:
{
int a;
void f() {
callme(some(parameter1,
<<<<<<< text by the vcs
parameter2),
||||||| text by the vcs
parameter2),
parameter3,
======= text by the vcs
parameter2, parameter3),
>>>>>>> text by the vcs
otherparameter);
}
}
llvm-svn: 206157
2014-04-14 09:14:11 +00:00
Daniel Jasper
e1e4319ab7
clang-format: Support configurable list of foreach-macros.
...
This fixes llvm.org/PR17242.
Patch by Brian Green, thank you!
llvm-svn: 205307
2014-04-01 12:55:11 +00:00
Manuel Klimek
9481556eb6
Get rid of the adapted isLiteral method.
...
We don't want to deviate from clang's standard terminology.
llvm-svn: 204997
2014-03-28 09:27:09 +00:00
Manuel Klimek
1f9d80ac66
Improve handling of bool expressions in template arguments.
...
Now correctly formats:
foo<true && false>();
llvm-svn: 204950
2014-03-27 19:00:52 +00:00
Daniel Jasper
c13ee34378
clang-format: Correctly identify ObjC Block with return type.
...
llvm-svn: 204905
2014-03-27 09:43:54 +00:00
Craig Topper
fb6b25b5e4
[C++11] Add 'override' keyword to virtual methods that override their base class.
...
llvm-svn: 203999
2014-03-15 04:29:04 +00:00
Ahmed Charles
dfca6f97bc
[C++11] Replace OwningPtr include with <memory>.
...
llvm-svn: 203389
2014-03-09 11:36:40 +00:00
Ahmed Charles
b89843299a
Replace OwningPtr with std::unique_ptr.
...
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.
llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Daniel Jasper
559b63cbb9
clang-format: Understand __attribute__s preceding parameter lists.
...
Before:
ReturnType __attribute__((unused))
function(int i);
After:
ReturnType __attribute__((unused))
function(int i);
This fixes llvm.org/PR18632.
llvm-svn: 200337
2014-01-28 20:13:43 +00:00
Daniel Jasper
cb51cf409b
clang-format: Enable formatting of lambdas with explicit return type.
...
So clang-format can now format:
int c = []()->int { return 2; }();
int c = []()->vector<int> { return { 2 }; }();
llvm-svn: 199368
2014-01-16 09:11:55 +00:00
Daniel Jasper
0160347b22
clang-format: Some tweaks to braces list formatting:
...
- Format a braced list with one element per line if it has nested
braced lists.
- Use a column layout only when the list has 6+ elements (instead of the
current 4+ elements).
llvm-svn: 198869
2014-01-09 13:42:56 +00:00