diff options
-rw-r--r-- | clang/lib/Format/FormatToken.h | 2 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 16 |
4 files changed, 19 insertions, 6 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 49885205994..93baaf29321 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -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; }; diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 04087e84871..f6505690796 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -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; } diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index ad548217b41..e06903c306c 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -784,7 +784,8 @@ void UnwrappedLineParser::parseStructuralElement() { 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(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1d64405f08f..084ffc94425 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1867,11 +1867,21 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) { "};"); 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. |