[cfe-dev] source traversing with clang......

Douglas Gregor dgregor at apple.com
Fri Jan 14 07:22:34 PST 2011

On Jan 14, 2011, at 3:07 AM, Bruce Stephens wrote:

> Douglas Gregor <dgregor-2kanFRK1NckAvxtiuMwx3w at public.gmane.org> writes:
>> On Jan 13, 2011, at 5:13 AM, jignesh vasoya wrote:
>>> Hi,
>>> I want to traverse source code of "C" language.
>>> i want to extract all the "for loops" in given C file. After extraction loop body i want to visit its body statements.
>>> then i want to extract all the functions one by one in the given source file.
>>> i want to do these using clang.
>>> what will be better? writing clang-plugin or separate program like whole program analysis?
>>> i may need to visit each and every statement of the function.
>> It's easier to write a clang-plugin or add a new action based on the -fsyntax-only action.
> If someone wanted to produce a standalone example (like a blend of
> clang-interpreter and PrintFunctionNames, I guess) that used
> RecursiveASTVisitor I suspect that would be valued.

Yes. Or if someone were to make it easy to build an plugin that let is drop new ASTConsumers into a compilation job, that would make this kind of extension really easy.

	- Doug

More information about the cfe-dev mailing list