From 56ef6aca2b3f6887f7c219932c1eafe0c5b7a000 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 1 Mar 2016 21:41:58 +0000 Subject: [PATCH] [clang-format] Detect constructor initializers preceded by `noexcept`. Patch by Erik Kessler, thank you. llvm-svn: 262402 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 7cb2c73..bc8d5c7 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -505,7 +505,7 @@ private: 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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 4872565..075757b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -10389,6 +10389,9 @@ TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) { 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" -- 2.7.4