From 5ebb2f362501bfe197418f321bb86a093a64f375 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 21 May 2014 13:08:17 +0000 Subject: [PATCH] clang-format: Fix incorrect macro call detection. In: struct A { A() noexcept(....) {} }; 'A()' is not a macro call. This fixes llvm.org/PR19814. llvm-svn: 209294 --- clang/lib/Format/UnwrappedLineParser.cpp | 4 +++- clang/unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 5af743b..0585442 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e5a94cf..cff851c4 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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" "};")); -- 2.7.4