From 314f15bff08b76bf96acf99141776ef64d2f1355 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 16 Nov 2019 21:00:53 +0100 Subject: Extend loplugin:external to warn about enums To mitigate the dangers of silently breaking ADL when moving enums into unnamed namespaces (see the commit message of 206b5b2661be37efdff3c6aedb6f248c4636be79 "New loplugin:external"), note all functions that are affected. (The plan is to extend loplugin:external further to also warn about classes and class templates, and the code to identify affected functions already takes that into account, so some parts of that code are not actually relevant for enums.) But it appears that none of the functions that are actually affected by the changes in this commit relied on being found through ADL, so no adaptions were necessary for them. (clang::DeclContext::collectAllContexts is non-const, which recursively means that External's Visit... functions must take non-const Decl*. Which required compilerplugins/clang/sharedvisitor/analyzer.cxx to be generalized to support such Visit... functions with non-const Decl* parameters.) Change-Id: Ia215291402bf850d43defdab3cff4db5b270d1bd Reviewed-on: https://gerrit.libreoffice.org/83001 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- svtools/source/config/helpopt.cxx | 3 ++- svtools/source/config/htmlcfg.cxx | 5 +++++ svtools/source/control/ctrltool.cxx | 5 +++++ svtools/source/svhtml/parhtml.cxx | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx index 07834d8bf76c..1137caaef436 100644 --- a/svtools/source/config/helpopt.cxx +++ b/svtools/source/config/helpopt.cxx @@ -38,7 +38,6 @@ using namespace com::sun::star; namespace { //global std::weak_ptr g_pHelpOptions; -} enum class HelpProperty { @@ -50,6 +49,8 @@ enum class HelpProperty OfflineHelpPopUp = 5 }; +} + class SvtHelpOptions_Impl : public utl::ConfigItem { bool bExtendedHelp; diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx index ed8fbfe49f96..fbd7f57e282f 100644 --- a/svtools/source/config/htmlcfg.cxx +++ b/svtools/source/config/htmlcfg.cxx @@ -29,6 +29,8 @@ #include #include +namespace { + enum class HtmlCfgFlags { NONE = 0x000, UnknownTags = 0x001, @@ -39,6 +41,9 @@ enum class HtmlCfgFlags { IsBasicWarning = 0x080, NumbersEnglishUS = 0x100, }; + +} + namespace o3tl { template<> struct typed_flags : is_typed_flags {}; } diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index 2ba347bf73d9..957e153e916a 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -89,12 +89,17 @@ public: OutputDevice* GetDevice() const { return mpDevice; } }; +namespace { + enum class FontListFontNameType { NONE = 0x00, PRINTER = 0x01, SCREEN = 0x02, }; + +} + namespace o3tl { template<> struct typed_flags : is_typed_flags {}; diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 6ce236566e61..523ed4fb28e4 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -1894,6 +1894,8 @@ bool HTMLParser::InternalImgToPrivateURL( OUString& rURL ) return bFound; } +namespace { + enum class HtmlMeta { NONE = 0, Author, @@ -1910,6 +1912,8 @@ enum class HtmlMeta { ContentType }; +} + // static HTMLOptionEnum const aHTMLMetaNameTable[] = { -- cgit