[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang include/vcl solenv/CompilerTest_compilerplugins_clang.mk vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 23 07:13:15 UTC 2019
compilerplugins/clang/returnconstval.cxx | 76 +++++++++++++++++++++++++
compilerplugins/clang/test/returnconstval.cxx | 21 ++++++
include/vcl/commandinfoprovider.hxx | 2
include/vcl/graphicfilter.hxx | 2
include/vcl/region.hxx | 4 -
include/vcl/status.hxx | 2
include/vcl/toolbox.hxx | 2
solenv/CompilerTest_compilerplugins_clang.mk | 1
vcl/headless/svptext.cxx | 2
vcl/inc/headless/svpgdi.hxx | 2
vcl/inc/qt5/Qt5Graphics.hxx | 2
vcl/inc/quartz/salgdi.h | 2
vcl/inc/salgdi.hxx | 2
vcl/inc/textrender.hxx | 2
vcl/inc/unx/cairotextrender.hxx | 2
vcl/inc/unx/genpspgraphics.h | 2
vcl/inc/unx/glyphcache.hxx | 2
vcl/inc/unx/salgdi.h | 2
vcl/inc/win/salgdi.h | 2
vcl/qt5/Qt5Graphics_Text.cxx | 2
vcl/quartz/salgdi.cxx | 5 -
vcl/source/control/field.cxx | 2
vcl/source/filter/graphicfilter.cxx | 4 -
vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 4 -
vcl/source/gdi/region.cxx | 4 -
vcl/source/helper/commandinfoprovider.cxx | 12 +--
vcl/source/window/status.cxx | 2
vcl/source/window/toolbox2.cxx | 2
vcl/unx/generic/gdi/cairotextrender.cxx | 5 -
vcl/unx/generic/gdi/font.cxx | 2
vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 5 -
vcl/unx/generic/print/genpspgraphics.cxx | 5 -
vcl/win/gdi/salfont.cxx | 5 -
33 files changed, 142 insertions(+), 49 deletions(-)
New commits:
commit 9d5b9bf881606e83a051cc192d08c4690f98a8ba
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 22 16:33:14 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 23 09:12:23 2019 +0200
loplugin:returnconstval in vcl
Change-Id: Id4a0b460ba3c43e80b80ae6e2da9e40a6753e14c
Reviewed-on: https://gerrit.libreoffice.org/77965
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx
index f1254a04a14a..8b5bac1a5c31 100644
--- a/include/vcl/commandinfoprovider.hxx
+++ b/include/vcl/commandinfoprovider.hxx
@@ -88,7 +88,7 @@ namespace vcl { namespace CommandInfoProvider {
const OUString& rsCommandName,
const OUString& rModuleName);
- VCL_DLLPUBLIC OUString const GetModuleIdentifier(const css::uno::Reference<css::frame::XFrame>& rxFrame);
+ VCL_DLLPUBLIC OUString GetModuleIdentifier(const css::uno::Reference<css::frame::XFrame>& rxFrame);
} }
#endif // INCLUDED_VCL_COMMANDINFOPROVIDER_HXX
diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 14373039b684..eea2e9ac8b7d 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -300,7 +300,7 @@ public:
const FilterErrorEx& GetLastError() const { return *pErrorEx;}
void ResetLastError();
- const Link<ConvertData&,bool> GetFilterCallback() const;
+ Link<ConvertData&,bool> GetFilterCallback() const;
static GraphicFilter& GetGraphicFilter();
static ErrCode LoadGraphic( const OUString& rPath, const OUString& rFilter,
Graphic& rGraphic,
diff --git a/include/vcl/region.hxx b/include/vcl/region.hxx
index 80feefcec5b5..3edcaa033636 100644
--- a/include/vcl/region.hxx
+++ b/include/vcl/region.hxx
@@ -82,8 +82,8 @@ public:
// access with converters, the asked data will be created from the most
// valuable data, buffered and returned
- const tools::PolyPolygon GetAsPolyPolygon() const;
- const basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const;
+ tools::PolyPolygon GetAsPolyPolygon() const;
+ basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const;
const RegionBand* GetAsRegionBand() const;
// manipulators
diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx
index c89b5064ff81..fe6ec34e41a4 100644
--- a/include/vcl/status.hxx
+++ b/include/vcl/status.hxx
@@ -156,7 +156,7 @@ public:
void* GetItemData( sal_uInt16 nItemId ) const;
void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
- const OUString GetItemCommand( sal_uInt16 nItemId );
+ OUString GetItemCommand( sal_uInt16 nItemId );
void SetHelpText( sal_uInt16 nItemId, const OUString& rText );
const OUString& GetHelpText( sal_uInt16 nItemId ) const;
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 21ba679150f6..32f9c061889e 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -413,7 +413,7 @@ public:
bool IsItemReallyVisible( sal_uInt16 nItemId ) const;
void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
- const OUString GetItemCommand( sal_uInt16 nItemId ) const;
+ OUString GetItemCommand( sal_uInt16 nItemId ) const;
using Window::SetQuickHelpText;
void SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText );
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index d81dfa19649a..e4b625b365cb 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -36,7 +36,7 @@ void SvpSalGraphics::GetFontMetric( ImplFontMetricDataRef& xFontMetric, int nFal
m_aTextRenderImpl.GetFontMetric(xFontMetric, nFallbackLevel);
}
-const FontCharMapRef SvpSalGraphics::GetFontCharMap() const
+FontCharMapRef SvpSalGraphics::GetFontCharMap() const
{
return m_aTextRenderImpl.GetFontCharMap();
}
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index b5c9df074932..b0e4aac4adad 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -173,7 +173,7 @@ public:
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
virtual void GetDevFontList( PhysicalFontCollection* ) override;
virtual void ClearDevFontCache() override;
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index cd4aa8add45e..a7c7aaa727ac 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -177,7 +177,7 @@ public:
virtual void SetTextColor(Color nColor) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric(ImplFontMetricDataRef&, int nFallbackLevel) override;
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const override;
virtual void GetDevFontList(PhysicalFontCollection*) override;
virtual void ClearDevFontCache() override;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 823dc41bda2c..8861cd79b9ad 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -342,7 +342,7 @@ public:
// get the current font's metrics
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
// get the repertoire of the current font
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
// graphics must fill supplied font list
virtual void GetDevFontList( PhysicalFontCollection* ) override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index bc7c9dc072bf..a504fb9fa071 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -133,7 +133,7 @@ public:
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) = 0;
// get the repertoire of the current font
- virtual const FontCharMapRef GetFontCharMap() const = 0;
+ virtual FontCharMapRef GetFontCharMap() const = 0;
// get the layout capabilities of the current font
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0;
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index 063b5d4462b2..742d8445299b 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -37,7 +37,7 @@ public:
virtual void SetTextColor( Color nColor ) = 0;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) = 0;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) = 0;
- virtual const FontCharMapRef GetFontCharMap() const = 0;
+ virtual FontCharMapRef GetFontCharMap() const = 0;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0;
virtual void GetDevFontList( PhysicalFontCollection* ) = 0;
virtual void ClearDevFontCache() = 0;
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 2881785dcbff..33b1a622945e 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -49,7 +49,7 @@ public:
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
virtual void GetDevFontList( PhysicalFontCollection* ) override;
virtual void ClearDevFontCache() override;
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 1f938d20bd3e..73084a4f6a61 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -84,7 +84,7 @@ public:
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
virtual void GetDevFontList( PhysicalFontCollection* ) override;
// graphics must drop any cached font info
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index a566f628012c..0331d7e9f86e 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -107,7 +107,7 @@ public:
void GetFontMetric(ImplFontMetricDataRef const &) const;
const unsigned char* GetTable( const char* pName, sal_uLong* pLength ) const;
- const FontCharMapRef GetFontCharMap() const;
+ FontCharMapRef GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities &) const;
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 22f6d8604b83..c9a9a5120a82 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -117,7 +117,7 @@ public:
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
virtual void GetDevFontList( PhysicalFontCollection* ) override;
virtual void ClearDevFontCache() override;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 83b9da828a26..d6d8dea14c24 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -335,7 +335,7 @@ public:
// get the current font's metrics
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
// get the repertoire of the current font
- virtual const FontCharMapRef GetFontCharMap() const override;
+ virtual FontCharMapRef GetFontCharMap() const override;
// get the layout capabilities of the current font
virtual bool GetFontCapabilities(vcl::FontCapabilities &rGetFontCapabilities) const override;
// graphics must fill supplied font list
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 04107c2841af..38723f3dd623 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -73,7 +73,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel)
rFMD->SetMinKashida(m_pTextStyle[nFallbackLevel]->GetKashidaWidth());
}
-const FontCharMapRef Qt5Graphics::GetFontCharMap() const
+FontCharMapRef Qt5Graphics::GetFontCharMap() const
{
if (!m_pTextStyle[0])
return FontCharMapRef(new FontCharMap());
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 080cb1adaa11..cf906d32acf3 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -507,12 +507,11 @@ std::unique_ptr<GenericSalLayout> AquaSalGraphics::GetTextLayout(int nFallbackLe
return std::make_unique<GenericSalLayout>(*mpTextStyle[nFallbackLevel]);
}
-const FontCharMapRef AquaSalGraphics::GetFontCharMap() const
+FontCharMapRef AquaSalGraphics::GetFontCharMap() const
{
if (!mpTextStyle[0])
{
- FontCharMapRef xFontCharMap( new FontCharMap() );
- return xFontCharMap;
+ return FontCharMapRef( new FontCharMap() );
}
return static_cast<const CoreTextFontFace*>(mpTextStyle[0]->GetFontFace())->GetFontCharMap();
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 7387a2996f05..f44d13e18b83 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -979,7 +979,7 @@ static OUString ImplMetricGetUnitText(const OUString& rStr)
// #104355# support localized measurements
-static const OUString ImplMetricToString( FieldUnit rUnit )
+static OUString ImplMetricToString( FieldUnit rUnit )
{
// return unit's default string (ie, the first one )
for (auto const& elem : ImplGetFieldUnits())
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index d42eaede02d1..b3ae04cc2eda 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2236,9 +2236,9 @@ void GraphicFilter::ResetLastError()
pErrorEx->nStreamError = ERRCODE_NONE;
}
-const Link<ConvertData&,bool> GraphicFilter::GetFilterCallback() const
+Link<ConvertData&,bool> GraphicFilter::GetFilterCallback() const
{
- const Link<ConvertData&,bool> aLink( LINK( const_cast<GraphicFilter*>(this), GraphicFilter, FilterCallback ) );
+ Link<ConvertData&,bool> aLink( LINK( const_cast<GraphicFilter*>(this), GraphicFilter, FilterCallback ) );
return aLink;
}
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index e1e819203b99..653a369a1e3d 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -352,7 +352,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDr
auto const& rWidgetDraw = static_cast<WidgetDrawActionImage const&>(*pDrawAction);
auto& rCacheImages = ImplGetSVData()->maGDIData.maThemeImageCache;
OUString rCacheKey = rWidgetDraw.msSource + "@" + OUString::number(nScaleFactor);
- auto& aIterator = rCacheImages.find(rCacheKey);
+ auto aIterator = rCacheImages.find(rCacheKey);
BitmapEx aBitmap;
if (aIterator == rCacheImages.end())
@@ -398,7 +398,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDr
auto& rCacheDrawCommands = ImplGetSVData()->maGDIData.maThemeDrawCommandsCache;
- auto& aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource);
+ auto aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource);
gfx::DrawRoot aDrawRoot;
diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx
index e2fb96dae080..983d76305fa9 100644
--- a/vcl/source/gdi/region.cxx
+++ b/vcl/source/gdi/region.cxx
@@ -1258,7 +1258,7 @@ tools::Rectangle vcl::Region::GetBoundRect() const
return tools::Rectangle();
}
-const tools::PolyPolygon vcl::Region::GetAsPolyPolygon() const
+tools::PolyPolygon vcl::Region::GetAsPolyPolygon() const
{
if(getPolyPolygon())
{
@@ -1286,7 +1286,7 @@ const tools::PolyPolygon vcl::Region::GetAsPolyPolygon() const
return tools::PolyPolygon();
}
-const basegfx::B2DPolyPolygon vcl::Region::GetAsB2DPolyPolygon() const
+basegfx::B2DPolyPolygon vcl::Region::GetAsB2DPolyPolygon() const
{
if(getB2DPolyPolygon())
{
diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx
index fa5fe17c79b5..f14ee9dd0efb 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -41,7 +41,7 @@ using namespace css::uno;
namespace vcl { namespace CommandInfoProvider {
-static Reference<container::XNameAccess> const GetCommandDescription()
+static Reference<container::XNameAccess> GetCommandDescription()
{
static WeakReference<container::XNameAccess> xWeakRef;
css::uno::Reference<container::XNameAccess> xRef(xWeakRef);
@@ -55,7 +55,7 @@ static Reference<container::XNameAccess> const GetCommandDescription()
return xRef;
}
-static Reference<ui::XModuleUIConfigurationManagerSupplier> const GetModuleConfigurationSupplier()
+static Reference<ui::XModuleUIConfigurationManagerSupplier> GetModuleConfigurationSupplier()
{
static WeakReference<ui::XModuleUIConfigurationManagerSupplier> xWeakRef;
css::uno::Reference<ui::XModuleUIConfigurationManagerSupplier> xRef(xWeakRef);
@@ -69,7 +69,7 @@ static Reference<ui::XModuleUIConfigurationManagerSupplier> const GetModuleConfi
return xRef;
}
-static Reference<ui::XAcceleratorConfiguration> const GetGlobalAcceleratorConfiguration()
+static Reference<ui::XAcceleratorConfiguration> GetGlobalAcceleratorConfiguration()
{
static WeakReference<ui::XAcceleratorConfiguration> xWeakRef;
css::uno::Reference<ui::XAcceleratorConfiguration> xRef(xWeakRef);
@@ -83,7 +83,7 @@ static Reference<ui::XAcceleratorConfiguration> const GetGlobalAcceleratorConfig
return xRef;
}
-static Reference<ui::XAcceleratorConfiguration> const GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
+static Reference<ui::XAcceleratorConfiguration> GetDocumentAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
{
Reference<frame::XController> xController = rxFrame->getController();
if (xController.is())
@@ -102,7 +102,7 @@ static Reference<ui::XAcceleratorConfiguration> const GetDocumentAcceleratorConf
return nullptr;
}
-static Reference<ui::XAcceleratorConfiguration> const GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
+static Reference<ui::XAcceleratorConfiguration> GetModuleAcceleratorConfiguration(const Reference<frame::XFrame>& rxFrame)
{
css::uno::Reference<css::ui::XAcceleratorConfiguration> curModuleAcceleratorConfiguration;
try
@@ -418,7 +418,7 @@ bool IsExperimental(const OUString& rsCommandName, const OUString& rModuleName)
return false;
}
-OUString const GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame)
+OUString GetModuleIdentifier(const Reference<frame::XFrame>& rxFrame)
{
static WeakReference<frame::XModuleManager2> xWeakRef;
css::uno::Reference<frame::XModuleManager2> xRef(xWeakRef);
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 61c17df48dab..c34a36ea1357 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -1187,7 +1187,7 @@ void StatusBar::SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand )
}
}
-const OUString StatusBar::GetItemCommand( sal_uInt16 nItemId )
+OUString StatusBar::GetItemCommand( sal_uInt16 nItemId )
{
sal_uInt16 nPos = GetItemPos( nItemId );
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 421e1c903815..f2844e59e0b0 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1345,7 +1345,7 @@ void ToolBox::SetItemCommand(sal_uInt16 nItemId, const OUString& rCommand)
pItem->maCommandStr = rCommand;
}
-const OUString ToolBox::GetItemCommand( sal_uInt16 nItemId ) const
+OUString ToolBox::GetItemCommand( sal_uInt16 nItemId ) const
{
ImplToolItem* pItem = ImplGetItem( nItemId );
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index f72664657673..8b55ab6da58d 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -346,13 +346,12 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
releaseCairoContext(cr);
}
-const FontCharMapRef CairoTextRender::GetFontCharMap() const
+FontCharMapRef CairoTextRender::GetFontCharMap() const
{
if( !mpFreetypeFont[0] )
return nullptr;
- const FontCharMapRef xFCMap = mpFreetypeFont[0]->GetFontCharMap();
- return xFCMap;
+ return mpFreetypeFont[0]->GetFontCharMap();
}
bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCapabilities) const
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 9dbcd5e3e101..29b0f4daa715 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -58,7 +58,7 @@ void X11SalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
mxTextRenderImpl->DrawTextLayout(rLayout, *this);
}
-const FontCharMapRef X11SalGraphics::GetFontCharMap() const
+FontCharMapRef X11SalGraphics::GetFontCharMap() const
{
return mxTextRenderImpl->GetFontCharMap();
}
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 0f68d76b04ee..86b7213e7ad7 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -682,10 +682,9 @@ bool FreetypeFont::GetAntialiasAdvice() const
// determine unicode ranges in font
-const FontCharMapRef FreetypeFont::GetFontCharMap() const
+FontCharMapRef FreetypeFont::GetFontCharMap() const
{
- const FontCharMapRef xFCMap = mpFontInfo->GetFontCharMap();
- return xFCMap;
+ return mpFontInfo->GetFontCharMap();
}
const FontCharMapRef& FreetypeFontInfo::GetFontCharMap()
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index b62bd7f90e8f..1eb73401d4ef 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -578,13 +578,12 @@ void GenPspGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
m_pPrinterGfx->DrawGlyph(aPos, *pGlyph);
}
-const FontCharMapRef GenPspGraphics::GetFontCharMap() const
+FontCharMapRef GenPspGraphics::GetFontCharMap() const
{
if( !m_pFreetypeFont[0] )
return nullptr;
- const FontCharMapRef xFCMap = m_pFreetypeFont[0]->GetFontCharMap();
- return xFCMap;
+ return m_pFreetypeFont[0]->GetFontCharMap();
}
bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 5a866092bf30..8a83a29d567b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -983,12 +983,11 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
rxFontMetric->ImplCalcLineSpacing(rHhea, rOS2, aOutlineMetric.otmEMSquare);
}
-const FontCharMapRef WinSalGraphics::GetFontCharMap() const
+FontCharMapRef WinSalGraphics::GetFontCharMap() const
{
if (!mpWinFontEntry[0])
{
- FontCharMapRef xDefFontCharMap( new FontCharMap() );
- return xDefFontCharMap;
+ return FontCharMapRef( new FontCharMap() );
}
return mpWinFontEntry[0]->GetFontFace()->GetFontCharMap();
}
commit 4ad54c347180f227fac127b70c4072c192c21ddd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 22 20:58:07 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 23 09:12:16 2019 +0200
new loplugin:returnconstval
look for code that thwarts copy-elision/move optimisations by
returning const values.
Change-Id: Iafa038d15051e06ee76d8a1c0ce8b7d234cd8488
Reviewed-on: https://gerrit.libreoffice.org/77964
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/returnconstval.cxx b/compilerplugins/clang/returnconstval.cxx
new file mode 100644
index 000000000000..beab3c654972
--- /dev/null
+++ b/compilerplugins/clang/returnconstval.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <string>
+#include <set>
+
+#include "plugin.hxx"
+
+/**
+ Find code where we are return a const value type from a function.
+ Which makes no sense.
+ Either we should return by non-const value, or by const ref.
+ e.g.
+ struct S2 {
+ OUString mv1;
+ const OUString get13() { return mv1; }
+ }
+
+ Specifically, this code pattern will prevent copy/move optimisations.
+*/
+
+namespace
+{
+class ReturnConstVal : public loplugin::FilteringPlugin<ReturnConstVal>
+{
+public:
+ explicit ReturnConstVal(loplugin::InstantiationData const& data)
+ : FilteringPlugin(data)
+ {
+ }
+
+ virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+
+ bool VisitFunctionDecl(const FunctionDecl* decl);
+};
+
+bool ReturnConstVal::VisitFunctionDecl(const FunctionDecl* functionDecl)
+{
+ if (ignoreLocation(functionDecl))
+ return true;
+ if (!functionDecl->hasBody())
+ return true;
+ // ignore stuff that forms part of the stable URE interface
+ if (isInUnoIncludeFile(functionDecl))
+ return true;
+ QualType t1{ functionDecl->getReturnType() };
+ if (!t1.isConstQualified())
+ return true;
+ if (t1->isReferenceType())
+ return true;
+ report(DiagnosticsEngine::Warning, "either return non-const, or by const ref",
+ functionDecl->getSourceRange().getBegin())
+ << functionDecl->getSourceRange();
+
+ // display the location of the class member declaration so I don't have to search for it by hand
+ auto canonicalDecl = functionDecl->getCanonicalDecl();
+ if (canonicalDecl != functionDecl)
+ {
+ report(DiagnosticsEngine::Note, "either return non-const, or by const ref",
+ canonicalDecl->getSourceRange().getBegin())
+ << canonicalDecl->getSourceRange();
+ }
+
+ return true;
+}
+
+loplugin::Plugin::Registration<ReturnConstVal> X("returnconstval", false);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/test/returnconstval.cxx b/compilerplugins/clang/test/returnconstval.cxx
new file mode 100644
index 000000000000..481ae84dff48
--- /dev/null
+++ b/compilerplugins/clang/test/returnconstval.cxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <rtl/ustring.hxx>
+
+struct S2
+{
+ OUString mv1;
+ // expected-error at +1 {{either return non-const, or by const ref [loplugin:returnconstval]}}
+ const OUString get1() { return mv1; }
+ const OUString& get2() { return mv1; }
+ OUString get3() { return mv1; }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index caeee4333e78..82c37fe34b07 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -51,6 +51,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/redundantpointerops \
compilerplugins/clang/test/refcounting \
compilerplugins/clang/test/referencecasting \
+ compilerplugins/clang/test/returnconstval \
compilerplugins/clang/test/salbool \
compilerplugins/clang/test/salcall \
compilerplugins/clang/test/sallogareas \
More information about the Libreoffice-commits
mailing list