[llvm-dev] clang-tidy: hard to repro bug in the 'modernize-use-default-member-init' check

Oleg Smolsky via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 6 15:33:13 PST 2021


Folks, I'm trying understand a `clang-tidy` bug where the
'modernize-use-default-member-init' check misbehaves on this (reduced)
input:

struct Thing {
    Thing(int arg) : a(arg), b(0) {}
    int a, b;
};

The check works correctly when running `clang-tidy` without a compilation
DB. The tool complains, but works correctly. Things also work correctly in
the LIT tests...

Yet when running with a compilation DB, I get this output after fixes are
applied (notice the trailing comma, which makes the code ill-formed):

struct Thing {
    Thing(int arg) : a(arg), {}
    int a, b{0};
};

How do I write a unit test for this? I mean how do I create a reliable
repro?

Thanks,
Oleg.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211206/76399ab3/attachment.html>


More information about the llvm-dev mailing list