[cfe-dev] Using Clang for a C Refactoring Tool

Steve Naroff snaroff at apple.com
Fri Apr 11 15:34:03 PDT 2008


Mike,

I believe Patrick was asking about a refactoring API (not refactoring  
GUI).

Patrick,

You might want to look @ Rewriter. The Rewriter class provides a  
foundation for many types of refactoring. RewriteTest is a fairly  
sophisticated client of the Rewriter that "refactors" ObjC AST's to C  
source code (without disturbing white space, comments, preprocessor  
directives, macros, etc.). It operates on each module in isolation.

That said, we don't currently have an API for traditional refactoring  
operations that span multiple modules (like rename global variable  
from "this to that" for an entire project). Creating some higher level  
API's would be nice (but need to be driven by the feature/task).

Emerson might be able to give you some more info. He is becoming  
familiar with clang and understands the refactoring domain.

snaroff


On Apr 11, 2008, at 1:41 PM, Mike Stump wrote:

> On Apr 10, 2008, at 5:59 PM, Patrick Flannery wrote:
>> One area which I have not spent enough time thinking about is what
>> an interface for refactoring should look like.
>
> UIs are hard and hard to test.  If you take the approach of simple
> text in and out, a GUI is free to hook up a pipe to it and a testsuite
> is that much more manageable.  Now, since clang/llvm is a library, the
> notion of hooking up a pipe is silly, but, conceptually you can think
> of the interface that way, and in practice, running the testsuite this
> way I think is worthwhile.
>
> Any GUI code should be independent (lay on top of the library
> interface for refactoring).
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list