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

Stephan Bergmann sbergman at redhat.com
Tue Feb 25 01:16:06 PST 2014


 compilerplugins/clang/compat.hxx        |   17 +++++++++++++++++
 compilerplugins/clang/pluginhandler.cxx |   11 ++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit 6f2774b209f0a52ad199f926cd56f581e73c79d5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 25 10:15:28 2014 +0100

    ...but Flags parameter was plain unsigned int prior to Clang 3.4
    
    Change-Id: Ife39abda6b5274ae196dcbf591d02fa3f36f6072

diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 4bc9a6b..b09a221 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -10,12 +10,17 @@
 #ifndef INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
 #define INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
 
+#include <memory>
+#include <string>
+
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
 
 // Compatibility wrapper to abstract over (trivial) changes in the Clang API:
 namespace compat {
@@ -66,6 +71,18 @@ inline unsigned getCustomDiagID(
 #endif
 }
 
+inline std::unique_ptr<llvm::raw_fd_ostream> create_raw_fd_ostream(
+    char const * Filename, std::string & ErrorInfo)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+    return std::unique_ptr<llvm::raw_fd_ostream>(
+        new llvm::raw_fd_ostream(Filename, ErrorInfo, llvm::sys::fs::F_None));
+#else
+    return std::unique_ptr<llvm::raw_fd_ostream>(
+        new llvm::raw_fd_ostream(Filename, ErrorInfo));
+#endif
+}
+
 }
 
 #endif
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 21d8990..361f12c 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -224,15 +224,16 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
         sprintf( filename, "%s.new.%d", modifyFile.c_str(), getpid());
         string error;
         bool ok = false;
-        raw_fd_ostream ostream( filename, error, sys::fs::F_None );
+        std::unique_ptr<raw_fd_ostream> ostream(
+            compat::create_raw_fd_ostream(filename, error) );
         if( error.empty())
             {
-            it->second.write( ostream );
-            ostream.close();
-            if( !ostream.has_error() && rename( filename, modifyFile.c_str()) == 0 )
+            it->second.write( *ostream );
+            ostream->close();
+            if( !ostream->has_error() && rename( filename, modifyFile.c_str()) == 0 )
                 ok = true;
             }
-        ostream.clear_error();
+        ostream->clear_error();
         unlink( filename );
         if( !ok )
             report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1)" ) << modifyFile << error;


More information about the Libreoffice-commits mailing list