/* SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company info@kdab.com SPDX-FileContributor: Sérgio Martins SPDX-FileCopyrightText: 2015 Sergio Martins SPDX-License-Identifier: LGPL-2.0-or-later */ #include "qmap-with-pointer-key.h" #include "StringUtils.h" #include "Utils.h" #include #include #include #include #include using namespace clang; void QMapWithPointerKey::VisitDecl(clang::Decl *decl) { auto *tsdecl = Utils::templateSpecializationFromVarDecl(decl); if (!tsdecl || clazy::name(tsdecl) != "QMap") { return; } const TemplateArgumentList &templateArguments = tsdecl->getTemplateArgs(); if (templateArguments.size() != 2) { return; } QualType qt = templateArguments[0].getAsType(); const Type *t = qt.getTypePtrOrNull(); if (t && t->isPointerType()) { emitWarning(decl->getBeginLoc(), "Use QHash instead of QMap when K is a pointer"); } }