[Libreoffice-commits] core.git: 3 commits - compilerplugins/clang compilerplugins/Makefile-clang.mk sw/source

Luboš Luňák l.lunak at suse.cz
Thu Mar 28 10:01:38 PDT 2013


 compilerplugins/Makefile-clang.mk                 |    2 -
 compilerplugins/clang/bodynotinblock.cxx          |   10 +++---
 compilerplugins/clang/bodynotinblock.hxx          |    2 -
 compilerplugins/clang/literalalternative.cxx      |    8 ++---
 compilerplugins/clang/plugin.cxx                  |   22 +++++++--------
 compilerplugins/clang/plugin.hxx                  |   25 ++++++++---------
 compilerplugins/clang/pluginhandler.cxx           |   22 +++++++--------
 compilerplugins/clang/pluginhandler.hxx           |    6 ++--
 compilerplugins/clang/postfixincrementfix.cxx     |    8 ++---
 compilerplugins/clang/postfixincrementfix.hxx     |    4 +-
 compilerplugins/clang/removeforwardstringdecl.cxx |    6 ++--
 compilerplugins/clang/removeforwardstringdecl.hxx |    2 -
 compilerplugins/clang/sallogareas.cxx             |   15 +++++-----
 compilerplugins/clang/sallogareas.hxx             |    2 -
 compilerplugins/clang/unusedvariablecheck.cxx     |    6 ++--
 compilerplugins/clang/unusedvariablecheck.hxx     |    2 -
 sw/source/filter/ww8/attributeoutputbase.hxx      |    1 
 sw/source/filter/ww8/docxattributeoutput.cxx      |   32 ++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx      |    3 ++
 sw/source/filter/ww8/rtfattributeoutput.cxx       |    5 +++
 sw/source/filter/ww8/rtfattributeoutput.hxx       |    1 
 sw/source/filter/ww8/ww8atr.cxx                   |   10 ++++++
 sw/source/filter/ww8/ww8attributeoutput.hxx       |    1 
 23 files changed, 124 insertions(+), 71 deletions(-)

New commits:
commit 153a69cad2efdb38f7da50bcd25158d127a944f4
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Mar 21 16:42:10 2013 +0100

    pass around CompilerInstance rather than ASTContext
    
    It's possible to get the latter from the former, and the former
    is useful for other things too (access to the preprocessor, for example).
    
    Change-Id: I708d709129fd3a35bf7c63da4de09c2e696b382d

diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx
index cd3e1a0..afd486d 100644
--- a/compilerplugins/clang/bodynotinblock.cxx
+++ b/compilerplugins/clang/bodynotinblock.cxx
@@ -28,14 +28,14 @@ For example:
 Here either both statements should be inside {} or the second statement in indented wrong.
 */
 
-BodyNotInBlock::BodyNotInBlock( ASTContext& context )
-    : Plugin( context )
+BodyNotInBlock::BodyNotInBlock( CompilerInstance& compiler )
+    : Plugin( compiler )
     {
     }
 
 void BodyNotInBlock::run()
     {
-    TraverseDecl( context.getTranslationUnitDecl());
+    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
     }
 
 bool BodyNotInBlock::VisitFunctionDecl( FunctionDecl* declaration )
@@ -110,9 +110,9 @@ void BodyNotInBlock::checkBody( const Stmt* body, SourceLocation stmtLocation, c
                 if( it != parents[ parent_pos ]->child_end())
                     {
                     bool invalid1, invalid2;
-                    unsigned bodyColumn = context.getSourceManager()
+                    unsigned bodyColumn = compiler.getSourceManager()
                         .getPresumedColumnNumber( body->getLocStart(), &invalid1 );
-                    unsigned nextStatementColumn = context.getSourceManager()
+                    unsigned nextStatementColumn = compiler.getSourceManager()
                         .getPresumedColumnNumber( (*it)->getLocStart(), &invalid2 );
                     if( invalid1 || invalid2 )
                         return;
diff --git a/compilerplugins/clang/bodynotinblock.hxx b/compilerplugins/clang/bodynotinblock.hxx
index e8d35dd..23f7609 100644
--- a/compilerplugins/clang/bodynotinblock.hxx
+++ b/compilerplugins/clang/bodynotinblock.hxx
@@ -21,7 +21,7 @@ class BodyNotInBlock
     , public Plugin
     {
     public:
-        explicit BodyNotInBlock( ASTContext& context );
+        explicit BodyNotInBlock( CompilerInstance& compiler );
         virtual void run();
         bool VisitFunctionDecl( FunctionDecl* declaration );
     private:
diff --git a/compilerplugins/clang/literalalternative.cxx b/compilerplugins/clang/literalalternative.cxx
index e90b688..06ba803 100644
--- a/compilerplugins/clang/literalalternative.cxx
+++ b/compilerplugins/clang/literalalternative.cxx
@@ -21,9 +21,9 @@ class LiteralAlternative:
     public RecursiveASTVisitor<LiteralAlternative>, public loplugin::Plugin
 {
 public:
-    explicit LiteralAlternative(ASTContext & context): Plugin(context) {}
+    explicit LiteralAlternative(CompilerInstance & compiler): Plugin(compiler) {}
 
-    virtual void run() { TraverseDecl(context.getTranslationUnitDecl()); }
+    virtual void run() { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
 
     bool VisitCallExpr(CallExpr * expr);
 };
@@ -65,7 +65,7 @@ bool LiteralAlternative::VisitCallExpr(CallExpr * expr) {
         // better to handle that at the level of non-expanded macros instead,
         // but I have not found out how to do that yet anyway):
         APSInt res;
-        if (expr->getArg(1)->isIntegerConstantExpr(res, context)) {
+        if (expr->getArg(1)->isIntegerConstantExpr(res, compiler.getASTContext())) {
             Expr const * arg0 = expr->getArg(0)->IgnoreParenImpCasts();
             StringLiteral const * lit = dyn_cast<StringLiteral>(arg0);
             bool match = false;
@@ -82,7 +82,7 @@ bool LiteralAlternative::VisitCallExpr(CallExpr * expr) {
                             subs->getBase()->IgnoreParenImpCasts());
                         match = lit != nullptr
                             && subs->getIdx()->isIntegerConstantExpr(
-                                res, context)
+                                res, compiler.getASTContext())
                             && res == 0;
                     }
                 }
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index f6c81f5..75d5578 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -20,20 +20,20 @@ Base classes for plugin actions.
 namespace loplugin
 {
 
-Plugin::Plugin( ASTContext& context )
-    : context( context )
+Plugin::Plugin( CompilerInstance& compiler )
+    : compiler( compiler )
     {
     }
 
 DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc )
     {
-    return report( level, message, context, loc );
+    return report( level, message, compiler, loc );
     }
 
-DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, ASTContext& context,
+DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef message, CompilerInstance& compiler,
     SourceLocation loc )
     {
-    DiagnosticsEngine& diag = context.getDiagnostics();
+    DiagnosticsEngine& diag = compiler.getDiagnostics();
 #if 0
     // Do some mappings (e.g. for -Werror) that clang does not do for custom messages for some reason.
     if( level == DiagnosticsEngine::Warning && diag.getWarningsAsErrors())
@@ -50,10 +50,10 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess
 
 bool Plugin::ignoreLocation( SourceLocation loc )
     {
-    SourceLocation expansionLoc = context.getSourceManager().getExpansionLoc( loc );
-    if( context.getSourceManager().isInSystemHeader( expansionLoc ))
+    SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc );
+    if( compiler.getSourceManager().isInSystemHeader( expansionLoc ))
         return true;
-    const char* bufferName = context.getSourceManager().getPresumedLoc( expansionLoc ).getFilename();
+    const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename();
     if( bufferName == NULL )
         return true;
     if( strncmp( bufferName, OUTDIR, strlen( OUTDIR )) == 0
@@ -64,15 +64,15 @@ bool Plugin::ignoreLocation( SourceLocation loc )
     return true;
     }
 
-void Plugin::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter )
+void Plugin::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter )
     {
     PluginHandler::registerPlugin( create, optionName, isRewriter );
     }
 
 /////
 
-RewritePlugin::RewritePlugin( ASTContext& context, Rewriter& rewriter )
-    : Plugin( context )
+RewritePlugin::RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter )
+    : Plugin( compiler )
     , rewriter( rewriter )
     {
     }
diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx
index d30c37a..f564ca4 100644
--- a/compilerplugins/clang/plugin.hxx
+++ b/compilerplugins/clang/plugin.hxx
@@ -17,6 +17,7 @@
 #include <clang/AST/RecursiveASTVisitor.h>
 #include <clang/Basic/FileManager.h>
 #include <clang/Basic/SourceManager.h>
+#include <clang/Frontend/CompilerInstance.h>
 
 #if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
 #include <clang/Rewrite/Rewriter.h>
@@ -40,21 +41,21 @@ namespace loplugin
 class Plugin
     {
     public:
-        explicit Plugin( ASTContext& context );
+        explicit Plugin( CompilerInstance& compiler );
         virtual ~Plugin();
         virtual void run() = 0;
         template< typename T > class Registration;
         DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
         static DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message,
-            ASTContext& context, SourceLocation loc = SourceLocation());
+            CompilerInstance& compiler, SourceLocation loc = SourceLocation());
     protected:
         bool ignoreLocation( SourceLocation loc );
         bool ignoreLocation( const Decl* decl );
         bool ignoreLocation( const Stmt* stmt );
