This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix detecting warning options for GCC
ClosedPublic

Authored by mstorsjo on Apr 6 2022, 4:52 AM.

Details

Summary

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)

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 6 2022, 4:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2022, 4:52 AM
Herald added a subscriber: mgorny. · View Herald Transcript
mstorsjo requested review of this revision.Apr 6 2022, 4:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2022, 4:52 AM
labath accepted this revision.Apr 6 2022, 4:56 AM

This is great. I've been bothered by this for quite a while, but I didn't realize the fix is that easy.

This revision is now accepted and ready to land.Apr 6 2022, 4:56 AM

Cool, I learned something new today. Thanks for adding that comment!

This revision was automatically updated to reflect the committed changes.