diff options
| author | Daniel Jasper <djasper@google.com> | 2015-08-11 20:32:24 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-08-11 20:32:24 +0000 |
| commit | a804d1ec8018bbeab1852ded20b2cba56fed1309 (patch) | |
| tree | 90b29c8dc0f5276e1d41b25b503eb59e7dae3fad | |
| parent | 916698d23d1110b9ff1a9db4b5fcfa5d8edaf217 (diff) | |
| download | bcm5719-llvm-a804d1ec8018bbeab1852ded20b2cba56fed1309.tar.gz bcm5719-llvm-a804d1ec8018bbeab1852ded20b2cba56fed1309.zip | |
clang-format: Make SpaceBeforeParens work with overloaded operators.
Patch by Jon Chesterfield, thank you!
llvm-svn: 244660
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index bd6fde09113..25ec7e6023d 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1997,7 +1997,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Right.isOneOf(TT_CtorInitializerColon, TT_ObjCBlockLParen)) return true; if (Right.is(TT_OverloadedOperatorLParen)) - return false; + return Style.SpaceBeforeParens == FormatStyle::SBPO_Always; if (Right.is(tok::colon)) { if (Line.First->isOneOf(tok::kw_case, tok::kw_default) || !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f71f63c7ddf..6eee541d0ba 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8279,6 +8279,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("static_assert(sizeof(char) == 1, \"Impossible!\");", NoSpace); verifyFormat("int f() throw(Deprecated);", NoSpace); verifyFormat("typedef void (*cb)(int);", NoSpace); + verifyFormat("T A::operator()();", NoSpace); + verifyFormat("X A::operator++(T);", NoSpace); FormatStyle Space = getLLVMStyle(); Space.SpaceBeforeParens = FormatStyle::SBPO_Always; @@ -8324,6 +8326,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("static_assert (sizeof (char) == 1, \"Impossible!\");", Space); verifyFormat("int f () throw (Deprecated);", Space); verifyFormat("typedef void (*cb) (int);", Space); + verifyFormat("T A::operator() ();", Space); + verifyFormat("X A::operator++ (T);", Space); } TEST_F(FormatTest, ConfigurableSpacesInParentheses) { |

