Hello everyone!
I recently found out that when generating call / caller graphs even
function calls which would be removed by the preprocessor (due to
conditional compilation) get included in the call graph. In some cases
this may not be desired. Consider the following example:
test.cpp:
#include <iostream>
using namespace std;
#define FUNC1
void func1(int test)
{
cout << "func1: Hallo" << endl;
}
void func2(int test)
{
cout << "func2: Hallo" << endl;
}
int main() {
#ifdef FUNC1
func1(0);
#else
func2(0);
#endif
return 0;
}
Doxygen produces something like this for the main function when
generating xml output:
<references refid="test_8cpp_1a5d7f916959f4f32d1f8d38816c20fbef"
compoundref="test_8cpp" startline="7" endline="10">func1</references>
<references refid="test_8cpp_1af40a1280e9eecc3ea5aa6e37a4b41f65"
compoundref="test_8cpp" startline="11" endline="14">func2</references>
But the second function (func2) gets never called.
The patch modifies the preprocessor in "pre.l" so that all line numbers
which would be removed by the preprocessor are stored in a dictionary.
This information is then used by "code.l" to check if function gets
actually called. This information could also be used for other purposes
in future. E. g. different background color for lines excluded by the
preprocessor like eclipse does.
With this patch I tried the least invasive approach. Only a small
modification to "prel.l" and "code.l" was necessary. The only thing
missing at the moment is a configuration option to turn this patch off,
because sometimes it could be useful to see all functions that could be
called.
Please test this patch and let me know if it breaks some things or
doesn't work for you as expected. If this patch will be included in
doxygen I'll also provide the missing configuration option.
The patch and the test case can be found at:
http://mmg.ath.cx:8081/cond_compilation_patch.zip
Regards,
Martin Gerlach.
|