Adapt pathname checks to mixed usage of \ and / on Windows

Change-Id: I91bc89a9076c6642e06b238f65f2d31a1d20c6b5
This commit is contained in:
Stephan Bergmann
2017-05-18 09:56:01 +02:00
parent 33cbc99fea
commit df8d092c3a
24 changed files with 253 additions and 187 deletions

View File

@@ -52,11 +52,11 @@ bool AutoMem::VisitCXXDeleteExpr(const CXXDeleteExpr* expr)
if (ignoreLocation( expr )) if (ignoreLocation( expr ))
return true; return true;
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart()));
if (aFileName.startswith(SRCDIR "/include/salhelper/") if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/salhelper/")
|| aFileName.startswith(SRCDIR "/include/osl/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
|| aFileName.startswith(SRCDIR "/salhelper/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/salhelper/")
|| aFileName.startswith(SRCDIR "/store/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/store/")
|| aFileName.startswith(SRCDIR "/sal/")) || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/"))
return true; return true;
if (mbInsideDestructor) if (mbInsideDestructor)

View File

@@ -67,8 +67,8 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
SourceLocation location = info->getLocation(); SourceLocation location = info->getLocation();
const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename(); const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
if( filename != NULL if( filename != NULL
&& ( strncmp( filename, BUILDDIR "/config_host/", strlen( BUILDDIR "/config_host/" )) == 0 && ( hasPathnamePrefix(filename, BUILDDIR "/config_host/")
|| strncmp( filename, BUILDDIR "/config_build/", strlen( BUILDDIR "/config_build/" )) == 0 )) || hasPathnamePrefix(filename, BUILDDIR "/config_build/") ))
{ {
// fprintf(stderr,"DEF: %s %s\n", macroToken.getIdentifierInfo()->getName().data(), filename ); // fprintf(stderr,"DEF: %s %s\n", macroToken.getIdentifierInfo()->getName().data(), filename );
configMacros.insert( macroToken.getIdentifierInfo()->getName()); 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(); const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
if( filename == NULL 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", report( DiagnosticsEngine::Error, "checking whether a config macro %0 is defined",
location ) << macroToken.getIdentifierInfo()->getName(); location ) << macroToken.getIdentifierInfo()->getName();

View File

@@ -39,23 +39,23 @@ void CheckUnusedParams::run()
{ {
StringRef fn( compiler.getSourceManager().getFileEntryForID( StringRef fn( compiler.getSourceManager().getFileEntryForID(
compiler.getSourceManager().getMainFileID())->getName() ); compiler.getSourceManager().getMainFileID())->getName() );
if (fn.startswith(SRCDIR "/sal/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/"))
return; return;
// Taking pointer to function // Taking pointer to function
if (fn == SRCDIR "/l10ntools/source/xmlparse.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/l10ntools/source/xmlparse.cxx"))
return; return;
// macro magic which declares something needed by an external library // 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; return;
// valid test/qa code // valid test/qa code
if (fn.startswith(SRCDIR "/compilerplugins/clang/test/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/compilerplugins/clang/test/"))
return; return;
if (fn == SRCDIR "/cppu/qa/test_reference.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/cppu/qa/test_reference.cxx"))
return; return;
// leave this alone for now // leave this alone for now
if (fn.startswith(SRCDIR "/libreofficekit/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/libreofficekit/"))
return; return;
m_phase = PluginPhase::FindAddressOf; m_phase = PluginPhase::FindAddressOf;
@@ -135,104 +135,104 @@ bool CheckUnusedParams::VisitFunctionDecl(FunctionDecl const * decl) {
StringRef fn = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(canon->getLocStart())); StringRef fn = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(canon->getLocStart()));
// Some backwards compat magic. // Some backwards compat magic.
// TODO Can probably be removed, but need to do some checking // 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; return true;
// Platform-specific code // Platform-specific code
if (fn == SRCDIR "/include/svl/svdde.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/svl/svdde.hxx"))
return true; return true;
if (fn == SRCDIR "/include/vcl/svmain.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/vcl/svmain.hxx"))
return true; return true;
// passing pointer to function // passing pointer to function
if (fn == SRCDIR "/include/vcl/bitmapaccess.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/vcl/bitmapaccess.hxx"))
return true; return true;
if (fn == SRCDIR "/vcl/inc/unx/gtk/gtkobject.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtkobject.hxx"))
return true; return true;
if (fn == SRCDIR "/vcl/inc/unx/gtk/gtksalframe.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtksalframe.hxx"))
return true; return true;
if (fn == SRCDIR "/vcl/inc/unx/gtk/gtkframe.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/unx/gtk/gtkframe.hxx"))
return true; return true;
if (fn == SRCDIR "/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx"))
return true; return true;
if (fn == SRCDIR "/extensions/source/propctrlr/propertyeditor.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/extensions/source/propctrlr/propertyeditor.hxx"))
return true; return true;
if (fn == SRCDIR "/forms/source/solar/inc/navtoolbar.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/solar/inc/navtoolbar.hxx"))
return true; return true;
if (fn == SRCDIR "/hwpfilter/source/grammar.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/hwpfilter/source/grammar.cxx"))
return true; return true;
if (fn == SRCDIR "/hwpfilter/source/lexer.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/hwpfilter/source/lexer.cxx"))
return true; return true;
// marked with a TODO/FIXME // marked with a TODO/FIXME
if (fn == SRCDIR "/vcl/inc/sallayout.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/vcl/inc/sallayout.hxx"))
return true; return true;
if (fn == SRCDIR "/accessibility/inc/standard/vclxaccessiblelist.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/accessibility/inc/standard/vclxaccessiblelist.hxx"))
return true; return true;
// these are "extern C" but clang doesn't seem to report that accurately // 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; return true;
// these all follow the same pattern, seems a pity to break that // 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; return true;
// looks like work in progress // 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; return true;
// macro magic // macro magic
if (fn == SRCDIR "/basctl/source/inc/basidesh.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/basctl/source/inc/basidesh.hxx"))
return true; return true;
// template magic // template magic
if (fn.startswith(SRCDIR "/canvas/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/canvas/"))
return true; return true;
if (fn.startswith(SRCDIR "/include/canvas/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/include/canvas/"))
return true; return true;
if (fn == SRCDIR "/include/comphelper/unwrapargs.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/comphelper/unwrapargs.hxx"))
return true; return true;
// this looks like vaguely useful code (ParseError) that I'm loathe to remove // 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; return true;
if (fn == SRCDIR "/include/svx/EnhancedCustomShapeFunctionParser.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/svx/EnhancedCustomShapeFunctionParser.hxx"))
return true; return true;
// TODO marker parameter in constructor, should probably be using an enum // 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; return true;
if (fn == SRCDIR "/sd/source/ui/inc/SlideTransitionPane.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/SlideTransitionPane.hxx"))
return true; return true;
if (fn == SRCDIR "/sd/source/ui/animations/CustomAnimationPane.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/animations/CustomAnimationPane.hxx"))
return true; return true;
if (fn == SRCDIR "/sd/source/ui/table/TableDesignPane.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/table/TableDesignPane.hxx"))
return true; return true;
// debug stuff // debug stuff
if (fn == SRCDIR "/sc/source/core/data/column2.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/sc/source/core/data/column2.cxx"))
return true; return true;
// weird stuff // weird stuff
if (fn == SRCDIR "/scaddins/source/analysis/analysishelper.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/scaddins/source/analysis/analysishelper.hxx"))
return true; return true;
// SFX_DECL_CHILDWINDOWCONTEXT macro stuff // 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; return true;
// TODO, need to remove this from the .sdi file too // 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; return true;
if (fn == SRCDIR "/sd/source/ui/inc/OutlineViewShell.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/inc/OutlineViewShell.hxx"))
return true; return true;
// SFX_DECL_INTERFACE macro stuff // 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; return true;
// debug stuff // debug stuff
if (fn == SRCDIR "/sd/source/filter/ppt/pptinanimations.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/filter/ppt/pptinanimations.hxx"))
return true; return true;
// takes pointer to fn // takes pointer to fn
if (fn == SRCDIR "/include/sfx2/shell.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/sfx2/shell.hxx"))
return true; return true;
// TODO, need to remove this from the .sdi file too // TODO, need to remove this from the .sdi file too
if (fqn == "SfxObjectShell::StateView_Impl") if (fqn == "SfxObjectShell::StateView_Impl")
return true; return true;
// SFX_DECL_CHILDWINDOW_WITHID macro // SFX_DECL_CHILDWINDOW_WITHID macro
if (fn == SRCDIR "/include/sfx2/infobar.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/include/sfx2/infobar.hxx"))
return true; return true;
// this looks like vaguely useful code (ParseError) that I'm loathe to remove // 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; return true;
// SFX_DECL_VIEWFACTORY macro // SFX_DECL_VIEWFACTORY macro
if (fn == SRCDIR "/starmath/inc/view.hxx") if (loplugin::isSamePathname(fn, SRCDIR "/starmath/inc/view.hxx"))
return true; return true;
// debugging // debugging
if (fqn == "BrowseBox::DoShowCursor" || fqn == "BrowseBox::DoHideCursor") if (fqn == "BrowseBox::DoShowCursor" || fqn == "BrowseBox::DoHideCursor")

