felix642 wrote:

Thank you for the feedback @AaronBallman.

Just to clarify:
> IMO, that's a CMake bug; adding an option we have to support forever to work 
> around that behavior is not really ideal.

Undoubtedly,  this was only an example on the reasoning behind this change.  
But I do think it is annoying from a user's perspective to be unable to use 
clang-tidy / clangd in those situations. They have to either wait for a fix 
from (in that case cmake) or us to properly fix the issue. This is not the 
first time this kind of issue happened and this is definitely not going to be 
the last one.

The main use case I see for this option would be to give the user the ability 
to run clang-tidy, clangd (or any clang-based tool as a matter of fact) on a 
gcc project and to get some decents results without having to maintain two 
separate build commands or to write some convoluted script to transform the 
gcc-based command line into something that clang will not complain about. 
Here's a few examples I found where people struggle with this exact problem:
(https://stackoverflow.com/questions/60227510/clang-tidy-report-error-unknown-argument-when-contain-other-compiler-options)
(https://stackoverflow.com/questions/68178126/clang-tidy-reporting-many-error-unknown-argument)
(https://github.com/clangd/clangd/discussions/1939)
(https://github.com/clangd/clangd/issues/662)

If we give the user the ability to run clang-based tools without any changes on 
they're project would, in my opinion,  greatly simplify the integration of 
those tools in existing projects. It follows the logic of "Make it work and 
then make it right" and the "Unrecognized argument" is probably one of the only 
thing keeping them from doing that.

> Personally, I'm not a big fan of having a command line option to control 
> diagnostics of command line options.

That being said, I'm wondering if it would be better to instead modify the 
`ClangTool` class to be able to ignore those unknown arguments instead of a 
adding a new argument to the clang-driver. Doing that would allow us to enable 
this option on a per-tool basis. i.e. A new option could be added to the 
clang-tidy config file `IgnoreUnknownArguments: True` to enable this option. 

This would limit the scope of this option and would give us the ability to 
enable it only for the use-cases that we think are needed.
 

https://github.com/llvm/llvm-project/pull/162201
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to