void OldStyleConnect::VisitStmt()

in src/checks/level2/old-style-connect.cpp [205:244]


void OldStyleConnect::VisitStmt(Stmt *s)
{
    auto *call = dyn_cast<CallExpr>(s);
    auto *ctorExpr = call ? nullptr : dyn_cast<CXXConstructExpr>(s);
    if (!call && !ctorExpr) {
        return;
    }

    if (m_context->lastMethodDecl && m_context->isQtDeveloper() && m_context->lastMethodDecl->getParent()
        && clazy::name(m_context->lastMethodDecl->getParent()) == "QObject") { // Don't warn of stuff inside qobject.h
        return;
    }

    FunctionDecl *function = call ? call->getDirectCallee() : ctorExpr->getConstructor();
    if (!function) {
        return;
    }

    auto *method = dyn_cast<CXXMethodDecl>(function);
    if (!method) {
        return;
    }

    const int classification = call ? classifyConnect(method, call) : classifyConnect(method, ctorExpr);

    if (!(classification & ConnectFlag_OldStyle)) {
        return;
    }

    if ((classification & ConnectFlag_OldStyleButNonLiteral)) {
        return;
    }

    if (classification & ConnectFlag_Bogus) {
        emitWarning(s->getBeginLoc(), "Internal error");
        return;
    }

    emitWarning(s->getBeginLoc(), "Old Style Connect", call ? fixits(classification, call) : fixits(classification, ctorExpr));
}