diff options
author | Daniel Jasper <djasper@google.com> | 2014-05-05 13:48:09 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-05-05 13:48:09 +0000 |
commit | f10a28d705d0e8c0300561d8e7991b735cf0a23a (patch) | |
tree | cca2c88ceeac73a43eaf5a793ee3b52f7358f253 /clang/lib/Format | |
parent | 76f98f8047dee94a3131f733ed99fb6fc23a0cfc (diff) | |
download | bcm5719-llvm-f10a28d705d0e8c0300561d8e7991b735cf0a23a.tar.gz bcm5719-llvm-f10a28d705d0e8c0300561d8e7991b735cf0a23a.zip |
clang-format: Understand functions with decltype return type.
Before:
decltype(long_name_forcing_break)
f() {}
After:
decltype(long_name_forcing_break)
f() {}
llvm-svn: 207965
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index a6e04c54a21..e2e342c4593 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -414,7 +414,9 @@ private: if (!parseParens()) return false; if (Line.MustBeDeclaration && Contexts.size() == 1 && - !Contexts.back().IsExpression && Line.First->Type != TT_ObjCProperty) + !Contexts.back().IsExpression && + Line.First->Type != TT_ObjCProperty && + (!Tok->Previous || Tok->Previous->isNot(tok::kw_decltype))) Line.MightBeFunctionDecl = true; break; case tok::l_square: @@ -869,6 +871,11 @@ private: PreviousNotConst->MatchingParen->Previous && PreviousNotConst->MatchingParen->Previous->isNot(tok::kw_template); + if (PreviousNotConst->is(tok::r_paren) && PreviousNotConst->MatchingParen && + PreviousNotConst->MatchingParen->Previous && + PreviousNotConst->MatchingParen->Previous->is(tok::kw_decltype)) + return true; + return (!IsPPKeyword && PreviousNotConst->is(tok::identifier)) || PreviousNotConst->Type == TT_PointerOrReference || PreviousNotConst->isSimpleTypeSpecifier(); |