Author: djasper
Date: Tue Oct  6 22:43:10 2015
New Revision: 249517

URL: http://llvm.org/viewvc/llvm-project?rev=249517&view=rev
Log:
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;

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=249517&r1=249516&r2=249517&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Oct  6 22:43:10 2015
@@ -855,6 +855,11 @@ void UnwrappedLineParser::parseStructura
     case tok::l_paren:
       parseParens();
       break;
+    case tok::kw_operator:
+      nextToken();
+      if (FormatTok->isBinaryOperator())
+        nextToken();
+      break;
     case tok::caret:
       nextToken();
       if (FormatTok->Tok.isAnyIdentifier() ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=249517&r1=249516&r2=249517&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Oct  6 22:43:10 2015
@@ -5327,6 +5327,8 @@ TEST_F(FormatTest, UnderstandsOverloaded
   verifyGoogleFormat("operator ::A();");
 
   verifyFormat("using A::operator+;");
+  verifyFormat("inline A operator^(const A &lhs, const A &rhs) {}\n"
+               "int i;");
 }
 
 TEST_F(FormatTest, UnderstandsFunctionRefQualification) {


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to