-        ASTContext& context;
+        CompilerInstance& compiler;
     private:
-        static void registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter );
-        template< typename T > static Plugin* createHelper( ASTContext& context, Rewriter& rewriter );
+        static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter );
+        template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter );
         enum { isRewriter = false };
     };
 
@@ -67,7 +68,7 @@ class RewritePlugin
     : public Plugin
     {
     public:
-        explicit RewritePlugin( ASTContext& context, Rewriter& rewriter );
+        explicit RewritePlugin( CompilerInstance& compiler, Rewriter& rewriter );
     protected:
         // This enum allows passing just 'RemoveLineIfEmpty' to functions below.
         enum RemoveLineIfEmpty_t { RemoveLineIfEmpty };
@@ -109,7 +110,7 @@ class RewritePlugin
         Rewriter& rewriter;
     private:
         template< typename T > friend class Plugin::Registration;
-        template< typename T > static Plugin* createHelper( ASTContext& context, Rewriter& rewriter );
+        template< typename T > static Plugin* createHelper( CompilerInstance& compiler, Rewriter& rewriter );
         enum { isRewriter = true };
         bool reportEditFailure( SourceLocation loc );
         bool adjustForWholeStatement( SourceRange* range );
@@ -136,7 +137,7 @@ class Plugin::Registration
 class RegistrationCreate
     {
     public:
-        template< typename T, bool > static T* create( ASTContext& context, Rewriter& rewriter );
+        template< typename T, bool > static T* create( CompilerInstance& compiler, Rewriter& rewriter );
     };
 
 /////
@@ -159,15 +160,15 @@ bool Plugin::ignoreLocation( const Stmt* stmt )
     }
 
 template< typename T >
-Plugin* Plugin::createHelper( ASTContext& context, Rewriter& )
+Plugin* Plugin::createHelper( CompilerInstance& compiler, Rewriter& )
     {
-    return new T( context );
+    return new T( compiler );
     }
 
 template< typename T >
