[PATCH] Extend PPCallbacks #if and #elif callbacks

Thompson, John John_Thompson at playstation.sony.com
Tue Jul 16 08:38:53 PDT 2013


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/6e9eb44a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tokencollection1.patch
Type: application/octet-stream
Size: 14241 bytes
Desc: tokencollection1.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/6e9eb44a/attachment.obj>


More information about the cfe-commits mailing list