[PATCH] Sema: Eliminate recursion from checkForFunctionCall()
Vedant Kumar
vsk at apple.com
Wed Jul 22 14:31:46 PDT 2015
> This is a fairly large block of code to further indent. Can you
> move this to a helper function as a separate, preparatory patch
> with no functionality change (NFC) that returns the new value of
> `State`?
I’ve attached a patch which separates the state update logic in checkForFunctionCall into a helper routine.
I’ll send a follow-up patch with the rest of the changes you requested shortly.
>> + // If the current state is FoundPathWithNoRecursiveCall, the successors
>> + // will be either FoundPathWithNoRecursiveCall or FoundPath. To determine
>> + // which, process all the Stmt's in this block to find any recursive
>> + // calls.
>> + for (const auto &B : CurBlock) {
>> + if (B.getKind() != CFGElement::Statement)
>> + continue;
>>
>> - const CallExpr *CE = dyn_cast<CallExpr>(B.getAs<CFGStmt>()->getStmt());
>> - if (CE && CE->getCalleeDecl() &&
>> - CE->getCalleeDecl()->getCanonicalDecl() == FD) {
>> -
>> - // Skip function calls which are qualified with a templated class.
>> - if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
>> - CE->getCallee()->IgnoreParenImpCasts())) {
>> - if (NestedNameSpecifier *NNS = DRE->getQualifier()) {
>> - if (NNS->getKind() == NestedNameSpecifier::TypeSpec &&
>> - isa<TemplateSpecializationType>(NNS->getAsType())) {
>> - continue;
>> + const CallExpr *CE = dyn_cast<CallExpr>(B.getAs<CFGStmt>()->getStmt());
>> + if (CE && CE->getCalleeDecl() &&
>> + CE->getCalleeDecl()->getCanonicalDecl() == FD) {
>> +
>> + // Skip function calls which are qualified with a templated class.
>> + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
>> + CE->getCallee()->IgnoreParenImpCasts())) {
>> + if (NestedNameSpecifier *NNS = DRE->getQualifier()) {
>> + if (NNS->getKind() == NestedNameSpecifier::TypeSpec &&
>> + isa<TemplateSpecializationType>(NNS->getAsType())) {
>> + continue;
>> + }
>> }
>> }
>> - }
>>
>> - if (const CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(CE)) {
>> - if (isa<CXXThisExpr>(MCE->getImplicitObjectArgument()) ||
>> - !MCE->getMethodDecl()->isVirtual()) {
>> - State = FoundPath;
>> + if (const CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(CE)) {
>> + if (isa<CXXThisExpr>(MCE->getImplicitObjectArgument()) ||
>> + !MCE->getMethodDecl()->isVirtual()) {
>> + CurState = FoundPath;
>> + break;
>> + }
>> + } else {
>> + CurState = FoundPath;
>> break;
>> }
>> - } else {
>> - State = FoundPath;
>> - break;
>> }
>> }
>> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: checkForFunctionCall-1.patch
Type: application/octet-stream
Size: 2704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150722/76a7395c/attachment.obj>
-------------- next part --------------
More information about the cfe-commits
mailing list