diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-11 12:36:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-11 12:37:50 +0200 |
commit | cc26cfd379ed32a4c41878370c8db237f327d544 (patch) | |
tree | f0a55ac3678c7ed758b4774f5e8bf7217840123f /compilerplugins | |
parent | b289cf8de23afa2e647b7b2045487bf3ac757e2a (diff) |
use more hasPathnamePrefix
Change-Id: I539e6aedad61d80b6ebe80104b77d720072395bd
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/constparams.cxx | 32 | ||||
-rw-r--r-- | compilerplugins/clang/expressionalwayszero.cxx | 18 | ||||
-rw-r--r-- | compilerplugins/clang/oncevar.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/unusedvariablemore.cxx | 11 | ||||
-rw-r--r-- | compilerplugins/clang/useuniqueptr.cxx | 42 |
5 files changed, 45 insertions, 66 deletions
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 3f1aad80b38e..94c4f74bee61 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -27,10 +27,6 @@ namespace { -static bool startswith(const std::string& rStr, const char* pSubStr) { - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - class ConstParams: public loplugin::FunctionAddress<ConstParams> { @@ -40,29 +36,29 @@ public: virtual void run() override { std::string fn(handler.getMainFileName()); loplugin::normalizeDotDotInFilePath(fn); - if (startswith(fn, SRCDIR "/sal/") + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/") || fn == SRCDIR "/jurt/source/pipe/staticsalhack.cxx" - || startswith(fn, SRCDIR "/bridges/") - || startswith(fn, SRCDIR "/binaryurp/") - || startswith(fn, SRCDIR "/stoc/") - || startswith(fn, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/bridges/") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/binaryurp/") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/stoc/") + || loplugin::hasPathnamePrefix(fn, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx") // some weird calling through a function pointer - || startswith(fn, SRCDIR "/svtools/source/table/defaultinputhandler.cxx") - || startswith(fn, SRCDIR "/sdext/source/pdfimport/test/pdfunzip.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/svtools/source/table/defaultinputhandler.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sdext/source/pdfimport/test/pdfunzip.cxx") // windows only - || startswith(fn, SRCDIR "/basic/source/sbx/sbxdec.cxx") - || startswith(fn, SRCDIR "/sfx2/source/doc/syspath.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/basic/source/sbx/sbxdec.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sfx2/source/doc/syspath.cxx") // ignore this for now - || startswith(fn, SRCDIR "/libreofficekit") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/libreofficekit") // I end up with a // CXXMemberCallExpr // to a // BuiltinType '<bound member function type>' // and the AST gives me no further useful information. - || startswith(fn, SRCDIR "/sw/source/core/doc/docfly.cxx") - || startswith(fn, SRCDIR "/sw/source/core/doc/DocumentContentOperationsManager.cxx") - || startswith(fn, SRCDIR "/sw/source/core/fields/cellfml.cxx") - || startswith(fn, SRCDIR "/sw/source/filter/ww8/ww8par6.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sw/source/core/doc/docfly.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sw/source/core/doc/DocumentContentOperationsManager.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sw/source/core/fields/cellfml.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sw/source/filter/ww8/ww8par6.cxx") ) return; diff --git a/compilerplugins/clang/expressionalwayszero.cxx b/compilerplugins/clang/expressionalwayszero.cxx index d53d20316a5d..c3bc0bb0730f 100644 --- a/compilerplugins/clang/expressionalwayszero.cxx +++ b/compilerplugins/clang/expressionalwayszero.cxx @@ -23,10 +23,6 @@ namespace { -static bool startswith(const std::string& rStr, const char* pSubStr) { - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - class ExpressionAlwaysZero: public loplugin::FilteringPlugin<ExpressionAlwaysZero> { @@ -40,23 +36,23 @@ public: loplugin::normalizeDotDotInFilePath(fn); // encoding of constant value for binary file format - if (startswith(fn, SRCDIR "/package/source/zipapi/ZipFile.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/package/source/zipapi/ZipFile.cxx")) return; // some auto-generated static data - if (startswith(fn, SRCDIR "/sal/textenc/tables.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/textenc/tables.cxx")) return; // nested conditional defines that are not worth cleaning up - if (startswith(fn, SRCDIR "/opencl/source/openclwrapper.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/opencl/source/openclwrapper.cxx")) return; // some kind of matrix calculation, the compiler will optimise it out anyway - if (startswith(fn, SRCDIR "/vcl/source/gdi/bitmap4.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/vcl/source/gdi/bitmap4.cxx")) return; // code follows a pattern - if (startswith(fn, SRCDIR "/svx/source/svdraw/svdhdl.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/svx/source/svdraw/svdhdl.cxx")) return; // looks like some kind of TODO marker - if (startswith(fn, SRCDIR "/chart2/source/view/main/PropertyMapper.cxx") - || startswith(fn, SRCDIR "/sc/source/core/data/formulacell.cxx")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/chart2/source/view/main/PropertyMapper.cxx") + || loplugin::hasPathnamePrefix(fn, SRCDIR "/sc/source/core/data/formulacell.cxx")) return; TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/compilerplugins/clang/oncevar.cxx b/compilerplugins/clang/oncevar.cxx index 587c8cb059ca..0f809b9ebfac 100644 --- a/compilerplugins/clang/oncevar.cxx +++ b/compilerplugins/clang/oncevar.cxx @@ -25,10 +25,6 @@ namespace { -bool startsWith(const std::string& rStr, const char* pSubStr) { - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - Expr const * lookThroughInitListExpr(Expr const * expr) { if (auto const ile = dyn_cast<InitListExpr>(expr->IgnoreParenImpCasts())) { if (ile->getNumInits() == 1) { @@ -94,9 +90,9 @@ public: || fn == SRCDIR "/embeddedobj/source/msole/oleembed.cxx") return; // some of this is necessary - if (startsWith( fn, SRCDIR "/sal/qa/")) + if (loplugin::hasPathnamePrefix( fn, SRCDIR "/sal/qa/")) return; - if (startsWith( fn, SRCDIR "/comphelper/qa/")) + if (loplugin::hasPathnamePrefix( fn, SRCDIR "/comphelper/qa/")) return; // TODO need to check calls via function pointer if (fn == SRCDIR "/i18npool/source/textconversion/textconversion_zh.cxx" diff --git a/compilerplugins/clang/unusedvariablemore.cxx b/compilerplugins/clang/unusedvariablemore.cxx index 2e8b69224aa5..8c153164f174 100644 --- a/compilerplugins/clang/unusedvariablemore.cxx +++ b/compilerplugins/clang/unusedvariablemore.cxx @@ -56,22 +56,17 @@ UnusedVariableMore::UnusedVariableMore(const InstantiationData& data) { } -static bool startswith(const std::string& rStr, const char* pSubStr) -{ - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - void UnusedVariableMore::run() { std::string fn(handler.getMainFileName()); loplugin::normalizeDotDotInFilePath(fn); // ignore QA folders - if (startswith(fn, SRCDIR "/sal/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/")) return; - if (startswith(fn, SRCDIR "/i18npool/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/i18npool/qa/")) return; - if (startswith(fn, SRCDIR "/sc/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sc/qa/")) return; // vector of shared_ptr used to delay destruction diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index c4fa336dac55..5c9157d26adc 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -156,10 +156,6 @@ private: std::string fn; }; -static bool startswith(const std::string& rStr, const char* pSubStr) { - return rStr.compare(0, strlen(pSubStr), pSubStr) == 0; -} - bool UseUniquePtr::VisitFunctionDecl(const FunctionDecl* functionDecl) { if (ignoreLocation(functionDecl)) @@ -326,23 +322,23 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C } } - if (startswith(fn, SRCDIR "/sal/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/")) return; - if (startswith(fn, SRCDIR "/comphelper/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/comphelper/qa/")) return; - if (startswith(fn, SRCDIR "/cppuhelper/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/cppuhelper/qa/")) return; - if (startswith(fn, SRCDIR "/libreofficekit/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/libreofficekit/qa/")) return; - if (startswith(fn, SRCDIR "/vcl/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/vcl/qa/")) return; - if (startswith(fn, SRCDIR "/sc/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sc/qa/")) return; - if (startswith(fn, SRCDIR "/sfx2/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sfx2/qa/")) return; - if (startswith(fn, SRCDIR "/smoketest/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/smoketest/")) return; - if (startswith(fn, WORKDIR)) + if (loplugin::hasPathnamePrefix(fn, WORKDIR)) return; // linked lists if (fn == SRCDIR "/vcl/source/gdi/regband.cxx") @@ -442,13 +438,13 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C // alloc/free routines for the hand constructed virtual function table if (fn == SRCDIR "/sal/textenc/convertisciidevangari.cxx") return; - if (startswith(fn, SRCDIR "/bridges/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/bridges/")) return; // bootstrap_map if (fn == SRCDIR "/sal/rtl/bootstrap.cxx") return; // too complicated for my small brain - if (startswith(fn, SRCDIR "/cppu/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/cppu/")) return; // linked list if (fn == SRCDIR "/vcl/source/gdi/octree.cxx") @@ -475,10 +471,10 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C if (fn == SRCDIR "/lotuswordpro/source/filter/lwpfribptr.cxx") return; // complicated - if (startswith(fn, SRCDIR "/connectivity/source/drivers/file/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/connectivity/source/drivers/file/")) return; // complicated - if (startswith(fn, SRCDIR "/unodevtools/source/skeletonmaker/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/unodevtools/source/skeletonmaker/")) return; llvm::StringRef parentName; @@ -730,7 +726,7 @@ void UseUniquePtr::CheckLoopDelete(const FunctionDecl* functionDecl, const CXXDe if (varDecl->hasInit() && isa<ExplicitCastExpr>(varDecl->getInit()->IgnoreImpCasts())) return; - if (startswith(fn, SRCDIR "/vcl/qa/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/vcl/qa/")) return; // linked list if (fn == SRCDIR "/registry/source/reflwrit.cxx") @@ -939,7 +935,7 @@ void UseUniquePtr::CheckMemberDeleteExpr(const FunctionDecl* functionDecl, const if (ignoreLocation(fieldDecl)) return; // to ignore things like the CPPUNIT macros - if (startswith(fn, WORKDIR "/")) + if (loplugin::hasPathnamePrefix(fn, WORKDIR "/")) return; // passes and stores pointers to member fields if (fn == SRCDIR "/sot/source/sdstor/stgdir.hxx") @@ -960,14 +956,14 @@ void UseUniquePtr::CheckMemberDeleteExpr(const FunctionDecl* functionDecl, const if (fn == SRCDIR "/sc/inc/formulacell.hxx") return; // some weird stuff going on here around struct Entity - if (startswith(fn, SRCDIR "/sax/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sax/")) return; - if (startswith(fn, SRCDIR "/include/sax/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/include/sax/")) return; // manipulation of tree structures ie. StgAvlNode, don't lend themselves to std::unique_ptr - if (startswith(fn, SRCDIR "/sot/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sot/")) return; - if (startswith(fn, SRCDIR "/include/sot/")) + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/include/sot/")) return; // the std::vector is being passed to another class if (fn == SRCDIR "/sfx2/source/explorer/nochaos.cxx") |