aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/FormatToken.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Format/FormatToken.h')
-rw-r--r--lib/Format/FormatToken.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h
index f335eda086c0..78bc0edc45c0 100644
--- a/lib/Format/FormatToken.h
+++ b/lib/Format/FormatToken.h
@@ -283,6 +283,10 @@ struct FormatToken {
bool is(const IdentifierInfo *II) const {
return II && II == Tok.getIdentifierInfo();
}
+ bool is(tok::PPKeywordKind Kind) const {
+ return Tok.getIdentifierInfo() &&
+ Tok.getIdentifierInfo()->getPPKeywordID() == Kind;
+ }
template <typename A, typename B> bool isOneOf(A K1, B K2) const {
return is(K1) || is(K2);
}
@@ -408,16 +412,16 @@ struct FormatToken {
/// \brief Returns \c true if this tokens starts a block-type list, i.e. a
/// list that should be indented with a block indent.
- bool opensBlockTypeList(const FormatStyle &Style) const {
+ bool opensBlockOrBlockTypeList(const FormatStyle &Style) const {
return is(TT_ArrayInitializerLSquare) ||
(is(tok::l_brace) &&
(BlockKind == BK_Block || is(TT_DictLiteral) ||
(!Style.Cpp11BracedListStyle && NestingLevel == 0)));
}
- /// \brief Same as opensBlockTypeList, but for the closing token.
- bool closesBlockTypeList(const FormatStyle &Style) const {
- return MatchingParen && MatchingParen->opensBlockTypeList(Style);
+ /// \brief Same as opensBlockOrBlockTypeList, but for the closing token.
+ bool closesBlockOrBlockTypeList(const FormatStyle &Style) const {
+ return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style);
}
private:
@@ -521,6 +525,8 @@ private:
/// properly supported by Clang's lexer.
struct AdditionalKeywords {
AdditionalKeywords(IdentifierTable &IdentTable) {
+ kw_final = &IdentTable.get("final");
+ kw_override = &IdentTable.get("override");
kw_in = &IdentTable.get("in");
kw_CF_ENUM = &IdentTable.get("CF_ENUM");
kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
@@ -530,11 +536,13 @@ struct AdditionalKeywords {
kw_finally = &IdentTable.get("finally");
kw_function = &IdentTable.get("function");
kw_import = &IdentTable.get("import");
+ kw_is = &IdentTable.get("is");
+ kw_let = &IdentTable.get("let");
kw_var = &IdentTable.get("var");
kw_abstract = &IdentTable.get("abstract");
+ kw_assert = &IdentTable.get("assert");
kw_extends = &IdentTable.get("extends");
- kw_final = &IdentTable.get("final");
kw_implements = &IdentTable.get("implements");
kw_instanceof = &IdentTable.get("instanceof");
kw_interface = &IdentTable.get("interface");
@@ -546,6 +554,7 @@ struct AdditionalKeywords {
kw_mark = &IdentTable.get("mark");
+ kw_extend = &IdentTable.get("extend");
kw_option = &IdentTable.get("option");
kw_optional = &IdentTable.get("optional");
kw_repeated = &IdentTable.get("repeated");
@@ -553,11 +562,14 @@ 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");
}
// Context sensitive keywords.
+ IdentifierInfo *kw_final;
+ IdentifierInfo *kw_override;
IdentifierInfo *kw_in;
IdentifierInfo *kw_CF_ENUM;
IdentifierInfo *kw_CF_OPTIONS;
@@ -569,12 +581,14 @@ struct AdditionalKeywords {
IdentifierInfo *kw_finally;
IdentifierInfo *kw_function;
IdentifierInfo *kw_import;
+ IdentifierInfo *kw_is;
+ IdentifierInfo *kw_let;
IdentifierInfo *kw_var;
// Java keywords.
IdentifierInfo *kw_abstract;
+ IdentifierInfo *kw_assert;
IdentifierInfo *kw_extends;
- IdentifierInfo *kw_final;
IdentifierInfo *kw_implements;
IdentifierInfo *kw_instanceof;
IdentifierInfo *kw_interface;
@@ -587,6 +601,7 @@ struct AdditionalKeywords {
IdentifierInfo *kw_mark;
// Proto keywords.
+ IdentifierInfo *kw_extend;
IdentifierInfo *kw_option;
IdentifierInfo *kw_optional;
IdentifierInfo *kw_repeated;
@@ -595,6 +610,7 @@ struct AdditionalKeywords {
// QT keywords.
IdentifierInfo *kw_signals;
+ IdentifierInfo *kw_qsignals;
IdentifierInfo *kw_slots;
IdentifierInfo *kw_qslots;
};