[lldb] Fix detecting warning options for GCC
authorMartin Storsjö <martin@martin.st>
Wed, 6 Apr 2022 10:45:20 +0000 (13:45 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 6 Apr 2022 19:50:07 +0000 (22:50 +0300)
commite546bbfda0ab91cf78c096d8c035851cc7c3b9f3
tree089135b580c2363947393bca1686c9ba714e6a93
parentee5fda1ff868d646d29c4cc2a23235ff1e16f2f9
[lldb] Fix detecting warning options for GCC

If testing for a warning option like -Wno-<foo> with GCC, GCC won't
print any diagnostic at all, leading to the options being accepted
incorrectly. However later, if compiling a file that actually prints
another warning, GCC will also print warnings about these -Wno-<foo>
options being unrecognized.

This avoids warning spam like this, for every lldb source file that
produces build warnings with GCC:

    At global scope:
    cc1plus: warning: unrecognized command line option ‘-Wno-vla-extension’
    cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’

This matches how such warning options are detected and added in
llvm/cmake/modules/HandleLLVMOptions.cmake, e.g. like this:

    check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
    append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)

Differential Revision: https://reviews.llvm.org/D123202
lldb/cmake/modules/LLDBConfig.cmake