forked from OSchip/llvm-project
clang-format: Prevent assertion discovered by fuzzer.
llvm-svn: 236578
This commit is contained in:
parent
4d9ec17f1e
commit
62c78f5474
|
@ -895,8 +895,16 @@ private:
|
||||||
(!Current.Previous || Current.Previous->isNot(tok::l_square))) {
|
(!Current.Previous || Current.Previous->isNot(tok::l_square))) {
|
||||||
Current.Type = TT_BinaryOperator;
|
Current.Type = TT_BinaryOperator;
|
||||||
} else if (Current.is(tok::comment)) {
|
} else if (Current.is(tok::comment)) {
|
||||||
Current.Type =
|
if (Current.TokenText.startswith("/*")) {
|
||||||
Current.TokenText.startswith("/*") ? TT_BlockComment : TT_LineComment;
|
if (Current.TokenText.endswith("*/"))
|
||||||
|
Current.Type = TT_BlockComment;
|
||||||
|
else
|
||||||
|
// The lexer has for some reason determined a comment here. But we
|
||||||
|
// cannot really handle it, if it isn't properly terminated.
|
||||||
|
Current.Tok.setKind(tok::unknown);
|
||||||
|
} else {
|
||||||
|
Current.Type = TT_LineComment;
|
||||||
|
}
|
||||||
} else if (Current.is(tok::r_paren)) {
|
} else if (Current.is(tok::r_paren)) {
|
||||||
if (rParenEndsCast(Current))
|
if (rParenEndsCast(Current))
|
||||||
Current.Type = TT_CastRParen;
|
Current.Type = TT_CastRParen;
|
||||||
|
|
|
@ -1056,6 +1056,8 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
|
||||||
|
|
||||||
verifyNoCrash("/\\\n/");
|
verifyNoCrash("/\\\n/");
|
||||||
verifyNoCrash("/\\\n* */");
|
verifyNoCrash("/\\\n* */");
|
||||||
|
// The 0-character somehow makes the lexer return a proper comment.
|
||||||
|
verifyNoCrash(StringRef("/*\\\0\n/", 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {
|
TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {
|
||||||
|
|
Loading…
Reference in New Issue