From 95390ce9e9f1ba4e618dd32a672b4f802e698c05 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sat, 23 Nov 2013 17:53:41 +0000 Subject: [PATCH] clang-format: Support Qt's slot access specifiers. 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 | 3 +++ unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 016c4db07b..9c0bf2696f 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -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(); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 1dc5215d18..d61dfc44d9 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) { -- 2.40.0