From cabc6fff222a1392b010aaa606725406d40673da Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sun, 29 May 2016 22:07:22 +0000 Subject: [PATCH] clang-format: Fix segfault introduced by allowing wraps after comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271191 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 3 ++- unittests/Format/FormatTestJS.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index f4d5ba6203..a0aed0dab4 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index e956ae2442..be6f960254 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -62,6 +62,11 @@ protected: } }; +TEST_F(FormatTestJS, BlockComments) { + verifyFormat("/* aaaaaaaaaaaaa */ aaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); +} + TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) { verifyFormat("a == = b;"); verifyFormat("a != = b;"); -- 2.40.0