Tools for finding unused feature declarations?

During the refactoring of some old code, I realized that a particular header file is filled with function declarations for functions that have long been removed from the .cpp file. Does anyone know a tool that could find (and delete) these automatically?

+3
source share
7 answers

You can, if possible, make the test.cpp file to call them all, the linker will mark those that have no code as unresolved, so your test code only needs to be compiled and not worry about the actual launch.

+2
source

PC-lint can be configured for a dedicated purpose:

I tried the following code for your question:

void foo(int );

int main()
{
    return 0;
}
lint.bat test_unused.cpp

and got the following result:

============================================================

--- Module:   test_unused.cpp (C++)

    --- Wrap-up for Module: test_unused.cpp

Info 752: local declarator 'foo(int)' (line 2, file test_unused.cpp) not referenced
test_unused.cpp(2) : Info 830: Location cited in prior message

============================================================

, 752 puropse:

lint.bat  -"e*"  +e752  test_unused.cpp

-e "*" + e752

+2

Doxygen, , . , (1 HTML- ) , , .

ctags , objdump - .o, . - .

0

, , , , . , script, , .

0

++ ftplugin vim, - vimmers, ftplugin . Ftplugin ctags (, ), .

,

0

, Doxygen (@Milan Babuskov), , . . gcc -Wunused- ; -fdump--cgraph.

0

PC-Lint, , , , .

0

Source: https://habr.com/ru/post/1697191/


All Articles