View File

@@ -64,8 +64,8 @@ public:
std::string fn( compiler.getSourceManager().getFileEntryForID( std::string fn( compiler.getSourceManager().getFileEntryForID(
compiler.getSourceManager().getMainFileID())->getName() ); compiler.getSourceManager().getMainFileID())->getName() );
normalizeDotDotInFilePath(fn); normalizeDotDotInFilePath(fn);
if (fn == SRCDIR "/basegfx/source/matrix/b2dhommatrix.cxx" if (loplugin::isSamePathname(fn, SRCDIR "/basegfx/source/matrix/b2dhommatrix.cxx")
|| fn == SRCDIR "/basegfx/source/matrix/b3dhommatrix.cxx") || loplugin::isSamePathname(fn, SRCDIR "/basegfx/source/matrix/b3dhommatrix.cxx"))
return; return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
@@ -118,7 +118,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
return; return;
SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( functionDecl->getLocation() ); SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( functionDecl->getLocation() );
StringRef filename = compiler.getSourceManager().getFilename(expansionLoc); StringRef filename = compiler.getSourceManager().getFilename(expansionLoc);
if (!filename.startswith(SRCDIR)) if (!loplugin::hasPathnamePrefix(filename, SRCDIR))
return; return;
filename = filename.substr(strlen(SRCDIR)+1); filename = filename.substr(strlen(SRCDIR)+1);

