From 0a84f178821bf7c7098744c30a37c2671eb1f1be Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 5 Aug 2014 17:58:54 +0000 Subject: [PATCH] [PR19983] SBPO_Always not covering all the cases. Patch by "Roman Kashitsyn" . Phabricator revision: http://reviews.llvm.org/D4788 llvm-svn: 214904 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ed6938fdbc87..ca85c10fe5be 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1630,7 +1630,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Tok.Previous->Type == TT_ConditionalExpr) return true; if (Tok.Previous->Type == TT_TemplateCloser && Tok.is(tok::l_paren)) - return false; + return Style.SpaceBeforeParens == FormatStyle::SBPO_Always; if (Tok.is(tok::less) && Tok.Previous->isNot(tok::l_paren) && Line.First->is(tok::hash)) return true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 74cca4fafbcc..6bbda9d6e3bd 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -7540,6 +7540,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { "default:\n" " break;\n" "}", NoSpace); + verifyFormat("auto i = std::make_unique(5);", NoSpace); FormatStyle Space = getLLVMStyle(); Space.SpaceBeforeParens = FormatStyle::SBPO_Always; @@ -7576,6 +7577,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("#if defined(x)\n" "#endif", Space); + verifyFormat("auto i = std::make_unique (5);", Space); } TEST_F(FormatTest, ConfigurableSpacesInParentheses) {