summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-01-07 14:36:11 +0000
committerDaniel Jasper <djasper@google.com>2016-01-07 14:36:11 +0000
commit54353dac756011f3edcfa324b6ec51ca940a1d4b (patch)
treefe08102a513c57f31cb34ac25e92815da61f636a /clang/lib/Format
parent9272a1c5a2c74b6d176f08c18d0f2fb7453b3d01 (diff)
downloadbcm5719-llvm-54353dac756011f3edcfa324b6ec51ca940a1d4b.tar.gz
bcm5719-llvm-54353dac756011f3edcfa324b6ec51ca940a1d4b.zip
clang-format: Support weird lambda macros.
Before: MACRO((AA & a) { return 1; }); After: MACRO((AA &a) { return 1; }); llvm-svn: 257062
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index caff1312f30..7390865d4cc 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -199,6 +199,18 @@ private:
Left->MatchingParen = CurrentToken;
CurrentToken->MatchingParen = Left;
+ if (CurrentToken->Next && CurrentToken->Next->is(tok::l_brace) &&
+ Left->Previous && Left->Previous->is(tok::l_paren)) {
+ // Detect the case where macros are used to generate lambdas or
+ // function bodies, e.g.:
+ // auto my_lambda = MARCO((Type *type, int i) { .. body .. });
+ for (FormatToken *Tok = Left; Tok != CurrentToken; Tok = Tok->Next) {
+ if (Tok->is(TT_BinaryOperator) &&
+ Tok->isOneOf(tok::star, tok::amp, tok::ampamp))
+ Tok->Type = TT_PointerOrReference;
+ }
+ }
+
if (StartsObjCMethodExpr) {
CurrentToken->Type = TT_ObjCMethodExpr;
if (Contexts.back().FirstObjCSelectorName) {
OpenPOWER on IntegriCloud