summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--canvas/source/cairo/cairo_canvasfont.cxx2
-rw-r--r--canvas/source/cairo/cairo_canvasfont.hxx2
-rw-r--r--canvas/source/cairo/cairo_devicehelper.cxx2
-rw-r--r--canvas/source/cairo/cairo_devicehelper.hxx2
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.cxx4
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.hxx4
-rw-r--r--canvas/source/cairo/cairo_spritedevicehelper.cxx2
-rw-r--r--canvas/source/cairo/cairo_spritedevicehelper.hxx2
-rw-r--r--canvas/source/tools/canvastools.cxx4
-rw-r--r--canvas/source/vcl/canvasfont.cxx2
-rw-r--r--canvas/source/vcl/canvasfont.hxx2
-rw-r--r--canvas/source/vcl/devicehelper.cxx2
-rw-r--r--canvas/source/vcl/devicehelper.hxx2
-rw-r--r--canvas/source/vcl/spritecanvas.hxx4
-rw-r--r--compilerplugins/clang/passstuffbyref.cxx6
-rw-r--r--compilerplugins/clang/test/passstuffbyref.cxx3
-rw-r--r--include/canvas/canvastools.hxx4
-rw-r--r--include/svtools/helpopt.hxx2
-rw-r--r--include/svtools/hyperlabel.hxx2
-rw-r--r--include/svtools/treelistbox.hxx4
-rw-r--r--svtools/inc/roadmap.hxx2
-rw-r--r--svtools/source/config/helpopt.cxx2
-rw-r--r--svtools/source/contnr/treelistbox.cxx4
-rw-r--r--svtools/source/control/hyperlabel.cxx2
-rw-r--r--svtools/source/control/roadmap.cxx2
25 files changed, 39 insertions, 30 deletions
diff --git a/canvas/source/cairo/cairo_canvasfont.cxx b/canvas/source/cairo/cairo_canvasfont.cxx
index cbb9ff8f0d58..896f06f3dbaf 100644
--- a/canvas/source/cairo/cairo_canvasfont.cxx
+++ b/canvas/source/cairo/cairo_canvasfont.cxx
@@ -146,7 +146,7 @@ namespace cairocanvas
return { "com.sun.star.rendering.CanvasFont" };
}
- vcl::Font CanvasFont::getVCLFont() const
+ vcl::Font const & CanvasFont::getVCLFont() const
{
return *maFont;
}
diff --git a/canvas/source/cairo/cairo_canvasfont.hxx b/canvas/source/cairo/cairo_canvasfont.hxx
index 2bcb97eb2f8b..20bc51b18df3 100644
--- a/canvas/source/cairo/cairo_canvasfont.hxx
+++ b/canvas/source/cairo/cairo_canvasfont.hxx
@@ -72,7 +72,7 @@ namespace cairocanvas
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- vcl::Font getVCLFont() const;
+ vcl::Font const & getVCLFont() const;
private:
::canvas::vcltools::VCLObject<vcl::Font> maFont;
diff --git a/canvas/source/cairo/cairo_devicehelper.cxx b/canvas/source/cairo/cairo_devicehelper.cxx
index d3a64b343f49..258f81af88e9 100644
--- a/canvas/source/cairo/cairo_devicehelper.cxx
+++ b/canvas/source/cairo/cairo_devicehelper.cxx
@@ -223,7 +223,7 @@ namespace cairocanvas
};
}
- uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
+ uno::Reference<rendering::XColorSpace> const & DeviceHelper::getColorSpace() const
{
// always the same
return DeviceColorSpace::get();
diff --git a/canvas/source/cairo/cairo_devicehelper.hxx b/canvas/source/cairo/cairo_devicehelper.hxx
index c98ded4d7bc4..f9dab470fbdc 100644
--- a/canvas/source/cairo/cairo_devicehelper.hxx
+++ b/canvas/source/cairo/cairo_devicehelper.hxx
@@ -83,7 +83,7 @@ namespace cairocanvas
css::uno::Any getDeviceHandle() const;
css::uno::Any getSurfaceHandle() const;
css::uno::Reference<
- css::rendering::XColorSpace > getColorSpace() const;
+ css::rendering::XColorSpace > const & getColorSpace() const;
/** called when DumpScreenContent property is enabled on
XGraphicDevice, and writes out bitmaps of current screen.
diff --git a/canvas/source/cairo/cairo_spritecanvas.cxx b/canvas/source/cairo/cairo_spritecanvas.cxx
index 12750d868644..578fa1d12dbc 100644
--- a/canvas/source/cairo/cairo_spritecanvas.cxx
+++ b/canvas/source/cairo/cairo_spritecanvas.cxx
@@ -173,12 +173,12 @@ namespace cairocanvas
return maDeviceHelper.getOutputDevice();
}
- SurfaceSharedPtr SpriteCanvas::getBufferSurface()
+ SurfaceSharedPtr const & SpriteCanvas::getBufferSurface()
{
return maDeviceHelper.getBufferSurface();
}
- SurfaceSharedPtr SpriteCanvas::getWindowSurface()
+ SurfaceSharedPtr const & SpriteCanvas::getWindowSurface()
{
return maDeviceHelper.getWindowSurface();
}
diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx
index a26701fea02e..b84086675b19 100644
--- a/canvas/source/cairo/cairo_spritecanvas.hxx
+++ b/canvas/source/cairo/cairo_spritecanvas.hxx
@@ -142,8 +142,8 @@ namespace cairocanvas
const css::rendering::ViewState& viewState,
const css::rendering::RenderState& renderState ) override;
- ::cairo::SurfaceSharedPtr getWindowSurface();
- ::cairo::SurfaceSharedPtr getBufferSurface();
+ ::cairo::SurfaceSharedPtr const & getWindowSurface();
+ ::cairo::SurfaceSharedPtr const & getBufferSurface();
const ::basegfx::B2ISize& getSizePixel();
void setSizePixel( const ::basegfx::B2ISize& rSize );
diff --git a/canvas/source/cairo/cairo_spritedevicehelper.cxx b/canvas/source/cairo/cairo_spritedevicehelper.cxx
index ef4d6b2d1996..483aaa13bbb2 100644
--- a/canvas/source/cairo/cairo_spritedevicehelper.cxx
+++ b/canvas/source/cairo/cairo_spritedevicehelper.cxx
@@ -124,7 +124,7 @@ namespace cairocanvas
setSize( ::basegfx::B2ISize(rBounds.Width, rBounds.Height) );
}
- SurfaceSharedPtr SpriteDeviceHelper::getWindowSurface()
+ SurfaceSharedPtr const & SpriteDeviceHelper::getWindowSurface()
{
return DeviceHelper::getSurface();
}
diff --git a/canvas/source/cairo/cairo_spritedevicehelper.hxx b/canvas/source/cairo/cairo_spritedevicehelper.hxx
index 86eaa34326e5..5336bb7d10f0 100644
--- a/canvas/source/cairo/cairo_spritedevicehelper.hxx
+++ b/canvas/source/cairo/cairo_spritedevicehelper.hxx
@@ -61,7 +61,7 @@ namespace cairocanvas
void setSize( const ::basegfx::B2ISize& rSize );
const ::cairo::SurfaceSharedPtr& getBufferSurface() { return mpBufferSurface; }
- ::cairo::SurfaceSharedPtr getWindowSurface();
+ ::cairo::SurfaceSharedPtr const & getWindowSurface();
::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent );
::cairo::SurfaceSharedPtr createSurface( BitmapSystemData const & rData, const Size& rSize );
const ::basegfx::B2ISize& getSizePixel() { return maSize; }
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index d1155243275c..477ba03b3703 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -863,12 +863,12 @@ namespace canvas
};
}
- uno::Reference<rendering::XIntegerBitmapColorSpace> getStdColorSpace()
+ uno::Reference<rendering::XIntegerBitmapColorSpace> const & getStdColorSpace()
{
return StandardColorSpaceHolder::get();
}
- uno::Reference<rendering::XIntegerBitmapColorSpace> getStdColorSpaceWithoutAlpha()
+ uno::Reference<rendering::XIntegerBitmapColorSpace> const & getStdColorSpaceWithoutAlpha()
{
return StandardNoAlphaColorSpaceHolder::get();
}
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx
index 2f1dabfe8216..5eb27f9cf0c4 100644
--- a/canvas/source/vcl/canvasfont.cxx
+++ b/canvas/source/vcl/canvasfont.cxx
@@ -159,7 +159,7 @@ namespace vclcanvas
return { "com.sun.star.rendering.CanvasFont" };
}
- vcl::Font CanvasFont::getVCLFont() const
+ vcl::Font const & CanvasFont::getVCLFont() const
{
return *maFont;
}
diff --git a/canvas/source/vcl/canvasfont.hxx b/canvas/source/vcl/canvasfont.hxx
index 83c37deeed34..1a953447aaff 100644
--- a/canvas/source/vcl/canvasfont.hxx
+++ b/canvas/source/vcl/canvasfont.hxx
@@ -75,7 +75,7 @@ namespace vclcanvas
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- vcl::Font getVCLFont() const;
+ vcl::Font const & getVCLFont() const;
private:
::canvas::vcltools::VCLObject<vcl::Font> maFont;
diff --git a/canvas/source/vcl/devicehelper.cxx b/canvas/source/vcl/devicehelper.cxx
index f4d6866e39bd..35e78123c6e7 100644
--- a/canvas/source/vcl/devicehelper.cxx
+++ b/canvas/source/vcl/devicehelper.cxx
@@ -189,7 +189,7 @@ namespace vclcanvas
};
}
- uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
+ uno::Reference<rendering::XColorSpace> const & DeviceHelper::getColorSpace() const
{
// always the same
return DeviceColorSpace::get();
diff --git a/canvas/source/vcl/devicehelper.hxx b/canvas/source/vcl/devicehelper.hxx
index 2a5d7ac2a42e..040fda5ebebb 100644
--- a/canvas/source/vcl/devicehelper.hxx
+++ b/canvas/source/vcl/devicehelper.hxx
@@ -75,7 +75,7 @@ namespace vclcanvas
css::uno::Any getDeviceHandle() const;
css::uno::Any getSurfaceHandle() const;
css::uno::Reference<
- css::rendering::XColorSpace > getColorSpace() const;
+ css::rendering::XColorSpace > const & getColorSpace() const;
const OutDevProviderSharedPtr& getOutDev() const { return mpOutDev; }
diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx
index 1d59b39adb8b..954d49d662d8 100644
--- a/canvas/source/vcl/spritecanvas.hxx
+++ b/canvas/source/vcl/spritecanvas.hxx
@@ -143,9 +143,9 @@ namespace vclcanvas
const GraphicAttr& rAttr ) const override;
/// Get backbuffer for this canvas
- OutDevProviderSharedPtr getFrontBuffer() const { return maDeviceHelper.getOutDev(); }
+ OutDevProviderSharedPtr const & getFrontBuffer() const { return maDeviceHelper.getOutDev(); }
/// Get window for this canvas
- BackBufferSharedPtr getBackBuffer() const { return maDeviceHelper.getBackBuffer(); }
+ BackBufferSharedPtr const & getBackBuffer() const { return maDeviceHelper.getBackBuffer(); }
private:
css::uno::Sequence< css::uno::Any > maArguments;
diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx
index 0630beb80b59..e152acec8673 100644
--- a/compilerplugins/clang/passstuffbyref.cxx
+++ b/compilerplugins/clang/passstuffbyref.cxx
@@ -402,6 +402,12 @@ bool PassStuffByRef::isReturnExprDisqualified(const Expr* expr)
FunctionDecl const * calleeFunctionDecl = callExpr->getDirectCallee();
if (!calleeFunctionDecl)
return true;
+ // TODO anything takes a param is suspect because it might return the param by ref.
+ // we could tighten this to only reject functions that have a param of the same type
+ // as the return type. Or we could check for such functions and disallow them.
+ // Or we could force such functions to be annotated somehow.
+ if (calleeFunctionDecl->getNumParams() > 0)
+ return true;
auto tc = loplugin::TypeCheck(calleeFunctionDecl->getReturnType());
if (!tc.LvalueReference() && !tc.Pointer())
return true;
diff --git a/compilerplugins/clang/test/passstuffbyref.cxx b/compilerplugins/clang/test/passstuffbyref.cxx
index 99e4a5a189b6..ed86d4d309d9 100644
--- a/compilerplugins/clang/test/passstuffbyref.cxx
+++ b/compilerplugins/clang/test/passstuffbyref.cxx
@@ -15,6 +15,7 @@
struct S1 {
OUString mv1;
OUString const & get() const { return mv1; }
+ OUString const & get2(bool) const { return mv1; }
};
struct S2 {
OUString mv1;
@@ -40,6 +41,8 @@ struct S2 {
// TODO
OUString get10() { return OUString(*&get6()); } // todoexpected-error {{rather return class rtl::OUString by const& than by value, to avoid unnecessary copying [loplugin:passstuffbyref]}}
OUString get11() const { return mxCow->get(); } // expected-error {{rather return class rtl::OUString by const& than by value, to avoid unnecessary copying [loplugin:passstuffbyref]}}
+ // TODO anything takes a param is suspect because it might return the param by ref
+ OUString get12() { return child.get2(false); } // todoexpected-error {{rather return class rtl::OUString by const& than by value, to avoid unnecessary copying [loplugin:passstuffbyref]}}
// no warning expected
OUString set1() { return OUString("xxx"); }
diff --git a/include/canvas/canvastools.hxx b/include/canvas/canvastools.hxx
index a16da1871c79..c21465d13496 100644
--- a/include/canvas/canvastools.hxx
+++ b/include/canvas/canvastools.hxx
@@ -329,7 +329,7 @@ namespace canvas
Use this method for dead-simple bitmap implementations,
that map all their formats to 8888 RGBA color.
*/
- CANVASTOOLS_DLLPUBLIC css::uno::Reference< css::rendering::XIntegerBitmapColorSpace> getStdColorSpace();
+ CANVASTOOLS_DLLPUBLIC css::uno::Reference< css::rendering::XIntegerBitmapColorSpace> const & getStdColorSpace();
/** Return a color space for a default RGB integer format
@@ -337,7 +337,7 @@ namespace canvas
that map all their formats to 8888 RGB color (the last byte
is unused).
*/
- CANVASTOOLS_DLLPUBLIC css::uno::Reference< css::rendering::XIntegerBitmapColorSpace> getStdColorSpaceWithoutAlpha();
+ CANVASTOOLS_DLLPUBLIC css::uno::Reference< css::rendering::XIntegerBitmapColorSpace> const & getStdColorSpaceWithoutAlpha();
/** Return a memory layout for a default RGBA integer format
diff --git a/include/svtools/helpopt.hxx b/include/svtools/helpopt.hxx
index 0a5bbf5666fb..6d55ad0b00b3 100644
--- a/include/svtools/helpopt.hxx
+++ b/include/svtools/helpopt.hxx
@@ -44,7 +44,7 @@ public:
const OUString& GetHelpStyleSheet()const;
void SetHelpStyleSheet(const OUString& rStyleSheet);
- OUString GetSystem() const;
+ OUString const & GetSystem() const;
};
#endif
diff --git a/include/svtools/hyperlabel.hxx b/include/svtools/hyperlabel.hxx
index 605d65dc4443..e7bc9d6c30b5 100644
--- a/include/svtools/hyperlabel.hxx
+++ b/include/svtools/hyperlabel.hxx
@@ -69,7 +69,7 @@ namespace svt
void SetClickHdl( const Link<HyperLabel*,void>& rLink ) { maClickHdl = rLink; }
- Size CalcMinimumSize( long nMaxWidth ) const;
+ Size const & CalcMinimumSize( long nMaxWidth ) const;
};
}
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index a9048ab0c705..e7f72b3b15be 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -697,7 +697,7 @@ public:
void SetCollapsedNodeBmp( const Image& );
void SetExpandedNodeBmp( const Image& );
- Image GetExpandedNodeBmp( ) const;
+ Image const & GetExpandedNodeBmp( ) const;
void SetFont( const vcl::Font& rFont );
@@ -796,7 +796,7 @@ public:
void LoseFocus();
bool EditingCanceled() const { return bCanceled; }
OUString GetText() const;
- OUString GetSavedValue() const;
+ OUString const & GetSavedValue() const;
void StopEditing( bool bCancel );
void Hide();
};
diff --git a/svtools/inc/roadmap.hxx b/svtools/inc/roadmap.hxx
index bfaf39befc25..3056dfb0bff6 100644
--- a/svtools/inc/roadmap.hxx
+++ b/svtools/inc/roadmap.hxx
@@ -72,7 +72,7 @@ public:
bool SelectRoadmapItemByID( ItemId _nItemID );
void SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl );
- Link<LinkParamNone*,void> GetItemSelectHdl( ) const;
+ Link<LinkParamNone*,void> const & GetItemSelectHdl( ) const;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
virtual void GetFocus() override;
virtual void ApplySettings( vcl::RenderContext& rRenderContext ) override;
diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx
index 3a2ec50d60da..87029df284eb 100644
--- a/svtools/source/config/helpopt.cxx
+++ b/svtools/source/config/helpopt.cxx
@@ -279,7 +279,7 @@ bool SvtHelpOptions::IsHelpTips() const
return pImpl->IsHelpTips();
}
-OUString SvtHelpOptions::GetSystem() const
+OUString const & SvtHelpOptions::GetSystem() const
{
return pImpl->GetSystem();
}
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index daa06402ebdc..563679879cbb 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -140,7 +140,7 @@ SvInplaceEdit2::~SvInplaceEdit2()
pEdit.disposeAndClear();
}
-OUString SvInplaceEdit2::GetSavedValue() const
+OUString const & SvInplaceEdit2::GetSavedValue() const
{
return pEdit->GetSavedValue();
}
@@ -2420,7 +2420,7 @@ void SvTreeListBox::SetCurEntry( SvTreeListEntry* pEntry )
pImpl->SetCurEntry( pEntry );
}
-Image SvTreeListBox::GetExpandedNodeBmp( ) const
+Image const & SvTreeListBox::GetExpandedNodeBmp( ) const
{
return pImpl->GetExpandedNodeBmp( );
}
diff --git a/svtools/source/control/hyperlabel.cxx b/svtools/source/control/hyperlabel.cxx
index ecf89817a862..036088385102 100644
--- a/svtools/source/control/hyperlabel.cxx
+++ b/svtools/source/control/hyperlabel.cxx
@@ -54,7 +54,7 @@ namespace svt
implInit();
}
- Size HyperLabel::CalcMinimumSize( long nMaxWidth ) const
+ Size const & HyperLabel::CalcMinimumSize( long nMaxWidth ) const
{
m_pImpl->m_aMinSize = FixedText::CalcMinimumSize( nMaxWidth );
// the MinimumSize is used to size the FocusRectangle
diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx
index 8f8c40be3050..539f4ec2e46e 100644
--- a/svtools/source/control/roadmap.cxx
+++ b/svtools/source/control/roadmap.cxx
@@ -507,7 +507,7 @@ void ORoadmap::SetItemSelectHdl(const Link<LinkParamNone*,void>& _rHdl)
m_pImpl->setSelectHdl(_rHdl);
}
-Link<LinkParamNone*,void> ORoadmap::GetItemSelectHdl() const
+Link<LinkParamNone*,void> const & ORoadmap::GetItemSelectHdl() const
{
return m_pImpl->getSelectHdl();
}