r195555 - clang-format: Support Qt's slot access specifiers.

Daniel Jasper djasper at google.com
Sat Nov 23 09:53:41 PST 2013


Author: djasper
Date: Sat Nov 23 11:53:41 2013
New Revision: 195555

URL: http://llvm.org/viewvc/llvm-project?rev=195555&view=rev
Log:
clang-format: Support Qt's slot access specifiers.

This fixes llvm.org/PR17241.

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=195555&r1=195554&r2=195555&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sat Nov 23 11:53:41 2013
@@ -1086,6 +1086,9 @@ void UnwrappedLineParser::parseSwitch()
 
 void UnwrappedLineParser::parseAccessSpecifier() {
   nextToken();
+  // Understand Qt's slots.
+  if (FormatTok->is(tok::identifier) && FormatTok->TokenText == "slots")
+    nextToken();
   // Otherwise, we don't know what it is, and we'd better keep the next token.
   if (FormatTok->Tok.is(tok::colon))
     nextToken();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=195555&r1=195554&r2=195555&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Nov 23 11:53:41 2013
@@ -1537,6 +1537,10 @@ TEST_F(FormatTest, UnderstandsAccessSpec
                      " private:\n"
                      "  void f() {}\n"
                      "};");
+  verifyFormat("class A {\n"
+               "public slots:\n"
+               "  void f() {}\n"
+               "};");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {





More information about the cfe-commits mailing list