Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clang Plugins working group

Similar presentations


Presentation on theme: "Clang Plugins working group"— Presentation transcript:

1 Clang Plugins working group
David Poliakoff

2 Use cases Static analysis Code instrumentation
Extract control flow graph How are STL containers used (push_back(), fixed-size/dynamic etc.)

3 Compiler plugins Clang plugins vs. llvm passes Other compilers
For source code / IR: clang plugins For LLVM assembly: llvm passes Both can do loop analysis Pass info from clang to llvm through artifacts Other compilers gcc: Undocumented plugin interface Intel / XL: good luck Nvidia: run away Can use source-to-source compilation from clang Vs. ROSE etc. ROSE has easier source-code insertion Clang has bigger user base

4 How to write a clang plugin
Find source locations for patterns of interest with clang-query E.g. match forStmt(hasDescendant(declRefExpr())) Respects defs and includes in compile_commands.json Can be created with Cmake, bare make Use arcane compiler knowledge Implement AST visitors Visits AST nodes (ifs, fors, function decls, ...) Overwrite corresponding visitor method and do stuff Build plugin (use recipe, e.g. from Eli’s website (see Resources)) Use plugin: clang++ -fplugin=myplugin.so source.cpp Can also build executables with plugin functionality

5 Resources https://clang.llvm.org/doxygen
refactoring-tools


Download ppt "Clang Plugins working group"

Similar presentations


Ads by Google