]> granicus.if.org Git - clang/commitdiff
clang-format: Support Qt's slot access specifiers.
authorDaniel Jasper <djasper@google.com>
Sat, 23 Nov 2013 17:53:41 +0000 (17:53 +0000)
committerDaniel Jasper <djasper@google.com>
Sat, 23 Nov 2013 17:53:41 +0000 (17:53 +0000)
This fixes llvm.org/PR17241.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195555 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 016c4db07bf41fd45d6beb20365d58187eae9e18..9c0bf2696fd085b236f3f5ae833790bf8a07cb09 100644 (file)
@@ -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();
index 1dc5215d187d774c31841bc36ecd58896128c183..d61dfc44d9000a70a31a1979f122f7fe128aad8e 100644 (file)
@@ -1537,6 +1537,10 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) {
                      " private:\n"
                      "  void f() {}\n"
                      "};");
+  verifyFormat("class A {\n"
+               "public slots:\n"
+               "  void f() {}\n"
+               "};");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {