[PATCH] Sema: Eliminate recursion from checkForFunctionCall()

Vedant Kumar vsk at apple.com
Thu Jul 23 11:54:07 PDT 2015


Two patches attached again: part1 no behavior change, part2 as before.

> Actually, this whole function looks like it's just checking for a
> recursive path.  You could change it to return `bool`, and rename it
> something like `hasRecursiveCall()`, and leave the state-related logic
> out of the helper.  Maybe better in a follow-up patch?

I went ahead and took care of this in the first patch, since it cleans things up nicely.

> I think this would be clearer like this:
> 
>    const CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(CE);
>    if (!MCE || isa<CXXThisExpr>(MCE->getImplicitObjectArgument()) ||
>        !MCE->getMethodDecl()->isVirtual())
>      return FoundPath;

Yup, done.

> In either case, this could be merged with the early exit:
> 
>    if (State == FoundPathWithNoRecursiveCall)
>      if (ExitID == ID)
>        return;
>      if (hasRecusiveCallInPath(FD, Block)
>        State = FoundPath;
>    }

Done.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkForFunctionCall-part1.patch
Type: application/octet-stream
Size: 3665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/08e0af0f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkForFunctionCall-part2.patch
Type: application/octet-stream
Size: 1960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/08e0af0f/attachment-0001.obj>


More information about the cfe-commits mailing list