[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Sun Oct 16 17:43:45 UTC 2016


 compilerplugins/clang/pluginhandler.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 35d9cd4969ba39d7ac8975d4102b4de5a9ae2562
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sun Oct 16 19:43:15 2016 +0200

    clang::FileEntry::getName now returns StringRef on Clang master
    
    Change-Id: I94c9676e52a3c60ad70567396a8484e844176c6e

diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index bdee467..89ba8f4 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 ];


More information about the Libreoffice-commits mailing list