diff options
author | Martin Probst <martin@probst.io> | 2017-08-09 15:19:16 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2017-08-09 15:19:16 +0000 |
commit | 0a19d433c1a52e65950998607517866ee42db40c (patch) | |
tree | da17af8b8a66f6863db6b6ce5f67b74c0ec0d314 | |
parent | 30e5194287a733e5cbfbf3ef95ecadce88a559da (diff) | |
download | bcm5719-llvm-0a19d433c1a52e65950998607517866ee42db40c.tar.gz bcm5719-llvm-0a19d433c1a52e65950998607517866ee42db40c.zip |
clang-format: [JS] detect ASI after closing parens.
Summary: A closing parenthesis followed by a declaration or statement should always terminate the current statement.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36491
llvm-svn: 310482
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index e6afd1f9887..fdf98839019 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -853,7 +853,8 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() { Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) return addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) + if ((PreviousMustBeValue || Previous->is(tok::r_paren)) && + isJSDeclOrStmt(Keywords, Next)) return addUnwrappedLine(); } diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index e6827296e12..fb035066d68 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1106,6 +1106,10 @@ TEST_F(FormatTestJS, WrapRespectsAutomaticSemicolonInsertion) { " readonly ratherLongField = 1;\n" "}", getGoogleJSStyleWithColumns(20)); + verifyFormat("const x = (5 + 9)\n" + "const y = 3\n", + "const x = ( 5 + 9)\n" + "const y = 3\n"); } TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) { |