forked from OSchip/llvm-project
[clang-format] Fix a crash on lambda trailing return type
Fixes #55625.
This commit is contained in:
parent
f4d52cad67
commit
130a9cc0a5
|
@ -1185,7 +1185,8 @@ private:
|
|||
}
|
||||
break;
|
||||
case tok::arrow:
|
||||
if (Tok->Previous && Tok->Previous->is(tok::kw_noexcept))
|
||||
if (Tok->isNot(TT_LambdaArrow) && Tok->Previous &&
|
||||
Tok->Previous->is(tok::kw_noexcept))
|
||||
Tok->setType(TT_TrailingReturnArrow);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -21338,6 +21338,7 @@ TEST_F(FormatTest, FormatsLambdas) {
|
|||
verifyFormat("int c = []() -> int * { return 2; }();\n");
|
||||
verifyFormat("int c = []() -> vector<int> { return {2}; }();\n");
|
||||
verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
|
||||
verifyFormat("foo([]() noexcept -> int {});");
|
||||
verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};");
|
||||
verifyGoogleFormat("auto a = [&b, c](D* d) -> pair<D*, D*> {};");
|
||||
verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
|
||||
|
|
Loading…
Reference in New Issue