[Libreoffice-commits] core.git: compilerplugins/clang config_host.mk.in configure.ac solenv/gbuild

Stephan Bergmann sbergman at redhat.com
Fri Dec 8 20:11:52 UTC 2017


 compilerplugins/clang/plugin.cxx        |   11 +++++++++++
 compilerplugins/clang/plugin.hxx        |    2 ++
 compilerplugins/clang/pluginhandler.cxx |    2 ++
 compilerplugins/clang/pluginhandler.hxx |    2 ++
 config_host.mk.in                       |    1 +
 configure.ac                            |    9 ++++++++-
 solenv/gbuild/platform/com_GCC_defs.mk  |    3 +++
 solenv/gbuild/platform/com_MSC_defs.mk  |    3 +++
 8 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 32c31c03d07219522426fe83d8b17d03ee0154a1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Dec 8 16:31:34 2017 +0100

    New --enable-compiler-plugins=debug mode
    
    ...to enable debug-only code in the plugins.  Some situations in the plugin code
    should never happen, yet must not by default report errors or trigger
    assertions, as some newly written LO code could trigger them nevertheless (in
    which case the plugin code will likely need to be adapted, to cater for these
    presumed-impossible situations).
    
    Such code can now be included in the plugins behind an if(isDebugMode()) guard,
    and can explicitly be enabled with --enable-compiler-plugins=debug.
    
    I deliberately made this a runtime rather than a compile time option (using
    some #ifdef guards in the plugin code, say), as it IMO keeps the code more
    readable, and also allows overridding COMPILER_PLUGINS_DEBUG=... on the make
    command line.
    
    Change-Id: Iea4f0c2783ad968a0de097fa710b3be1a248de73
    Reviewed-on: https://gerrit.libreoffice.org/46096
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx
index 3c716112cd47..e43cec4eb998 100644
--- a/compilerplugins/clang/plugin.cxx
+++ b/compilerplugins/clang/plugin.cxx
@@ -370,6 +370,17 @@ Plugin::IdenticalDefaultArgumentsResult Plugin::checkIdenticalDefaultArguments(
     if (structurallyIdentical(argument1, argument2)) {
         return IdenticalDefaultArgumentsResult::Yes;
     }
+    if (isDebugMode()) {
+        report(
+            DiagnosticsEngine::Fatal, "TODO: Unexpected 'IdenticalDefaultArgumentsResult::Maybe'",
+            argument1->getExprLoc())
+            << argument1->getSourceRange();
+        report(
+            DiagnosticsEngine::Note, "TODO: second argument is here", argument2->getExprLoc())
+            << argument2->getSourceRange();
+        argument1->dump();
+        argument2->dump();
+    }
     return IdenticalDefaultArgumentsResult::Maybe;
 }
 
diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx
index 02897031cd7b..4560157e4afd 100644
--- a/compilerplugins/clang/plugin.hxx
+++ b/compilerplugins/clang/plugin.hxx
@@ -78,6 +78,8 @@ protected:
     bool isInUnoIncludeFile(SourceLocation spellingLocation) const;
     bool isInUnoIncludeFile(const FunctionDecl*) const;
 
+    bool isDebugMode() const { return handler.isDebugMode(); }
+
     static bool isUnitTestMode();
 
     bool containsPreprocessingConditionalInclusion(SourceRange range);
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index ff1c6b6922cb..1740a5d05486 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -113,6 +113,8 @@ void PluginHandler::handleOption( const std::string& option )
         warningsAsErrors = true;
     else if( option == "unit-test-mode" )
         unitTestMode = true;
+    else if (option == "debug")
+        debugMode = true;
     else
         report( DiagnosticsEngine::Fatal, "unknown option %0" ) << option;
 }
diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx
index bd49f7cfeb5e..2befaf7fc6a8 100644
--- a/compilerplugins/clang/pluginhandler.hxx
+++ b/compilerplugins/clang/pluginhandler.hxx
@@ -55,6 +55,7 @@ public:
             CompilerInstance& compiler, SourceLocation loc = SourceLocation());
     bool ignoreLocation(SourceLocation loc);
     bool addRemoval( SourceLocation loc );
+    bool isDebugMode() const { return debugMode; }
     static bool isUnitTestMode();
 private:
     void handleOption( const std::string& option );
@@ -69,6 +70,7 @@ private:
     std::string scope;
     std::string warningsOnly;
     bool warningsAsErrors;
+    bool debugMode = false;
 };
 
 /**
diff --git a/config_host.mk.in b/config_host.mk.in
index 5a71f572258b..648212d00b0d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -72,6 +72,7 @@ export COMPATH=@COMPATH@
 export COMPILER_PLUGINS=@COMPILER_PLUGINS@
 export COMPILER_PLUGINS_CXX=@COMPILER_PLUGINS_CXX@
 export COMPILER_PLUGINS_CXX_LINKFLAGS=@COMPILER_PLUGINS_CXX_LINKFLAGS@
+export COMPILER_PLUGINS_DEBUG=@COMPILER_PLUGINS_DEBUG@
 export COM_IS_CLANG=@COM_IS_CLANG@
 export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@
 export CPPUNIT_LIBS=$(gb_SPACE)@CPPUNIT_LIBS@
diff --git a/configure.ac b/configure.ac
index 56d7a9454e2f..e216e5fd9617 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1102,7 +1102,13 @@ AC_ARG_WITH(valgrind,
 libo_FUZZ_ARG_ENABLE(compiler-plugins,
     AS_HELP_STRING([--enable-compiler-plugins],
         [Enable compiler plugins that will perform additional checks during
-         building. Enabled automatically by --enable-dbgutil.]))
+         building. Enabled automatically by --enable-dbgutil.
+         Use --enable-compiler-plugins=debug to also enable debug code in the plugins.]))
+COMPILER_PLUGINS_DEBUG=
+if test "$enable_compiler_plugins" = debug; then
+    enable_compiler_plugins=yes
+    COMPILER_PLUGINS_DEBUG=TRUE
+fi
 
 libo_FUZZ_ARG_ENABLE(ooenv,
     AS_HELP_STRING([--disable-ooenv],
@@ -6474,6 +6480,7 @@ fi
 AC_SUBST(COMPILER_PLUGINS)
 AC_SUBST(COMPILER_PLUGINS_CXX)
 AC_SUBST(COMPILER_PLUGINS_CXX_LINKFLAGS)
+AC_SUBST(COMPILER_PLUGINS_DEBUG)
 AC_SUBST(CLANGDIR)
 AC_SUBST(CLANGLIBDIR)
 
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index 11b7871a3e6f..e1082c952528 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -210,6 +210,9 @@ ifneq ($(UPDATE_FILES),)
 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
 endif
 endif
+ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
+gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
+endif
 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
 gb_COMPILER_SETUP := CCACHE_CPP2=1
 gb_COMPILER_PLUGINS_SETUP := ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox CCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox
diff --git a/solenv/gbuild/platform/com_MSC_defs.mk b/solenv/gbuild/platform/com_MSC_defs.mk
index 2925315da324..507264e1db89 100644
--- a/solenv/gbuild/platform/com_MSC_defs.mk
+++ b/solenv/gbuild/platform/com_MSC_defs.mk
@@ -316,6 +316,9 @@ ifneq ($(UPDATE_FILES),)
 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
 endif
 endif
+ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
+gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
+endif
 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
     -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
 else


More information about the Libreoffice-commits mailing list