diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-08 17:34:50 +0000 |
commit | 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch) | |
tree | 62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/clang/lib/Format/FormatToken.cpp | |
parent | cf037972ea8863e2bab7461d77345367d2c1e054 (diff) | |
parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Format/FormatToken.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Format/FormatToken.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/Format/FormatToken.cpp b/contrib/llvm-project/clang/lib/Format/FormatToken.cpp index f9f0d712bc16..d994ed048899 100644 --- a/contrib/llvm-project/clang/lib/Format/FormatToken.cpp +++ b/contrib/llvm-project/clang/lib/Format/FormatToken.cpp @@ -75,6 +75,21 @@ bool FormatToken::isTypeOrIdentifier() const { return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier); } +bool FormatToken::isBlockIndentedInitRBrace(const FormatStyle &Style) const { + assert(is(tok::r_brace)); + if (!Style.Cpp11BracedListStyle || + Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent) { + return false; + } + const auto *LBrace = MatchingParen; + assert(LBrace && LBrace->is(tok::l_brace)); + if (LBrace->is(BK_BracedInit)) + return true; + if (LBrace->Previous && LBrace->Previous->is(tok::equal)) + return true; + return false; +} + 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()) @@ -96,7 +111,7 @@ void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {} unsigned CommaSeparatedList::formatAfterToken(LineState &State, ContinuationIndenter *Indenter, bool DryRun) { - if (State.NextToken == nullptr || !State.NextToken->Previous) + if (!State.NextToken || !State.NextToken->Previous) return 0; if (Formats.size() == 1) |