[cfe-dev] ConditionalOperator::setCond is gone

Douglas Gregor dgregor at apple.com
Tue Mar 8 07:59:52 PST 2011


On Mar 8, 2011, at 4:55 AM, Olaf Krzikalla wrote:

> Hi @clang
> 
> for in-place AST transformations of my source-to-source transformation 
> tool I use the setXXX member functions of the various expression classes 
> (e.g setLHS, setRHS etc.) quiet heavily. Now I had to notice that 
> ConditionalOperator::setCond was removed without any appropriate 
> replacement. Is there any reason behind that decision? For the moment I 
> have re-added it locally but if there is a general tendency to remove 
> the setXXX member functions then I better start to refactor my code 
> early (however I would argue against a removal beforehand).

Yes, we have been removing setXXX member functions, because mutating an AST in-place is extremely dangerous. AST mutations look local, but it's very easy for them to have non-local effects that break the invariants of the AST.

Plus, immutable ASTs are far better when dealing with serialized representations of ASTs, because coping with in-place modifications to ASTs when serializing again is *extremely* complicated. See, for example, the chained PCH work in the AST reader/writer.

	- Doug



More information about the cfe-dev mailing list