r254407 - clang-format: treat Q_SIGNALS as an access modifier
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 1 04:05:08 PST 2015
Author: djasper
Date: Tue Dec 1 06:05:04 2015
New Revision: 254407
URL: http://llvm.org/viewvc/llvm-project?rev=254407&view=rev
Log:
clang-format: treat Q_SIGNALS as an access modifier
Patch by Alexander Richardson, thank you!
Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/FormatToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=254407&r1=254406&r2=254407&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Dec 1 06:05:04 2015
@@ -561,6 +561,7 @@ struct AdditionalKeywords {
kw_returns = &IdentTable.get("returns");
kw_signals = &IdentTable.get("signals");
+ kw_qsignals = &IdentTable.get("Q_SIGNALS");
kw_slots = &IdentTable.get("slots");
kw_qslots = &IdentTable.get("Q_SLOTS");
}
@@ -607,6 +608,7 @@ struct AdditionalKeywords {
// QT keywords.
IdentifierInfo *kw_signals;
+ IdentifierInfo *kw_qsignals;
IdentifierInfo *kw_slots;
IdentifierInfo *kw_qslots;
};
Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=254407&r1=254406&r2=254407&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Tue Dec 1 06:05:04 2015
@@ -90,8 +90,8 @@ private:
return 0;
if (RootToken.isAccessSpecifier(false) ||
RootToken.isObjCAccessSpecifier() ||
- (RootToken.is(Keywords.kw_signals) && RootToken.Next &&
- RootToken.Next->is(tok::colon)))
+ (RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+ RootToken.Next && RootToken.Next->is(tok::colon)))
return Style.AccessModifierOffset;
return 0;
}
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=254407&r1=254406&r2=254407&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Dec 1 06:05:04 2015
@@ -784,7 +784,8 @@ void UnwrappedLineParser::parseStructura
parseJavaScriptEs6ImportExport();
return;
}
- if (FormatTok->is(Keywords.kw_signals)) {
+ if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,
+ Keywords.kw_slots, Keywords.kw_qslots)) {
nextToken();
if (FormatTok->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=254407&r1=254406&r2=254407&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Dec 1 06:05:04 2015
@@ -1867,11 +1867,21 @@ TEST_F(FormatTest, UnderstandsAccessSpec
"};");
verifyFormat("class A {\n"
"public slots:\n"
- " void f() {}\n"
+ " void f1() {}\n"
"public Q_SLOTS:\n"
- " void f() {}\n"
+ " void f2() {}\n"
+ "protected slots:\n"
+ " void f3() {}\n"
+ "protected Q_SLOTS:\n"
+ " void f4() {}\n"
+ "private slots:\n"
+ " void f5() {}\n"
+ "private Q_SLOTS:\n"
+ " void f6() {}\n"
"signals:\n"
- " void g();\n"
+ " void g1();\n"
+ "Q_SIGNALS:\n"
+ " void g2();\n"
"};");
// Don't interpret 'signals' the wrong way.
More information about the cfe-commits
mailing list