[PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.

Erik Kessler via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 00:48:06 PST 2016


erik65536 updated this revision to Diff 49155.
erik65536 added a comment.

Change is() || is() to isOneOf() and added a test case.


http://reviews.llvm.org/D17621

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10379,6 +10379,9 @@
   verifyFormat("SomeClass::Constructor()\n"
                "    : a(a) {}",
                Style);
+  verifyFormat("SomeClass::Constructor() noexcept\n"
+               "    : a(a) {}",
+               Style);
   verifyFormat("SomeClass::Constructor()\n"
                "    : a(a)\n"
                "    , b(b)\n"
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -504,7 +504,7 @@
         Tok->Type = TT_BitFieldColon;
       } else if (Contexts.size() == 1 &&
                  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-        if (Tok->Previous->is(tok::r_paren))
+        if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
           Tok->Type = TT_CtorInitializerColon;
         else
           Tok->Type = TT_InheritanceColon;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17621.49155.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160226/578f8bb0/attachment.bin>


More information about the cfe-commits mailing list