compilerplugins/clang/constantparam.cxx | 2 +- compilerplugins/clang/constfields.cxx | 2 +- compilerplugins/clang/countusersofdefaultparams.cxx | 2 +- compilerplugins/clang/expandablemethods.cxx | 2 +- compilerplugins/clang/finalclasses.cxx | 2 +- compilerplugins/clang/inlinefields.cxx | 2 +- compilerplugins/clang/mergeclasses.cxx | 2 +- compilerplugins/clang/methodcycles.cxx | 2 +- compilerplugins/clang/plugin.cxx | 3 +-- compilerplugins/clang/shouldreturnbool.cxx | 2 +- compilerplugins/clang/singlevalfields.cxx | 2 +- compilerplugins/clang/store/badvectorinit.cxx | 2 +- compilerplugins/clang/store/constantfunction.cxx | 2 +- compilerplugins/clang/store/defaultparams.cxx | 2 +- compilerplugins/clang/store/deletedspecial.cxx | 2 +- compilerplugins/clang/store/fpcomparison.cxx | 2 +- compilerplugins/clang/store/returnbyref.cxx | 2 +- compilerplugins/clang/store/revisibility.cxx | 2 +- compilerplugins/clang/store/stylepolice.cxx | 2 +- compilerplugins/clang/unnecessaryvirtual.cxx | 2 +- compilerplugins/clang/unusedenumconstants.cxx | 2 +- compilerplugins/clang/unusedfields.cxx | 2 +- compilerplugins/clang/unusedmethods.cxx | 2 +- compilerplugins/clang/virtualdown.cxx | 2 +- 24 files changed, 24 insertions(+), 25 deletions(-)
New commits: commit 35ed524811d36723a79774d4cac7379aaee247dd Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Sun Oct 6 20:44:39 2019 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Oct 7 17:17:49 2019 +0200 do not use compiler.getSourceManager().getFilename() This is a continuation of ff002524c12471668e63837a804b6006f9136a34. When compiling with icecream, its -frewrite-includes merges all #include's into one .cxx file and marks them with with line markers. But SourceManager::getFilename() doesn't take those into account and so it reports all of those as <stdin>. So use getFileNameOfSpellingLoc(), which explicitly handles this case. And we should probably never ever use SourceManager::getFilename(). Change-Id: Ia194c2e041578e1e199aee2df2f885922ef7e31a Reviewed-on: https://gerrit.libreoffice.org/80379 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx index 208fc19ca0f7..eb3880c267a2 100644 --- a/compilerplugins/clang/constantparam.cxx +++ b/compilerplugins/clang/constantparam.cxx @@ -119,7 +119,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde if (isInUnoIncludeFile(functionDecl)) return; SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( functionDecl->getLocation() ); - StringRef filename = compiler.getSourceManager().getFilename(expansionLoc); + StringRef filename = getFileNameOfSpellingLoc(expansionLoc); if (!loplugin::hasPathnamePrefix(filename, SRCDIR "/")) return; filename = filename.substr(strlen(SRCDIR)+1); diff --git a/compilerplugins/clang/constfields.cxx b/compilerplugins/clang/constfields.cxx index 6613c836b892..069998ff4cc1 100644 --- a/compilerplugins/clang/constfields.cxx +++ b/compilerplugins/clang/constfields.cxx @@ -233,7 +233,7 @@ MyFieldInfo ConstFields::niceName(const FieldDecl* fieldDecl) SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc(fieldDecl->getLocation()); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); aInfo.sourceLocation = std::string(name.substr(strlen(SRCDIR) + 1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); diff --git a/compilerplugins/clang/countusersofdefaultparams.cxx b/compilerplugins/clang/countusersofdefaultparams.cxx index 12057dec9264..14b2c62434b9 100644 --- a/compilerplugins/clang/countusersofdefaultparams.cxx +++ b/compilerplugins/clang/countusersofdefaultparams.cxx @@ -208,7 +208,7 @@ bool CountUsersOfDefaultParams::VisitCXXConstructExpr(const CXXConstructExpr * c std::string CountUsersOfDefaultParams::locationToString(const SourceLocation& sourceLoc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( sourceLoc ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); return std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); } diff --git a/compilerplugins/clang/expandablemethods.cxx b/compilerplugins/clang/expandablemethods.cxx index 4da75cfd0f02..cf2f8ac2bc0a 100644 --- a/compilerplugins/clang/expandablemethods.cxx +++ b/compilerplugins/clang/expandablemethods.cxx @@ -160,7 +160,7 @@ MyFuncInfo ExpandableMethods::niceName(const FunctionDecl* functionDecl) std::string ExpandableMethods::toString(SourceLocation loc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); std::string sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(sourceLocation); return sourceLocation; diff --git a/compilerplugins/clang/finalclasses.cxx b/compilerplugins/clang/finalclasses.cxx index f31f28d8f895..b90c9c4c72ec 100644 --- a/compilerplugins/clang/finalclasses.cxx +++ b/compilerplugins/clang/finalclasses.cxx @@ -128,7 +128,7 @@ bool FinalClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) return true; SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl)); - std::string filename = compiler.getSourceManager().getFilename(spellingLocation); + std::string filename = getFileNameOfSpellingLoc(spellingLocation); auto sourceLocation = filename.substr(strlen(SRCDIR)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(spellingLocation)); definitionMap.insert( std::pair<std::string,std::string>(s, sourceLocation) ); diff --git a/compilerplugins/clang/inlinefields.cxx b/compilerplugins/clang/inlinefields.cxx index 0c1d28e20e0c..7ae4fb1345b7 100644 --- a/compilerplugins/clang/inlinefields.cxx +++ b/compilerplugins/clang/inlinefields.cxx @@ -119,7 +119,7 @@ MyFieldInfo InlineFields::niceName(const FieldDecl* fieldDecl) aInfo.fieldName = fieldDecl->getNameAsString(); SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( fieldDecl->getLocation() ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); aInfo.sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(aInfo.sourceLocation); diff --git a/compilerplugins/clang/mergeclasses.cxx b/compilerplugins/clang/mergeclasses.cxx index bac4a36df1d8..a37abd568d02 100644 --- a/compilerplugins/clang/mergeclasses.cxx +++ b/compilerplugins/clang/mergeclasses.cxx @@ -149,7 +149,7 @@ bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl) if (decl->isThisDeclarationADefinition()) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(decl)); - std::string filename = compiler.getSourceManager().getFilename(spellingLocation); + std::string filename = getFileNameOfSpellingLoc(spellingLocation); filename = filename.substr(strlen(SRCDIR)); std::string s = decl->getQualifiedNameAsString(); if (ignoreClass(s)) diff --git a/compilerplugins/clang/methodcycles.cxx b/compilerplugins/clang/methodcycles.cxx index 20a31171c001..3b0df79da574 100644 --- a/compilerplugins/clang/methodcycles.cxx +++ b/compilerplugins/clang/methodcycles.cxx @@ -176,7 +176,7 @@ MyFuncInfo MethodCycles::niceName(const FunctionDecl* functionDecl) std::string MethodCycles::toString(SourceLocation loc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc(loc); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); std::string sourceLocation = std::string(name.substr(strlen(SRCDIR) + 1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 84975c99107a..5a5ba4bad9ab 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -622,8 +622,7 @@ bool RewritePlugin::wouldRewriteWorkdir(SourceLocation loc) return false; } return - compiler.getSourceManager().getFilename( - compiler.getSourceManager().getSpellingLoc(loc)) + getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(loc)) .startswith(WORKDIR "/"); } diff --git a/compilerplugins/clang/shouldreturnbool.cxx b/compilerplugins/clang/shouldreturnbool.cxx index 937dba126da0..e69ee162e50a 100644 --- a/compilerplugins/clang/shouldreturnbool.cxx +++ b/compilerplugins/clang/shouldreturnbool.cxx @@ -199,7 +199,7 @@ bool ShouldReturnBool::IsInteresting(FunctionDecl const* functionDecl) return false; // not sure what basegfx is doing here - StringRef fileName{ compiler.getSourceManager().getFilename(functionDecl->getLocation()) }; + StringRef fileName{ getFileNameOfSpellingLoc(functionDecl->getLocation()) }; if (loplugin::isSamePathname(fileName, SRCDIR "/include/basegfx/range/basicrange.hxx")) return false; // false + diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx index 7e8195bdacb4..88d0506b4dff 100644 --- a/compilerplugins/clang/singlevalfields.cxx +++ b/compilerplugins/clang/singlevalfields.cxx @@ -128,7 +128,7 @@ void SingleValFields::niceName(const FieldDecl* fieldDecl, MyFieldInfo& aInfo) aInfo.fieldType = fieldDecl->getType().getAsString(); SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( fieldDecl->getLocation() ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); aInfo.sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(aInfo.sourceLocation); } diff --git a/compilerplugins/clang/store/badvectorinit.cxx b/compilerplugins/clang/store/badvectorinit.cxx index 68cba18de580..67c50fb59189 100644 --- a/compilerplugins/clang/store/badvectorinit.cxx +++ b/compilerplugins/clang/store/badvectorinit.cxx @@ -113,7 +113,7 @@ bool BadVectorInit::TraverseFunctionDecl(FunctionDecl* decl) StringRef BadVectorInit::getFilename(SourceLocation loc) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(loc); - StringRef name { compiler.getSourceManager().getFilename(spellingLocation) }; + StringRef name { getFileNameOfSpellingLoc(spellingLocation) }; return name; } diff --git a/compilerplugins/clang/store/constantfunction.cxx b/compilerplugins/clang/store/constantfunction.cxx index b2be6b90532d..59f9e5659ded 100644 --- a/compilerplugins/clang/store/constantfunction.cxx +++ b/compilerplugins/clang/store/constantfunction.cxx @@ -45,7 +45,7 @@ public: StringRef ConstantFunction::getFilename(const FunctionDecl* functionDecl) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(functionDecl->getCanonicalDecl()->getNameInfo().getLoc()); - StringRef name { compiler.getSourceManager().getFilename(spellingLocation) }; + StringRef name { getFileNameOfSpellingLoc(spellingLocation) }; return name; } diff --git a/compilerplugins/clang/store/defaultparams.cxx b/compilerplugins/clang/store/defaultparams.cxx index 71a637e72c04..331fd8ae843d 100644 --- a/compilerplugins/clang/store/defaultparams.cxx +++ b/compilerplugins/clang/store/defaultparams.cxx @@ -91,7 +91,7 @@ bool DefaultParams::VisitCallExpr(CallExpr * callExpr) { if (!found) break; // Ignore CPPUNIT, it's macros contain some stuff that triggers us - StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(parmVarDecl->getLocStart())); + StringRef aFileName = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(parmVarDecl->getLocStart())); if (aFileName.find("include/cppunit") != std::string::npos) break; report( diff --git a/compilerplugins/clang/store/deletedspecial.cxx b/compilerplugins/clang/store/deletedspecial.cxx index 5d66de352184..b287283cdd36 100644 --- a/compilerplugins/clang/store/deletedspecial.cxx +++ b/compilerplugins/clang/store/deletedspecial.cxx @@ -141,7 +141,7 @@ bool DeletedSpecial::whitelist( std::string const & path) { return getClass(decl)->getQualifiedNameAsString() == name - && (compiler.getSourceManager().getFilename( + && (getFileNameOfSpellingLoc( compiler.getSourceManager().getSpellingLoc(decl->getLocation())) == SRCDIR "/" + path); } diff --git a/compilerplugins/clang/store/fpcomparison.cxx b/compilerplugins/clang/store/fpcomparison.cxx index 8ad5d4c3b9e6..d56b02644445 100644 --- a/compilerplugins/clang/store/fpcomparison.cxx +++ b/compilerplugins/clang/store/fpcomparison.cxx @@ -70,7 +70,7 @@ bool FpComparison::ignore(FunctionDecl* function) return true; } // 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 = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(function->getLocStart())); if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/")) { return true; } diff --git a/compilerplugins/clang/store/returnbyref.cxx b/compilerplugins/clang/store/returnbyref.cxx index 697ab752909d..fd99a2d0ec06 100644 --- a/compilerplugins/clang/store/returnbyref.cxx +++ b/compilerplugins/clang/store/returnbyref.cxx @@ -128,7 +128,7 @@ nextStmt->dump(); std::string ReturnByRef::getFilename(SourceLocation loc) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(loc); - return compiler.getSourceManager().getFilename(spellingLocation); + return getFileNameOfSpellingLoc(spellingLocation); } loplugin::Plugin::Registration< ReturnByRef > X("returnbyref"); diff --git a/compilerplugins/clang/store/revisibility.cxx b/compilerplugins/clang/store/revisibility.cxx index 9aa04f7b2560..3ca541c1fadc 100644 --- a/compilerplugins/clang/store/revisibility.cxx +++ b/compilerplugins/clang/store/revisibility.cxx @@ -63,7 +63,7 @@ bool ReVisibility::VisitFunctionDecl(FunctionDecl const * decl) { } } if (decl->isThisDeclarationADefinition() && first != nullptr - && !(compiler.getSourceManager().getFilename( + && !(getFileNameOfSpellingLoc( compiler.getSourceManager().getSpellingLoc( decl->getLocation())) .startswith(SRCDIR "/libreofficekit/"))) diff --git a/compilerplugins/clang/store/stylepolice.cxx b/compilerplugins/clang/store/stylepolice.cxx index 2c0ac68c2e4c..f8536108a37d 100644 --- a/compilerplugins/clang/store/stylepolice.cxx +++ b/compilerplugins/clang/store/stylepolice.cxx @@ -38,7 +38,7 @@ private: StringRef StylePolice::getFilename(SourceLocation loc) { SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(loc); - StringRef name { compiler.getSourceManager().getFilename(spellingLocation) }; + StringRef name { getFileNameOfSpellingLoc(spellingLocation) }; return name; } diff --git a/compilerplugins/clang/unnecessaryvirtual.cxx b/compilerplugins/clang/unnecessaryvirtual.cxx index afc324cee156..e5325855aa82 100644 --- a/compilerplugins/clang/unnecessaryvirtual.cxx +++ b/compilerplugins/clang/unnecessaryvirtual.cxx @@ -188,7 +188,7 @@ void UnnecessaryVirtual::MarkRootOverridesNonEmpty( const CXXMethodDecl* methodD std::string UnnecessaryVirtual::toString(SourceLocation loc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); std::string sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(sourceLocation); return sourceLocation; diff --git a/compilerplugins/clang/unusedenumconstants.cxx b/compilerplugins/clang/unusedenumconstants.cxx index b106d308fdb5..a5fcd7b7b1d5 100644 --- a/compilerplugins/clang/unusedenumconstants.cxx +++ b/compilerplugins/clang/unusedenumconstants.cxx @@ -105,7 +105,7 @@ MyFieldInfo UnusedEnumConstants::niceName(const EnumConstantDecl* enumConstantDe } SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( enumConstantDecl->getLocation() ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); aInfo.sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(aInfo.sourceLocation); diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index 1e63ac19a3dd..692f17cffa79 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -247,7 +247,7 @@ MyFieldInfo UnusedFields::niceName(const FieldDecl* fieldDecl) aInfo.fieldType = fieldDecl->getType().getAsString(); SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( fieldDecl->getLocation() ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); aInfo.sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(aInfo.sourceLocation); diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index 5f998712d3ef..0b362415ba1c 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -187,7 +187,7 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl) std::string UnusedMethods::toString(SourceLocation loc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc ); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); std::string sourceLocation = std::string(name.substr(strlen(SRCDIR)+1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); loplugin::normalizeDotDotInFilePath(sourceLocation); return sourceLocation; diff --git a/compilerplugins/clang/virtualdown.cxx b/compilerplugins/clang/virtualdown.cxx index 0bc9bf491148..f254b5a10411 100644 --- a/compilerplugins/clang/virtualdown.cxx +++ b/compilerplugins/clang/virtualdown.cxx @@ -208,7 +208,7 @@ std::string VirtualDown::niceName(const CXXMethodDecl* cxxMethodDecl) std::string VirtualDown::toString(SourceLocation loc) { SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc(loc); - StringRef name = compiler.getSourceManager().getFilename(expansionLoc); + StringRef name = getFileNameOfSpellingLoc(expansionLoc); std::string sourceLocation = std::string(name.substr(strlen(SRCDIR) + 1)) + ":" + std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits