Marcus Rodrigues via llvm-dev
2015-Sep-14 19:34 UTC
[llvm-dev] 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150914/9ced7614/attachment.html>
David Blaikie via llvm-dev
2015-Sep-14 20:08 UTC
[llvm-dev] AST of a program without any interference of semantic analyzer
(this conversation is more applicable to cfe-dev (cc'd) rather than llvm-dev (please drop llvm-dev from further replies) On Mon, Sep 14, 2015 at 12:34 PM, Marcus Rodrigues via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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? >Short answer: no. I suppose it might be supportable in C (we shuold produce an AST, but we will produce errors (you can suppress them), with invalid nodes for the variable references), it's certainly not supportable in C++ owing to the non-context-free nature of the C++ programming language. - Dave> > Since now, thank you very much! > > Regards, > Marcus > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150914/3df76f8b/attachment.html>