Kaydet (Commit) 32c31c03 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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/46096Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 39854837
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
};
/**
......
......@@ -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@
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment