summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp7
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp2
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index e36d7efffd2..b25abeae937 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -715,6 +715,13 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
return;
bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+ if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+ // If the token before the previous one is an '@', the previous token is an
+ // annotation and can precede another identifier/value.
+ const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+ if (PrePrevious->is(tok::at))
+ return;
+ }
if (Next->is(tok::exclaim) && PreviousMustBeValue)
addUnwrappedLine();
bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 73f3afbaf09..912682449e3 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -686,6 +686,8 @@ TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
verifyFormat("x instanceof String", "x\n"
"instanceof\n"
"String");
+ verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+ " bar) {}");
}
TEST_F(FormatTestJS, ClosureStyleCasts) {
OpenPOWER on IntegriCloud