summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-10-06 20:44:39 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-10-07 15:21:50 +0200
commitc8bf651fb9b97eca6af7d1d26c62681cc5c7ec0f (patch)
tree8c78c377aa4dc4876d5ee691772ff0342c36d4fe
parentadd missing const (diff)
downloadcore-c8bf651fb9b97eca6af7d1d26c62681cc5c7ec0f.tar.gz
core-c8bf651fb9b97eca6af7d1d26c62681cc5c7ec0f.zip
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/80326 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--compilerplugins/clang/constantparam.cxx2
-rw-r--r--compilerplugins/clang/constfields.cxx2
-rw-r--r--compilerplugins/clang/constmethod.cxx2
-rw-r--r--compilerplugins/clang/countusersofdefaultparams.cxx2
-rw-r--r--compilerplugins/clang/expandablemethods.cxx2
-rw-r--r--compilerplugins/clang/finalclasses.cxx2
-rw-r--r--compilerplugins/clang/inlinefields.cxx2
-rw-r--r--compilerplugins/clang/mergeclasses.cxx2
-rw-r--r--compilerplugins/clang/methodcycles.cxx2
-rw-r--r--compilerplugins/clang/plugin.cxx3
-rw-r--r--compilerplugins/clang/shouldreturnbool.cxx2
-rw-r--r--compilerplugins/clang/singlevalfields.cxx2
-rw-r--r--compilerplugins/clang/store/badvectorinit.cxx2
-rw-r--r--compilerplugins/clang/store/constantfunction.cxx2
-rw-r--r--compilerplugins/clang/store/defaultparams.cxx2
-rw-r--r--compilerplugins/clang/store/deletedspecial.cxx2
-rw-r--r--compilerplugins/clang/store/fpcomparison.cxx2
-rw-r--r--compilerplugins/clang/store/returnbyref.cxx2
-rw-r--r--compilerplugins/clang/store/revisibility.cxx2
-rw-r--r--compilerplugins/clang/store/stylepolice.cxx2
-rw-r--r--compilerplugins/clang/stringconcatliterals.cxx2
-rw-r--r--compilerplugins/clang/unnecessaryvirtual.cxx2
-rw-r--r--compilerplugins/clang/unusedenumconstants.cxx2
-rw-r--r--compilerplugins/clang/unusedfields.cxx2
-rw-r--r--compilerplugins/clang/unusedmethods.cxx2
-rw-r--r--compilerplugins/clang/virtualdead.cxx2
-rw-r--r--compilerplugins/clang/virtualdown.cxx2
-rw-r--r--compilerplugins/clang/writeonlyvars.cxx2
28 files changed, 28 insertions, 29 deletions
diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx
index f1257dbb0e96..33e25909c681 100644
--- a/compilerplugins/clang/constantparam.cxx
+++ b/compilerplugins/clang/constantparam.cxx
@@ -121,7 +121,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 ce73e0d8e51f..85546bed6c69 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/constmethod.cxx b/compilerplugins/clang/constmethod.cxx
index 888d1bbd15bd..fe19b38c15ac 100644
--- a/compilerplugins/clang/constmethod.cxx
+++ b/compilerplugins/clang/constmethod.cxx
@@ -46,7 +46,7 @@ public:
if (getFunctionsWithAddressTaken().find((FunctionDecl const *)canonicalDecl)
!= getFunctionsWithAddressTaken().end())
continue;
- StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(canonicalDecl)));
+ StringRef aFileName = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(canonicalDecl)));
if (loplugin::isSamePathname(aFileName, SRCDIR "/include/LibreOfficeKit/LibreOfficeKit.hxx"))
continue;
report(
diff --git a/compilerplugins/clang/countusersofdefaultparams.cxx b/compilerplugins/clang/countusersofdefaultparams.cxx
index b469833b27b9..79fa99742afc 100644
--- a/compilerplugins/clang/countusersofdefaultparams.cxx
+++ b/compilerplugins/clang/countusersofdefaultparams.cxx
@@ -214,7 +214,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 e91a3c0ecf4c..2732d4e598fd 100644
--- a/compilerplugins/clang/expandablemethods.cxx
+++ b/compilerplugins/clang/expandablemethods.cxx
@@ -162,7 +162,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 0a57e5d38a7b..e6e1a83c36cb 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 bf48e8822a03..5d34dfc49d34 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -621,8 +621,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 03cc0c856a6f..e46d05d0b28f 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 e1a159a8387e..52631dabaa10 100644
--- a/compilerplugins/clang/singlevalfields.cxx
+++ b/compilerplugins/clang/singlevalfields.cxx
@@ -154,7 +154,7 @@ void SingleValFields::niceName(const DeclaratorDecl* fieldOrVarDecl, MyFieldInfo
aInfo.fieldType = fieldOrVarDecl->getType().getAsString();
SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( fieldOrVarDecl->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 982482fb4ce0..3d0b911e863c 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/stringconcatliterals.cxx b/compilerplugins/clang/stringconcatliterals.cxx
index f6008175f38d..2d2699a09acf 100644
--- a/compilerplugins/clang/stringconcatliterals.cxx
+++ b/compilerplugins/clang/stringconcatliterals.cxx
@@ -105,7 +105,7 @@ bool StringConcatLiterals::VisitCallExpr(CallExpr const * expr) {
// We add an extra " " in the TOOLS_WARN_EXCEPTION macro, which triggers this plugin
if (loplugin::isSamePathname(
- compiler.getSourceManager().getFilename(
+ getFileNameOfSpellingLoc(
compiler.getSourceManager().getSpellingLoc(
compiler.getSourceManager().getImmediateMacroCallerLoc(
compiler.getSourceManager().getImmediateMacroCallerLoc(
diff --git a/compilerplugins/clang/unnecessaryvirtual.cxx b/compilerplugins/clang/unnecessaryvirtual.cxx
index df3dda68adbc..7f6751017bc0 100644
--- a/compilerplugins/clang/unnecessaryvirtual.cxx
+++ b/compilerplugins/clang/unnecessaryvirtual.cxx
@@ -187,7 +187,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 fb5a109c5b37..f64028e11ce3 100644
--- a/compilerplugins/clang/unusedenumconstants.cxx
+++ b/compilerplugins/clang/unusedenumconstants.cxx
@@ -118,7 +118,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.loc = 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 c9df58e427a2..b552630a51d1 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 e24fec99c3d2..9977593d5b1e 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/virtualdead.cxx b/compilerplugins/clang/virtualdead.cxx
index dd6e311193b8..bfcb3d7c94cb 100644
--- a/compilerplugins/clang/virtualdead.cxx
+++ b/compilerplugins/clang/virtualdead.cxx
@@ -253,7 +253,7 @@ std::string VirtualDead::getCallValue(const Expr* arg)
std::string VirtualDead::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/virtualdown.cxx b/compilerplugins/clang/virtualdown.cxx
index 9e59c842f49f..48df7934bc04 100644
--- a/compilerplugins/clang/virtualdown.cxx
+++ b/compilerplugins/clang/virtualdown.cxx
@@ -204,7 +204,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));
diff --git a/compilerplugins/clang/writeonlyvars.cxx b/compilerplugins/clang/writeonlyvars.cxx
index d9daa172820d..fcaf3d3c7e26 100644
--- a/compilerplugins/clang/writeonlyvars.cxx
+++ b/compilerplugins/clang/writeonlyvars.cxx
@@ -510,7 +510,7 @@ MyVarInfo WriteOnlyVars::niceName(const VarDecl* varDecl)
SourceLocation expansionLoc
= compiler.getSourceManager().getExpansionLoc(varDecl->getLocation());
- StringRef filename = compiler.getSourceManager().getFilename(expansionLoc);
+ StringRef filename = getFileNameOfSpellingLoc(expansionLoc);
aInfo.sourceLocation
= std::string(filename.substr(strlen(SRCDIR) + 1)) + ":"
+ std::to_string(compiler.getSourceManager().getSpellingLineNumber(expansionLoc));