[Libreoffice-commits] core.git: cppcheck style fix for noExplicitConstructor in writerfilter

Stephan Bergmann sbergman at redhat.com
Mon Dec 5 09:58:10 UTC 2016


On 12/03/2016 07:10 PM, Jochen Nitschke wrote:
> commit 76936e787bd13fb1a747b7c716df3fba2d0d3fa9
> Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
> Date:   Sat Dec 3 13:39:44 2016 +0100
>
>     cppcheck style fix for noExplicitConstructor in writerfilter
>
>     make ctors with one parameter explicit

Seeing this and similar commits mentioning "cppcheck" and 
"noExplicitConstructor" made me curious:

* Is cppcheck reporting each and every ctor (with one parameter? 
callable with one argument?) that isn't declared as explicit?  Or does 
it use some heuristic that might be actually useful?

* Why that concentration on single-parameter ctors?  Is cppcheck a 
pre-C++11 tool?  That leads to an arbitrary-looking mix of explicit and 
non-explicit ctors in cases like

[...]
> diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
> index eeb9730..d113fbf 100644
> --- a/writerfilter/source/rtftok/rtfvalue.hxx
> +++ b/writerfilter/source/rtftok/rtfvalue.hxx
> @@ -32,14 +32,14 @@ public:
>               css::uno::Reference<css::embed::XEmbeddedObject> const& xObject,
>               bool bForceString, const RTFShape& aShape);
>      RTFValue();
> -    RTFValue(int nValue);
> +    explicit RTFValue(int nValue);
>      RTFValue(const OUString& sValue, bool bForce = false);
> -    RTFValue(RTFSprms rAttributes);
> +    explicit RTFValue(RTFSprms rAttributes);
>      RTFValue(RTFSprms rAttributes, RTFSprms rSprms);
> -    RTFValue(css::uno::Reference<css::drawing::XShape> const& xShape);
> -    RTFValue(css::uno::Reference<css::io::XInputStream> const& xStream);
> -    RTFValue(css::uno::Reference<css::embed::XEmbeddedObject> const& xObject);
> -    RTFValue(const RTFShape& aShape);
> +    explicit RTFValue(css::uno::Reference<css::drawing::XShape> const& xShape);
> +    explicit RTFValue(css::uno::Reference<css::io::XInputStream> const& xStream);
> +    explicit RTFValue(css::uno::Reference<css::embed::XEmbeddedObject> const& xObject);
> +    explicit RTFValue(const RTFShape& aShape);
>      virtual ~RTFValue() override;
>      void setString(const OUString& sValue);
>      virtual int getInt() const override;


More information about the LibreOffice mailing list