From dbb3d042e052d26f9973dbfade318b9f2fe2ac40 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 29 Nov 2013 08:51:56 +0000 Subject: [PATCH] clang-format: Correctly handle Qt's Q_SLOTS. This should fix llvm.org/PR17241. Maybe it sticks this time :-). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195953 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 3 ++- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 9c0bf2696f..1eb0ae1700 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -1087,7 +1087,8 @@ void UnwrappedLineParser::parseSwitch() { void UnwrappedLineParser::parseAccessSpecifier() { nextToken(); // Understand Qt's slots. - if (FormatTok->is(tok::identifier) && FormatTok->TokenText == "slots") + if (FormatTok->is(tok::identifier) && + (FormatTok->TokenText == "slots" || FormatTok->TokenText == "Q_SLOTS")) nextToken(); // Otherwise, we don't know what it is, and we'd better keep the next token. if (FormatTok->Tok.is(tok::colon)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e1960d290f..ccad1d4b00 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1540,6 +1540,8 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) { verifyFormat("class A {\n" "public slots:\n" " void f() {}\n" + "public Q_SLOTS:\n" + " void f() {}\n" "};"); } -- 2.50.1