From 84c47a10741c7be02ac448833f32beaf53c0abde 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. llvm-svn: 195555 --- clang/lib/Format/UnwrappedLineParser.cpp | 3 +++ clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 016c4db07bf4..9c0bf2696fd0 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1dc5215d187d..d61dfc44d900 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) {