clang-format: Fix incorrect trailing return arrow detection.

Before:
  auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {}

After:
  auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {}

llvm-svn: 220373
This commit is contained in:
Daniel Jasper 2014-10-22 08:42:58 +00:00
parent c928de3e8e
commit e8a4939b77
2 changed files with 2 additions and 1 deletions

View File

@ -779,7 +779,7 @@ private:
} else if (Current.is(tok::kw_auto)) {
AutoFound = true;
} else if (Current.is(tok::arrow) && AutoFound &&
Line.MustBeDeclaration) {
Line.MustBeDeclaration && Current.NestingLevel == 0) {
Current.Type = TT_TrailingReturnArrow;
} else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
Current.Type =

View File

@ -3526,6 +3526,7 @@ TEST_F(FormatTest, TrailingReturnType) {
" -> alias::tensor<Order, T, mem::tag::cpu> {}");
verifyFormat("auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const\n"
" -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}");
verifyFormat("auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {}");
// Not trailing return types.
verifyFormat("void f() { auto a = b->c(); }");