-Plugin* RewritePlugin::createHelper( ASTContext& context, Rewriter& rewriter )
+Plugin* RewritePlugin::createHelper( CompilerInstance& compiler, Rewriter& rewriter )
     {
-    return new T( context, rewriter );
+    return new T( compiler, rewriter );
     }
 
 template< typename T >
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 7fa382c..69b8c04 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -25,7 +25,7 @@ namespace loplugin
 
 struct PluginData
     {
-    Plugin* (*create)( ASTContext&, Rewriter& );
+    Plugin* (*create)( CompilerInstance&, Rewriter& );
     Plugin* object;
     const char* optionName;
     bool isRewriter;
@@ -36,9 +36,9 @@ static PluginData plugins[ MAX_PLUGINS ];
 static int pluginCount = 0;
 static bool pluginObjectsCreated = false;
 
-PluginHandler::PluginHandler( ASTContext& context, const vector< string >& args )
-    : context( context )
-    , rewriter( context.getSourceManager(), context.getLangOpts())
+PluginHandler::PluginHandler( CompilerInstance& compiler, const vector< string >& args )
+    : compiler( compiler )
+    , rewriter( compiler.getSourceManager(), compiler.getLangOpts())
     , scope( "mainfile" )
     {
     bool wasPlugin = false;
@@ -95,11 +95,11 @@ void PluginHandler::createPlugin( const string& name )
         if( name.empty())  // no plugin given -> create non-writer plugins
             {
             if( !plugins[ i ].isRewriter )
-                plugins[ i ].object = plugins[ i ].create( context, rewriter );
+                plugins[ i ].object = plugins[ i ].create( compiler, rewriter );
             }
         else if( plugins[ i ].optionName == name )
             {
-            plugins[ i ].object = plugins[ i ].create( context, rewriter );
+            plugins[ i ].object = plugins[ i ].create( compiler, rewriter );
             return;
             }
         }
@@ -107,7 +107,7 @@ void PluginHandler::createPlugin( const string& name )
         report( DiagnosticsEngine::Fatal, "unknown plugin tool %0" ) << name;
     }
 
-void PluginHandler::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter )
+void PluginHandler::registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter )
     {
     assert( !pluginObjectsCreated );
     assert( pluginCount < MAX_PLUGINS );
@@ -120,7 +120,7 @@ void PluginHandler::registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ),
 
 DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc )
     {
-    return Plugin::report( level, message, context, loc );
+    return Plugin::report( level, message, compiler, loc );
     }
 
 void PluginHandler::HandleTranslationUnit( ASTContext& context )
@@ -218,7 +218,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
 
 ASTConsumer* LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef )
     {
-    return new PluginHandler( Compiler.getASTContext(), _args );
+    return new PluginHandler( Compiler, _args );
     }
 
 bool LibreOfficeAction::ParseArgs( const CompilerInstance&, const vector< string >& args )
diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx
index 0a3251e..fcba582 100644
--- a/compilerplugins/clang/pluginhandler.hxx
+++ b/compilerplugins/clang/pluginhandler.hxx
@@ -26,15 +26,15 @@ class PluginHandler
     : public ASTConsumer
     {
     public:
-        PluginHandler( ASTContext& context, const vector< string >& args );
+        PluginHandler( CompilerInstance& compiler, const vector< string >& args );
         virtual ~PluginHandler();
         virtual void HandleTranslationUnit( ASTContext& context );
-        static void registerPlugin( Plugin* (*create)( ASTContext&, Rewriter& ), const char* optionName, bool isRewriter );
+        static void registerPlugin( Plugin* (*create)( CompilerInstance&, Rewriter& ), const char* optionName, bool isRewriter );
     private:
         void handleOption( const string& option );
         void createPlugin( const string& name );
         DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
-        ASTContext& context;
+        CompilerInstance& compiler;
         Rewriter rewriter;
         string scope;
     };
diff --git a/compilerplugins/clang/postfixincrementfix.cxx b/compilerplugins/clang/postfixincrementfix.cxx
index 6520ee8..0402dec 100644
--- a/compilerplugins/clang/postfixincrementfix.cxx
+++ b/compilerplugins/clang/postfixincrementfix.cxx
@@ -19,14 +19,14 @@ Change all postfix ++ operators of non-trivial types to prefix if possible.
 namespace loplugin
 {
 
-PostfixIncrementFix::PostfixIncrementFix( ASTContext& context, Rewriter& rewriter )
-    : RewritePlugin( context, rewriter )
+PostfixIncrementFix::PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter )
+    : RewritePlugin( compiler, rewriter )
     {
     }
 
 void PostfixIncrementFix::run()
     {
-    TraverseDecl( context.getTranslationUnitDecl());
+    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
     }
 
 bool PostfixIncrementFix::VisitFunctionDecl( FunctionDecl* declaration )
