File indexing completed on 2024-05-12 17:13:19
0001 /* 0002 This file is part of the clazy static checker. 0003 0004 Copyright (C) 2015 Sergio Martins <smartins@kde.org> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include "ruleofbase.h" 0023 #include "StringUtils.h" 0024 #include "clazy_stl.h" 0025 0026 #include <clang/AST/DeclCXX.h> 0027 0028 #include <vector> 0029 0030 class ClazyContext; 0031 0032 using namespace clang; 0033 using namespace std; 0034 0035 RuleOfBase::RuleOfBase(const std::string &name, ClazyContext *context) 0036 : CheckBase(name, context) 0037 { 0038 } 0039 0040 bool RuleOfBase::isBlacklisted(CXXRecordDecl *record) const 0041 { 0042 if (!record || clazy::startsWith(record->getQualifiedNameAsString(), "std::")) 0043 return true; 0044 0045 const auto qualifiedName = clazy::classNameFor(record); 0046 0047 static const vector<string> blacklisted = { "QAtomicInt", "QBasicAtomicInteger", "QAtomicInteger", "QBasicAtomicPointer", 0048 "QList::iterator", "QList::const_iterator", "QTextBlock::iterator", 0049 "QAtomicPointer", "QtPrivate::ConverterMemberFunction", 0050 "QtPrivate::ConverterMemberFunctionOk", "QtPrivate::ConverterFunctor", 0051 "QtMetaTypePrivate::VariantData", "QScopedArrayPointer", 0052 "QtPrivate::AlignOfHelper", "QColor", "QCharRef", "QByteRef", 0053 "QObjectPrivate::Connection", "QMutableListIterator", 0054 "QStringList", "QVariant::Private", 0055 "QModelIndex", // Qt4 0056 "QPair", // Qt4 0057 "QSet", // Fixed for Qt 5.7 0058 "QSet::iterator", 0059 "QSet::const_iterator", 0060 "QLinkedList::iterator", 0061 "QLinkedList::const_iterator", 0062 "QJsonArray::const_iterator", 0063 "QJsonArray::iterator", 0064 "QTextFrame::iterator", 0065 "QFuture::const_iterator", 0066 "QFuture::iterator", 0067 "QMatrix", 0068 "QBitRef", "QJsonValueRef", 0069 "QTypedArrayData::iterator" 0070 }; 0071 return clazy::contains(blacklisted, qualifiedName); 0072 }