clang/find-unprefixed-members.cxx | 22 +++++++--------------- clang/test.hxx | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 17 deletions(-)
New commits: commit be70d9edbd52c0cc0fd82647e7af00ac38a327e7 Author: Miklos Vajna <[email protected]> Date: Wed Oct 28 20:15:22 2015 +0100 clang: ignore member functions of structs in find-unprefixed-members E.g. SwPosition is not prefixed, but those members are accessed almost always directly from the outside, so it doesn't really matter that it has a few member functions, it's still just a struct. diff --git a/clang/find-unprefixed-members.cxx b/clang/find-unprefixed-members.cxx index 51f3f47..1ca5a08 100644 --- a/clang/find-unprefixed-members.cxx +++ b/clang/find-unprefixed-members.cxx @@ -116,6 +116,9 @@ public: return true; clang::CXXRecordDecl* pRecord = pDecl->getParent(); + if (pRecord->getKindName().str() == "struct") + return true; + m_aFunctions.insert(pRecord->getQualifiedNameAsString()); return true; } diff --git a/clang/test.hxx b/clang/test.hxx index 1ef233c..cd89c60 100644 --- a/clang/test.hxx +++ b/clang/test.hxx @@ -30,11 +30,19 @@ public: C() { } }; /// This has no member functions, so members are OK to be not prefixed. -struct S +class S1 { int nX, mnY, m_nZ; - S() { } - ~S() { } + S1() { } + ~S1() { } +}; +/// This has member functions, but is a struct, so members are still OK to be not prefixed. +struct S2 +{ + int nX, mnY, m_nZ; + S2() { } + void foo() { } + ~S2() { } }; } commit d8eca99285d8fe96b62189930863cb07dd30797b Author: Miklos Vajna <[email protected]> Date: Wed Oct 28 20:14:37 2015 +0100 clang: ignore members with ctor/dtors only in find-unprefixed-members diff --git a/clang/find-unprefixed-members.cxx b/clang/find-unprefixed-members.cxx index d8c609c..51f3f47 100644 --- a/clang/find-unprefixed-members.cxx +++ b/clang/find-unprefixed-members.cxx @@ -36,7 +36,7 @@ class Visitor : public clang::RecursiveASTVisitor<Visitor> const Context m_rContext; /// List of qualified class name -- member name pairs. std::vector<std::pair<std::string, std::string>> m_aResults; - /// List of qualified class names which have ctors/dtors/member functions. + /// List of qualified class names which have member functions. std::set<std::string> m_aFunctions; public: @@ -110,22 +110,11 @@ public: return true; } - bool VisitCXXConstructorDecl(clang::CXXConstructorDecl* pDecl) - { - clang::CXXRecordDecl* pRecord = pDecl->getParent(); - m_aFunctions.insert(pRecord->getQualifiedNameAsString()); - return true; - } - - bool VisitCXXDestructorDecl(clang::CXXDestructorDecl* pDecl) - { - clang::CXXRecordDecl* pRecord = pDecl->getParent(); - m_aFunctions.insert(pRecord->getQualifiedNameAsString()); - return true; - } - bool VisitCXXMethodDecl(clang::CXXMethodDecl* pDecl) { + if (clang::isa<clang::CXXConstructorDecl>(pDecl) || clang::isa<clang::CXXDestructorDecl>(pDecl)) + return true; + clang::CXXRecordDecl* pRecord = pDecl->getParent(); m_aFunctions.insert(pRecord->getQualifiedNameAsString()); return true; @@ -151,7 +140,7 @@ public: aVisitor.TraverseDecl(rContext.getTranslationUnitDecl()); const std::set<std::string>& rFunctions = aVisitor.getFunctions(); const std::vector<std::pair<std::string, std::string>>& rResults = aVisitor.getResults(); - // Ignore missing prefixes in structs without ctors/dtors/member functions. + // Ignore missing prefixes in structs without member functions. bool bFound = false; for (const std::string& rFunction : rFunctions) { diff --git a/clang/test.hxx b/clang/test.hxx index 1669b9d..1ef233c 100644 --- a/clang/test.hxx +++ b/clang/test.hxx @@ -29,10 +29,12 @@ public: C() { } }; -/// This has no ctor/dtor/member functions, so members are OK to be not prefixed. +/// This has no member functions, so members are OK to be not prefixed. struct S { int nX, mnY, m_nZ; + S() { } + ~S() { } }; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
