Fix crasher bug in clang-format.

llvm-svn: 215549
This commit is contained in:
Manuel Klimek 2014-08-13 14:00:41 +00:00
parent 498cce575f
commit 5f594f80f4
2 changed files with 8 additions and 1 deletions

View File

@ -701,8 +701,11 @@ private:
for (FormatToken *Previous = Current.Previous;
Previous && !Previous->isOneOf(tok::comma, tok::semi);
Previous = Previous->Previous) {
if (Previous->isOneOf(tok::r_square, tok::r_paren))
if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
Previous = Previous->MatchingParen;
if (!Previous)
break;
}
if ((Previous->Type == TT_BinaryOperator ||
Previous->Type == TT_UnaryOperator) &&
Previous->isOneOf(tok::star, tok::amp)) {

View File

@ -9200,5 +9200,9 @@ TEST_F(FormatTest, DisableRegions) {
" int k;"));
}
TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
format("? ) =");
}
} // end namespace tooling
} // end namespace clang