diff --git a/compilerplugins/clang/postfixincrementfix.hxx b/compilerplugins/clang/postfixincrementfix.hxx
index 7edb352..f3afbd7f 100644
--- a/compilerplugins/clang/postfixincrementfix.hxx
+++ b/compilerplugins/clang/postfixincrementfix.hxx
@@ -21,7 +21,7 @@ class PostfixIncrementFix
     , public RewritePlugin
     {
     public:
-        explicit PostfixIncrementFix( ASTContext& context, Rewriter& rewriter );
+        explicit PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter );
         virtual void run();
         bool VisitFunctionDecl( FunctionDecl* declaration );
     private:
diff --git a/compilerplugins/clang/removeforwardstringdecl.cxx b/compilerplugins/clang/removeforwardstringdecl.cxx
index 736cbe3..8350c77 100644
--- a/compilerplugins/clang/removeforwardstringdecl.cxx
+++ b/compilerplugins/clang/removeforwardstringdecl.cxx
@@ -19,14 +19,14 @@ Remove all forward declarations of rtl strings. I.e. 'namespace rtl { class OUSt
 namespace loplugin
 {
 
-RemoveForwardStringDecl::RemoveForwardStringDecl( ASTContext& context, Rewriter& rewriter )
-    : RewritePlugin( context, rewriter )
+RemoveForwardStringDecl::RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter )
+    : RewritePlugin( compiler, rewriter )
     {
     }
 
 void RemoveForwardStringDecl::run()
     {
-    TraverseDecl( context.getTranslationUnitDecl());
+    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
     }
 
 bool RemoveForwardStringDecl::VisitNamespaceDecl( NamespaceDecl* declaration )
diff --git a/compilerplugins/clang/removeforwardstringdecl.hxx b/compilerplugins/clang/removeforwardstringdecl.hxx
index 2b66a52..b57afeb 100644
--- a/compilerplugins/clang/removeforwardstringdecl.hxx
+++ b/compilerplugins/clang/removeforwardstringdecl.hxx
@@ -21,7 +21,7 @@ class RemoveForwardStringDecl
     , public RewritePlugin
     {
     public:
-        explicit RemoveForwardStringDecl( ASTContext& context, Rewriter& rewriter );
+        explicit RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter );
         virtual void run();
         bool VisitNamespaceDecl( NamespaceDecl* declaration );
     private:
diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx
index 2f88905..7ce64bc 100644
--- a/compilerplugins/clang/sallogareas.cxx
+++ b/compilerplugins/clang/sallogareas.cxx
@@ -25,8 +25,8 @@ report if the area is not listed there. The fix is either use a proper area or a
 if appropriate.
 */
 
-SalLogAreas::SalLogAreas( ASTContext& context )
-    : Plugin( context )
+SalLogAreas::SalLogAreas( CompilerInstance& compiler )
+    : Plugin( compiler )
     {
     }
 
@@ -34,7 +34,7 @@ void SalLogAreas::run()
     {
     inFunction = NULL;
     lastSalDetailLogStreamMacro = SourceLocation();
-    TraverseDecl( context.getTranslationUnitDecl());
+    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
     }
 
 bool SalLogAreas::VisitFunctionDecl( FunctionDecl* function )
@@ -59,7 +59,7 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
                 // The SAL_DETAIL_LOG_STREAM macro expands to two calls to sal::detail::log(),
                 // so do not warn repeatedly about the same macro (the area->getLocStart() of all the calls
                 // from the same macro should be the same).
-                SourceLocation expansionLocation = context.getSourceManager().getExpansionLoc( call->getLocStart());
+                SourceLocation expansionLocation = compiler.getSourceManager().getExpansionLoc( call->getLocStart());
                 if( expansionLocation == lastSalDetailLogStreamMacro )
                     return true;
                 lastSalDetailLogStreamMacro = expansionLocation;
