diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-05 07:50:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-05 09:48:43 +0200 |
commit | e1261e6ea6e897d38f69c0d250ec34ccf0f6d545 (patch) | |
tree | f6fea1de114f6e81d8e61014a7b366ddedc67b16 /compilerplugins/clang | |
parent | e5d943d984bb0918f971eec45f45384cc0c72b67 (diff) |
loplugin:finalclasses in vcl
Change-Id: I7de9cd6c5569217aa8d379c6d112cd1874bca8e2
Reviewed-on: https://gerrit.libreoffice.org/43151
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/finalclasses.cxx | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/compilerplugins/clang/finalclasses.cxx b/compilerplugins/clang/finalclasses.cxx index 4b7a35804719..294e52592a51 100644 --- a/compilerplugins/clang/finalclasses.cxx +++ b/compilerplugins/clang/finalclasses.cxx @@ -57,7 +57,11 @@ public: bool shouldVisitTemplateInstantiations () const { return true; } + bool shouldVisitImplicitCode() const { return true; } + bool VisitCXXRecordDecl( const CXXRecordDecl* decl); +private: + void checkBase(QualType qt); }; bool startsWith(const std::string& rStr, const char* pSubStr) { @@ -81,23 +85,18 @@ bool FinalClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) if (ignoreLocation(decl)) return true; decl = decl->getCanonicalDecl(); - if (!decl->isThisDeclarationADefinition()) + if (!decl->hasDefinition()) return true; for (auto it = decl->bases_begin(); it != decl->bases_end(); ++it) { const CXXBaseSpecifier spec = *it; - // need to look through typedefs, hence the getUnqualifiedDesugaredType - QualType baseType = spec.getType().getDesugaredType(compiler.getASTContext()); - std::string x; - // so that we get just the template name, excluding the template parameters - if (baseType->isRecordType()) - x = baseType->getAsCXXRecordDecl()->getQualifiedNameAsString(); - else if (auto templateType = baseType->getAs<TemplateSpecializationType>()) - x = templateType->getTemplateName().getAsTemplateDecl()->getQualifiedNameAsString(); - else - x = baseType.getAsString(); - inheritedFromSet.insert( x ); + checkBase(spec.getType()); + } + for (auto it = decl->vbases_begin(); it != decl->vbases_end(); ++it) + { + const CXXBaseSpecifier spec = *it; + checkBase(spec.getType()); } bool bFoundProtected = false; @@ -135,6 +134,21 @@ bool FinalClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) return true; } +void FinalClasses::checkBase(QualType baseType) +{ + // need to look through typedefs, hence the getUnqualifiedDesugaredType + baseType = baseType.getDesugaredType(compiler.getASTContext()); + std::string x; + // so that we get just the template name, excluding the template parameters + if (baseType->isRecordType()) + x = baseType->getAsCXXRecordDecl()->getQualifiedNameAsString(); + else if (auto templateType = baseType->getAs<TemplateSpecializationType>()) + x = templateType->getTemplateName().getAsTemplateDecl()->getQualifiedNameAsString(); + else + x = baseType.getAsString(); + inheritedFromSet.insert( x ); +} + loplugin::Plugin::Registration< FinalClasses > X("finalclasses", false); } |