View File

@@ -94,16 +94,16 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl)
} }
StringRef aFileName = getFilename(functionDecl->getLocStart()); StringRef aFileName = getFilename(functionDecl->getLocStart());
if (aFileName.startswith(SRCDIR "/sal/") if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sal/")
|| aFileName.startswith(SRCDIR "/bridges/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/bridges/")
|| aFileName.startswith(SRCDIR "/binaryurp/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/binaryurp/")
|| aFileName.startswith(SRCDIR "/stoc/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/stoc/")
|| aFileName.startswith(WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx") || loplugin::hasPathnamePrefix(aFileName, WORKDIR "/YaccTarget/unoidl/source/sourceprovider-parser.cxx")
// some weird calling through a function pointer // 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 // windows only
|| aFileName.startswith(SRCDIR "/basic/source/sbx/sbxdec.cxx") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/basic/source/sbx/sbxdec.cxx")
|| aFileName.startswith(SRCDIR "/sfx2/source/doc/syspath.cxx")) { || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sfx2/source/doc/syspath.cxx")) {
return true; return true;
} }

View File

@@ -47,53 +47,53 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
// FIXME complex stuff to fix later // 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; return true;
if (aFileName.startswith(SRCDIR "/chart2/source/")) if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/chart2/source/"))
return true; return true;
if (aFileName == SRCDIR "/cppcanvas/source/mtfrenderer/emfplus.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/cppcanvas/source/mtfrenderer/emfplus.cxx"))
return true; return true;
if (aFileName == SRCDIR "/cui/source/customize/eventdlg.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/cui/source/customize/eventdlg.hxx"))
return true; return true;
if (aFileName == SRCDIR "/include/sfx2/recentdocsview.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/include/sfx2/recentdocsview.hxx"))
return true; return true;
if (aFileName == SRCDIR "/include/sfx2/templatelocalview.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/include/sfx2/templatelocalview.hxx"))
return true; return true;
if (aFileName == SRCDIR "/filter/source/graphicfilter/idxf/dxfentrd.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/filter/source/graphicfilter/idxf/dxfentrd.hxx"))
return true; return true;
if (aFileName == SRCDIR "/framework/source/uielement/popuptoolbarcontroller.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/framework/source/uielement/popuptoolbarcontroller.cxx"))
return true; return true;
if (aFileName == SRCDIR "/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx"))
return true; return true;
if (aFileName == SRCDIR "/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sc/source/ui/vba/vbastyles.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sc/source/ui/vba/vbastyles.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sd/inc/Outliner.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/inc/Outliner.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sd/source/ui/annotations/annotationtag.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/annotations/annotationtag.cxx"))
return true; return true;
if (aFileName == SRCDIR "/sd/source/ui/inc/FrameView.hxx" if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/inc/FrameView.hxx")
|| aFileName == SRCDIR "/sd/source/filter/ppt/../../ui/inc/FrameView.hxx") || loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/filter/ppt/../../ui/inc/FrameView.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sd/source/ui/inc/unopage.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/inc/unopage.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sd/source/ui/view/viewoverlaymanager.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sd/source/ui/view/viewoverlaymanager.cxx"))
return true; return true;
if (aFileName == SRCDIR "/sdext/source/presenter/PresenterSpritePane.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sdext/source/presenter/PresenterSpritePane.hxx"))
return true; return true;
if (aFileName == SRCDIR "/store/source/stortree.hxx" if (loplugin::isSamePathname(aFileName, SRCDIR "/store/source/stortree.hxx")
|| aFileName == SRCDIR "/store/source/stordata.hxx") || loplugin::isSamePathname(aFileName, SRCDIR "/store/source/stordata.hxx"))
return true; return true;
if (aFileName == SRCDIR "/svx/source/table/cell.hxx" if (loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/table/cell.hxx")
|| aFileName == SRCDIR "/svx/source/unodraw/../table/cell.hxx" || loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/unodraw/../table/cell.hxx")
|| aFileName == SRCDIR "/svx/source/accessibility/../table/cell.hxx") || loplugin::isSamePathname(aFileName, SRCDIR "/svx/source/accessibility/../table/cell.hxx"))
return true; return true;
if (aFileName == SRCDIR "/sw/source/uibase/inc/dbtree.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/sw/source/uibase/inc/dbtree.hxx"))
return true; return true;
if (aFileName == SRCDIR "/vcl/unx/generic/print/genpspgraphics.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/unx/generic/print/genpspgraphics.cxx"))
return true; return true;
if (aFileName == SRCDIR "/xmloff/source/draw/ximplink.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/xmloff/source/draw/ximplink.hxx"))
return true; return true;
const CXXRecordDecl* parentCXXRecordDecl = dyn_cast<CXXRecordDecl>(fieldDecl->getDeclContext()); const CXXRecordDecl* parentCXXRecordDecl = dyn_cast<CXXRecordDecl>(fieldDecl->getDeclContext());

