llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.41k stars 11.74k forks source link

[clang format] how to set the format by lamda as args #64234

Open aengusjiang opened 1 year ago

aengusjiang commented 1 year ago

the code like below:

void login_srv::on_run()
{
    INFO_MT("co1 min_log_level:{}|sched num:{} ...", FLG_min_log_level, co::schedulers().size());

    for (auto &&c : m_context_vec)
    {
        const auto sched = c.sched;
        sched->go([&, this] {
            m_wg.add();

            c.uws_app
                ->listen(m_port,
                         [&c, this](auto *socket) {
                             int a = 1;
                             int bb = 2;
                         })
                .run();
            m_wg.done();
            INFO_MT_IF(0 == c.id, "[service] co{} uwebsocket done.", c.id);
        });
    }
}

expect the format like this:

void login_srv::on_run()
{
    INFO_MT("co1 min_log_level:{}|sched num:{} ...", FLG_min_log_level, co::schedulers().size());

    for (auto &&c : m_context_vec)
    {
        const auto sched = c.sched;
        sched->go([&, this] {
            m_wg.add();
            c.uws_app->listen(m_port, [&c, this](auto *socket) {
                    int a = 1;
                    int bb = 2;
                }).run();
            m_wg.done();
            INFO_MT_IF(0 == c.id, "[service] co{} uwebsocket done.", c.id);
        });
    }
}

use the clangformat style by Microsoft

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-format

aengusjiang commented 1 year ago

by it's normal without continue chain call function such as below: image

but with chain call, it's seem doesn't work: image

aengusjiang commented 1 year ago

This is may be a issue, please help me.

clang-format.txt

aengusjiang commented 1 year ago

how about this question or issue?

aengusjiang commented 1 year ago

I think this is an issue.