AST of a program without any interference of semantic analyzer

Dear LLVMers,

I’m developing a tool to extract constraints from C programs. To do it, I
need, firstly, to be able to go over the Abstract Syntax Tree of a program.
Thus, I’m trying to use clang to get the AST of a program and start my
work from it. The problem that I’m having is that I don’t know how I can
get the AST of a program without any intervention of the semantic analyzer.
I would like to analyze programs that have uses of undeclared variables.
However, once clang finds an undeclared variable, it stops building the tree,
and just shows me the errors. If I need to modify clang, to continue producing
the tree, e.g., assuming that every undeclared variable is extern, how can I do it?

Or, in other words, is there a way to disable the semantic analysis
and get the AST of a program without any interference of the this analyzer?

Since now, thank you very much!

Regards,

Marcus

(this conversation is more applicable to cfe-dev (cc’d) rather than llvm-dev (please drop llvm-dev from further replies)