[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Thu May 18 07:57:51 UTC 2017


 compilerplugins/clang/automem.cxx             |   10 +-
 compilerplugins/clang/checkconfigmacros.cxx   |    6 -
 compilerplugins/clang/checkunusedparams.cxx   |   88 +++++++++++++-------------
 compilerplugins/clang/constantparam.cxx       |    6 -
 compilerplugins/clang/constparams.cxx         |   16 ++--
 compilerplugins/clang/datamembershadow.cxx    |   52 +++++++--------
 compilerplugins/clang/externandnotdefined.cxx |    2 
 compilerplugins/clang/fpcomparison.cxx        |    2 
 compilerplugins/clang/fragiledestructor.cxx   |   16 ++--
 compilerplugins/clang/memoryvar.cxx           |    4 -
 compilerplugins/clang/nullptr.cxx             |    5 -
 compilerplugins/clang/plugin.cxx              |   77 +++++++++++++++++-----
 compilerplugins/clang/plugin.hxx              |    8 ++
 compilerplugins/clang/refcounting.cxx         |    2 
 compilerplugins/clang/reservedid.cxx          |   15 +++-
 compilerplugins/clang/salbool.cxx             |   10 +-
 compilerplugins/clang/staticmethods.cxx       |   12 +--
 compilerplugins/clang/stringconcat.cxx        |    6 +
 compilerplugins/clang/stringconstant.cxx      |   27 +++++--
 compilerplugins/clang/stringstatic.cxx        |    4 -
 compilerplugins/clang/unnecessaryoverride.cxx |   28 ++++----
 compilerplugins/clang/unoany.cxx              |    2 
 compilerplugins/clang/useuniqueptr.cxx        |   18 ++---
 compilerplugins/clang/vclwidgets.cxx          |   24 +++----
 24 files changed, 253 insertions(+), 187 deletions(-)

New commits:
commit df8d092c3a3c65bc23bc3c1da281cc4cb10a1e3d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu May 18 09:56:01 2017 +0200

    Adapt pathname checks to mixed usage of \ and / on Windows
    
    Change-Id: I91bc89a9076c6642e06b238f65f2d31a1d20c6b5

diff --git a/compilerplugins/clang/automem.cxx b/compilerplugins/clang/automem.cxx
index 1b49d13cb097..3aa671fef1b5 100644
--- a/compilerplugins/clang/automem.cxx
+++ b/compilerplugins/clang/automem.cxx
@@ -52,11 +52,11 @@ bool AutoMem::VisitCXXDeleteExpr(const CXXDeleteExpr* expr)
     if (ignoreLocation( expr ))
         return true;
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
-    if (aFileName.startswith(SRCDIR "/include/salhelper/")
-        || aFileName.startswith(SRCDIR "/include/osl/")
-        || aFileName.startswith(SRCDIR "/salhelper/")
-        || aFileName.startswith(SRCDIR "/store/")
-        || aFileName.startswith(SRCDIR "/sal/"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/salhelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/salhelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/store/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/"))
         return true;
 
     if (mbInsideDestructor)
diff --git a/compilerplugins/clang/checkconfigmacros.cxx b/compilerplugins/clang/checkconfigmacros.cxx
index d35008c70c20..d42adb08cc67 100644
--- a/compilerplugins/clang/checkconfigmacros.cxx
+++ b/compilerplugins/clang/checkconfigmacros.cxx
@@ -67,8 +67,8 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
     SourceLocation location = info->getLocation();
     const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
     if( filename != NULL
-        && ( strncmp( filename, BUILDDIR "/config_host/", strlen( BUILDDIR "/config_host/" )) == 0
-            || strncmp( filename, BUILDDIR "/config_build/", strlen( BUILDDIR "/config_build/" )) == 0 ))
+        && ( hasPathnamePrefix(filename, BUILDDIR "/config_host/")
+            || hasPathnamePrefix(filename, BUILDDIR "/config_build/") ))
         {
 //        fprintf(stderr,"DEF: %s %s\n", macroToken.getIdentifierInfo()->getName().data(), filename );
         configMacros.insert( macroToken.getIdentifierInfo()->getName());
@@ -105,7 +105,7 @@ void CheckConfigMacros::checkMacro( const Token& macroToken, SourceLocation loca
         {
         const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
         if( filename == NULL
-            || strncmp( filename, SRCDIR "/include/LibreOfficeKit/", strlen( SRCDIR "/include/LibreOfficeKit/" )) != 0 )
+            || !hasPathnamePrefix(filename, SRCDIR "/include/LibreOfficeKit/") )
             {
             report( DiagnosticsEngine::Error, "checking whether a config macro %0 is defined",
                 location ) << macroToken.getIdentifierInfo()->getName();
diff --git a/compilerplugins/clang/checkunusedparams.cxx b/compilerplugins/clang/checkunusedparams.cxx
index f3118e1391f5..790236873d99 100644
--- a/compilerplugins/clang/checkunusedparams.cxx
+++ b/compilerplugins/clang/checkunusedparams.cxx
@@ -39,23 +39,23 @@ void CheckUnusedParams::run()
 {
     StringRef fn( compiler.getSourceManager().getFileEntryForID(
                       compiler.getSourceManager().getMainFileID())->getName() );
-    if (fn.startswith(SRCDIR "/sal/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/"))
          return;
     // Taking pointer to function
-    if (fn == SRCDIR "/l10ntools/source/xmlparse.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/l10ntools/source/xmlparse.cxx"))
          return;
     // macro magic which declares something needed by an external library
-    if (fn == SRCDIR "/svl/source/misc/gridprinter.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/svl/source/misc/gridprinter.cxx"))
          return;
 
     // valid test/qa code
-    if (fn.startswith(SRCDIR "/compilerplugins/clang/test/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/compilerplugins/clang/test/"))
          return;
-    if (fn == SRCDIR "/cppu/qa/test_reference.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/cppu/qa/test_reference.cxx"))
          return;
 
     // leave this alone for now
-    if (fn.startswith(SRCDIR "/libreofficekit/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/libreofficekit/"))
          return;
 
     m_phase = PluginPhase::FindAddressOf;
@@ -135,104 +135,104 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) {
     StringRef fn = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(canon->getLocStart()));
     // Some backwards compat magic.
     // TODO Can probably be removed, but need to do some checking
-    if (fn == SRCDIR "/include/sax/fshelper.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/sax/fshelper.hxx"))
          return true;
     // Platform-specific code
-    if (fn == SRCDIR "/include/svl/svdde.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/svl/svdde.hxx"))
          return true;
