diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:05 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:05 +0000 |
| commit | cf1b401909b5e54edfd80656b1a18eaa31f9f6f1 (patch) | |
| tree | edb0ffff2a43d84ba9b4c862b394cfeeebb36ddc /lib/Format/FormatToken.h | |
| parent | ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af (diff) | |
Diffstat (limited to 'lib/Format/FormatToken.h')
| -rw-r--r-- | lib/Format/FormatToken.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index c5bf48cdcc06..0fe91adcd472 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -465,7 +465,8 @@ struct FormatToken { return is(TT_ArrayInitializerLSquare) || (is(tok::l_brace) && (BlockKind == BK_Block || is(TT_DictLiteral) || - (!Style.Cpp11BracedListStyle && NestingLevel == 0))); + (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || + (is(tok::less) && Style.Language == FormatStyle::LK_Proto); } /// \brief Same as opensBlockOrBlockTypeList, but for the closing token. @@ -475,6 +476,19 @@ struct FormatToken { return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style); } + /// \brief Return the actual namespace token, if this token starts a namespace + /// block. + const FormatToken *getNamespaceToken() const { + const FormatToken *NamespaceTok = this; + if (is(tok::comment)) + NamespaceTok = NamespaceTok->getNextNonComment(); + // Detect "(inline)? namespace" in the beginning of a line. + if (NamespaceTok && NamespaceTok->is(tok::kw_inline)) + NamespaceTok = NamespaceTok->getNextNonComment(); + return NamespaceTok && NamespaceTok->is(tok::kw_namespace) ? NamespaceTok + : nullptr; + } + private: // Disallow copying. FormatToken(const FormatToken &) = delete; |
