[cfe-dev] ConditionalOperator::setCond is gone

Douglas Gregor dgregor at apple.com
Thu Mar 10 08:11:51 PST 2011


On Mar 10, 2011, at 6:03 AM, Olaf Krzikalla wrote:

> Am 09.03.2011 17:27, schrieb Douglas Gregor:
>> It's bad library design to write a library that can't maintain its own invariants, but that's exactly the problem with ConditionalOperator::setCond() and the many other mutators in the AST. I'm fine with having some way of mutating the AST, if it preserves invariants.
> OK, agreed. So please can you tell me which invariants in particular are violated by inplace mutations. Maybe we can find a satisfying solution.

Several things come to mind immediately:

	1) There's *no* checking that the types of the replacement expressions actually make sense within their node. If the type changes
	2) If any temporaries are contained in the new subexpression (or were in the old subexpression that was replaced), those temporaries need to be bound and noted in an outer expression
	3) A number of properties, including type- and value-dependent, whether there is a parameter pack in the subexpression, etc., are incrementally computed. If replacing a subexpression changes any of those, you need to propagate that change upward.

	- Doug





More information about the cfe-dev mailing list