Author: mprobst Date: Mon Apr 11 02:35:57 2016 New Revision: 265916 URL: http://llvm.org/viewvc/llvm-project?rev=265916&view=rev Log: clang-format: [JS] do not insert semicolons after wrapped annotations.
Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D18943 Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=265916&r1=265915&r2=265916&view=diff ============================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Apr 11 02:35:57 2016 @@ -715,6 +715,13 @@ void UnwrappedLineParser::readTokenWithJ 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); Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=265916&r1=265915&r2=265916&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Apr 11 02:35:57 2016 @@ -686,6 +686,8 @@ TEST_F(FormatTestJS, AutomaticSemicolonI verifyFormat("x instanceof String", "x\n" "instanceof\n" "String"); + verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n" + " bar) {}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits