[PATCH] Added comprehensive macro arg usage logic to Use-Nullptr Transform

Manuel Klimek klimek at google.com
Fri May 3 11:18:24 PDT 2013


On Fri, May 3, 2013 at 7:09 PM, Edwin Vane <edwin.vane at intel.com> wrote:

>
>   Small suggestions addressed. Thank you.
>
>   As for Lexer::makeFileCharRange(), it is accomplishing something
> different using the same mechanisms as I'm using here, hence the
> similarity. Perhaps there's some refactoring that could be done to get
> functions like Lexer::getImmediateMacroName() (which I based much of my
> understanding on), Lexer::makeFileCharRange(), and numerous SourceManager
> functions to avoid repeated code. I do see similar tasks happening:
>
>     if macro arg expansion:
>       do something
>     else
>       do something else
>
>   Generally this is all done in digging out of (or in to, depending how
> you look at it) macro expansions. Whereas makeFileCharRange() is attempting
> to produce a SourceRange with file locations, the new functionality in this
> patch is trying to answer this question: given a NullTo(Member)Pointer cast
> that expands from a macro arg, do all uses of that arg result in
> NullTo(Member)Pointer casts. The three steps to accomplish this are
> described in allArgUsesValid():
>
>     # Get the SourceLocation of the arg and the macro to which that arg is
> given.
>     # Find the first ancestor of the cast that doesn't expand from the
> macro found in step 1. This is just to limit our search through the AST in
> step 3.
>     # Look at all descendants of node from step 2. Any that have source
> locations matching the arg from step 1 must have a NullTo(Member)Pointer
> cast somewhere along the descendant chain. This is taken to suffice as "all
> uses of the arg result in NullTo(Member)Pointer casts".
>

Ok, I just wanted to make sure we're not missing something. I'm convinced
enough we don't have a simpler way (hopefully "yet" :), so LG.

Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130503/64a34c0f/attachment.html>


More information about the cfe-commits mailing list