r234320 - clang-format: Fix regression formatting QT's "signals:" from r234318.
Daniel Jasper
djasper at google.com
Tue Apr 7 08:04:40 PDT 2015
Author: djasper
Date: Tue Apr 7 10:04:40 2015
New Revision: 234320
URL: http://llvm.org/viewvc/llvm-project?rev=234320&view=rev
Log:
clang-format: Fix regression formatting QT's "signals:" from r234318.
Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.h
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=234320&r1=234319&r2=234320&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Apr 7 10:04:40 2015
@@ -549,6 +549,10 @@ struct AdditionalKeywords {
kw_repeated = &IdentTable.get("repeated");
kw_required = &IdentTable.get("required");
kw_returns = &IdentTable.get("returns");
+
+ kw_signals = &IdentTable.get("signals");
+ kw_slots = &IdentTable.get("slots");
+ kw_qslots = &IdentTable.get("Q_SLOTS");
}
// Context sensitive keywords.
@@ -583,6 +587,11 @@ struct AdditionalKeywords {
IdentifierInfo *kw_repeated;
IdentifierInfo *kw_required;
IdentifierInfo *kw_returns;
+
+ // QT keywords.
+ IdentifierInfo *kw_signals;
+ IdentifierInfo *kw_slots;
+ IdentifierInfo *kw_qslots;
};
} // namespace format
Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.h?rev=234320&r1=234319&r2=234320&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.h Tue Apr 7 10:04:40 2015
@@ -80,7 +80,8 @@ private:
if (Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript)
return 0;
- if (RootToken.isAccessSpecifier(false) || RootToken.isObjCAccessSpecifier())
+ if (RootToken.isAccessSpecifier(false) ||
+ RootToken.isObjCAccessSpecifier() || RootToken.is(Keywords.kw_signals))
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=234320&r1=234319&r2=234320&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Apr 7 10:04:40 2015
@@ -753,6 +753,10 @@ void UnwrappedLineParser::parseStructura
parseJavaScriptEs6ImportExport();
return;
}
+ if (FormatTok->is(Keywords.kw_signals)) {
+ parseAccessSpecifier();
+ return;
+ }
// In all other cases, parse the declaration.
break;
default:
@@ -1410,8 +1414,7 @@ void UnwrappedLineParser::parseSwitch()
void UnwrappedLineParser::parseAccessSpecifier() {
nextToken();
// Understand Qt's slots.
- if (FormatTok->is(tok::identifier) &&
- (FormatTok->TokenText == "slots" || FormatTok->TokenText == "Q_SLOTS"))
+ if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
nextToken();
// Otherwise, we don't know what it is, and we'd better keep the next token.
if (FormatTok->Tok.is(tok::colon))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=234320&r1=234319&r2=234320&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Apr 7 10:04:40 2015
@@ -1897,6 +1897,8 @@ TEST_F(FormatTest, UnderstandsAccessSpec
" void f() {}\n"
"public Q_SLOTS:\n"
" void f() {}\n"
+ "signals:\n"
+ " void g();\n"
"};");
}
More information about the cfe-commits
mailing list