Open llvmbot opened 9 years ago
That makes sense; we should probably consider the functions to not be in the main source file if they were expanded from a macro that was defined outside that file. That perhaps doesn't go far enough (consider a macro defined in the main source file, that produces several functions, where after each macro invocation only a subset of the functions is used) but seems like a good start.
Clang's rule for this warning is somewhat different; we base the decision to warn on whether the function is defined in the main source file versus in a header file.
Why do these unused functions exist in remote.c? If they're being conditionally used, the usual convention is to also conditionally define them.
See https://sourceware.org/ml/gdb/2015-02/msg00072.html and https://sourceware.org/ml/gdb/2015-02/msg00074.html for an explanation.
Clang's rule for this warning is somewhat different; we base the decision to warn on whether the function is defined in the main source file versus in a header file.
Why do these unused functions exist in remote.c? If they're being conditionally used, the usual convention is to also conditionally define them.
Extended Description
Clang 3.5, 3.6 and 3.7svn are all erroneously warning on static inlines as seen in gdb-7.9/gdb/remote.c...
remote.c:2567:1058: warning: unused function 'VEC_thread_item_t_embedded_size' [-Wunused-function] remote.c:2567:1210: warning: unused function 'VEC_thread_item_t_embedded_init' [-Wunused-function] remote.c:2567:2076: warning: unused function 'VEC_thread_item_t_pop' [-Wunused-function] ...
I can't find the clang documentation but FSF gcc's shows...
-Wunused-function Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.
The attached preprocessed source for gdb-7.9/gdb/remote.c reproduces the problem with...
clang-3.6 -Wunused-function -c remote.i