]> granicus.if.org Git - clang/commitdiff
clang-format: Fix segfault introduced by allowing wraps after comments.
authorDaniel Jasper <djasper@google.com>
Sun, 29 May 2016 22:07:22 +0000 (22:07 +0000)
committerDaniel Jasper <djasper@google.com>
Sun, 29 May 2016 22:07:22 +0000 (22:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271191 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestJS.cpp

index f4d5ba62035d4c9f0d22bfd1a5e43db518cefeb0..a0aed0dab47a53ad65f5ae4db4e51afbd2929386 100644 (file)
@@ -478,7 +478,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
   //
   // is common and should be formatted like a free-standing function.
   if (Style.Language != FormatStyle::LK_JavaScript ||
-      Current.NestingLevel != 0 || !PreviousNonComment->is(tok::equal) ||
+      Current.NestingLevel != 0 || !PreviousNonComment ||
+      !PreviousNonComment->is(tok::equal) ||
       !Current.isOneOf(Keywords.kw_async, Keywords.kw_function))
     State.Stack.back().NestedBlockIndent = State.Column;
 
index e956ae2442494f653989f97b0ea3e7044deeed9b..be6f960254574fc05243760034376a1d7d3678d1 100644 (file)
@@ -62,6 +62,11 @@ protected:
   }
 };
 
+TEST_F(FormatTestJS, BlockComments) {
+  verifyFormat("/* aaaaaaaaaaaaa */ aaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+}
+
 TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
   verifyFormat("a == = b;");
   verifyFormat("a != = b;");