r281816 - clang-format: [JS] Fix a crash in handledTemplateStrings.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 17 00:20:37 PDT 2016
Author: djasper
Date: Sat Sep 17 02:20:36 2016
New Revision: 281816
URL: http://llvm.org/viewvc/llvm-project?rev=281816&view=rev
Log:
clang-format: [JS] Fix a crash in handledTemplateStrings.
Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=281816&r1=281815&r2=281816&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Sat Sep 17 02:20:36 2016
@@ -235,6 +235,8 @@ void FormatTokenLexer::handleTemplateStr
return;
}
if (BacktickToken->is(tok::r_brace)) {
+ if (StateStack.size() == 1)
+ return;
StateStack.pop();
if (StateStack.top() != LexerState::TEMPLATE_STRING)
return;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=281816&r1=281815&r2=281816&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Sep 17 02:20:36 2016
@@ -1253,6 +1253,9 @@ TEST_F(FormatTestJS, NestedTemplateStrin
verifyFormat(
"var x = `<ul>${xs.map(x => `<li>${x}</li>`).join('\\n')}</ul>`;");
verifyFormat("var x = `he${({text: 'll'}.text)}o`;");
+
+ // Crashed at some point.
+ verifyFormat("}");
}
TEST_F(FormatTestJS, TaggedTemplateStrings) {
More information about the cfe-commits
mailing list