secure-software-engineering / phasar

A LLVM-based static analysis framework.
Other
930 stars 140 forks source link

Can Phasar transform source-level CFG to IR-level CFG #482

Closed ash1852 closed 1 year ago

ash1852 commented 2 years ago

Hi, I want to implement a value range analysis via clang-tidy.I know CFG can get via buildCFG() method, but it is source-level(Even if I can get the AST, the AST is very complex and I want it to be simplified the most). I would like to know if it is possible to implement source-level CFG to IR-level(simplified AST or other simple representation easy to analyze) CFG conversion through some API in phasar. Thank you very much.

MMory commented 2 years ago

Hi, I am not sure whether I understand your question/intention correctly. The IR level implies that you already did a compilation of the program under analysis to LLVM IR. When that is the case Phasar can build a CFG for you. I understand this is not what you want, though. You want to build a CFG for some IR given your own source code level CFG, right?

Phasar has the facilities to perform mapping from IR to source code. So you could iterate over the IR and map call sites to source code call sites for which you have your own callee functionality. We have no such thing already implemented in Phasar and I am not sure whether this would make sense, given that there is an infinite amount of possible CFG representations on the source level.