[cfe-dev] Changing the size of ConstantArrayType
peter at pcc.me.uk
Mon Jan 31 14:20:54 PST 2011
On Mon, Jan 31, 2011 at 10:39:17PM +0100, Dimitrij Kotrev wrote:
> i need a way to change the size of the ConstantArrayType after the AST
> is created.
> I thought about two ways to do it:
> 1. I'll add a setSize method to ConstantArrayType class.
Types are immutable once created, so you can't do this.
> 2. I replace 'somehow' the node in the AST with a new one, which has
> the size i need.
You can use ASTContext::getConstantArrayType to create a new
ConstantArrayType (or retrieve an existing one matching the given
parameters). But actually replacing the type everywhere in the AST
may be difficult, as the AST is not designed to be modified after
> But i dont know what are the consequences when i'll do it the one or
> the other way. And
> is it possible to do it so anyway? What are the other options i have
> to solve this problem?
To answer this question it would help if you explain more about what
you are trying to do and why you think you need to change array sizes
after AST construction.
More information about the cfe-dev