View File

@@ -59,7 +59,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) {
} }
StringRef fileName { compiler.getSourceManager().getFilename(functionDecl->getLocation()) }; StringRef fileName { compiler.getSourceManager().getFilename(functionDecl->getLocation()) };
// the filters use some kind of dynamic loading stunt // the filters use some kind of dynamic loading stunt
if (fileName.startswith(SRCDIR "/filter/qa/")) { if (loplugin::hasPathnamePrefix(fileName, SRCDIR "/filter/qa/")) {
return true; return true;
} }
report( report(

View File

@@ -70,7 +70,7 @@ bool FpComparison::ignore(FunctionDecl* function)
} }
// we assume that these modules know what they are doing with FP stuff // we assume that these modules know what they are doing with FP stuff
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(function->getLocStart())); StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(function->getLocStart()));
if (aFileName.startswith(SRCDIR "/sc/")) { if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/")) {
return true; return true;
} }
if (!function->doesThisDeclarationHaveABody()) { if (!function->doesThisDeclarationHaveABody()) {

View File

@@ -48,12 +48,12 @@ bool FragileDestructor::TraverseCXXDestructorDecl(CXXDestructorDecl* pCXXDestruc
// ignore this for now, too tricky for me to work out // ignore this for now, too tricky for me to work out
StringRef aFileName = compiler.getSourceManager().getFilename( StringRef aFileName = compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc(pCXXDestructorDecl->getLocStart())); compiler.getSourceManager().getSpellingLoc(pCXXDestructorDecl->getLocStart()));
if (aFileName.startswith(SRCDIR "/include/comphelper/") if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
|| aFileName.startswith(SRCDIR "/include/cppuhelper/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/")
|| aFileName.startswith(SRCDIR "/cppuhelper/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/cppuhelper/")
|| aFileName.startswith(SRCDIR "/comphelper/") || 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 // 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); return RecursiveASTVisitor::TraverseCXXDestructorDecl(pCXXDestructorDecl);
mbChecking = true; mbChecking = true;
@@ -87,9 +87,9 @@ bool FragileDestructor::VisitCXXMemberCallExpr(const CXXMemberCallExpr* callExpr
} }
// e.g. osl/thread.hxx and cppuhelper/compbase.hxx // e.g. osl/thread.hxx and cppuhelper/compbase.hxx
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(methodDecl->getLocStart())); StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(methodDecl->getLocStart()));
if (aFileName.startswith(SRCDIR "/include/osl/") if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/osl/")
|| aFileName.startswith(SRCDIR "/include/comphelper/") || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/comphelper/")
|| aFileName.startswith(SRCDIR "/include/cppuhelper/")) || loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/cppuhelper/"))
return true; return true;
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,

View File

@@ -80,10 +80,10 @@ bool MemoryVar::TraverseFunctionDecl(FunctionDecl * decl)
// I'm not getting accurate results from clang right now // I'm not getting accurate results from clang right now
StringRef aFileName = getFilename(varLoc); StringRef aFileName = getFilename(varLoc);
// TODO these files are doing some weird stuff I don't know how to ignore yet // 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; 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; return true;
} }

View File

