diff options
author | Sergio Martins <smartins@kde.org> | 2017-09-21 18:44:06 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2017-09-21 18:44:06 +0100 |
commit | c25a564e5adc195b3577f03a376d4777a0255602 (patch) | |
tree | 8b7b2d98940032a5b9b58644aa27c3ad1b656711 /src/QtUtils.cpp | |
parent | 641ef2cf56a5d8e64e43a46e01aee0efd354215a (diff) |
Refactor into QtUtils::recordHasCtorWithParam
So code can be shared
Diffstat (limited to 'src/QtUtils.cpp')
-rw-r--r-- | src/QtUtils.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/QtUtils.cpp b/src/QtUtils.cpp index 6bda1eb0..37e0f980 100644 --- a/src/QtUtils.cpp +++ b/src/QtUtils.cpp @@ -323,3 +323,28 @@ CXXMethodDecl *QtUtils::pmfFromUnary(UnaryOperator *uo) return nullptr; } + +bool QtUtils::recordHasCtorWithParam(clang::CXXRecordDecl *record, const std::string ¶mType, bool &ok, int &numCtors) +{ + ok = true; + numCtors = 0; + if (!record || !record->hasDefinition() || + record->getDefinition() != record) { // Means fwd decl + ok = false; + return false; + } + + for (auto ctor : record->ctors()) { + if (ctor->isCopyOrMoveConstructor()) + continue; + numCtors++; + for (auto param : ctor->parameters()) { + QualType qt = TypeUtils::pointeeQualType(param->getType()); + if (!qt.isConstQualified() && TypeUtils::derivesFrom(qt, paramType)) { + return true; + } + } + } + + return false; +} |