[cfe-dev] sharing IR for expressions across statements?

David Tarditi via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 18 17:49:04 PST 2017


We're synthesizing some clang AST expressions as part of a research project to add more checking to C.     I have a question about Expr and its subclasses in the clang AST.  Is it OK to share expression nodes across statements or is it assumed that expressions are not shared across statements?  For example, if I have an Expr e and I want to build two assignment expressions tmp1 = e and tmp2 = e + 5, do I need to clone e so that there are not two pointers to e?

For context, we have a way of declaring bounds for pointer variables.    From that, we can infer bounds for C expressions.  We'll then use the inferred bounds to inject runtime bounds checks at memory dereferences.   It's quite natural to share the expressions for bounds across statements in this situation.

Thanks,
David


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170119/82fb7291/attachment.html>


More information about the cfe-dev mailing list