@@ -230,8 +230,9 @@ bool Nullptr::TraverseLinkageSpecDecl(LinkageSpecDecl * decl) {
} }
bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const { bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
return compiler.getSourceManager().getFilename(spellingLocation) return loplugin::hasPathnamePrefix(
.startswith(SRCDIR "/include/LibreOfficeKit/"); compiler.getSourceManager().getFilename(spellingLocation),
SRCDIR "/include/LibreOfficeKit/");
} }
bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const { bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {

View File

@@ -12,6 +12,7 @@
#include "plugin.hxx" #include "plugin.hxx"
#include <cassert> #include <cassert>
#include <cstddef>
#include <string> #include <string>
#include <clang/Basic/FileManager.h> #include <clang/Basic/FileManager.h>
@@ -42,8 +43,8 @@ bool Plugin::ignoreLocation( SourceLocation loc )
return true; return true;
const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename(); const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename();
if (bufferName == NULL if (bufferName == NULL
|| strncmp( bufferName, SRCDIR "/external/", strlen( SRCDIR "/external/" )) == 0 || hasPathnamePrefix(bufferName, SRCDIR "/external/")
|| strcmp( bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list" ) == 0 ) || isSamePathname(bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list") )
// workdir/CustomTarget/sdext/pdfimport/hash.cxx is generated from // workdir/CustomTarget/sdext/pdfimport/hash.cxx is generated from
// sdext/source/pdfimport/wrapper/keyword_list by gperf, which // sdext/source/pdfimport/wrapper/keyword_list by gperf, which
// inserts various #line directives denoting the latter into the // 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 // generated into the start of hash.cxx, #if'ed for __GNUC__, but
// for clang-cl it is an issue) // for clang-cl it is an issue)
return true; return true;
if( strncmp( bufferName, WORKDIR, strlen( WORKDIR )) == 0 ) if( hasPathnamePrefix(bufferName, WORKDIR) )
{ {
// workdir/CustomTarget/vcl/unx/kde4/tst_exclude_socket_notifiers.moc // workdir/CustomTarget/vcl/unx/kde4/tst_exclude_socket_notifiers.moc
// includes // includes
@@ -67,12 +68,12 @@ bool Plugin::ignoreLocation( SourceLocation loc )
} }
std::string s(bufferName); std::string s(bufferName);
normalizeDotDotInFilePath(s); normalizeDotDotInFilePath(s);
if (strncmp(s.c_str(), WORKDIR, strlen(WORKDIR)) == 0) { if (hasPathnamePrefix(s, WORKDIR)) {
return true; return true;
} }
} }
if( strncmp( bufferName, BUILDDIR, strlen( BUILDDIR )) == 0 if( hasPathnamePrefix(bufferName, BUILDDIR)
|| strncmp( bufferName, SRCDIR, strlen( SRCDIR )) == 0 ) || hasPathnamePrefix(bufferName, SRCDIR) )
return false; // ok return false; // ok
return true; return true;
} }
@@ -165,19 +166,19 @@ bool Plugin::isInUnoIncludeFile(SourceLocation spellingLocation) const {
StringRef name { StringRef name {
compiler.getSourceManager().getFilename(spellingLocation) }; compiler.getSourceManager().getFilename(spellingLocation) };
return compiler.getSourceManager().isInMainFile(spellingLocation) return compiler.getSourceManager().isInMainFile(spellingLocation)
? (name == SRCDIR "/cppu/source/cppu/compat.cxx" ? (isSamePathname(name, SRCDIR "/cppu/source/cppu/compat.cxx")
|| name == SRCDIR "/cppuhelper/source/compat.cxx" || isSamePathname(name, SRCDIR "/cppuhelper/source/compat.cxx")
|| name == SRCDIR "/sal/osl/all/compat.cxx") || isSamePathname(name, SRCDIR "/sal/osl/all/compat.cxx"))
: (name.startswith(SRCDIR "/include/com/") : (hasPathnamePrefix(name, SRCDIR "/include/com/")
|| name.startswith(SRCDIR "/include/cppu/") || hasPathnamePrefix(name, SRCDIR "/include/cppu/")
|| name.startswith(SRCDIR "/include/cppuhelper/") || hasPathnamePrefix(name, SRCDIR "/include/cppuhelper/")
|| name.startswith(SRCDIR "/include/osl/") || hasPathnamePrefix(name, SRCDIR "/include/osl/")
|| name.startswith(SRCDIR "/include/rtl/") || hasPathnamePrefix(name, SRCDIR "/include/rtl/")
|| name.startswith(SRCDIR "/include/sal/") || hasPathnamePrefix(name, SRCDIR "/include/sal/")
|| name.startswith(SRCDIR "/include/salhelper/") || hasPathnamePrefix(name, SRCDIR "/include/salhelper/")
|| name.startswith(SRCDIR "/include/systools/") || hasPathnamePrefix(name, SRCDIR "/include/systools/")
|| name.startswith(SRCDIR "/include/typelib/") || hasPathnamePrefix(name, SRCDIR "/include/typelib/")
|| name.startswith(SRCDIR "/include/uno/")); || hasPathnamePrefix(name, SRCDIR "/include/uno/"));
} }
bool Plugin::isInUnoIncludeFile(const FunctionDecl* functionDecl) const { bool Plugin::isInUnoIncludeFile(const FunctionDecl* functionDecl) const {
@@ -423,6 +424,44 @@ bool RewritePlugin::reportEditFailure( SourceLocation loc )
return false; 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 } // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -222,6 +222,14 @@ RewritePlugin::RewriteOption operator|( RewritePlugin::RewriteOption option1, Re
return static_cast< RewritePlugin::RewriteOption >( int( option1 ) | int( option2 )); 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 } // namespace
#endif // COMPILEPLUGIN_H #endif // COMPILEPLUGIN_H

View File

