diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index b65971103ef..98ef453e4cd 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -694,8 +694,9 @@ private: } 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 && Current.Previous && - Current.Previous->isNot(tok::kw_decltype)) { + !Line.InPPDirective && + (!Current.Previous || + Current.Previous->isNot(tok::kw_decltype))) { bool ParametersOfFunctionType = Current.Previous && Current.Previous->is(tok::r_paren) && Current.Previous->MatchingParen && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e80d1e3d112..aad0cb19fb2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4754,6 +4754,8 @@ TEST_F(FormatTest, FormatsCasts) { // FIXME: single value wrapped with paren will be treated as cast. verifyFormat("void f(int i = (kValue)*kMask) {}"); + verifyFormat("{ (void)F; }"); + // Don't break after a cast's verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" " (aaaaaaaaaaaaaaaaaaaaaaaaaa *)(aaaaaaaaaaaaaaaaaaaaaa +\n" |

