From 0e6b5702afc36a6f8a18f1113361ead38daf9610 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 7 Oct 2015 03:43:10 +0000 Subject: [PATCH] clang-format: Fix false ObjC block detection. Before: inline A operator^(const A &lhs, const A &rhs) {} int i; After: inline A operator^(const A &lhs, const A &rhs) {} int i; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249517 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 5 +++++ unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 159e60bfe1..634dbe9708 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -855,6 +855,11 @@ void UnwrappedLineParser::parseStructuralElement() { case tok::l_paren: parseParens(); break; + case tok::kw_operator: + nextToken(); + if (FormatTok->isBinaryOperator()) + nextToken(); + break; case tok::caret: nextToken(); if (FormatTok->Tok.isAnyIdentifier() || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6a265f3dd1..ff9d2d473f 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5327,6 +5327,8 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) { verifyGoogleFormat("operator ::A();"); verifyFormat("using A::operator+;"); + verifyFormat("inline A operator^(const A &lhs, const A &rhs) {}\n" + "int i;"); } TEST_F(FormatTest, UnderstandsFunctionRefQualification) { -- 2.50.1