diff options
Diffstat (limited to 'src/TypeUtils.cpp')
-rw-r--r-- | src/TypeUtils.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/TypeUtils.cpp b/src/TypeUtils.cpp index 0dea5120..9098028b 100644 --- a/src/TypeUtils.cpp +++ b/src/TypeUtils.cpp @@ -86,7 +86,7 @@ void TypeUtils::heapOrStackAllocated(Expr *arg, const std::string &type, } std::vector<DeclRefExpr*> declrefs; - HierarchyUtils::getChilds(arg, declrefs, 3); + clazy::getChilds(arg, declrefs, 3); std::vector<DeclRefExpr*> interestingDeclRefs; for (auto declref : declrefs) { @@ -98,7 +98,7 @@ void TypeUtils::heapOrStackAllocated(Expr *arg, const std::string &type, QualType qt = t->isPointerType() ? t->getPointeeType() : declref->getType(); - if (t && type == StringUtils::simpleTypeName(qt, lo)) { + if (t && type == clazy::simpleTypeName(qt, lo)) { interestingDeclRefs.push_back(declref); } } @@ -115,7 +115,8 @@ void TypeUtils::heapOrStackAllocated(Expr *arg, const std::string &type, } } -bool TypeUtils::derivesFrom(CXXRecordDecl *derived, CXXRecordDecl *possibleBase) +bool TypeUtils::derivesFrom(const CXXRecordDecl *derived, const CXXRecordDecl *possibleBase, + std::vector<CXXRecordDecl*> *baseClasses) { if (!derived || !possibleBase || derived == possibleBase) return false; @@ -124,8 +125,11 @@ bool TypeUtils::derivesFrom(CXXRecordDecl *derived, CXXRecordDecl *possibleBase) const Type *type = base.getType().getTypePtrOrNull(); if (!type) continue; CXXRecordDecl *baseDecl = type->getAsCXXRecordDecl(); + baseDecl = baseDecl ? baseDecl->getCanonicalDecl() : nullptr; - if (possibleBase == baseDecl || derivesFrom(baseDecl, possibleBase)) { + if (possibleBase == baseDecl || derivesFrom(baseDecl, possibleBase, baseClasses)) { + if (baseClasses) + baseClasses->push_back(baseDecl); return true; } } @@ -133,7 +137,7 @@ bool TypeUtils::derivesFrom(CXXRecordDecl *derived, CXXRecordDecl *possibleBase) return false; } -bool TypeUtils::derivesFrom(clang::CXXRecordDecl *derived, const std::string &possibleBase) +bool TypeUtils::derivesFrom(const clang::CXXRecordDecl *derived, const std::string &possibleBase) { if (!derived || !derived->hasDefinition()) return false; |