@@ -448,7 +448,7 @@ bool RefCounting::VisitVarDecl(const VarDecl * varDecl) {
if (containsSalhelperReferenceObjectSubclass(varDecl->getType().getTypePtr())) { if (containsSalhelperReferenceObjectSubclass(varDecl->getType().getTypePtr())) {
StringRef name { compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(varDecl->getLocation())) }; StringRef name { compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(varDecl->getLocation())) };
// this is playing games that it believes is safe // 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; return true;
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,

View File

@@ -75,8 +75,14 @@ void ReservedId::run() {
if (loc.isValid() && !ignoreLocation(loc)) { if (loc.isValid() && !ignoreLocation(loc)) {
auto file = compiler.getSourceManager() auto file = compiler.getSourceManager()
.getFilename(loc); .getFilename(loc);
if (file != SRCDIR "/include/cppuhelper/implbase_ex_post.hxx" if (!loplugin::isSamePathname(
&& file != SRCDIR "/include/cppuhelper/implbase_ex_pre.hxx") file,
SRCDIR
"/include/cppuhelper/implbase_ex_post.hxx")
&& !loplugin::isSamePathname(
file,
SRCDIR
"/include/cppuhelper/implbase_ex_pre.hxx"))
{ {
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
@@ -102,7 +108,7 @@ bool ReservedId::VisitNamedDecl(NamedDecl const * decl) {
return true; return true;
} }
auto filename = compiler.getSourceManager().getFilename(spelLoc); 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")) && filename.endswith("share.hxx"))
{ {
return true; return true;
@@ -215,7 +221,8 @@ ReservedId::Kind ReservedId::determineKind(llvm::StringRef const & id) {
} }
bool ReservedId::isInLokIncludeFile(SourceLocation spellingLocation) const { bool ReservedId::isInLokIncludeFile(SourceLocation spellingLocation) const {
return compiler.getSourceManager().getFilename(spellingLocation).startswith( return loplugin::hasPathnamePrefix(
compiler.getSourceManager().getFilename(spellingLocation),
SRCDIR "/include/LibreOfficeKit/"); SRCDIR "/include/LibreOfficeKit/");
} }

View File

@@ -763,8 +763,9 @@ bool SalBool::TraverseStaticAssertDecl(StaticAssertDecl * decl) {
// //
// inside static_assert in cppu/source/uno/check.cxx: // inside static_assert in cppu/source/uno/check.cxx:
return return
(compiler.getSourceManager().getFilename(decl->getLocation()) loplugin::isSamePathname(
== SRCDIR "/cppu/source/uno/check.cxx") compiler.getSourceManager().getFilename(decl->getLocation()),
SRCDIR "/cppu/source/uno/check.cxx")
|| RecursiveASTVisitor::TraverseStaticAssertDecl(decl); || RecursiveASTVisitor::TraverseStaticAssertDecl(decl);
} }
@@ -800,8 +801,9 @@ bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const {
return false; return false;
} }
auto f = compiler.getSourceManager().getFilename(spellingLocation); auto f = compiler.getSourceManager().getFilename(spellingLocation);
return f == SRCDIR "/cppu/qa/test_any.cxx" return loplugin::isSamePathname(f, SRCDIR "/cppu/qa/test_any.cxx")
|| f == SRCDIR "/cppu/source/uno/check.cxx"; // TODO: the offset checks || loplugin::isSamePathname(f, SRCDIR "/cppu/source/uno/check.cxx");
// TODO: the offset checks
} }
bool SalBool::rewrite(SourceLocation location) { bool SalBool::rewrite(SourceLocation location) {

View File

@@ -99,12 +99,12 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
return true; return true;
} }
// don't mess with the backwards compatibility stuff // 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; return true;
} }
// the DDE has a dummy implementation on Linux and a real one on Windows // the DDE has a dummy implementation on Linux and a real one on Windows
std::string aFilename = getFilename(pCXXMethodDecl->getCanonicalDecl()->getLocStart()); 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; return true;
} }
auto cdc = loplugin::DeclCheck(pCXXMethodDecl->getParent()); auto cdc = loplugin::DeclCheck(pCXXMethodDecl->getParent());
@@ -124,17 +124,17 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
return true; return true;
} }
// the unotools and svl config code stuff is doing weird stuff with a reference-counted statically allocated pImpl class // 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; return true;
} }
if (startsWith(aFilename, SRCDIR "/include/svl")) { if (loplugin::hasPathnamePrefix(aFilename, SRCDIR "/include/svl")) {
return true; 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; return true;
} }
// there is some odd stuff happening here I don't fully understand, leave it for now // 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; return true;
} }
// classes that have static data and some kind of weird reference-counting trick in its constructor // classes that have static data and some kind of weird reference-counting trick in its constructor

View File

