facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.89k stars 2.01k forks source link

`incremental-analysis` results in no files being analyzed #1650

Open oO0oO0oO0o0o00 opened 2 years ago

oO0oO0oO0o0o00 commented 2 years ago

The command line option --incremental-analysis (and --continue-analysis as well) results in no files being analyzed. It seems that there isn't any article about the use of the arguments, and the help message is not quite intuitive. Also, the "incremental" analysis of Infer often refer to -r mode, which is s bit incremental but deletes all specs ahead of analysis.

What is the correct way to use those two arguments for real incremental analysis that only analyzes changed procedures and those that depend on them (NOT those they depend on)? Thanks~

$ inferc run --meowcat-only -- make Capturing in make/cc mode... cc a.c -o a.o -c cc b.c -o b.o -c cc c.c -o c.o -c cc a.o b.o c.o -o meow Done. Found 3 source files to analyze in /root/tinfer/_make/infer-out 3/3 100% 6.098ms

$ touch b.c # or edit some procedure for real, irrelevant but still tested

$ infer run --incremental-analysis -r --meowcat-only --changed-files-index b.txt -- make Incremental analysis: invalidating procedures that have been changed Incremental analysis: 4 nodes in reverse analysis call graph, 2 of which were invalidated Capturing in make/cc mode... Done. Nothing to compile. Try running make clean first. There was nothing to analyze.

- [x] If possible, a minimal example to reproduce your problem:
As shown in the mysteries `--meowcat-only`, we've added a dummy checker `meowcat` to print and record traces. Moving them to any existing checkers and change the argument to `--xxx-only` yield the same result. Actually, no checkers have been run at this point.
No else changes were made to the source code.

Here is our test project:
a.c
```c
#include <stdio.h>
#include "a.h"
#include "b.h"

int main() {
    printf("%d\n", funcB(0));
    return 0;
}

b.c

#include "b.h"
#include "c.h"

int funcB(int a) {
    return funcC(a + 2) + funcC(a + 1);
}//

c.c

#include "c.h"

int funcC(int a) {
    return a + 1;
}

a.h

int main();

b.h

int funcB(int);

c.h

int funcC(int);

Makefile

PROG=meow

build: $(PROG)
    @echo "Done."

$(PROG): a.o b.o c.o
    $(CC) a.o b.o c.o -o $(PROG)

a.o: a.c a.h b.h c.h
    $(CC) a.c -o a.o -c

b.o: b.c b.h c.h
    $(CC) b.c -o b.o -c

c.o: c.c c.h
    $(CC) c.c -o c.o -c

clean:
    rm -f a.o b.o c.o $(PROG)

Besides the mentioned commands, many other sequences of commands with different arguments _e.g. with or without -r) were also tested automatically. The behavior --continue-analysis is slightly different, so we could focus on --incremental-analysis for now.