| 1 |
/* |
| 2 |
SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]> |
| 3 |
|
| 4 |
SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "ruleofbase.h" |
| 8 |
#include "StringUtils.h" |
| 9 |
#include "clazy_stl.h" |
| 10 |
|
| 11 |
#include <clang/AST/DeclCXX.h> |
| 12 |
|
| 13 |
#include <vector> |
| 14 |
|
| 15 |
using namespace clang; |
| 16 |
|
| 17 |
RuleOfBase::RuleOfBase(const std::string &name, Options options) |
| 18 |
: CheckBase(name, options) |
| 19 |
{ |
| 20 |
} |
| 21 |
|
| 22 |
bool RuleOfBase::isBlacklisted(CXXRecordDecl *record) const |
| 23 |
{ |
| 24 |
if (!record || clazy::startsWith(record->getQualifiedNameAsString(), "std::")) { |
| 25 |
return true; |
| 26 |
} |
| 27 |
|
| 28 |
const auto qualifiedName = clazy::classNameFor(record); |
| 29 |
|
| 30 |
static const std::vector<std::string> blacklisted = { |
| 31 |
"QAtomicInt", |
| 32 |
"QBasicAtomicInteger", |
| 33 |
"QAtomicInteger", |
| 34 |
"QBasicAtomicPointer", |
| 35 |
"QList::iterator", |
| 36 |
"QList::const_iterator", |
| 37 |
"QTextBlock::iterator", |
| 38 |
"QAtomicPointer", |
| 39 |
"QtPrivate::ConverterMemberFunction", |
| 40 |
"QtPrivate::ConverterMemberFunctionOk", |
| 41 |
"QtPrivate::ConverterFunctor", |
| 42 |
"QtMetaTypePrivate::VariantData", |
| 43 |
"QScopedArrayPointer", |
| 44 |
"QtPrivate::AlignOfHelper", |
| 45 |
"QColor", |
| 46 |
"QCharRef", |
| 47 |
"QByteRef", |
| 48 |
"QObjectPrivate::Connection", |
| 49 |
"QMutableListIterator", |
| 50 |
"QStringList", |
| 51 |
"QVariant::Private", |
| 52 |
"QSet", // Fixed for Qt 5.7 |
| 53 |
"QSet::iterator", |
| 54 |
"QSet::const_iterator", |
| 55 |
"QLinkedList::iterator", |
| 56 |
"QLinkedList::const_iterator", |
| 57 |
"QJsonArray::const_iterator", |
| 58 |
"QJsonArray::iterator", |
| 59 |
"QTextFrame::iterator", |
| 60 |
"QFuture::const_iterator", |
| 61 |
"QFuture::iterator", |
| 62 |
"QMatrix", |
| 63 |
"QBitRef", |
| 64 |
"QJsonValueRef", |
| 65 |
"QTypedArrayData::iterator", |
| 66 |
}; |
| 67 |
return clazy::contains(blacklisted, qualifiedName); |
| 68 |
} |