Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-analyze header file #34

Closed
csordasmarton opened this issue Nov 29, 2021 · 1 comment · Fixed by Ericsson/codechecker#3616
Closed

Re-analyze header file #34

csordasmarton opened this issue Nov 29, 2021 · 1 comment · Fixed by Ericsson/codechecker#3616
Assignees
Milestone

Comments

@csordasmarton
Copy link
Contributor

Let's suppose that I have the following header and source files:
f.h:

#ifndef F_H
#define F_H
void foo() { sizeof(42); }
#endif

a.cpp:

#include "f.h"
void bar() { foo(); }

b.cpp:

#include "f.h"
void bar() { foo(); }

c.cpp:

void bar() { sizeof(43); }

I also have the following simple Makefile:

all: a b c

a: a.cpp
	g++ -c a.cpp
b: b.cpp
	g++ -c b.cpp
c: c.cpp
	g++ -c c.cpp

Let's suppose that I setup the CodeChecker VSCode plugin and I want to modify my header file (f.h). In this case I have to re-analyze all the source files which depend on this header file (a.cpp and b.cpp but not c.cpp).

For now if I modify a header file it will call the analysis and set the --file option to this header file which will not do what we want.

To figure out these source files which need to be reanalyzed we can use the tu_collector tool from CodeChecker: tu_collector -l ~/myproject/.codechecker/compile_commands.json -d --filter ~/myproject/f.h

The result will be the list of source files:

~/myproject/a.cpp
~/myproject/b.cpp
@csordasmarton csordasmarton added this to the 0.0.2 milestone Dec 20, 2021
@csordasmarton
Copy link
Contributor Author

Maybe it would be better to solve this problem inside CodeCheker rather than in the plugin. So if someone provides a header file to the analyze command (CodeChecker analyze --file x.h ... ) we will use the tu_collector under the hood the figure out which source files are depends on the given header file and we will analyze these source files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant