Clang-tidy issues warning -fno-fat-lto-objects

Hi,

I use clang-tidy and gcc (on Windows with cross-compilation but that shouldn’t matter).

Later clang versions now warn about
warning: optimization flag ‘-fno-fat-lto-objects’ is not supported [clang-diagnostic-ignored-optimization-argument]

Since CMake adds this flag when enabling IPO/LTO for gcc, could it also make sure that unsuitable flags are filtered for clang-tidy?

An issue could be filed, but these kinds of “what versions of clang-tidy know about which flags” is a monumental task and never-ending problem. Some kind of genex that does “hide this flag from clang-tidy” (or iwyu or whatever other co-compiles are out there) is probably the better way to do it long-term.

CMake already knows what the IPO flags are and that those are useless for a static analyzer.

I think the main problem is the way the command line is forwarded to clang-tidy, piped through cmake itself that knows nothing from configuration time.

At the same time, clang-tidy is unable to disable a useless warning. :confused:

Maybe I’ll just write a thin wrapper around clang-tidy, filtering command line arguments.

The mentioned argument NEVER worked for clang-tidy, so the version really doesn’t matter for this specific problem.

Ah, true; CMake might be able to do this in this specific instance. However:

Knowing that this is true for any specific flag is not easy to know and baking it into CMake is a hazard as the time dimension is not ignorable in its case.