fix filename detection in clang plugins

SourceManager::getFilename() returns "<stdin>" whenever icecream is used.

Change-Id: I4e3e1b90880c5fd2b53f20e4ce3e38e3a0486973
This commit is contained in:
Luboš Luňák
2014-03-23 15:31:04 +01:00
parent 59698a4797
commit f7859e5282
2 changed files with 3 additions and 3 deletions

View File

@@ -160,8 +160,8 @@ bool LiteralToBoolConversion::isFromCIncludeFile(
return false;
}
#endif
return compiler.getSourceManager().getFilename(spellingLocation).endswith(
".h");
return StringRef(compiler.getSourceManager().getPresumedLoc(spellingLocation)
.getFilename()).endswith(".h");
}
bool LiteralToBoolConversion::isMacroBodyExpansion(SourceLocation location)

View File

@@ -97,7 +97,7 @@ static const Type* extractTemplateType(Expr* cce);
bool ReferenceCasting::VisitCXXConstructExpr( CXXConstructExpr* cce )
{
// don't bother processing anything in the Reference.h file. Makes my life easier when debugging this.
if( compiler.getSourceManager().getFilename( cce->getSourceRange().getBegin() ).find( "Reference.h" ) != StringRef::npos )
if( StringRef(compiler.getSourceManager().getPresumedLoc( cce->getSourceRange().getBegin() )).find( "Reference.h" ) != StringRef::npos )
return true;
// look for calls to the Reference<T>(x,UNO_something) constructor