[cfe-dev] Clang and Preprocessor Directives

Chris Lattner clattner at apple.com
Sun Apr 20 19:54:12 PDT 2008


<cc'ing cfe-dev>

On Apr 20, 2008, at 7:20 PM, pingu219 at gmail.com wrote:

> Thanks for the reply and sorry for being a little vague. For the  
> purposes of refactoring ideally the refactoring tool shouldn't work  
> on fully preprocessed code output which would mean all included  
> files merged into a single unit, preprocessor directives and  
> comments taken out etc. Also it would raise the issue of what  
> happens if the user modifies preprocessed code that was actually  
> part of a macro before. There is also a problem with conditional  
> compilation where you can't really just evaluate one conditional  
> branch otherwise refactoring might break the program too.
>
> The conditional compilation problem may be too big for me to handle  
> for now but I was wondering if Clang preserves preprocessor  
> directives like macros in its own internal representation so that if  
> the user tries to perform a refactoring which would affect the  
> correctness of a macro, the program would be able to pick that up or  
> maybe to introduce changes to the macro definition as well. Also if  
> it's possible for included files to be represented separately so to  
> speak. It was mentioned that clang may be ideal for refactoring so I  
> was wondering how far support for refactoring extended.

clang does not preserve preprocessing directives in the AST, as this  
is not possible to do in general.  It does indicate whether tokens  
came from a preprocessor expansion or not though.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080420/1638b08e/attachment.html>


More information about the cfe-dev mailing list