compilerplugins/clang/pluginhandler.cxx        |   20 +++++++++++++-------
 compilerplugins/clang/pluginhandler.hxx        |    1 +
 compilerplugins/clang/test/finalprotected.cxx  |   12 ++++++------
 compilerplugins/clang/test/passstuffbyref.cxx  |    4 +++-
 compilerplugins/clang/test/redundantinline.hxx |    2 +-
 compilerplugins/clang/test/stringconstant.cxx  |    2 +-
 compilerplugins/clang/test/useuniqueptr.cxx    |    2 +-
 compilerplugins/clang/test/vclwidgets.cxx      |    8 ++++----
 solenv/gbuild/LinkTarget.mk                    |    2 +-
 solenv/gbuild/platform/com_GCC_defs.mk         |    2 ++
 10 files changed, 33 insertions(+), 22 deletions(-)

New commits:
commit 45c06838e95c94445359536d84c6328fa8b17a66
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Jun 19 09:00:59 2017 +0200

    only unit-test one loplugin at a time
    
    tell the plugin code when we are unit-testing it, so we can suppress all
    the warnings except for the plugin we are currently testing
    
    Change-Id: I240c8e37eba90c219e53c29531a3a43bc841a1c8

diff --git a/compilerplugins/clang/pluginhandler.cxx 
b/compilerplugins/clang/pluginhandler.cxx
index cc9ea891ceac..ad043e87e58d 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -62,16 +62,15 @@ PluginHandler::PluginHandler( CompilerInstance& compiler, 
const vector< string >
     , rewriter( compiler.getSourceManager(), compiler.getLangOpts())
     , scope( "mainfile" )
     , warningsAsErrors( false )
+    , unitTestMode( false )
     {
     set< string > rewriters;
-    for( vector< string >::const_iterator it = args.begin();
-         it != args.end();
-         ++it )
+    for( string const & arg : args )
         {
-        if( it->size() >= 2 && (*it)[ 0 ] == '-' && (*it)[ 1 ] == '-' )
-            handleOption( it->substr( 2 ));
+        if( arg.size() >= 2 && arg[ 0 ] == '-' && arg[ 1 ] == '-' )
+            handleOption( arg.substr( 2 ));
         else
-            rewriters.insert( *it );
+            rewriters.insert( arg );
         }
     createPlugins( rewriters );
     bPluginObjectsCreated = true;
@@ -110,6 +109,8 @@ void PluginHandler::handleOption( const string& option )
         }
     else if( option == "warnings-as-errors" )
         warningsAsErrors = true;
+    else if( option == "unit-test-mode" )
+        unitTestMode = true;
     else
         report( DiagnosticsEngine::Fatal, "unknown option %0" ) << option;
     }
@@ -190,7 +191,12 @@ void PluginHandler::HandleTranslationUnit( ASTContext& 
context )
          ++i )
         {
         if( plugins[ i ].object != NULL )
-            plugins[ i ].object->run();
+            {
+            // When in unit-test mode, ignore plugins whose names don't match 
the filename of the test,
+            // so that we only generate warnings for the plugin that we want 
to test.
+            if (!unitTestMode || mainFileName.find(plugins[ i ].optionName) != 
StringRef::npos)
+                plugins[ i ].object->run();
+            }
         }
 #if defined _WIN32
     //TODO: make the call to 'rename' work on Windows (where the renamed-to
diff --git a/compilerplugins/clang/pluginhandler.hxx 
b/compilerplugins/clang/pluginhandler.hxx
index 3d5f6c82e3d9..a2cc136f5751 100644
--- a/compilerplugins/clang/pluginhandler.hxx
+++ b/compilerplugins/clang/pluginhandler.hxx
@@ -47,6 +47,7 @@ class PluginHandler
         string scope;
         string warningsOnly;
         bool warningsAsErrors;
