From: Daniel Jasper Date: Wed, 21 May 2014 13:08:17 +0000 (+0000) Subject: clang-format: Fix incorrect macro call detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba2156840cb45e707ac25057a6ec19044754475c;p=clang clang-format: Fix incorrect macro call detection. In: struct A { A() noexcept(....) {} }; 'A()' is not a macro call. This fixes llvm.org/PR19814. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209294 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 5af743bba5..0585442550 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -605,7 +605,9 @@ bool tokenCanStartNewLine(clang::Token Tok) { // Colon is used in labels, base class lists, initializer lists, // range-based for loops, ternary operator, but should never be the // first token in an unwrapped line. - Tok.isNot(tok::colon); + Tok.isNot(tok::colon) && + // 'noexcept' is a trailing annotation. + Tok.isNot(tok::kw_noexcept); } void UnwrappedLineParser::parseStructuralElement() { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e5a94cf1e9..cff851c4f7 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2557,6 +2557,7 @@ TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) { "}\n")); EXPECT_EQ("class A {\n" " A() : t(0) {}\n" + " A(int i) noexcept() : {}\n" " A(X x)\n" // FIXME: function-level try blocks are broken. " try : t(0) {\n" " } catch (...) {\n" @@ -2564,6 +2565,7 @@ TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) { "};", format("class A {\n" " A()\n : t(0) {}\n" + " A(int i)\n noexcept() : {}\n" " A(X x)\n" " try : t(0) {} catch (...) {}\n" "};"));