AST matchers use

Hi,
Can we use AST Matchers to find out external functions and variables ? i.e if we have ASTs of say two different files and we want to find if a function is used in one file and defined in another can we find it with AST Matcher? And can we build a CFG after finding the dependencies across files? Please guide.
Thanks,
Siddharth