diff options
| author | Daniel Jasper <djasper@google.com> | 2013-12-16 08:36:18 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-12-16 08:36:18 +0000 |
| commit | 3682fcda17f315b6c1d4eccd8e41b12de3bc45db (patch) | |
| tree | 2eaab485d2cc1eebaea44ce533349b2ca91cd9dc /clang/lib | |
| parent | c39b56fe14683957bae2248dd0433ee4c893e054 (diff) | |
| download | bcm5719-llvm-3682fcda17f315b6c1d4eccd8e41b12de3bc45db.tar.gz bcm5719-llvm-3682fcda17f315b6c1d4eccd8e41b12de3bc45db.zip | |
clang-format: Fix formatting of function type parameters.
Before:
void f() { typedef void (*f)(int * a); }
After:
void f() { typedef void (*f)(int *a); }
llvm-svn: 197369
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9132ba43770..19759afc854 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -605,12 +605,17 @@ private: Previous->Type = TT_PointerOrReference; } } - } else if (Current.isOneOf(tok::kw_return, tok::kw_throw) || - (Current.is(tok::l_paren) && !Line.MustBeDeclaration && - !Line.InPPDirective && - (!Current.Previous || - !Current.Previous->isOneOf(tok::kw_for, tok::kw_catch)))) { + } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) { Contexts.back().IsExpression = true; + } else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration && + !Line.InPPDirective) { + bool ParametersOfFunctionType = + Current.Previous && Current.Previous->is(tok::r_paren) && + Current.Previous->MatchingParen && + Current.Previous->MatchingParen->Type == TT_FunctionTypeLParen; + bool IsForOrCatch = Current.Previous && + Current.Previous->isOneOf(tok::kw_for, tok::kw_catch); + Contexts.back().IsExpression = !ParametersOfFunctionType && !IsForOrCatch; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); |