@@ -74,14 +74,15 @@ bool SalLogAreas::VisitCallExpr( CallExpr* call )
                     }
                 if( inFunction->getQualifiedNameAsString() == "sal::detail::log" )
                     return true; // This function only forwards to sal_detail_log, so ok.
-                if( call->getArg( 1 )->isNullPointerConstant( context, Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull )
+                if( call->getArg( 1 )->isNullPointerConstant( compiler.getASTContext(),
+                    Expr::NPC_ValueDependentIsNotNull ) != Expr::NPCK_NotNull )
                     { // If the area argument is a null pointer, that is allowed only for SAL_DEBUG.
-                    const SourceManager& source = context.getSourceManager();
+                    const SourceManager& source = compiler.getSourceManager();
                     for( SourceLocation loc = call->getLocStart();
                          loc.isMacroID();
                          loc = source.getImmediateExpansionRange( loc ).first )
                         {
-                        StringRef inMacro = Lexer::getImmediateMacroName( loc, source, context.getLangOpts());
+                        StringRef inMacro = Lexer::getImmediateMacroName( loc, source, compiler.getLangOpts());
                         if( inMacro == "SAL_DEBUG" )
                             return true; // ok
                         }
diff --git a/compilerplugins/clang/sallogareas.hxx b/compilerplugins/clang/sallogareas.hxx
index d572591..4b3e366 100644
--- a/compilerplugins/clang/sallogareas.hxx
+++ b/compilerplugins/clang/sallogareas.hxx
@@ -23,7 +23,7 @@ class SalLogAreas
     , public Plugin
     {
     public:
-        explicit SalLogAreas( ASTContext& context );
+        explicit SalLogAreas( CompilerInstance& compiler );
         virtual void run();
         bool VisitFunctionDecl( FunctionDecl* function );
         bool VisitCallExpr( CallExpr* call );
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index 989269f..c0bf8be 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -30,14 +30,14 @@ SAL_WARN_UNUSED (see e.g. OUString). For external classes such as std::vector
 that cannot be edited there is a manual list below.
 */
 
-UnusedVariableCheck::UnusedVariableCheck( ASTContext& context )
-    : Plugin( context )
+UnusedVariableCheck::UnusedVariableCheck( CompilerInstance& compiler )
+    : Plugin( compiler )
     {
     }
 
 void UnusedVariableCheck::run()
     {
-    TraverseDecl( context.getTranslationUnitDecl());
+    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
     }
 
 bool UnusedVariableCheck::VisitVarDecl( VarDecl* var )
diff --git a/compilerplugins/clang/unusedvariablecheck.hxx b/compilerplugins/clang/unusedvariablecheck.hxx
index 6ccdee3..98df658 100644
--- a/compilerplugins/clang/unusedvariablecheck.hxx
+++ b/compilerplugins/clang/unusedvariablecheck.hxx
@@ -21,7 +21,7 @@ class UnusedVariableCheck
     , public Plugin
     {
     public:
-        explicit UnusedVariableCheck( ASTContext& context );
+        explicit UnusedVariableCheck( CompilerInstance& compiler );
         virtual void run();
         bool VisitVarDecl( VarDecl* var );
     };
commit 9ab15ecc4f162cd6d8ce305f0d7ac064c1e1704c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Mar 21 16:17:07 2013 +0100

    -Wextra for compiler plugins
    
    Change-Id: I246dcf1d2c099c510435d21f0dd47e3c098456f2

diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk
index c762912..ff92ba4f 100644
--- a/compilerplugins/Makefile-clang.mk
+++ b/compilerplugins/Makefile-clang.mk
@@ -11,7 +11,7 @@
 # You may occassionally want to override some of these
 
 # Compile flags ('make CLANGCXXFLAGS=-g' if you need to debug the plugin)
-CLANGCXXFLAGS=-O2 -Wall -g
+CLANGCXXFLAGS=-O2 -Wall -Wextra -g
 
 # The uninteresting rest.
 
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 0d27ff67..7fa382c 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -216,12 +216,12 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
         }
     }
 
-ASTConsumer* LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile )
+ASTConsumer* LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef )
     {
     return new PluginHandler( Compiler.getASTContext(), _args );
     }
 
