r209294 - clang-format: Fix incorrect macro call detection.

Daniel Jasper djasper at google.com
Wed May 21 06:08:17 PDT 2014


Author: djasper
Date: Wed May 21 08:08:17 2014
New Revision: 209294

URL: http://llvm.org/viewvc/llvm-project?rev=209294&view=rev
Log:
clang-format: Fix incorrect macro call detection.

In:
  struct A {
    A()
        noexcept(....) {}
  };

'A()' is not a macro call.
This fixes llvm.org/PR19814.

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=209294&r1=209293&r2=209294&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed May 21 08:08:17 2014
@@ -605,7 +605,9 @@ bool tokenCanStartNewLine(clang::Token T
          // 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() {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=209294&r1=209293&r2=209294&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 21 08:08:17 2014
@@ -2557,6 +2557,7 @@ TEST_F(FormatTest, MacroCallsWithoutTrai
                    "}\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, MacroCallsWithoutTrai
             "};",
             format("class A {\n"
                    "  A()\n : t(0) {}\n"
+                   "  A(int i)\n noexcept() : {}\n"
                    "  A(X x)\n"
                    "  try : t(0) {} catch (...) {}\n"
                    "};"));





More information about the cfe-commits mailing list