Hi,

To facilitate the modularize tool's tracking of #if and #elif preprocessor 
conditional directives, it would be useful for the PPCallbacks interface to 
include two new arguments in the callbacks for these directives, a vector of 
tokens for the conditional expression (after substitution) and a Boolean flag 
indicating the evaluated value for the condition expression.  There was a FIXME 
in the original header for the former, and the later was discussed on cfe-dev.

The enclosed patch represents my attempt to implement this.

Some design considerations were to minimize performance impact, and to avoid 
making the existing code more complicated than necessary.  Most of the logic 
for handling the conditional expression was in one or two files, so it seemed a 
reasonable approach was to handle the token collection in some new member 
functions in Preprocessor used for lexing the next tokens, such that only 
function call name changes were needed in the conditional expression code.

The vector for storing the collected tokens is lazily created or cleared in the 
common EvaluateDirectiveExpression function.  It's defined as an OwningPtr to 
have it released when the Preprocessor object is destructed.

One concern is there might be user code outside of the repository that would 
need to be changed to accommodate this API change.

I would appreciate your review feedback and/or permission to check in.

Thanks.

-John

Attachment: tokencollection1.patch
Description: tokencollection1.patch

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to