Author: Marek Kurdej Date: 2022-02-10T10:51:03+01:00 New Revision: 4efde1e554cce3f017b3d1ce700bd1860eed2ccd
URL: https://github.com/llvm/llvm-project/commit/4efde1e554cce3f017b3d1ce700bd1860eed2ccd DIFF: https://github.com/llvm/llvm-project/commit/4efde1e554cce3f017b3d1ce700bd1860eed2ccd.diff LOG: [clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC. Added: Modified: clang/lib/Format/FormatToken.cpp clang/lib/Format/FormatToken.h Removed: ################################################################################ diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 40aa8f5cacb25..5577918d70927 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -74,6 +74,20 @@ bool FormatToken::isTypeOrIdentifier() const { return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier); } +bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle &Style) const { + // C# Does not indent object initialisers as continuations. + if (is(tok::l_brace) && getBlockKind() == BK_BracedInit && Style.isCSharp()) + return true; + if (is(TT_TemplateString) && opensScope()) + return true; + return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) || + (is(tok::l_brace) && + (getBlockKind() == BK_Block || is(TT_DictLiteral) || + (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || + (is(tok::less) && (Style.Language == FormatStyle::LK_Proto || + Style.Language == FormatStyle::LK_TextProto)); +} + TokenRole::~TokenRole() {} void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {} diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index f116a89ac6440..6586ababd1e7b 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -696,19 +696,7 @@ struct FormatToken { /// Returns \c true if this tokens starts a block-type list, i.e. a /// list that should be indented with a block indent. - bool opensBlockOrBlockTypeList(const FormatStyle &Style) const { - // C# Does not indent object initialisers as continuations. - if (is(tok::l_brace) && getBlockKind() == BK_BracedInit && Style.isCSharp()) - return true; - if (is(TT_TemplateString) && opensScope()) - return true; - return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) || - (is(tok::l_brace) && - (getBlockKind() == BK_Block || is(TT_DictLiteral) || - (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || - (is(tok::less) && (Style.Language == FormatStyle::LK_Proto || - Style.Language == FormatStyle::LK_TextProto)); - } + LLVM_NODISCARD bool opensBlockOrBlockTypeList(const FormatStyle &Style) const; /// Returns whether the token is the left square bracket of a C++ /// structured binding declaration. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits