hanchenye-llvm-project/clang/lib/Format
Krasimir Georgiev 5528cace04 [clang-format] tweaked another case of lambda formatting
Summary:
This is done in order to improve cases where the lambda's body is moved too far to the right. Consider the following snippet with column limit set to 79:

```
void f() {
  leader::MakeThisCallHere(&leader_service_,
                           cq_.get(),
                           [this, liveness](const leader::ReadRecordReq& req,
                                            std::function<void()> done) {
                             logger_->HandleReadRecord(
                                 req, resp, std::move(done));
                           });

  leader::MakeAnother(&leader_service_,
                      cq_.get(),
                      [this, liveness](const leader::ReadRecordReq& req,
                                       std::function<void()> done) {
                        logger_->HandleReadRecord(
                            req, resp, std::move(done), a);
                      });
}
```

The tool favors extra indentation for the lambda body and so the code incurs extra wrapping and adjacent calls are indented to a different level. I find this behavior annoying and I'd like the tool to favor new lines and, thus, use the extra width.

The fix, reduced, brings the following formatting.

Before:

    function(1,
             [] {
               DoStuff();
               //
             },
             1);

After:

    function(
        1,
        [] {
          DoStuff();
          //
        },
        1);

Refer to the new tests in FormatTest.cpp

Contributed by oleg.smolsky!

Reviewers: djasper, klimek, krasimir

Subscribers: cfe-commits, owenpan

Tags: #clang

Differential Revision: https://reviews.llvm.org/D52676

llvm-svn: 345753
2018-10-31 17:56:57 +00:00
..
AffectedRangeManager.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
AffectedRangeManager.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
BreakableToken.cpp clang-format: [JS] don't break comments before any '{' 2018-08-03 13:58:33 +00:00
BreakableToken.h [clang-format] Silence -Wdocumentation warnings 2018-07-30 12:22:41 +00:00
CMakeLists.txt Reland "Move #include manipulation code to new lib/Tooling/Inclusions." 2018-06-04 09:04:12 +00:00
ContinuationIndenter.cpp [clang-format] tweaked another case of lambda formatting 2018-10-31 17:56:57 +00:00
ContinuationIndenter.h Remove trailing space 2018-07-30 19:24:48 +00:00
Encoding.h NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it 2018-07-24 00:07:49 +00:00
Format.cpp NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects) 2018-10-30 20:31:30 +00:00
FormatInternal.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
FormatToken.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
FormatToken.h [clang-format] tweaked another case of lambda formatting 2018-10-31 17:56:57 +00:00
FormatTokenLexer.cpp clang-format: better handle statement macros 2018-10-02 16:37:51 +00:00
FormatTokenLexer.h clang-format: better handle statement macros 2018-10-02 16:37:51 +00:00
NamespaceEndCommentsFixer.cpp clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier 2018-09-05 07:44:02 +00:00
NamespaceEndCommentsFixer.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SortJavaScriptImports.cpp [clang] Update uses of DEBUG macro to LLVM_DEBUG. 2018-05-15 13:30:56 +00:00
SortJavaScriptImports.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
TokenAnalyzer.cpp [clang] Update uses of DEBUG macro to LLVM_DEBUG. 2018-05-15 13:30:56 +00:00
TokenAnalyzer.h Add SourceManagerForFile helper which sets up SourceManager and dependencies for a single file with code snippet 2018-05-09 21:35:52 +00:00
TokenAnnotator.cpp [clang-format] tweaked another case of lambda formatting 2018-10-31 17:56:57 +00:00
TokenAnnotator.h clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier 2018-09-05 07:44:02 +00:00
UnwrappedLineFormatter.cpp [clang-format] tweaked another case of lambda formatting 2018-10-31 17:56:57 +00:00
UnwrappedLineFormatter.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
UnwrappedLineParser.cpp Java annotation declaration being handled correctly 2018-10-19 16:19:52 +00:00
UnwrappedLineParser.h clang-format: better handle statement macros 2018-10-02 16:37:51 +00:00
UsingDeclarationsSorter.cpp [clang] Update uses of DEBUG macro to LLVM_DEBUG. 2018-05-15 13:30:56 +00:00
UsingDeclarationsSorter.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
WhitespaceManager.cpp llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...) 2018-09-26 22:16:28 +00:00
WhitespaceManager.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00