Skip to content

Commit fe26853

Browse files
committed
[clang-format] Fix a crash caused by commit f03bf8c
1 parent 76275c0 commit fe26853

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class AnnotatingParser {
493493
(CurrentToken->Next->is(tok::l_paren) ||
494494
(CurrentToken->Next->is(tok::l_square) &&
495495
(Line.MustBeDeclaration ||
496-
PrevNonComment->isTypeName(LangOpts))))) {
496+
(PrevNonComment && PrevNonComment->isTypeName(LangOpts)))))) {
497497
OpeningParen.setType(OpeningParen.Next->is(tok::caret)
498498
? TT_ObjCBlockLParen
499499
: TT_FunctionTypeLParen);

clang/unittests/Format/FormatTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13691,6 +13691,10 @@ TEST_F(FormatTest, FormatsArrays) {
1369113691
" .aaaaaaaaaaaaaaaaaaaaaa();");
1369213692
verifyFormat("a[::b::c];");
1369313693

13694+
verifyFormat("{\n"
13695+
" (*a)[0] = 1;\n"
13696+
"}");
13697+
1369413698
verifyNoCrash("a[,Y?)]", getLLVMStyleWithColumns(10));
1369513699

1369613700
FormatStyle NoColumnLimit = getLLVMStyleWithColumns(0);

0 commit comments

Comments
 (0)