[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] Clang and Preprocessor Directives
From:       Chris Lattner <clattner () apple ! com>
Date:       2008-04-21 2:54:12
Message-ID: 73789C1C-0B79-420C-9272-29135A6BD320 () apple ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


<cc'ing cfe-dev>

On Apr 20, 2008, at 7:20 PM, pingu219@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


[Attachment #5 (text/html)]

<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; ">&lt;cc'ing cfe-dev&gt;<div><br><div><div>On \
Apr 20, 2008, at 7:20 PM, <a href="mailto:pingu219@gmail.com">pingu219@gmail.com</a> \
wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><font \
color="#888888"></font>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. <br> <br>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.</blockquote><div><br \
class="webkit-block-placeholder"></div>clang does not preserve preprocessing \
directives in the AST, as this is not possible to do in general. &nbsp;It does \
indicate whether tokens came from a preprocessor expansion or not \
though.</div><div><br \
class="webkit-block-placeholder"></div><div>-Chris</div><div><br></div></div></body></html>




_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic