CoatiSoftware / Sourcetrail

Sourcetrail - free and open-source interactive source explorer
https://www.sourcetrail.com/
GNU General Public License v3.0
14.72k stars 1.37k forks source link

Add Clang ast-matcher support #635

Open egraether opened 5 years ago

egraether commented 5 years ago

http://clang.llvm.org/docs/LibASTMatchersReference.html

andijcr commented 5 years ago

A personal use case: find all instance of a global variable access (in a embedded enviroment there are plenty). in clang-query, i write a matcher somewhat like this: match declRefExpr(hasDeclaration(varDecl(unless(hasAncestor(functionDecl()))))) which matches on the ast all the cases where the scope was accessed for a symbol, filter for the one declared as variables, and filter out those declared inside a function.