]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect macro call detection.
authorDaniel Jasper <djasper@google.com>
Wed, 21 May 2014 13:08:17 +0000 (13:08 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 21 May 2014 13:08:17 +0000 (13:08 +0000)
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

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 5af743bba5a57ab341ef44cb58871fc2ba01080b..058544255037ef874cee3dce0724575ce774d476 100644 (file)
@@ -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() {
index e5a94cf1e94287cff524d986cbb46995e7649c75..cff851c4f7757b5ddff0217e80dacbf66120e101 100644 (file)
@@ -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"
                    "};"));