-bool LibreOfficeAction::ParseArgs( const CompilerInstance& CI, const vector< string >& args )
+bool LibreOfficeAction::ParseArgs( const CompilerInstance&, const vector< string >& args )
     {
     _args = args;
     return true;
diff --git a/compilerplugins/clang/postfixincrementfix.cxx b/compilerplugins/clang/postfixincrementfix.cxx
index 9dac516..6520ee8 100644
--- a/compilerplugins/clang/postfixincrementfix.cxx
+++ b/compilerplugins/clang/postfixincrementfix.cxx
@@ -125,7 +125,7 @@ bool PostfixIncrementFix::canChangePostfixToPrefix( const CXXOperatorCallExpr* o
     }
 
 bool PostfixIncrementFix::canChangeInConditionStatement( const CXXOperatorCallExpr* op, const Expr* condition,
-    const StmtParents& parents, int parent_pos )
+    const StmtParents& parents, unsigned int parent_pos )
     {
     // cannot be changed in condition, can be changed in statements
     if( parent_pos == parents.size() - 1 )
diff --git a/compilerplugins/clang/postfixincrementfix.hxx b/compilerplugins/clang/postfixincrementfix.hxx
index beae8a7..7edb352 100644
--- a/compilerplugins/clang/postfixincrementfix.hxx
+++ b/compilerplugins/clang/postfixincrementfix.hxx
@@ -30,7 +30,7 @@ class PostfixIncrementFix
         void fixPostfixOperators( const Stmt* stmt, StmtParents& parents );
         bool canChangePostfixToPrefix( const CXXOperatorCallExpr* op, StmtParents& parents, int parent_pos );
         bool canChangeInConditionStatement( const CXXOperatorCallExpr* op, const Expr* condition,
-            const StmtParents& parents, int parent_pos );
+            const StmtParents& parents, unsigned int parent_pos );
         bool shouldDoChange( const Expr* op );
     };
 
commit 2716dc0d4231f83fc2e1f3939bdce49c7b171e6c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Mar 20 19:06:12 2013 +0100

    export placeholder (RES_JUMPEDITFLD) to .docx (part of bnc#779630)
    
    Change-Id: Idbf2b1e04eebab703ba3e6c3fac8e50829833c70

diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index a009162..62b80c7 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -568,6 +568,7 @@ protected:
     virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd ) = 0;
     virtual void PostitField( const SwField* pFld ) = 0;
     virtual bool DropdownField( const SwField* pFld ) = 0;
+    virtual bool PlaceholderField( const SwField* pFld ) = 0;
 
     virtual bool AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark );
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index bbe5231..be4f9ed 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -622,6 +622,7 @@ void DocxAttributeOutput::EndRun()
     m_pSerializer->endElementNS( XML_w, XML_r );
 
     WritePostponedMath();
+    WritePendingPlaceholder();
 
     if ( m_closeHyperlinkInThisRun )
     {
@@ -3781,6 +3782,36 @@ bool DocxAttributeOutput::DropdownField( const SwField* pFld )
     return bExpand;
 }
 
