diff options
Diffstat (limited to 'compilerplugins/clang/mergeclasses.cxx')
-rw-r--r-- | compilerplugins/clang/mergeclasses.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/compilerplugins/clang/mergeclasses.cxx b/compilerplugins/clang/mergeclasses.cxx index 017f66680ffb..5081517f402a 100644 --- a/compilerplugins/clang/mergeclasses.cxx +++ b/compilerplugins/clang/mergeclasses.cxx @@ -11,6 +11,8 @@ #include <set> #include <string> #include <iostream> +#include "config_clang.h" +#include "compat.hxx" #include "plugin.hxx" #include <fstream> @@ -55,6 +57,8 @@ public: virtual void run() override { + handler.enableTreeWideAnalysisMode(); + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); // dump all our output in one write call - this is to try and limit IO "crosstalk" between multiple processes @@ -83,14 +87,15 @@ public: bool ignoreClass(StringRef s) { // ignore stuff in the standard library, and UNO stuff we can't touch. - if (s.startswith("rtl::") || s.startswith("sal::") || s.startswith("com::sun::") - || s.startswith("std::") || s.startswith("boost::") + if (compat::starts_with(s, "rtl::") || compat::starts_with(s, "sal::") + || compat::starts_with(s, "com::sun::") || compat::starts_with(s, "std::") + || compat::starts_with(s, "boost::") || s == "OString" || s == "OUString" || s == "bad_alloc") { return true; } // ignore instantiations of pointers and arrays - if (s.endswith("*") || s.endswith("]")) { + if (compat::ends_with(s, "*") || compat::ends_with(s, "]")) { return true; } return false; @@ -102,7 +107,9 @@ bool MergeClasses::VisitVarDecl( const VarDecl* pVarDecl ) if (ignoreLocation(pVarDecl)) { return true; } - std::string s = pVarDecl->getType().getAsString(); + if (pVarDecl->getType()->isReferenceType()) + return true; + std::string s = pVarDecl->getType().getUnqualifiedType().getAsString(); if (!ignoreClass(s)) instantiatedSet.insert(s); return true; @@ -114,7 +121,9 @@ bool MergeClasses::VisitFieldDecl( const FieldDecl* pFieldDecl ) if (ignoreLocation(pFieldDecl)) { return true; } - std::string s = pFieldDecl->getType().getAsString(); + if (pFieldDecl->getType()->isReferenceType()) + return true; + std::string s = pFieldDecl->getType().getUnqualifiedType().getAsString(); if (!ignoreClass(s)) instantiatedSet.insert(s); return true; @@ -126,7 +135,7 @@ bool MergeClasses::VisitCXXConstructExpr( const CXXConstructExpr* pCXXConstructE return true; } // ignore calls when a sub-class is constructing its superclass - if (pCXXConstructExpr->getConstructionKind() != CXXConstructExpr::ConstructionKind::CK_Complete) { + if (pCXXConstructExpr->getConstructionKind() != compat::CXXConstructionKind::Complete) { return true; } const CXXConstructorDecl* pCXXConstructorDecl = pCXXConstructExpr->getConstructor(); @@ -144,7 +153,7 @@ bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) } if (decl->isThisDeclarationADefinition()) { - SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl)); + SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getBeginLoc()); auto filename = getFilenameOfLocation(spellingLocation); filename = filename.substr(strlen(SRCDIR)); std::string s = decl->getQualifiedNameAsString(); |