diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-16 19:43:15 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-16 19:43:15 +0200 |
commit | 35d9cd4969ba39d7ac8975d4102b4de5a9ae2562 (patch) | |
tree | 1c38ccf7b476b768cc7fe9dd0e6e4d8fae09fd49 /compilerplugins | |
parent | 9a0e3d1de75a1986d614a52f1f41276411709cce (diff) |
clang::FileEntry::getName now returns StringRef on Clang master
Change-Id: I94c9676e52a3c60ad70567396a8484e844176c6e
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/pluginhandler.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index bdee467fa82f..89ba8f435da0 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -171,9 +171,8 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) { if( context.getDiagnostics().hasErrorOccurred()) return; - char const*const mainFileName = context.getSourceManager().getFileEntryForID(context.getSourceManager().getMainFileID())->getName(); - size_t const len = strlen(mainFileName); - if (len > 3 && strncmp(mainFileName + len - 3, ".ii", 3) == 0) + StringRef const mainFileName = context.getSourceManager().getFileEntryForID(context.getSourceManager().getMainFileID())->getName(); + if (mainFileName.endswith(".ii")) { report(DiagnosticsEngine::Fatal, "input file has suffix .ii: \"%0\"\nhighly suspicious, probably ccache generated, this will break warning suppressions; export CCACHE_CPP2=1 to prevent this") << mainFileName; @@ -201,11 +200,12 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) string modifyFile; const char* pathWarning = NULL; bool bSkip = false; - if( strncmp( e->getName(), WORKDIR "/", strlen( WORKDIR "/" )) == 0 ) + StringRef const name = e->getName(); + if( name.startswith(WORKDIR "/") ) pathWarning = "modified source in workdir/ : %0"; - else if( strcmp( SRCDIR, BUILDDIR ) != 0 && strncmp( e->getName(), BUILDDIR "/", strlen( BUILDDIR "/" )) == 0 ) + else if( strcmp( SRCDIR, BUILDDIR ) != 0 && name.startswith(BUILDDIR "/") ) pathWarning = "modified source in build dir : %0"; - else if( strncmp( e->getName(), SRCDIR "/", strlen( SRCDIR "/" )) == 0 ) + else if( name.startswith(SRCDIR "/") ) ; // ok else { @@ -213,7 +213,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) bSkip = true; } if( modifyFile.empty()) - modifyFile = e->getName(); + modifyFile = name; // Check whether the modified file is in the wanted scope if( scope == "mainfile" ) { @@ -229,7 +229,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) } // Warn only now, so that files not in scope do not cause warnings. if( pathWarning != NULL ) - report( DiagnosticsEngine::Warning, pathWarning ) << e->getName(); + report( DiagnosticsEngine::Warning, pathWarning ) << name; if( bSkip ) continue; char* filename = new char[ modifyFile.length() + 100 ]; |