[cfe-dev] Should we build semantically invalid nodes?

Chris Lattner clattner at apple.com
Sun Oct 26 13:21:51 PDT 2008


On Oct 26, 2008, at 12:27 PM, Argiris Kirtzidis wrote:

> Chris Lattner wrote:
>>
>>
>> On top of that, refactoring isn't just about renaming things... it  
>> has to do a lot of verification to make sure that the  
>> transformation is safe.  For example, in:
>>
>>
>> int G;
>> int foo(int H) {
>>  return G+H;
>> }
>>
>> A refactoring tool is supposed to not allow you to rename G to H  
>> because it would be shadowed (and thus change semantics) in foo.
>
> This is orthogonal to finding all the references. If you want to  
> disallow shadowing, whether you have
>
> int G;
> int foo(int H) {
> return G+H;
> }
>
> or
>
> int G;
> int foo(int H) {
> return reinterpret_cast<char>(G)+H;
> }
>
> you still have to check shadowing.

I understand that it is possible.  It boils down to an engineering  
tradeoff: is it more important for refactorings to be robust and easy  
to develop, or more important to handle broken code.  Further, if you  
handle broken code, how many broken cases do you handle and how do we  
distinguish between them?  Refactoring in general needs full type info  
and many other things.  While I understand that this case is  
conceptually simple, there are many other cases that aren't.

-Chris



More information about the cfe-dev mailing list