+bool DocxAttributeOutput::PlaceholderField( const SwField* pFld )
+{
+    assert( pendingPlaceholder == NULL );
+    pendingPlaceholder = pFld;
+    return false; // do not expand
+}
+
+void DocxAttributeOutput::WritePendingPlaceholder()
+{
+    if( pendingPlaceholder == NULL )
+        return;
+    const SwField* pFld = pendingPlaceholder;
+    pendingPlaceholder = NULL;
+    m_pSerializer->startElementNS( XML_w, XML_sdt, FSEND );
+    m_pSerializer->startElementNS( XML_w, XML_sdtPr, FSEND );
+    if( !pFld->GetPar2().isEmpty())
+        m_pSerializer->singleElementNS( XML_w, XML_alias,
+            FSNS( XML_w, XML_val ), OUStringToOString( pFld->GetPar2(), RTL_TEXTENCODING_UTF8 ), FSEND );
+    m_pSerializer->singleElementNS( XML_w, XML_temporary, FSEND );
+    m_pSerializer->singleElementNS( XML_w, XML_showingPlcHdr, FSEND );
+    m_pSerializer->singleElementNS( XML_w, XML_text, FSEND );
+    m_pSerializer->endElementNS( XML_w, XML_sdtPr );
+    m_pSerializer->startElementNS( XML_w, XML_sdtContent, FSEND );
+    m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+    RunText( pFld->GetPar1());
+    m_pSerializer->endElementNS( XML_w, XML_r );
+    m_pSerializer->endElementNS( XML_w, XML_sdtContent );
+    m_pSerializer->endElementNS( XML_w, XML_sdt );
+}
+
 void DocxAttributeOutput::SetField( const SwField& rFld, ww::eField eType, const String& rCmd )
 {
     // field bookmarks are handled in the EndRun method
@@ -4834,6 +4865,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_startedHyperlink( false ),
       m_postponedGraphic( NULL ),
       m_postponedMath( NULL ),
+      pendingPlaceholder( NULL ),
       m_postitFieldsMaxId( 0 ),
       m_anchorId( 0 ),
       m_nextFontId( 1 ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 94edd1b..8689d53 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -326,6 +326,7 @@ private:
     void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph = false );
 
     void WriteFFData( const FieldInfos& rInfos );
+    void WritePendingPlaceholder();
 
     void EmbedFontStyle( const OUString& name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
         FontPitch pitch, rtl_TextEncoding encoding );
@@ -532,6 +533,7 @@ protected:
     virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd );
     virtual void PostitField( const SwField* pFld );
     virtual bool DropdownField( const SwField* pFld );
+    virtual bool PlaceholderField( const SwField* pFld );
 
     virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark );
 
@@ -627,6 +629,7 @@ private:
     };
     std::list< PostponedGraphic >* m_postponedGraphic;
     const SwOLENode* m_postponedMath;
+    const SwField* pendingPlaceholder;
     std::vector< const SwPostItField* > m_postitFields;
     unsigned int m_postitFieldsMaxId;
     int m_anchorId;
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 6d9320e..47ad371 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3074,6 +3074,11 @@ bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
     return true;
 }
 
+bool RtfAttributeOutput::PlaceholderField( const SwField* )
+{
+    return true; // expand to text?
+}
+
 RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
     : m_rExport( rExport ),
     m_bStrikeDouble( false ),
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 83fb58c..fb40139 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -407,6 +407,7 @@ protected:
     virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd );
     virtual void PostitField( const SwField* pFld );
     virtual bool DropdownField( const SwField* pFld );
+    virtual bool PlaceholderField( const SwField* pFld );
 
     /// Reference to the export, where to get the data from
     RtfExport &m_rExport;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 4f9161f..fe01be8 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2473,6 +2473,11 @@ bool WW8AttributeOutput::DropdownField( const SwField* pFld )
     return bExpand;
 }
 
+bool WW8AttributeOutput::PlaceholderField( const SwField* )
+{
+    return true; // expand to text?
+}
+
 void WW8AttributeOutput::RefField( const SwField &rFld, const String &rRef)
 {
     String sStr( FieldString( ww::eREF ) );
@@ -2922,7 +2927,7 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
             }
         }
         break;
-        case RES_HIDDENTXTFLD:
+    case RES_HIDDENTXTFLD:
         {
             String sExpand(pFld->GetPar2());
             if (sExpand.Len())
@@ -2931,6 +2936,9 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
             }
         }
         break;
+    case RES_JUMPEDITFLD:
+        bWriteExpand = PlaceholderField( pFld );
+        break;
     default:
         bWriteExpand = true;
         break;
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 1ebceed..4c64635 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -391,6 +391,7 @@ protected:
     virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd );
     virtual void PostitField( const SwField* pFld );
     virtual bool DropdownField( const SwField* pFld );
+    virtual bool PlaceholderField( const SwField* pFld );
 
     virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark );
 


More information about the Libreoffice-commits mailing list