diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-12-08 16:31:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-12-08 21:09:39 +0100 |
commit | 32c31c03d07219522426fe83d8b17d03ee0154a1 (patch) | |
tree | 42f7de5211b51611c83dc1a3602e2f1e7cbb8049 /compilerplugins | |
parent | 39854837073158555ee26bee9254d1e5ac36a215 (diff) |
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@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 11 | ||||
-rw-r--r-- | compilerplugins/clang/plugin.hxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/pluginhandler.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/pluginhandler.hxx | 2 |
4 files changed, 17 insertions, 0 deletions
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; }; /** |