What are the resources to create a static analyzer for C in C?

I have a school project to develop a static analyzer in C for C.

Where to begin? What resources can help me?

I guess I will need to parse C, so what are good parsers for C or tools for creating C parsers?

+3
source share
4 answers

First, I will go over to antlr , look at the beginning of the manual , it has a lot of information about parsing, etc., I personally use antlr, since it gives a choice of the purpose of code generation .

antlr c ++, .

.

+2

, Clang ( , , , , / ).

+1

, C?

langauge (, #, Java, Python), ANTLR .

C , lex yacc (flex bison) , , , .

, Uno , . lex/yacc . ++.

, , SpinRoot. Wikipedia .

+1

- . Antlr , C ( ++). - , gcc -E.

As for the rest, you can take a look at some of the existing sources of analyzers, namely Clang and CIL , read about SSA representation and abstract interpretation . Choosing the right intermediate view for your code is the key.

I doubt this can be a simple task in simple C, so you are likely to end up injecting some kind of DSL on top of it to handle AST and transformations. It sounds like more than a typical school project.

+1
source

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


All Articles