r193605 - clang-format: Fix overloaded operator for global-scoped conversions.

Daniel Jasper djasper at google.com
Tue Oct 29 05:24:23 PDT 2013


Author: djasper
Date: Tue Oct 29 07:24:23 2013
New Revision: 193605

URL: http://llvm.org/viewvc/llvm-project?rev=193605&view=rev
Log:
clang-format: Fix overloaded operator for global-scoped conversions.

Before:
  operator::A();

After:
  operator ::A();

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=193605&r1=193604&r2=193605&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 29 07:24:23 2013
@@ -1337,7 +1337,7 @@ bool TokenAnnotator::spaceRequiredBefore
   if (Tok.Type == TT_CtorInitializerColon || Tok.Type == TT_ObjCBlockLParen)
     return true;
   if (Tok.Previous->Tok.is(tok::kw_operator))
-    return false;
+    return Tok.is(tok::coloncolon);
   if (Tok.Type == TT_OverloadedOperatorLParen)
     return false;
   if (Tok.is(tok::colon))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=193605&r1=193604&r2=193605&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Oct 29 07:24:23 2013
@@ -3902,6 +3902,7 @@ TEST_F(FormatTest, UnderstandsOverloaded
 
   verifyGoogleFormat("operator void*();");
   verifyGoogleFormat("operator SomeType<SomeType<int>>();");
+  verifyGoogleFormat("operator ::A();");
 
   verifyFormat("using A::operator+;");
 }





More information about the cfe-commits mailing list