-    if (fn == SRCDIR "/include/vcl/svmain.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/vcl/svmain.hxx"))
          return true;
     // passing pointer to function
-    if (fn == SRCDIR "/include/vcl/bitmapaccess.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/vcl/bitmapaccess.hxx"))
          return true;
-    if (fn == SRCDIR "/vcl/inc/unx/gtk/gtkobject.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtkobject.hxx"))
          return true;
-    if (fn == SRCDIR "/vcl/inc/unx/gtk/gtksalframe.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtksalframe.hxx"))
          return true;
-    if (fn == SRCDIR "/vcl/inc/unx/gtk/gtkframe.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtkframe.hxx"))
          return true;
-    if (fn == SRCDIR "/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx"))
          return true;
-    if (fn == SRCDIR "/extensions/source/propctrlr/propertyeditor.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/extensions/source/propctrlr/propertyeditor.hxx"))
          return true;
-    if (fn == SRCDIR "/forms/source/solar/inc/navtoolbar.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/solar/inc/navtoolbar.hxx"))
          return true;
-    if (fn == SRCDIR "/hwpfilter/source/grammar.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/hwpfilter/source/grammar.cxx"))
          return true;
-    if (fn == SRCDIR "/hwpfilter/source/lexer.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/hwpfilter/source/lexer.cxx"))
          return true;
     // marked with a TODO/FIXME
-    if (fn == SRCDIR "/vcl/inc/sallayout.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/sallayout.hxx"))
          return true;
-    if (fn == SRCDIR "/accessibility/inc/standard/vclxaccessiblelist.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/accessibility/inc/standard/vclxaccessiblelist.hxx"))
          return true;
     // these are "extern C" but clang doesn't seem to report that accurately
-    if (fn == SRCDIR "/sax/source/fastparser/fastparser.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sax/source/fastparser/fastparser.cxx"))
          return true;
     // these all follow the same pattern, seems a pity to break that
-    if (fn == SRCDIR "/include/vcl/graphicfilter.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/vcl/graphicfilter.hxx"))
          return true;
     // looks like work in progress
-    if (fn == SRCDIR "/vcl/source/filter/ipdf/pdfdocument.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/vcl/source/filter/ipdf/pdfdocument.cxx"))
          return true;
     // macro magic
-    if (fn == SRCDIR "/basctl/source/inc/basidesh.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/basctl/source/inc/basidesh.hxx"))
          return true;
     // template magic
-    if (fn.startswith(SRCDIR "/canvas/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/canvas/"))
          return true;
-    if (fn.startswith(SRCDIR "/include/canvas/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/include/canvas/"))
          return true;
-    if (fn == SRCDIR "/include/comphelper/unwrapargs.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/comphelper/unwrapargs.hxx"))
          return true;
     // this looks like vaguely useful code (ParseError) that I'm loathe to remove
-    if (fn == SRCDIR "/connectivity/source/inc/RowFunctionParser.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/connectivity/source/inc/RowFunctionParser.hxx"))
          return true;
-    if (fn == SRCDIR "/include/svx/EnhancedCustomShapeFunctionParser.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/svx/EnhancedCustomShapeFunctionParser.hxx"))
          return true;
     // TODO marker parameter in constructor, should probably be using an enum
-    if (fn == SRCDIR "/framework/inc/uielement/uicommanddescription.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/framework/inc/uielement/uicommanddescription.hxx"))
          return true;
-    if (fn == SRCDIR "/sd/source/ui/inc/SlideTransitionPane.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/SlideTransitionPane.hxx"))
          return true;
-    if (fn == SRCDIR "/sd/source/ui/animations/CustomAnimationPane.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/animations/CustomAnimationPane.hxx"))
          return true;
-    if (fn == SRCDIR "/sd/source/ui/table/TableDesignPane.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/table/TableDesignPane.hxx"))
          return true;
     // debug stuff
-    if (fn == SRCDIR "/sc/source/core/data/column2.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sc/source/core/data/column2.cxx"))
          return true;
     // weird stuff
-    if (fn == SRCDIR "/scaddins/source/analysis/analysishelper.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/scaddins/source/analysis/analysishelper.hxx"))
          return true;
     // SFX_DECL_CHILDWINDOWCONTEXT macro stuff
-    if (fn == SRCDIR "/sd/source/ui/inc/NavigatorChildWindow.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/NavigatorChildWindow.hxx"))
          return true;
     // TODO, need to remove this from the .sdi file too
-    if (fn == SRCDIR "/sd/source/ui/inc/SlideSorterViewShell.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/SlideSorterViewShell.hxx"))
          return true;
-    if (fn == SRCDIR "/sd/source/ui/inc/OutlineViewShell.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/OutlineViewShell.hxx"))
          return true;
     // SFX_DECL_INTERFACE macro stuff
-    if (fn == SRCDIR "/sd/source/ui/inc/ViewShellBase.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/ViewShellBase.hxx"))
          return true;
     // debug stuff
-    if (fn == SRCDIR "/sd/source/filter/ppt/pptinanimations.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/filter/ppt/pptinanimations.hxx"))
          return true;
     // takes pointer to fn
-    if (fn == SRCDIR "/include/sfx2/shell.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/sfx2/shell.hxx"))
          return true;
     // TODO, need to remove this from the .sdi file too
     if (fqn == "SfxObjectShell::StateView_Impl")
          return true;
     // SFX_DECL_CHILDWINDOW_WITHID macro
-    if (fn == SRCDIR "/include/sfx2/infobar.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/include/sfx2/infobar.hxx"))
          return true;
     // this looks like vaguely useful code (ParseError) that I'm loathe to remove
-    if (fn == SRCDIR "/slideshow/source/inc/slideshowexceptions.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/slideshow/source/inc/slideshowexceptions.hxx"))
          return true;
     // SFX_DECL_VIEWFACTORY macro
