[llvm-bugs] [Bug 40335] New: [clang-format] Don't force non-breaking macro calls

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 16 06:47:26 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40335

            Bug ID: 40335
           Summary: [clang-format] Don't force non-breaking macro calls
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dennis.felsing at sap.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Hi,

Function calls and initialization lists can include line breaks in their
arguments and clang-format keeps them as they are. When using the EXPECT_THAT
and ElementsAre calls in gmock though clang-format rewrites all arguments to a
single line. Is it possible to make the behaviour of EXPECT_THAT(v,
ElementsAre(...)) more consistent with regular function calls so that the
elements stay on their own lines?

See the following example:

$ clang-format --version
clang-format version 9.0.0 (https://github.com/llvm-mirror/clang
7e968f8a6a2b7d07835493c04dd1989d46970599) (https://github.com/llvm-mirror/llvm
0cb1621554afa8612836c4edfc890fe337320008)
$ cat .clang-format
Language: Cpp
BasedOnStyle: WebKit
Cpp11BracedListStyle: true
$ cat x.cpp
#include <vector>
#include <gmock/gmock.h>

using namespace testing;

int g(int x)
{
    return x;
}

int f(int x, int y)
{
    return x + y;
}

int main()
{
    std::vector<int> v = {1,
        2};

    g(f(1,
        2));

    EXPECT_THAT(v, ElementsAre(1,
        2));
}
$ clang-format x.cpp
#include <vector>
#include <gmock/gmock.h>

using namespace testing;

int g(int x)
{
    return x;
}

int f(int x, int y)
{
    return x + y;
}

int main()
{
    std::vector<int> v = {1,
        2};

    g(f(1,
        2));

    EXPECT_THAT(v, ElementsAre(1,
        2));
}

clang-format 4 did just fine here and kept the format that I expect.

Best regards
Dennis

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190116/3ba2ac4e/attachment.html>


More information about the llvm-bugs mailing list