[Libreoffice-commits] core.git: compilerplugins/clang solenv/gbuild
compilerplugins/clang/plugin.cxx |6 ++ solenv/gbuild/platform/com_GCC_defs.mk |2 +- 2 files changed, 7 insertions(+), 1 deletion(-) New commits: commit 473f2dec087288309cb169bf84c12124e1d7d7d1 Author: Michael Stahl AuthorDate: Sun Mar 14 21:34:03 2021 +0100 Commit: Michael Stahl CommitDate: Thu Mar 25 09:48:23 2021 +0100 compilerplugins: fix clang plugin allowlists for sccache-dist While icecream passes preprocessed (via -frewrite-includes) input to the compiler on stdin, sccache-dist writes it to a file at the same location as the source file in its sandbox. So we need a new heuristic to detect that the input has -frewrite-includes applied; there is not any variable that sccache sets, users could have SCCACHE_CACHE_SIZE set but only if they use the disk cache, so check CXX for now. Also set SCCACHE_EXTRAFILES to include log-areas.dox required by plugin. Change-Id: I4e00bfb0db7dab28f228fc0e85d753506e2c86b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112480 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 753c548cf252..c68eceb67c32 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -251,6 +251,12 @@ StringRef Plugin::getFilenameOfLocation(SourceLocation spellingLocation) const } else { +char const*const pCXX = getenv("CXX"); +if (pCXX && strstr(pCXX, "sccache")) +{ // heuristic; sccache passes file with -frewrite-directives by name +s_Mode = STDIN; +return getFilenameOfLocation(spellingLocation); +} auto const fn(compiler.getSourceManager().getFilename(spellingLocation)); if (!fn.data()) // wtf? happens in sot/source/sdstor/stg.cxx { diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index 876d57ab6fa2..e07bd2824ff5 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -254,7 +254,7 @@ 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 +gb_COMPILER_PLUGINS_SETUP := ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox CCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox SCCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \ -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors else ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: compilerplugins/clang solenv/gbuild
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 GrandinDate: 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
[Libreoffice-commits] core.git: compilerplugins/clang solenv/gbuild
compilerplugins/clang/pluginhandler.cxx |6 ++ solenv/gbuild/LinkTarget.mk | 79 solenv/gbuild/platform/com_GCC_class.mk | 74 - 3 files changed, 85 insertions(+), 74 deletions(-) New commits: commit 38da1ed9195578aed4edb9d3c9c9eb2587923658 Author: Stephan BergmannDate: Fri Jan 27 10:46:15 2017 +0100 Make plugin rewriting work on Windows too ...in a somewhat hacked-up way for now (see the TODO comment) Change-Id: Ida89fb8257b876cfca05b3048ce15996091c5703 diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx index b46079bb1..b6e45c8 100644 --- a/compilerplugins/clang/pluginhandler.cxx +++ b/compilerplugins/clang/pluginhandler.cxx @@ -191,6 +191,11 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) if( plugins[ i ].object != NULL ) plugins[ i ].object->run(); } +#if defined _WIN32 +//TODO: make the call to 'rename' work on Windows (where the renamed-to +// original file is probably still held open somehow): +rewriter.overwriteChangedFiles(); +#else for( Rewriter::buffer_iterator it = rewriter.buffer_begin(); it != rewriter.buffer_end(); ++it ) @@ -256,6 +261,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context ) report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1)" ) << modifyFile << error; delete[] filename; } +#endif } #if CLANG_VERSION >= 30600 diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk index 3b9a0d5..ca1f5ad 100644 --- a/solenv/gbuild/LinkTarget.mk +++ b/solenv/gbuild/LinkTarget.mk @@ -73,6 +73,85 @@ gb_LinkTarget_LAYER_LINKPATHS := \ NONE:URELIB+OOO+NONE. \ +# Used to run a compiler plugin tool. +# +# At least for now, these definitions are generic enough so that they can be +# shared across all current use cases (COMPILER_EXTERNAL_TOOL, +# COMPILER_PLUGIN_TOOL) on all relevant toolchains (GCC?, Clang, clang-cl). If +# it ever becomes necessary, they can be moved to e.g. +# platform/com_{GCC,MSC}_class.mk and made different there. +# +# $(call gb_CObject__tool_command,relative-source,source) +define gb_CObject__tool_command +$(call gb_Output_announce,$(1).c,$(true),C ,3) +$(call gb_Helper_abbreviate_dirs,\ +ICECC=no CCACHE_DISABLE=1 \ + $(gb_CC) \ + $(DEFS) \ + $(gb_LTOFLAGS) \ + $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \ + $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \ + $(gb_COMPILER_PLUGINS) \ + $(T_CFLAGS) $(T_CFLAGS_APPEND) \ + $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \ + -c $(2) \ + -I$(dir $(2)) \ + $(INCLUDE) \ + ) +endef +define gb_ObjCObject__tool_command +$(call gb_Output_announce,$(1).m,$(true),OCC,3) +$(call gb_Helper_abbreviate_dirs,\ +ICECC=no CCACHE_DISABLE=1 \ + $(gb_CC) \ + $(DEFS) \ + $(gb_LTOFLAGS) \ + $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \ + $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \ + $(gb_COMPILER_PLUGINS) \ + $(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND) \ + $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \ + -c $(2) \ + -I$(dir $(2)) \ + $(INCLUDE) \ + ) +endef +define gb_CxxObject__tool_command +$(call gb_Output_announce,$(1).cxx,$(true),CXX,3) +$(call gb_Helper_abbreviate_dirs,\ +ICECC=no CCACHE_DISABLE=1 \ + $(gb_CXX) \ + $(DEFS) \ + $(gb_LTOFLAGS) \ + $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \ + $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \ + $(gb_COMPILER_PLUGINS) \ + $(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \ + $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \ + -c $(2) \ + -I$(dir $(2)) \ + $(INCLUDE) \ + ) +endef +define gb_ObjCxxObject__tool_command +$(call gb_Output_announce,$(1).mm,$(true),OCX,3) +$(call gb_Helper_abbreviate_dirs,\ +ICECC=no CCACHE_DISABLE=1 \ + $(gb_CXX) \ + $(DEFS) \ + $(gb_LTOFLAGS) \ + $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \ + $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if
[Libreoffice-commits] core.git: compilerplugins/clang solenv/gbuild
compilerplugins/clang/sallogareas.cxx |6 +++--- solenv/gbuild/platform/com_GCC_defs.mk |2 +- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit 294ad90704b7b19aa64c26bfa83442a96a31e57b Author: Tor Lillqvist t...@iki.fi Date: Wed Apr 24 11:42:09 2013 +0300 Update location of log-areas.dox Change-Id: If54a3d7047f13ae9c9345c21737a89afee645403 diff --git a/compilerplugins/clang/sallogareas.cxx b/compilerplugins/clang/sallogareas.cxx index 7ce64bc..0724ca7 100644 --- a/compilerplugins/clang/sallogareas.cxx +++ b/compilerplugins/clang/sallogareas.cxx @@ -20,7 +20,7 @@ namespace loplugin /* This is a compile check. -Check area used in SAL_INFO/SAL_WARN macros against the list in sal/inc/sal/log-areas.dox and +Check area used in SAL_INFO/SAL_WARN macros against the list in include/sal/log-areas.dox and report if the area is not listed there. The fix is either use a proper area or add it to the list if appropriate. */ @@ -104,14 +104,14 @@ void SalLogAreas::checkArea( StringRef area, SourceLocation location ) readLogAreas(); if( !logAreas.count( area )) { -report( DiagnosticsEngine::Warning, unknown log area '%0' (check or extend sal/inc/sal/log-areas.dox), +report( DiagnosticsEngine::Warning, unknown log area '%0' (check or extend include/sal/log-areas.dox), location ) area; } } void SalLogAreas::readLogAreas() { -ifstream is( SRCDIR /sal/inc/sal/log-areas.dox ); +ifstream is( SRCDIR /include/sal/log-areas.dox ); while( is.good()) { string line; diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index f0c7c44..e6c2ee6 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -163,7 +163,7 @@ gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FIL endif endif # extra EF variable to make the command line shorter (just like is done with $(SRCDIR) etc.) -gb_COMPILER_PLUGINS_SETUP := EF=$(SRCDIR)/sal/inc/sal/log-areas.dox ICECC_EXTRAFILES=$$EF CCACHE_EXTRAFILES=$$EF +gb_COMPILER_PLUGINS_SETUP := EF=$(SRCDIR)/include/sal/log-areas.dox ICECC_EXTRAFILES=$$EF CCACHE_EXTRAFILES=$$EF else gb_COMPILER_PLUGINS := gb_COMPILER_PLUGINS_SETUP := ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits