clang icon indicating copy to clipboard operation
clang copied to clipboard

Add On-the-fly analysis support

Open gamesh411 opened this issue 6 years ago • 8 comments

Add an option to enable on-the-fly parsing of needed ASTs during CTU analysis. The option CTUCompilationDatabase should be a path to a compilation database, which has all the necessary information to generate the ASTs. In case an empty string is given, on-the-fly parsing is disabled.

gamesh411 avatar Aug 01 '19 10:08 gamesh411

Could you plase check the new test files 'ctu-on-the-fly.c' and 'ctu-on-the-fly.cpp'. I have managed to get almost working, however there are 2 issues still reamining.

First issue: During the analysis of sometimes the file part is entirely left off from the diagnostic. The interesting part is that Line number is OK, just the file part gets lost. This could be fixed by making the check more lenient in case of on-demand analysis (eg. not requiring that the diagnostic contains the file information).

Second issue: Inline assembly importing fails if -std=c89 is given inside compile_commands.json for the c test (see the test RUN: lines for the contents of the compile_commands.json). If however no -std=c89 is given, then unsupported AST node error is given during the analysis (I assume that it must be the clang tool which parses the file).

What are your thoughts?

Thanks

gamesh411 avatar Aug 09 '19 16:08 gamesh411

I have a working solution updated. The parsing logic of external TUs should be refactored to increase maintainability. However, this change is complex enough as is, and I would recommend refactoring in a separate change.

There is another ongoing issue with passing configuration options to CTUContext during the CallEvent handling of the analyzer engine. This promotes parameter-style passing of information, however, the Context object would be better off with constructor parameter injection or getters and setters (which is still a bit inferior to constructor injection because the values are set every time an external TU definition is requested from the context).

gamesh411 avatar Oct 05 '19 09:10 gamesh411

Fixed a remaining typo.

gamesh411 avatar Oct 05 '19 12:10 gamesh411

I have refactored and rebased the solution. There is an extra diagnostic as requested, and I have asserted some invariants in the code.

gamesh411 avatar Oct 22 '19 07:10 gamesh411

CI still fails...

martong avatar Oct 28 '19 16:10 martong

run tests (this message is intended for the build bot, if you answer to this message then you owe me a bottle of whiskey)

martong avatar Oct 29 '19 16:10 martong

run tests

martong avatar Oct 29 '19 16:10 martong

run tests

gamesh411 avatar Oct 30 '19 13:10 gamesh411