-    if (fn == SRCDIR "/starmath/inc/view.hxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/starmath/inc/view.hxx"))
          return true;
     // debugging
     if (fqn == "BrowseBox::DoShowCursor" || fqn == "BrowseBox::DoHideCursor")
diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx
index 59f3d45b92a9..5f80b80358f3 100644
--- a/compilerplugins/clang/constantparam.cxx
+++ b/compilerplugins/clang/constantparam.cxx
@@ -64,8 +64,8 @@ public:
         std::string fn( compiler.getSourceManager().getFileEntryForID(
                         compiler.getSourceManager().getMainFileID())->getName() );
         normalizeDotDotInFilePath(fn);
-        if (fn == SRCDIR "/basegfx/source/matrix/b2dhommatrix.cxx"
-            || fn == SRCDIR "/basegfx/source/matrix/b3dhommatrix.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/basegfx/source/matrix/b2dhommatrix.cxx")
+            || loplugin::isSamePathname(fn, SRCDIR "/basegfx/source/matrix/b3dhommatrix.cxx"))
              return;
 
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
@@ -118,7 +118,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
         return;
     SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( functionDecl->getLocation() );
     StringRef filename = compiler.getSourceManager().getFilename(expansionLoc);
-    if (!filename.startswith(SRCDIR))
+    if (!loplugin::hasPathnamePrefix(filename, SRCDIR))
         return;
     filename = filename.substr(strlen(SRCDIR)+1);
 
diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx
index 52f1ffe12e19..ad5549d02263 100644
--- a/compilerplugins/clang/constparams.cxx
+++ b/compilerplugins/clang/constparams.cxx
@@ -94,16 +94,16 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl)
     }
 
     StringRef aFileName = getFilename(functionDecl->getLocStart());
-    if (aFileName.startswith(SRCDIR "/sal/")
-        || aFileName.startswith(SRCDIR "/bridges/")
-        || aFileName.startswith(SRCDIR "/binaryurp/")
-        || aFileName.startswith(SRCDIR "/stoc/")
-        || aFileName.startswith(WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx")
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/bridges/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/binaryurp/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/stoc/")
+        || loplugin::hasPathnamePrefix(aFileName, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx")
         // some weird calling through a function pointer
-        || aFileName.startswith(SRCDIR "/svtools/source/table/defaultinputhandler.cxx")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/svtools/source/table/defaultinputhandler.cxx")
         // windows only
-        || aFileName.startswith(SRCDIR "/basic/source/sbx/sbxdec.cxx")
-        || aFileName.startswith(SRCDIR "/sfx2/source/doc/syspath.cxx")) {
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/basic/source/sbx/sbxdec.cxx")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sfx2/source/doc/syspath.cxx")) {
         return true;
     }
 
diff --git a/compilerplugins/clang/datamembershadow.cxx b/compilerplugins/clang/datamembershadow.cxx
index 96f658c2c970..b946b7001759 100644
--- a/compilerplugins/clang/datamembershadow.cxx
+++ b/compilerplugins/clang/datamembershadow.cxx
@@ -47,53 +47,53 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
 
     // FIXME complex stuff to fix later
 
-    if (aFileName == SRCDIR "/connectivity/source/inc/calc/CTable.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/connectivity/source/inc/calc/CTable.hxx"))
         return true;
-    if (aFileName.startswith(SRCDIR "/chart2/source/"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/chart2/source/"))
         return true;
-    if (aFileName == SRCDIR "/cppcanvas/source/mtfrenderer/emfplus.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/cppcanvas/source/mtfrenderer/emfplus.cxx"))
         return true;
-    if (aFileName == SRCDIR "/cui/source/customize/eventdlg.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/cui/source/customize/eventdlg.hxx"))
         return true;
-    if (aFileName == SRCDIR "/include/sfx2/recentdocsview.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/sfx2/recentdocsview.hxx"))
         return true;
-    if (aFileName == SRCDIR "/include/sfx2/templatelocalview.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/sfx2/templatelocalview.hxx"))
         return true;
-    if (aFileName == SRCDIR "/filter/source/graphicfilter/idxf/dxfentrd.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/filter/source/graphicfilter/idxf/dxfentrd.hxx"))
         return true;
-    if (aFileName == SRCDIR "/framework/source/uielement/popuptoolbarcontroller.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/framework/source/uielement/popuptoolbarcontroller.cxx"))
         return true;
-    if (aFileName == SRCDIR "/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx"))
         return true;
-    if (aFileName == SRCDIR "/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sc/source/ui/vba/vbastyles.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sc/source/ui/vba/vbastyles.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sd/inc/Outliner.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/inc/Outliner.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sd/source/ui/annotations/annotationtag.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/annotations/annotationtag.cxx"))
         return true;
-    if (aFileName == SRCDIR "/sd/source/ui/inc/FrameView.hxx"
-        || aFileName == SRCDIR "/sd/source/filter/ppt/../../ui/inc/FrameView.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/inc/FrameView.hxx")
+        || loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/filter/ppt/../../ui/inc/FrameView.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sd/source/ui/inc/unopage.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/inc/unopage.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sd/source/ui/view/viewoverlaymanager.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/view/viewoverlaymanager.cxx"))
         return true;
-    if (aFileName == SRCDIR "/sdext/source/presenter/PresenterSpritePane.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sdext/source/presenter/PresenterSpritePane.hxx"))
         return true;
-    if (aFileName == SRCDIR "/store/source/stortree.hxx"
-        || aFileName == SRCDIR "/store/source/stordata.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/store/source/stortree.hxx")
+        || loplugin::isSamePathname(aFileName, SRCDIR "/store/source/stordata.hxx"))
         return true;
-    if (aFileName == SRCDIR "/svx/source/table/cell.hxx"
-        || aFileName == SRCDIR "/svx/source/unodraw/../table/cell.hxx"
-        || aFileName == SRCDIR "/svx/source/accessibility/../table/cell.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/table/cell.hxx")
+        || loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/unodraw/../table/cell.hxx")
+        || loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/accessibility/../table/cell.hxx"))
         return true;
