forked from OSchip/llvm-project
Improve detection of trailing return types.
Trailing return types can only occur in declaration contexts. Before: void f() { auto a = b -> c(); } After: void f() { auto a = b->c(); } llvm-svn: 186087
This commit is contained in:
parent
889865fb69
commit
a3501d4b81
|
@ -607,7 +607,8 @@ private:
|
|||
NameFound = true;
|
||||
} else if (Current.is(tok::kw_auto)) {
|
||||
AutoFound = true;
|
||||
} else if (Current.is(tok::arrow) && AutoFound) {
|
||||
} else if (Current.is(tok::arrow) && AutoFound &&
|
||||
Line.MustBeDeclaration) {
|
||||
Current.Type = TT_TrailingReturnArrow;
|
||||
} else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
|
||||
Current.Type =
|
||||
|
|
|
@ -2476,6 +2476,9 @@ TEST_F(FormatTest, TrailingReturnType) {
|
|||
verifyFormat("template <size_t Order, typename T>\n"
|
||||
"auto load_img(const std::string &filename)\n"
|
||||
" -> alias::tensor<Order, T, mem::tag::cpu> {}");
|
||||
|
||||
// Not trailing return types.
|
||||
verifyFormat("void f() { auto a = b->c(); }");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {
|
||||
|
|
Loading…
Reference in New Issue