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

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 6 17:03:11 PST 2021


I'd probably start by analyzing the bug, maybe figuring out the root cause
- then work backwards for the test case to commit along with the test.
(figuring out the root cause might reveal easier ways to reproduce the bug,
once it's understood)

To root cause the bug, I'd try parallel debugging sessions - with and
without a compilation DB, for instance - stepping through each, and seeing
where the behavior diverges, and why it diverges.

On Mon, Dec 6, 2021 at 3:33 PM Oleg Smolsky via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211206/4eb71642/attachment.html>


More information about the llvm-dev mailing list