
FYI, the issue was due to not so optimal translation units configuration. Instead of bundle of TU-s with self-contained headers tests (one GIL's header per .cpp) I fixed generated single .cpp with all headers included (https://github.com/boostorg/gil/pull/184). Then, I run clang-tidy against that single .cpp file. This does the trick and the modernize-use-using fixes are applied correctly. More details here http://lists.llvm.org/pipermail/cfe-users/2018-December/001454.html Best regards, Mateusz On Mon, 10 Dec 2018 at 22:18, Mateusz Loskot <mateusz@loskot.net> wrote:
(I'm forwarding here my clang-tidy problem I posted to cfe-user mailing list, since it touches Boost library, a highly templated library, and I'm hoping we have experienced clang-tidy users among Boost developers. Considering it a part of Boost library development, I hope it is not off-topic here.)
---------- Forwarded message --------- From: Mateusz Loskot <mateusz@loskot.net> Date: Mon, 10 Dec 2018 at 22:14 Subject: [run-clang-tidy] new replacement overlaps with an existing replacement To: <cfe-users@lists.llvm.org>
Hi,
I'm running clang-tidy 7.0 (also tried 5.0) to modernise some aspects of Boost.GIL (https://github.com/boostorg/gil) source code.
I've noticed, clang-tidy 7.0 (also 5.0) does not apply fixes for some of modernize-use-* checks, especially modernize-use-using.
I run it this way:
``` cd ${BOOST_ROOT}/libs/gil cmake -S . -B _build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. run-clang-tidy.py -p=_build -header-filter='boost\/gil\/.*' -checks='-*,modernize-use-using' -fix ```
Then, I see huge number of "The new replacement overlaps with an existing replacement." diagnostics. Below, I copied an extract that hopefully is useful to figure out what is happening and going wrong.
Basically, there are two class templates and a bunch of tag types:
1. file_stream_device https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e2... 2. get_write_device with partial specialisations, `enable_if`-ed https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e2...
The file_stream_device is specialised for a tag and final get_write_device specialisation is matched.
And, clang-tidy tries to substitute this alias in get_write_device
typedef detail::file_stream_device< FormatTag > type;
not with
using type = detail::file_stream_device< FormatTag > ;
but with `using type` for each FormatTag-based specialisation
``` New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<bmp_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<bmp_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<jpeg_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<png_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<png_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<png_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<pnm_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<targa_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<targa_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<tiff_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. New replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<tiff_tag>" Existing replacement: /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp: 1885:+52:"using type = detail::file_stream_device<FormatTag>" The new replacement overlaps with an existing replacement. ```
Why clang-tidy tries to re-fix the typedef with new replacement instead of keeping the existing one, the generic one?
i.e. using type = detail::file_stream_device<FormatTag>
I've tried to prepare a minimal example, but I couldn't reproduce this issue.
I observed, that if I manually prepare compile_database.json with single .cpp file that just `#include <boost/gil/io/device.hpp>`, that is the header with definition of the base templates and no definitions with higher level specialisations for format tags are included, then clang-tidy applies the expected fixes without any warnings.
Could anyone share any insights about this issue?
Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
-- Mateusz Loskot, http://mateusz.loskot.net