diff options
-rw-r--r-- | lib/Format/Format.cpp | 4 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index bdcf5b67fe..90bcf6feb7 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1049,7 +1049,7 @@ public: break; case tok::kw_if: case tok::kw_while: - if (CurrentToken->is(tok::l_paren)) { + if (CurrentToken != NULL && CurrentToken->is(tok::l_paren)) { next(); if (!parseParens(/*LookForDecls=*/true)) return false; @@ -1088,7 +1088,7 @@ public: Tok->Type = TT_BinaryOperator; break; case tok::kw_operator: - if (CurrentToken->is(tok::l_paren)) { + if (CurrentToken != NULL && CurrentToken->is(tok::l_paren)) { CurrentToken->Type = TT_OverloadedOperator; next(); if (CurrentToken != NULL && CurrentToken->is(tok::r_paren)) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index c1c1696d9e..fb5221ee24 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1679,11 +1679,16 @@ TEST_F(FormatTest, BlockComments) { "/* */someCall(parameter);", getLLVMStyleWithColumns(15))); } -TEST_F(FormatTest, Fuck) { +TEST_F(FormatTest, FormatStarDependingOnContext) { verifyFormat("void f(int *a);"); verifyFormat("void f() { f(fint * b); }"); } +TEST_F(FormatTest, SpecialTokensAtEndOfLine) { + verifyFormat("while"); + verifyFormat("operator"); +} + //===----------------------------------------------------------------------===// // Objective-C tests. //===----------------------------------------------------------------------===// |