-    if (aFileName == SRCDIR "/sw/source/uibase/inc/dbtree.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sw/source/uibase/inc/dbtree.hxx"))
         return true;
-    if (aFileName == SRCDIR "/vcl/unx/generic/print/genpspgraphics.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/unx/generic/print/genpspgraphics.cxx"))
         return true;
-    if (aFileName == SRCDIR "/xmloff/source/draw/ximplink.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/xmloff/source/draw/ximplink.hxx"))
         return true;
 
     const CXXRecordDecl* parentCXXRecordDecl = dyn_cast<CXXRecordDecl>(fieldDecl->getDeclContext());
diff --git a/compilerplugins/clang/externandnotdefined.cxx b/compilerplugins/clang/externandnotdefined.cxx
index 6d4a7989782e..2558ec62684d 100644
--- a/compilerplugins/clang/externandnotdefined.cxx
+++ b/compilerplugins/clang/externandnotdefined.cxx
@@ -59,7 +59,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) {
     }
     StringRef fileName { compiler.getSourceManager().getFilename(functionDecl->getLocation()) };
     // the filters use some kind of dynamic loading stunt
-    if (fileName.startswith(SRCDIR "/filter/qa/")) {
+    if (loplugin::hasPathnamePrefix(fileName, SRCDIR "/filter/qa/")) {
         return true;
     }
     report(
diff --git a/compilerplugins/clang/fpcomparison.cxx b/compilerplugins/clang/fpcomparison.cxx
index 025d4e028534..1cc7616c887b 100644
--- a/compilerplugins/clang/fpcomparison.cxx
+++ b/compilerplugins/clang/fpcomparison.cxx
@@ -70,7 +70,7 @@ bool FpComparison::ignore(FunctionDecl* function)
     }
     // we assume that these modules know what they are doing with FP stuff
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(function->getLocStart()));
-    if (aFileName.startswith(SRCDIR "/sc/")) {
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/")) {
         return true;
     }
     if (!function->doesThisDeclarationHaveABody()) {
diff --git a/compilerplugins/clang/fragiledestructor.cxx b/compilerplugins/clang/fragiledestructor.cxx
index e17418b26606..b438a81c33e3 100644
--- a/compilerplugins/clang/fragiledestructor.cxx
+++ b/compilerplugins/clang/fragiledestructor.cxx
@@ -48,12 +48,12 @@ bool FragileDestructor::TraverseCXXDestructorDecl(CXXDestructorDecl* pCXXDestruc
     // ignore this for now, too tricky for me to work out
     StringRef aFileName = compiler.getSourceManager().getFilename(
             compiler.getSourceManager().getSpellingLoc(pCXXDestructorDecl->getLocStart()));
-    if (aFileName.startswith(SRCDIR "/include/comphelper/")
-        || aFileName.startswith(SRCDIR "/include/cppuhelper/")
-        || aFileName.startswith(SRCDIR "/cppuhelper/")
-        || aFileName.startswith(SRCDIR "/comphelper/")
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/cppuhelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/comphelper/")
         // don't know how to detect this in clang - it is making an explicit call to it's own method, so presumably OK
-        || aFileName == SRCDIR "/basic/source/sbx/sbxvalue.cxx"
+        || loplugin::isSamePathname(aFileName, SRCDIR "/basic/source/sbx/sbxvalue.cxx")
        )
         return RecursiveASTVisitor::TraverseCXXDestructorDecl(pCXXDestructorDecl);
     mbChecking = true;
@@ -87,9 +87,9 @@ bool FragileDestructor::VisitCXXMemberCallExpr(const CXXMemberCallExpr* callExpr
     }
     // e.g. osl/thread.hxx and cppuhelper/compbase.hxx
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(methodDecl->getLocStart()));
-    if (aFileName.startswith(SRCDIR "/include/osl/")
-        || aFileName.startswith(SRCDIR "/include/comphelper/")
-        || aFileName.startswith(SRCDIR "/include/cppuhelper/"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
+        || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/"))
         return true;
     report(
         DiagnosticsEngine::Warning,
diff --git a/compilerplugins/clang/memoryvar.cxx b/compilerplugins/clang/memoryvar.cxx
index 32c0e038d092..708e58cc3a50 100644
--- a/compilerplugins/clang/memoryvar.cxx
+++ b/compilerplugins/clang/memoryvar.cxx
@@ -80,10 +80,10 @@ bool MemoryVar::TraverseFunctionDecl(FunctionDecl * decl)
         // I'm not getting accurate results from clang right now
         StringRef aFileName = getFilename(varLoc);
         // TODO these files are doing some weird stuff I don't know how to ignore yet
-        if (aFileName.startswith(SRCDIR "/vcl/source/filter")) {
+        if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/vcl/source/filter")) {
            return true;
         }
-        if (aFileName.startswith(SRCDIR "/sw/source/core/layout/frmtool.cxx")) {
+        if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sw/source/core/layout/frmtool.cxx")) {
            return true;
         }
 
diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx
index 577a95715118..bcfb88cb6f66 100644
--- a/compilerplugins/clang/nullptr.cxx
+++ b/compilerplugins/clang/nullptr.cxx
@@ -230,8 +230,9 @@ bool Nullptr::TraverseLinkageSpecDecl(LinkageSpecDecl * decl) {
 }
 
 bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
-    return compiler.getSourceManager().getFilename(spellingLocation)
-        .startswith(SRCDIR "/include/LibreOfficeKit/");
+    return loplugin::hasPathnamePrefix(
+        compiler.getSourceManager().getFilename(spellingLocation),
+        SRCDIR "/include/LibreOfficeKit/");
 }
 
 bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index d5b2401c8bf9..9c308b1f8509 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -12,6 +12,7 @@
 #include "plugin.hxx"
 
 #include <cassert>
+#include <cstddef>
 #include <string>
 
 #include <clang/Basic/FileManager.h>
@@ -42,8 +43,8 @@ bool Plugin::ignoreLocation( SourceLocation loc )
         return true;
     const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename();
     if (bufferName == NULL
-        || strncmp( bufferName, SRCDIR "/external/", strlen( SRCDIR "/external/" )) == 0
-        || strcmp( bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list" ) == 0 )
+        || hasPathnamePrefix(bufferName, SRCDIR "/external/")
+        || isSamePathname(bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list") )
             // workdir/CustomTarget/sdext/pdfimport/hash.cxx is generated from
             // sdext/source/pdfimport/wrapper/keyword_list by gperf, which
             // inserts various #line directives denoting the latter into the
@@ -55,7 +56,7 @@ bool Plugin::ignoreLocation( SourceLocation loc )
             // generated into the start of hash.cxx, #if'ed for __GNUC__, but
             // for clang-cl it is an issue)
         return true;
-    if( strncmp( bufferName, WORKDIR, strlen( WORKDIR )) == 0 )
+    if( hasPathnamePrefix(bufferName, WORKDIR) )
     {
         // workdir/CustomTarget/vcl/unx/kde4/tst_exclude_socket_notifiers.moc
         // includes
@@ -67,12 +68,12 @@ bool Plugin::ignoreLocation( SourceLocation loc )
         }
         std::string s(bufferName);
         normalizeDotDotInFilePath(s);
-        if (strncmp(s.c_str(), WORKDIR, strlen(WORKDIR)) == 0) {
+        if (hasPathnamePrefix(s, WORKDIR)) {
             return true;
         }
     }
-    if( strncmp( bufferName, BUILDDIR, strlen( BUILDDIR )) == 0
-        || strncmp( bufferName, SRCDIR, strlen( SRCDIR )) == 0 )
+    if( hasPathnamePrefix(bufferName, BUILDDIR)
+        || hasPathnamePrefix(bufferName, SRCDIR) )
         return false; // ok
     return true;
     }
@@ -165,19 +166,19 @@ bool Plugin::isInUnoIncludeFile(SourceLocation spellingLocation) const {
     StringRef name {
         compiler.getSourceManager().getFilename(spellingLocation) };
     return compiler.getSourceManager().isInMainFile(spellingLocation)
-        ? (name == SRCDIR "/cppu/source/cppu/compat.cxx"
-           || name == SRCDIR "/cppuhelper/source/compat.cxx"
-           || name == SRCDIR "/sal/osl/all/compat.cxx")
-        : (name.startswith(SRCDIR "/include/com/")
-           || name.startswith(SRCDIR "/include/cppu/")
-           || name.startswith(SRCDIR "/include/cppuhelper/")
-           || name.startswith(SRCDIR "/include/osl/")
-           || name.startswith(SRCDIR "/include/rtl/")
-           || name.startswith(SRCDIR "/include/sal/")
-           || name.startswith(SRCDIR "/include/salhelper/")
-           || name.startswith(SRCDIR "/include/systools/")
-           || name.startswith(SRCDIR "/include/typelib/")
-           || name.startswith(SRCDIR "/include/uno/"));
+        ? (isSamePathname(name, SRCDIR "/cppu/source/cppu/compat.cxx")
+           || isSamePathname(name, SRCDIR "/cppuhelper/source/compat.cxx")
+           || isSamePathname(name, SRCDIR "/sal/osl/all/compat.cxx"))
+        : (hasPathnamePrefix(name, SRCDIR "/include/com/")
+           || hasPathnamePrefix(name, SRCDIR "/include/cppu/")
+           || hasPathnamePrefix(name, SRCDIR "/include/cppuhelper/")
+           || hasPathnamePrefix(name, SRCDIR "/include/osl/")
+           || hasPathnamePrefix(name, SRCDIR "/include/rtl/")
+           || hasPathnamePrefix(name, SRCDIR "/include/sal/")
+           || hasPathnamePrefix(name, SRCDIR "/include/salhelper/")
+           || hasPathnamePrefix(name, SRCDIR "/include/systools/")
+           || hasPathnamePrefix(name, SRCDIR "/include/typelib/")
+           || hasPathnamePrefix(name, SRCDIR "/include/uno/"));
 }
 
 bool Plugin::isInUnoIncludeFile(const FunctionDecl* functionDecl) const {
@@ -423,6 +424,44 @@ bool RewritePlugin::reportEditFailure( SourceLocation loc )
     return false;
     }
 
+namespace {
+
+template<typename Fn> bool checkPathname(
+    StringRef pathname, StringRef against, Fn check)
+{
+    if (check(pathname, against)) {
+        return true;
+    }
+#if defined _WIN32
+    for (std::size_t n = 0;;) {
+        std::size_t n1 = pathname.find('\\', n);
+        if (n1 >= against.size()) {
+            return check(pathname.substr(n), against.substr(n));
+        }
+        if (against[n1] != '/'
+            || pathname.substr(n, n1 - n) != against.substr(n, n1 - n))
+        {
+            break;
+        }
+        n = n1 + 1;
+    }
+#endif
+    return false;
+}
+
+}
+
+bool hasPathnamePrefix(StringRef pathname, StringRef prefix) {
+    return checkPathname(
+        pathname, prefix,
+        [](StringRef p, StringRef a) { return p.startswith(a); });
+}
+
+bool isSamePathname(StringRef pathname, StringRef other) {
+    return checkPathname(
+        pathname, other, [](StringRef p, StringRef a) { return p == a; });
+}
+
 } // namespace
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx
index eeda9de0867e..7bb79598e854 100644
--- a/compilerplugins/clang/plugin.hxx
+++ b/compilerplugins/clang/plugin.hxx
@@ -222,6 +222,14 @@ RewritePlugin::RewriteOption operator|( RewritePlugin::RewriteOption option1, Re
     return static_cast< RewritePlugin::RewriteOption >( int( option1 ) | int( option2 ));
     }
 
+// Same as pathname.startswith(prefix), except on Windows, where pathname (but
+// not prefix) may also contain backslashes:
+bool hasPathnamePrefix(StringRef pathname, StringRef prefix);
+
+// Same as pathname == other, except on Windows, where pathname (but not other)
+// may also contain backslashes:
+bool isSamePathname(StringRef pathname, StringRef other);
+
 } // namespace
 
 #endif // COMPILEPLUGIN_H
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 7db90ed5b01a..e008a9e501dd 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -448,7 +448,7 @@ bool RefCounting::VisitVarDecl(const VarDecl * varDecl) {
         if (containsSalhelperReferenceObjectSubclass(varDecl->getType().getTypePtr())) {
             StringRef name { compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(varDecl->getLocation())) };
             // this is playing games that it believes is safe
-            if (name == SRCDIR "/stoc/source/security/permissions.cxx")
+            if (loplugin::isSamePathname(name, SRCDIR "/stoc/source/security/permissions.cxx"))
                 return true;
             report(
                 DiagnosticsEngine::Warning,
diff --git a/compilerplugins/clang/reservedid.cxx b/compilerplugins/clang/reservedid.cxx
index c6757199cbf9..50c1fe10eb02 100644
--- a/compilerplugins/clang/reservedid.cxx
+++ b/compilerplugins/clang/reservedid.cxx
@@ -75,8 +75,14 @@ void ReservedId::run() {
                         if (loc.isValid() && !ignoreLocation(loc)) {
                             auto file = compiler.getSourceManager()
                                 .getFilename(loc);
-                            if (file != SRCDIR "/include/cppuhelper/implbase_ex_post.hxx"
-                                && file != SRCDIR "/include/cppuhelper/implbase_ex_pre.hxx")
+                            if (!loplugin::isSamePathname(
+                                    file,
+                                    SRCDIR
+                                        "/include/cppuhelper/implbase_ex_post.hxx")
+                                && !loplugin::isSamePathname(
+                                    file,
+                                    SRCDIR
+                                        "/include/cppuhelper/implbase_ex_pre.hxx"))
                             {
                                 report(
                                     DiagnosticsEngine::Warning,
@@ -102,7 +108,7 @@ bool ReservedId::VisitNamedDecl(NamedDecl const * decl) {
         return true;
     }
     auto filename = compiler.getSourceManager().getFilename(spelLoc);
-    if (filename.startswith(SRCDIR "/bridges/source/cpp_uno/")
+    if (loplugin::hasPathnamePrefix(filename, SRCDIR "/bridges/source/cpp_uno/")
         && filename.endswith("share.hxx"))
     {
         return true;
@@ -215,7 +221,8 @@ ReservedId::Kind ReservedId::determineKind(llvm::StringRef const & id) {
 }
 
 bool ReservedId::isInLokIncludeFile(SourceLocation spellingLocation) const {
-    return compiler.getSourceManager().getFilename(spellingLocation).startswith(
+    return loplugin::hasPathnamePrefix(
+        compiler.getSourceManager().getFilename(spellingLocation),
         SRCDIR "/include/LibreOfficeKit/");
 }
 
diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index a17f112b2fea..8f42ef9e2b0f 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -763,8 +763,9 @@ bool SalBool::TraverseStaticAssertDecl(StaticAssertDecl * decl) {
     //
     // inside static_assert in cppu/source/uno/check.cxx:
     return
-        (compiler.getSourceManager().getFilename(decl->getLocation())
-         == SRCDIR "/cppu/source/uno/check.cxx")
+        loplugin::isSamePathname(
+            compiler.getSourceManager().getFilename(decl->getLocation()),
+            SRCDIR "/cppu/source/uno/check.cxx")
         || RecursiveASTVisitor::TraverseStaticAssertDecl(decl);
 }
 
@@ -800,8 +801,9 @@ bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const {
         return false;
     }
     auto f = compiler.getSourceManager().getFilename(spellingLocation);
-    return f == SRCDIR "/cppu/qa/test_any.cxx"
-        || f == SRCDIR "/cppu/source/uno/check.cxx"; // TODO: the offset checks
+    return loplugin::isSamePathname(f, SRCDIR "/cppu/qa/test_any.cxx")
+        || loplugin::isSamePathname(f, SRCDIR "/cppu/source/uno/check.cxx");
+        // TODO: the offset checks
 }
 
 bool SalBool::rewrite(SourceLocation location) {
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index f33f10f907c7..d0dd43eb40ee 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -99,12 +99,12 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
         return true;
     }
     // don't mess with the backwards compatibility stuff
-    if (getFilename(pCXXMethodDecl->getLocStart()) == SRCDIR "/cppuhelper/source/compat.cxx") {
+    if (loplugin::isSamePathname(getFilename(pCXXMethodDecl->getLocStart()), SRCDIR "/cppuhelper/source/compat.cxx")) {
         return true;
     }
     // the DDE has a dummy implementation on Linux and a real one on Windows
     std::string aFilename = getFilename(pCXXMethodDecl->getCanonicalDecl()->getLocStart());
-    if (aFilename == SRCDIR "/include/svl/svdde.hxx") {
+    if (loplugin::isSamePathname(aFilename, SRCDIR "/include/svl/svdde.hxx")) {
         return true;
     }
     auto cdc = loplugin::DeclCheck(pCXXMethodDecl->getParent());
@@ -124,17 +124,17 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
         return true;
     }
     // the unotools and svl config code stuff is doing weird stuff with a reference-counted statically allocated pImpl class
-    if (startsWith(aFilename, SRCDIR "/include/unotools")) {
+    if (loplugin::hasPathnamePrefix(aFilename, SRCDIR "/include/unotools")) {
         return true;
     }
-    if (startsWith(aFilename, SRCDIR "/include/svl")) {
+    if (loplugin::hasPathnamePrefix(aFilename, SRCDIR "/include/svl")) {
         return true;
     }
-    if (startsWith(aFilename, SRCDIR "/include/framework") || startsWith(aFilename, SRCDIR "/framework")) {
+    if (loplugin::hasPathnamePrefix(aFilename, SRCDIR "/include/framework") || loplugin::hasPathnamePrefix(aFilename, SRCDIR "/framework")) {
         return true;
     }
     // there is some odd stuff happening here I don't fully understand, leave it for now
-    if (startsWith(aFilename, SRCDIR "/include/canvas") || startsWith(aFilename, SRCDIR "/canvas")) {
+    if (loplugin::hasPathnamePrefix(aFilename, SRCDIR "/include/canvas") || loplugin::hasPathnamePrefix(aFilename, SRCDIR "/canvas")) {
         return true;
     }
     // classes that have static data and some kind of weird reference-counting trick in its constructor
diff --git a/compilerplugins/clang/stringconcat.cxx b/compilerplugins/clang/stringconcat.cxx
index 1efdea8875da..f6e791ee2f37 100644
--- a/compilerplugins/clang/stringconcat.cxx
+++ b/compilerplugins/clang/stringconcat.cxx
@@ -98,8 +98,10 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
     StringRef name {
         compiler.getSourceManager().getFilename(
             compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
-    if (name == SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx"
-        || name == SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx")
+    if (loplugin::isSamePathname(
+            name, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx")
+        || loplugin::isSamePathname(
+            name, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx"))
     {
         return true;
     }
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index 8616096a4f8c..a5ea9506f153 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -320,7 +320,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
         // u.equalsIngoreAsciiCase("foo"):
         auto file = compiler.getSourceManager().getFilename(
             compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
-        if (file == SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx") {
+        if (loplugin::isSamePathname(
+                file, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx"))
+        {
             return true;
         }
         handleChar(
@@ -336,7 +338,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
         // u.equalsIngoreAsciiCase("foo"):
         auto file = compiler.getSourceManager().getFilename(
             compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
-        if (file == SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx") {
+        if (loplugin::isSamePathname(
+                file, SRCDIR "/sal/qa/rtl/strings/test_oustring_compare.cxx"))
+        {
             return true;
         }
         handleCharLen(
@@ -702,8 +706,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
                 auto file = compiler.getSourceManager().getFilename(
                     compiler.getSourceManager().getSpellingLoc(
                         expr->getLocStart()));
-                if (file
-                    == SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx")
+                if (loplugin::isSamePathname(
+                        file,
+                        SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx"))
                 {
                     return true;
                 }
@@ -990,12 +995,14 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
                                             compiler.getSourceManager()
                                             .getSpellingLoc(
                                                 expr->getLocStart()));
-                                    if (file
-                                        == (SRCDIR
-                                            "/sal/qa/rtl/strings/test_ostring_concat.cxx")
-                                        || (file
-                                            == (SRCDIR
-                                            "/sal/qa/rtl/strings/test_oustring_concat.cxx")))
+                                    if (loplugin::isSamePathname(
+                                            file,
+                                            (SRCDIR
+                                             "/sal/qa/rtl/strings/test_ostring_concat.cxx"))
+                                        || loplugin::isSamePathname(
+                                            file,
+                                            (SRCDIR
+                                             "/sal/qa/rtl/strings/test_oustring_concat.cxx")))
                                     {
                                         return true;
                                     }
diff --git a/compilerplugins/clang/stringstatic.cxx b/compilerplugins/clang/stringstatic.cxx
index e82d173d0b16..4c3be5dc194a 100644
--- a/compilerplugins/clang/stringstatic.cxx
+++ b/compilerplugins/clang/stringstatic.cxx
@@ -42,10 +42,10 @@ void StringStatic::run()
     StringRef fn( compiler.getSourceManager().getFileEntryForID(
                       compiler.getSourceManager().getMainFileID())->getName() );
     // passing around pointers to global OUString
-    if (fn.startswith(SRCDIR "/filter/source/svg/"))
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/filter/source/svg/"))
          return;
     // has a mix of literals and refs to external OUStrings
-    if (fn == SRCDIR "/ucb/source/ucp/webdav-neon/ContentProperties.cxx")
+    if (loplugin::isSamePathname(fn, SRCDIR "/ucb/source/ucp/webdav-neon/ContentProperties.cxx"))
          return;
 
     TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx
index 5102faab7a78..98b51a03a18b 100644
--- a/compilerplugins/clang/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/unnecessaryoverride.cxx
@@ -34,24 +34,24 @@ public:
         // ignore some files with problematic macros
         StringRef fn( compiler.getSourceManager().getFileEntryForID(
                           compiler.getSourceManager().getMainFileID())->getName() );
-        if (fn == SRCDIR "/sd/source/ui/framework/factories/ChildWindowPane.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/framework/factories/ChildWindowPane.cxx"))
              return;
-        if (fn == SRCDIR "/forms/source/component/Date.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/component/Date.cxx"))
              return;
-        if (fn == SRCDIR "/forms/source/component/Time.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/component/Time.cxx"))
             return;
-        if (fn == SRCDIR "/svx/source/dialog/hyperdlg.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/svx/source/dialog/hyperdlg.cxx"))
             return;
-        if (fn == SRCDIR "/svx/source/dialog/rubydialog.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/svx/source/dialog/rubydialog.cxx"))
             return;
-        if (fn.startswith(SRCDIR "/canvas"))
+        if (loplugin::hasPathnamePrefix(fn, SRCDIR "/canvas"))
             return;
-        if (fn == SRCDIR "/sc/source/ui/view/spelldialog.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/sc/source/ui/view/spelldialog.cxx"))
             return;
-        if (fn == SRCDIR "/sd/source/ui/dlg/SpellDialogChildWindow.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/dlg/SpellDialogChildWindow.cxx"))
             return;
         // HAVE_ODBC_ADMINISTRATION
-        if (fn == SRCDIR "/dbaccess/source/ui/dlg/dsselect.cxx")
+        if (loplugin::isSamePathname(fn, SRCDIR "/dbaccess/source/ui/dlg/dsselect.cxx"))
             return;
 
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
@@ -84,7 +84,7 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
        && !isInUnoIncludeFile(methodDecl))
     {
         // the code is this method is only __compiled__ if OSL_DEBUG_LEVEL > 1
-        if (aFileName == SRCDIR "/tools/source/stream/strmunx.cxx")
+        if (loplugin::isSamePathname(aFileName, SRCDIR "/tools/source/stream/strmunx.cxx"))
             return true;
 
         // Warn about unnecessarily user-declared destructors.
@@ -206,16 +206,16 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
         }
     }
     // sometimes the disambiguation happens in a base class
-    if (aFileName == SRCDIR "/comphelper/source/property/propertycontainer.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/comphelper/source/property/propertycontainer.cxx"))
         return true;
     // not sure what is happening here
-    if (aFileName == SRCDIR "/extensions/source/bibliography/datman.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/extensions/source/bibliography/datman.cxx"))
         return true;
     // some very creative method hiding going on here
-    if (aFileName == SRCDIR "/svx/source/dialog/checklbx.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/dialog/checklbx.cxx"))
         return true;
     // entertaining template magic
-    if (aFileName == SRCDIR "/sc/source/ui/vba/vbaformatcondition.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/sc/source/ui/vba/vbaformatcondition.cxx"))
         return true;
     // not sure what is going on here, but removing the override causes a crash
      if (methodDecl->getQualifiedNameAsString() == "SwXTextDocument::queryAdapter")
diff --git a/compilerplugins/clang/unoany.cxx b/compilerplugins/clang/unoany.cxx
index 6fdf3b45d94f..1db0f993f13b 100644
--- a/compilerplugins/clang/unoany.cxx
+++ b/compilerplugins/clang/unoany.cxx
@@ -29,7 +29,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
         return true;
     }
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
-    if (aFileName == SRCDIR "/include/com/sun/star/uno/Any.hxx") {
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Any.hxx")) {
         return true;
     }
     if (expr->getOperator() != OO_Equal) {
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index 24f6007ca2af..59d1a3f3ec68 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -92,31 +92,31 @@ bool UseUniquePtr::VisitCXXDestructorDecl(const CXXDestructorDecl* destructorDec
         return true;
     // to ignore things like the CPPUNIT macros
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(pFieldDecl->getLocStart()));
-    if (aFileName.startswith(WORKDIR))
+    if (loplugin::hasPathnamePrefix(aFileName, WORKDIR))
         return true;
     // passes and stores pointers to member fields
-    if (aFileName.startswith(SRCDIR "/sot/source/sdstor/stgdir.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sot/source/sdstor/stgdir.hxx"))
         return true;
     // something platform-specific
-    if (aFileName.startswith(SRCDIR "/hwpfilter/source/htags.h"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/hwpfilter/source/htags.h"))
         return true;
     // @TODO there is clearly a bug in the ownership here, the operator= method cannot be right
-    if (aFileName.startswith(SRCDIR "/include/formula/formdata.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/formula/formdata.hxx"))
         return true;
     // passes pointers to member fields
-    if (aFileName.startswith(SRCDIR "/sd/inc/sdpptwrp.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sd/inc/sdpptwrp.hxx"))
         return true;
     // @TODO there is clearly a bug in the ownership here, the ScJumpMatrixToken copy constructor cannot be right
-    if (aFileName.startswith(SRCDIR "/sc/inc/token.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/inc/token.hxx"))
         return true;
     // @TODO intrusive linked-lists here, with some trickiness
-    if (aFileName.startswith(SRCDIR "/sw/source/filter/html/parcss1.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sw/source/filter/html/parcss1.hxx"))
         return true;
     // @TODO SwDoc has some weird ref-counting going on
-    if (aFileName.startswith(SRCDIR "/sw/inc/shellio.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sw/inc/shellio.hxx"))
         return true;
     // @TODO it's sharing pointers with another class
-    if (aFileName.startswith(SRCDIR "/sc/inc/formulacell.hxx"))
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/inc/formulacell.hxx"))
         return true;
 
     report(
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 2d5dd6333bc9..c273b4aa8874 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -235,9 +235,9 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
         SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
                               pCXXDestructorDecl->getLocStart());
         StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
-        if (   !(filename.startswith(SRCDIR "/vcl/source/window/window.cxx"))
-            && !(filename.startswith(SRCDIR "/vcl/source/gdi/virdev.cxx"))
-            && !(filename.startswith(SRCDIR "/vcl/qa/cppunit/lifecycle.cxx")) )
+        if (   !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/source/window/window.cxx"))
+            && !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/source/gdi/virdev.cxx"))
+            && !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/qa/cppunit/lifecycle.cxx")) )
         {
             report(
                 DiagnosticsEngine::Warning,
@@ -274,7 +274,7 @@ void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const SourceLocation& s
         return;
     }
     StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
-    if (filename == SRCDIR "/include/rtl/ref.hxx") {
+    if (loplugin::isSamePathname(filename, SRCDIR "/include/rtl/ref.hxx")) {
         return;
     }
     const CXXRecordDecl* pointeeClass = lhsType->getPointeeType()->getAsCXXRecordDecl();
@@ -356,9 +356,9 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
         checkAssignmentForVclPtrToRawConversion(spellingLocation, pVarDecl->getType().getTypePtr(), pVarDecl->getInit());
     }
     StringRef aFileName = compiler.getSourceManager().getFilename(spellingLocation);
-    if (aFileName == SRCDIR "/include/vcl/vclptr.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx"))
         return true;
-    if (aFileName == SRCDIR "/vcl/source/window/layout.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/source/window/layout.cxx"))
         return true;
     // whitelist the valid things that can contain pointers.
     // It is containing stuff like std::unique_ptr we get worried
@@ -408,13 +408,13 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) {
         return true;
     }
     StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart()));
-    if (aFileName == SRCDIR "/include/vcl/vclptr.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx"))
         return true;
-    if (aFileName == SRCDIR "/include/rtl/ref.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/rtl/ref.hxx"))
         return true;
-    if (aFileName == SRCDIR "/include/o3tl/enumarray.hxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/include/o3tl/enumarray.hxx"))
         return true;
-    if (aFileName == SRCDIR "/vcl/source/window/layout.cxx")
+    if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/source/window/layout.cxx"))
         return true;
     if (fieldDecl->isBitField()) {
         return true;
@@ -665,7 +665,7 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr)
         SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
                               pCXXDeleteExpr->getLocStart());
         StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
-        if ( !(filename.startswith(SRCDIR "/include/vcl/vclreferencebase.hxx")))
+        if ( !(loplugin::hasPathnamePrefix(filename, SRCDIR "/include/vcl/vclreferencebase.hxx")))
         {
             report(
                 DiagnosticsEngine::Warning,
@@ -841,7 +841,7 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr )
     const CXXRecordDecl* recordDecl = pConstructorDecl->getParent();
     if (isDerivedFromVclReferenceBase(recordDecl)) {
         StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(constructExpr->getLocStart()));
-        if (aFileName != SRCDIR "/include/vcl/vclptr.hxx") {
+        if (!loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx")) {
             report(
                 DiagnosticsEngine::Warning,
                 "Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create",


More information about the Libreoffice-commits mailing list