@@ -98,8 +98,10 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
StringRef name { StringRef name {
compiler.getSourceManager().getFilename( compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) }; compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
if (name == SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx" if (loplugin::isSamePathname(
|| name == SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx") name, SRCDIR "/sal/qa/rtl/strings/test_ostring_concat.cxx")
|| loplugin::isSamePathname(
name, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx"))
{ {
return true; return true;
} }

View File

@@ -320,7 +320,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
// u.equalsIngoreAsciiCase("foo"): // u.equalsIngoreAsciiCase("foo"):
auto file = compiler.getSourceManager().getFilename( auto file = compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); 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; return true;
} }
handleChar( handleChar(
@@ -336,7 +338,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
// u.equalsIngoreAsciiCase("foo"): // u.equalsIngoreAsciiCase("foo"):
auto file = compiler.getSourceManager().getFilename( auto file = compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); 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; return true;
} }
handleCharLen( handleCharLen(
@@ -702,8 +706,9 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
auto file = compiler.getSourceManager().getFilename( auto file = compiler.getSourceManager().getFilename(
compiler.getSourceManager().getSpellingLoc( compiler.getSourceManager().getSpellingLoc(
expr->getLocStart())); expr->getLocStart()));
if (file if (loplugin::isSamePathname(
== SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx") file,
SRCDIR "/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx"))
{ {
return true; return true;
} }
@@ -990,12 +995,14 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
compiler.getSourceManager() compiler.getSourceManager()
.getSpellingLoc( .getSpellingLoc(
expr->getLocStart())); expr->getLocStart()));
if (file if (loplugin::isSamePathname(
== (SRCDIR file,
"/sal/qa/rtl/strings/test_ostring_concat.cxx") (SRCDIR
|| (file "/sal/qa/rtl/strings/test_ostring_concat.cxx"))
== (SRCDIR || loplugin::isSamePathname(
"/sal/qa/rtl/strings/test_oustring_concat.cxx"))) file,
(SRCDIR
"/sal/qa/rtl/strings/test_oustring_concat.cxx")))
{ {
return true; return true;
} }

View File

@@ -42,10 +42,10 @@ void StringStatic::run()
StringRef fn( compiler.getSourceManager().getFileEntryForID( StringRef fn( compiler.getSourceManager().getFileEntryForID(
compiler.getSourceManager().getMainFileID())->getName() ); compiler.getSourceManager().getMainFileID())->getName() );
// passing around pointers to global OUString // passing around pointers to global OUString
if (fn.startswith(SRCDIR "/filter/source/svg/")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/filter/source/svg/"))
return; return;
// has a mix of literals and refs to external OUStrings // 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; return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());

View File

@@ -34,24 +34,24 @@ public:
// ignore some files with problematic macros // ignore some files with problematic macros
StringRef fn( compiler.getSourceManager().getFileEntryForID( StringRef fn( compiler.getSourceManager().getFileEntryForID(
compiler.getSourceManager().getMainFileID())->getName() ); 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; return;
if (fn == SRCDIR "/forms/source/component/Date.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/component/Date.cxx"))
return; return;
if (fn == SRCDIR "/forms/source/component/Time.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/forms/source/component/Time.cxx"))
return; return;
if (fn == SRCDIR "/svx/source/dialog/hyperdlg.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/svx/source/dialog/hyperdlg.cxx"))
return; return;
if (fn == SRCDIR "/svx/source/dialog/rubydialog.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/svx/source/dialog/rubydialog.cxx"))
return; return;
if (fn.startswith(SRCDIR "/canvas")) if (loplugin::hasPathnamePrefix(fn, SRCDIR "/canvas"))
return; return;
if (fn == SRCDIR "/sc/source/ui/view/spelldialog.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/sc/source/ui/view/spelldialog.cxx"))
return; return;
if (fn == SRCDIR "/sd/source/ui/dlg/SpellDialogChildWindow.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/sd/source/ui/dlg/SpellDialogChildWindow.cxx"))
return; return;
// HAVE_ODBC_ADMINISTRATION // HAVE_ODBC_ADMINISTRATION
if (fn == SRCDIR "/dbaccess/source/ui/dlg/dsselect.cxx") if (loplugin::isSamePathname(fn, SRCDIR "/dbaccess/source/ui/dlg/dsselect.cxx"))
return; return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
@@ -84,7 +84,7 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
&& !isInUnoIncludeFile(methodDecl)) && !isInUnoIncludeFile(methodDecl))
{ {
// the code is this method is only __compiled__ if OSL_DEBUG_LEVEL > 1 // 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; return true;
// Warn about unnecessarily user-declared destructors. // Warn about unnecessarily user-declared destructors.
@@ -206,16 +206,16 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
} }
} }
// sometimes the disambiguation happens in a base class // 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; return true;
// not sure what is happening here // 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; return true;
// some very creative method hiding going on here // 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; return true;
// entertaining template magic // 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; return true;
// not sure what is going on here, but removing the override causes a crash // not sure what is going on here, but removing the override causes a crash
if (methodDecl->getQualifiedNameAsString() == "SwXTextDocument::queryAdapter") if (methodDecl->getQualifiedNameAsString() == "SwXTextDocument::queryAdapter")

View File

@@ -29,7 +29,7 @@ bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr)
return true; return true;
} }
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); 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; return true;
} }
if (expr->getOperator() != OO_Equal) { if (expr->getOperator() != OO_Equal) {

View File

@@ -92,31 +92,31 @@ bool UseUniquePtr::VisitCXXDestructorDecl(const CXXDestructorDecl* destructorDec
return true; return true;
// to ignore things like the CPPUNIT macros // to ignore things like the CPPUNIT macros
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(pFieldDecl->getLocStart())); StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(pFieldDecl->getLocStart()));
if (aFileName.startswith(WORKDIR)) if (loplugin::hasPathnamePrefix(aFileName, WORKDIR))
return true; return true;
// passes and stores pointers to member fields // 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; return true;
// something platform-specific // something platform-specific
if (aFileName.startswith(SRCDIR "/hwpfilter/source/htags.h")) if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/hwpfilter/source/htags.h"))
return true; return true;
// @TODO there is clearly a bug in the ownership here, the operator= method cannot be right // @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; return true;
// passes pointers to member fields // passes pointers to member fields
if (aFileName.startswith(SRCDIR "/sd/inc/sdpptwrp.hxx")) if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sd/inc/sdpptwrp.hxx"))
return true; return true;
// @TODO there is clearly a bug in the ownership here, the ScJumpMatrixToken copy constructor cannot be right // @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; return true;
// @TODO intrusive linked-lists here, with some trickiness // @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; return true;
// @TODO SwDoc has some weird ref-counting going on // @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; return true;
// @TODO it's sharing pointers with another class // @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; return true;
report( report(

View File

@@ -235,9 +235,9 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
pCXXDestructorDecl->getLocStart()); pCXXDestructorDecl->getLocStart());
StringRef filename = compiler.getSourceManager().getFilename(spellingLocation); StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
if ( !(filename.startswith(SRCDIR "/vcl/source/window/window.cxx")) if ( !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/source/window/window.cxx"))
&& !(filename.startswith(SRCDIR "/vcl/source/gdi/virdev.cxx")) && !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/source/gdi/virdev.cxx"))
&& !(filename.startswith(SRCDIR "/vcl/qa/cppunit/lifecycle.cxx")) ) && !(loplugin::hasPathnamePrefix(filename, SRCDIR "/vcl/qa/cppunit/lifecycle.cxx")) )
{ {
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
@@ -274,7 +274,7 @@ void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const SourceLocation& s
return; return;
} }
StringRef filename = compiler.getSourceManager().getFilename(spellingLocation); StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
if (filename == SRCDIR "/include/rtl/ref.hxx") { if (loplugin::isSamePathname(filename, SRCDIR "/include/rtl/ref.hxx")) {
return; return;
} }
const CXXRecordDecl* pointeeClass = lhsType->getPointeeType()->getAsCXXRecordDecl(); const CXXRecordDecl* pointeeClass = lhsType->getPointeeType()->getAsCXXRecordDecl();
@@ -356,9 +356,9 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) {
checkAssignmentForVclPtrToRawConversion(spellingLocation, pVarDecl->getType().getTypePtr(), pVarDecl->getInit()); checkAssignmentForVclPtrToRawConversion(spellingLocation, pVarDecl->getType().getTypePtr(), pVarDecl->getInit());
} }
StringRef aFileName = compiler.getSourceManager().getFilename(spellingLocation); StringRef aFileName = compiler.getSourceManager().getFilename(spellingLocation);
if (aFileName == SRCDIR "/include/vcl/vclptr.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/include/vcl/vclptr.hxx"))
return true; return true;
if (aFileName == SRCDIR "/vcl/source/window/layout.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/source/window/layout.cxx"))
return true; return true;
// whitelist the valid things that can contain pointers. // whitelist the valid things that can contain pointers.
// It is containing stuff like std::unique_ptr we get worried // It is containing stuff like std::unique_ptr we get worried
@@ -408,13 +408,13 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) {
return true; return true;
} }
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart())); 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; return true;
if (aFileName == SRCDIR "/include/rtl/ref.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/include/rtl/ref.hxx"))
return true; return true;
if (aFileName == SRCDIR "/include/o3tl/enumarray.hxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/include/o3tl/enumarray.hxx"))
return true; return true;
if (aFileName == SRCDIR "/vcl/source/window/layout.cxx") if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/source/window/layout.cxx"))
return true; return true;
if (fieldDecl->isBitField()) { if (fieldDecl->isBitField()) {
return true; return true;
@@ -665,7 +665,7 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr)
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
pCXXDeleteExpr->getLocStart()); pCXXDeleteExpr->getLocStart());
StringRef filename = compiler.getSourceManager().getFilename(spellingLocation); StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
if ( !(filename.startswith(SRCDIR "/include/vcl/vclreferencebase.hxx"))) if ( !(loplugin::hasPathnamePrefix(filename, SRCDIR "/include/vcl/vclreferencebase.hxx")))
{ {
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
@@ -841,7 +841,7 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr )
const CXXRecordDecl* recordDecl = pConstructorDecl->getParent(); const CXXRecordDecl* recordDecl = pConstructorDecl->getParent();
if (isDerivedFromVclReferenceBase(recordDecl)) { if (isDerivedFromVclReferenceBase(recordDecl)) {
StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(constructExpr->getLocStart())); 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( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
"Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create", "Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create",