+        bool unitTestMode;
     };
 
 /**
diff --git a/compilerplugins/clang/test/finalprotected.cxx 
b/compilerplugins/clang/test/finalprotected.cxx
index 99fb19584a8d..c15564874447 100644
--- a/compilerplugins/clang/test/finalprotected.cxx
+++ b/compilerplugins/clang/test/finalprotected.cxx
@@ -10,25 +10,25 @@
 
 class S final {
 protected:
-    void f(int f) { f1 = f; }  // expected-error {{final class should not have 
protected members - convert them to private [loplugin:finalprotected]}} 
expected-error {{[loplugin:unreffun]}}
+    void f(int f) { f1 = f; }  // expected-error {{final class should not have 
protected members - convert them to private [loplugin:finalprotected]}}
     int f1;      // expected-error {{final class should not have protected 
members - convert them to private [loplugin:finalprotected]}}
 public:
-    void g();    // expected-error {{[loplugin:externandnotdefined]}} 
expected-error {{[loplugin:unreffun]}}
+    void g();
     int g1;
 private:
-    void h();    // expected-error {{[loplugin:externandnotdefined]}} 
expected-error {{[loplugin:unreffun]}}
+    void h();
     int h1;
 };
 
 class S2 {
 protected:
-    void f(int f) { f1 = f; } // expected-error {{[loplugin:unreffun]}}
+    void f(int f) { f1 = f; }
     int f1;
 public:
-    void g();    // expected-error {{[loplugin:externandnotdefined]}} 
expected-error {{[loplugin:unreffun]}}
+    void g();
     int g1;
 private:
-    void h();    // expected-error {{[loplugin:externandnotdefined]}} 
expected-error {{[loplugin:unreffun]}}
+    void h();
     int h1;
 };
 
diff --git a/compilerplugins/clang/test/passstuffbyref.cxx 
b/compilerplugins/clang/test/passstuffbyref.cxx
index 7c31af77df77..89f51fb1c294 100644
--- a/compilerplugins/clang/test/passstuffbyref.cxx
+++ b/compilerplugins/clang/test/passstuffbyref.cxx
@@ -19,11 +19,13 @@ struct S {
 };
 
 
-void f() // expected-error {{Unreferenced externally visible function 
definition [loplugin:unreffun]}}
+void f()
 {
     S* s;
     OUString v1, v2;
     s = new S(v1, v2);
 }
 
+// expected-no-diagnostics
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/redundantinline.hxx 
b/compilerplugins/clang/test/redundantinline.hxx
index a0c91ceb67be..e4efc5663e42 100644
--- a/compilerplugins/clang/test/redundantinline.hxx
+++ b/compilerplugins/clang/test/redundantinline.hxx
@@ -19,7 +19,7 @@ S1::S1() = default;
 
 struct S2 {
     inline S2() = default; // expected-error {{[loplugin:redundantinline]}}
-    inline ~S2() = default; // expected-error {{[loplugin:redundantinline]}} 
expected-error {{[loplugin:unnecessaryoverride]}}
+    inline ~S2() = default; // expected-error {{[loplugin:redundantinline]}}
 };
 
 struct S3 {
diff --git a/compilerplugins/clang/test/stringconstant.cxx 
b/compilerplugins/clang/test/stringconstant.cxx
index 392567fa3cab..1b1eca2794bb 100644
--- a/compilerplugins/clang/test/stringconstant.cxx
+++ b/compilerplugins/clang/test/stringconstant.cxx
@@ -14,7 +14,7 @@
 #include "com/sun/star/uno/Reference.hxx"
 #include "rtl/strbuf.hxx"
 
-extern void foo(OUString const &); // expected-error {{extern prototype in 
main file without definition}}
+extern void foo(OUString const &);
 
 struct Foo {
     Foo(OUString const &, int) {}
diff --git a/compilerplugins/clang/test/useuniqueptr.cxx 
b/compilerplugins/clang/test/useuniqueptr.cxx
index c705bbf0f158..564e93ccbdc0 100644
--- a/compilerplugins/clang/test/useuniqueptr.cxx
+++ b/compilerplugins/clang/test/useuniqueptr.cxx
@@ -10,7 +10,7 @@
 
 class Foo {
     char* m_pbar; // expected-note {{member is here [loplugin:useuniqueptr]}}
-    ~Foo() // expected-error {{Unreferenced externally visible function 
definition [loplugin:unreffun]}}
+    ~Foo()
     {
         delete m_pbar; // expected-error {{a destructor with only a single 
unconditional call to delete on a member, is a sure sign it should be using 
std::unique_ptr for that field [loplugin:useuniqueptr]}}
         m_pbar = nullptr;
diff --git a/compilerplugins/clang/test/vclwidgets.cxx 
b/compilerplugins/clang/test/vclwidgets.cxx
index d7926c0c4e98..9ead1c905289 100644
--- a/compilerplugins/clang/test/vclwidgets.cxx
+++ b/compilerplugins/clang/test/vclwidgets.cxx
@@ -16,7 +16,7 @@ struct Widget : public VclReferenceBase
 {
     VclPtr<Widget> mpParent;
 
-    void widget1() // expected-error {{Unreferenced externally visible 
function definition [loplugin:unreffun]}}
+    void widget1()
     {
         // test that we ignore assignments from a member field
         Widget* p = mpParent;
@@ -48,7 +48,7 @@ Widget* g()
 }
 
 // test the variable init detection
-void bar() // expected-error {{Unreferenced externally visible function 
definition [loplugin:unreffun]}}
+void bar()
 {
     Widget* p = f(); // expected-error {{assigning a returned-by-value 
VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you 
know that the RHS does not return a newly created T, then add a '.get()' to the 
RHS [loplugin:vclwidgets]}}
     (void)p;
@@ -59,7 +59,7 @@ void bar() // expected-error {{Unreferenced externally 
visible function definiti
 }
 
 // test the assignment detection
-void bar2() // expected-error {{Unreferenced externally visible function 
definition [loplugin:unreffun]}}
+void bar2()
 {
     Widget* p;
     p = nullptr;
@@ -76,7 +76,7 @@ void bar2() // expected-error {{Unreferenced externally 
visible function definit
 template<class T>
 T * get() { return nullptr; }
 
-void bar3() // expected-error {{Unreferenced externally visible function 
definition [loplugin:unreffun]}}
+void bar3()
 {
     Widget* p;
     p = get<Widget>();
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 4ef1bf954965..0ce457380c15 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -287,7 +287,7 @@ else
 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
        $(call gb_Output_announce,$*.cxx,$(true),$(if 
$(COMPILER_TEST),CPT,CXX),3)
        $(eval $(gb_CxxObject__set_pchflags))
-       $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) 
$(T_CXXFLAGS_APPEND),$<,$(call 
gb_CxxObject_get_dep_target,$*),$(COMPILER_PLUGINS))
+       $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) 
$(T_CXXFLAGS_APPEND) $(if $(COMPILER_TEST),$(gb_COMPILER_TEST_FLAGS)),$<,$(call 
gb_CxxObject_get_dep_target,$*),$(COMPILER_PLUGINS))
 endif
 
 ifeq ($(gb_FULLDEPS),$(true))
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk 
b/solenv/gbuild/platform/com_GCC_defs.mk
index 19d44df64e39..97a2538b1895 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -191,6 +191,7 @@ gb_LinkTarget_INCLUDE :=\
     -I$(BUILDDIR)/config_$(gb_Side) \
 
 ifeq ($(COM_IS_CLANG),TRUE)
+gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
 ifeq ($(COMPILER_PLUGIN_TOOL),)
 gb_COMPILER_PLUGINS := -Xclang -load -Xclang 
$(BUILDDIR)/compilerplugins/obj/plugin.so -Xclang -add-plugin -Xclang loplugin
 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
@@ -209,6 +210,7 @@ gb_COMPILER_PLUGINS_SETUP := 
ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.do
 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
     -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
 else
+gb_COMPILER_TEST_FLAGS :=
 gb_COMPILER_SETUP :=
 gb_COMPILER_PLUGINS :=
 gb_COMPILER_PLUGINS_SETUP :=
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to