do not use compiler.getSourceManager().getFilename()
This is a continuation of ff002524c1
.
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user