Further fixing of loplugin:simplifypointertobool for libstdc++ std::shared_ptr
...after fe6cce01c8
"Fix
loplugin:simplifypointertobool for libstdc++ std::shared_ptr", this time for
uses of oox::drawingml:💹:ModelRef, which derives from std::shared_ptr.
Change-Id: I7e9620da52b3f6d26c6fe6d7909888c3a221c164
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94975
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -830,19 +830,21 @@ bool hasExternalLinkage(VarDecl const * decl) {
|
|||||||
|
|
||||||
bool isSmartPointerType(const Expr* e)
|
bool isSmartPointerType(const Expr* e)
|
||||||
{
|
{
|
||||||
// First check the object type as written, in case the get member function is
|
// First check whether the object type as written is, or is derived from, std::unique_ptr or
|
||||||
// declared at a base class of std::unique_ptr or std::shared_ptr:
|
// std::shared_ptr, in case the get member function is declared at a base class of that std
|
||||||
auto const t = e->IgnoreImpCasts()->getType();
|
// type:
|
||||||
auto const tc1 = loplugin::TypeCheck(t);
|
if (loplugin::isDerivedFrom(
|
||||||
if (tc1.ClassOrStruct("unique_ptr").StdNamespace()
|
e->IgnoreImpCasts()->getType()->getAsCXXRecordDecl(),
|
||||||
|| tc1.ClassOrStruct("shared_ptr").StdNamespace())
|
[](Decl const * decl) {
|
||||||
|
auto const dc = loplugin::DeclCheck(decl);
|
||||||
|
return dc.ClassOrStruct("unique_ptr").StdNamespace()
|
||||||
|
|| dc.ClassOrStruct("shared_ptr").StdNamespace();
|
||||||
|
}))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Then check the object type coerced to the type of the get member function, in
|
// Then check the object type coerced to the type of the get member function, in
|
||||||
// case the type-as-written is derived from one of these types (tools::SvRef is
|
// case the type-as-written is derived from one of these types (tools::SvRef is
|
||||||
// final, but the rest are not; but note that this will fail when the type-as-
|
// final, but the rest are not):
|
||||||
// written is derived from std::unique_ptr or std::shared_ptr for which the get
|
|
||||||
// member function is declared at a base class):
|
|
||||||
auto const tc2 = loplugin::TypeCheck(e->getType());
|
auto const tc2 = loplugin::TypeCheck(e->getType());
|
||||||
if (tc2.ClassOrStruct("unique_ptr").StdNamespace()
|
if (tc2.ClassOrStruct("unique_ptr").StdNamespace()
|
||||||
|| tc2.ClassOrStruct("shared_ptr").StdNamespace()
|
|| tc2.ClassOrStruct("shared_ptr").StdNamespace()
|
||||||
|
@@ -238,7 +238,7 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram )
|
|||||||
}
|
}
|
||||||
bool bManualLayout=false;
|
bool bManualLayout=false;
|
||||||
// manual positioning and size
|
// manual positioning and size
|
||||||
if( mrModel.mxLayout.get() )
|
if( mrModel.mxLayout )
|
||||||
{
|
{
|
||||||
LayoutConverter aLayoutConv( *this, *mrModel.mxLayout );
|
LayoutConverter aLayoutConv( *this, *mrModel.mxLayout );
|
||||||
// manual size needs ChartLegendExpansion_CUSTOM
|
// manual size needs ChartLegendExpansion_CUSTOM
|
||||||
|
@@ -2015,7 +2015,7 @@ void InputObjectBase::construct( const InputObjectBase& rParent )
|
|||||||
|
|
||||||
bool InputObjectBase::implIsValid() const
|
bool InputObjectBase::implIsValid() const
|
||||||
{
|
{
|
||||||
return mxStrm.get() && OutputObjectBase::implIsValid();
|
return mxStrm && OutputObjectBase::implIsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize )
|
void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize )
|
||||||
@@ -2318,7 +2318,7 @@ void TextStreamObjectBase::implDump()
|
|||||||
|
|
||||||
void TextStreamObjectBase::constructTextStrmObj( rtl_TextEncoding eTextEnc )
|
void TextStreamObjectBase::constructTextStrmObj( rtl_TextEncoding eTextEnc )
|
||||||
{
|
{
|
||||||
if( mxStrm.get() )
|
if( mxStrm )
|
||||||
mxTextStrm = std::make_shared<TextInputStream>( getContext(), *mxStrm, eTextEnc );
|
mxTextStrm = std::make_shared<TextInputStream>( getContext(), *mxStrm, eTextEnc );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2450,7 +2450,7 @@ void RecordObjectBase::construct( const ObjectBase& rParent,
|
|||||||
|
|
||||||
bool RecordObjectBase::implIsValid() const
|
bool RecordObjectBase::implIsValid() const
|
||||||
{
|
{
|
||||||
return mxBaseStrm.get() && InputObjectBase::implIsValid();
|
return mxBaseStrm && InputObjectBase::implIsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordObjectBase::implDump()
|
void RecordObjectBase::implDump()
|
||||||
|
@@ -1859,7 +1859,7 @@ VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
|
|||||||
mrVbaData( rVbaData )
|
mrVbaData( rVbaData )
|
||||||
{
|
{
|
||||||
mxInStrm = rxStrm;
|
mxInStrm = rxStrm;
|
||||||
if( mxInStrm.get() )
|
if( mxInStrm )
|
||||||
{
|
{
|
||||||
BinaryInputStreamRef xVbaStrm( std::make_shared<::oox::ole::VbaInputStream>( *mxInStrm ) );
|
BinaryInputStreamRef xVbaStrm( std::make_shared<::oox::ole::VbaInputStream>( *mxInStrm ) );
|
||||||
SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
|
SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
|
||||||
@@ -1868,7 +1868,7 @@ VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
|
|||||||
|
|
||||||
bool VbaDirStreamObject::implIsValid() const
|
bool VbaDirStreamObject::implIsValid() const
|
||||||
{
|
{
|
||||||
return mxInStrm.get() && SequenceRecordObjectBase::implIsValid();
|
return mxInStrm && SequenceRecordObjectBase::implIsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
|
bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
|
||||||
|
Reference in New Issue
Block a user