diff options
author | Jonathan Coe <jbcoe@google.com> | 2020-03-09 17:33:53 +0000 |
---|---|---|
committer | Jonathan Coe <jbcoe@google.com> | 2020-03-09 17:36:21 +0000 |
commit | eb682b80274d5486d062e3f53040969f592277e4 (patch) | |
tree | e071ae3956aae56b270cdedae82b2c81340847cb /clang/lib | |
parent | 63b683a8168fa03bd8dfa7567c73ad507104f666 (diff) | |
download | llvm-eb682b80274d5486d062e3f53040969f592277e4.zip llvm-eb682b80274d5486d062e3f53040969f592277e4.tar.gz llvm-eb682b80274d5486d062e3f53040969f592277e4.tar.bz2 |
[clang-format] C# does not indent braced initializers as continuations
Summary: C# treats object initializers as braced init blocks. Braced init blocks are no longer indented as continuations.
Reviewers: krasimir
Reviewed By: krasimir
Subscribers: cfe-commits
Tags: #clang-format, #clang
Differential Revision: https://reviews.llvm.org/D75731
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/FormatToken.h | 3 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 072e1ad..1b885b5 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -509,6 +509,9 @@ 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) && BlockKind == BK_BracedInit && Style.isCSharp()) + return true; if (is(TT_TemplateString) && opensScope()) return true; return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) || diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 58cc679..00447eb 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1677,7 +1677,10 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons, } break; case tok::l_square: - tryToParseLambda(); + if (Style.isCSharp()) + parseSquare(); + else + tryToParseLambda(); break; case tok::l_paren: parseParens(); |