summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/pluginhandler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/pluginhandler.cxx')
-rw-r--r--compilerplugins/clang/pluginhandler.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index b1e789a4a8c5..a4637cd78e6d 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -55,9 +55,21 @@ static int pluginCount = 0;
static bool bPluginObjectsCreated = false;
static bool unitTestMode = false;
+StringRef initMainFileName(CompilerInstance& compiler)
+{
+ StringRef const& fn(compiler.getASTContext().getSourceManager().getFileEntryForID(
+ compiler.getASTContext().getSourceManager().getMainFileID())->getName());
+ if (fn == "<stdin>")
+ // stdin means icecream, so we can rely on -main-file-name containing the full path name
+ return compiler.getCodeGenOpts().MainFileName;
+ else
+ // this is always a full path name
+ return fn;
+}
+
PluginHandler::PluginHandler( CompilerInstance& compiler, const std::vector< std::string >& args )
: compiler( compiler )
- , mainFileName(compiler.getASTContext().getSourceManager().getFileEntryForID(compiler.getASTContext().getSourceManager().getMainFileID())->getName())
+ , mainFileName(initMainFileName(compiler))
, rewriter( compiler.getSourceManager(), compiler.getLangOpts())
, scope( "mainfile" )
, warningsAsErrors( false )