/* SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company info@kdab.com SPDX-FileContributor: Sérgio Martins SPDX-License-Identifier: LGPL-2.0-or-later */ #include "tr-non-literal.h" #include "HierarchyUtils.h" #include #include #include #include #include using namespace clang; void TrNonLiteral::VisitStmt(clang::Stmt *stmt) { auto *callExpr = dyn_cast(stmt); if (!callExpr || callExpr->getNumArgs() <= 0) { return; } FunctionDecl *func = callExpr->getDirectCallee(); if (!func || func->getQualifiedNameAsString() != qtNamespaced("QObject::tr")) { return; } Expr *arg1 = callExpr->getArg(0); if (clazy::getFirstChildOfType2(arg1) == nullptr) { emitWarning(stmt, "tr() without a literal string"); } }