diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-01-15 13:50:26 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-01-15 15:58:07 +0100 |
commit | 29bc12777ceffd00ed0ae103b8f2affa26897b4e (patch) | |
tree | 137886309baa148e3e84646f89600c00dd37d0fe /include/oox | |
parent | fe37aa64ff79abcd3aeedeb03d8d74798225a367 (diff) |
Let loplugin:nullptr look into template instantiations
It missed some occurrences of 0 when only looking into uninstantiated template
code, as Clang doesn't model them with an ImplicitCastExpr, even if the target
is known to be a (dependent) pointer type.
Looking into all template instantiations of course carries the risk that a given
use of 0 is meant to be interpreted as a pointer in some and as an integer in
other instantiations. But the only case where that happened in the current code
base is RegistryValueList::getElement (include/registry/registry.hxx), where {}
is arguably a better choice anyway. (And which would presumably also hold for
any future such cases.)
Change-Id: I708bcfc8bedc0a49c9282d7814eb325afa29905c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128462
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/oox')
-rw-r--r-- | include/oox/drawingml/chart/modelbase.hxx | 2 | ||||
-rw-r--r-- | include/oox/helper/containerhelper.hxx | 6 | ||||
-rw-r--r-- | include/oox/helper/refmap.hxx | 2 | ||||
-rw-r--r-- | include/oox/helper/refvector.hxx | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/include/oox/drawingml/chart/modelbase.hxx b/include/oox/drawingml/chart/modelbase.hxx index cd4e97176736..cdec3da17ce4 100644 --- a/include/oox/drawingml/chart/modelbase.hxx +++ b/include/oox/drawingml/chart/modelbase.hxx @@ -38,7 +38,7 @@ public: ModelRef() {} ModelRef( const std::shared_ptr< ModelType >& rxModel ) : std::shared_ptr< ModelType >( rxModel ) {} - bool is() const { return this->get() != 0; } + bool is() const { return this->get() != nullptr; } ModelType& create() { (*this) = std::make_shared<ModelType>(); return **this; } template< typename Param1Type > diff --git a/include/oox/helper/containerhelper.hxx b/include/oox/helper/containerhelper.hxx index 10af6995f52c..3b725d5094ba 100644 --- a/include/oox/helper/containerhelper.hxx +++ b/include/oox/helper/containerhelper.hxx @@ -245,13 +245,13 @@ public: template< typename VectorType > /*static*/ const typename VectorType::value_type* ContainerHelper::getVectorElement( const VectorType& rVector, sal_Int32 nIndex ) { - return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : 0; + return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : nullptr; } template< typename VectorType > /*static*/ typename VectorType::value_type* ContainerHelper::getVectorElementAccess( VectorType& rVector, sal_Int32 nIndex ) { - return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : 0; + return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : nullptr; } template< typename VectorType > @@ -264,7 +264,7 @@ template< typename MapType > /*static*/ const typename MapType::mapped_type* ContainerHelper::getMapElement( const MapType& rMap, const typename MapType::key_type& rKey ) { typename MapType::const_iterator aIt = rMap.find( rKey ); - return (aIt == rMap.end()) ? 0 : &aIt->second; + return (aIt == rMap.end()) ? nullptr : &aIt->second; } template< typename MapType > diff --git a/include/oox/helper/refmap.hxx b/include/oox/helper/refmap.hxx index fb32c9d8c30f..2e63af512049 100644 --- a/include/oox/helper/refmap.hxx +++ b/include/oox/helper/refmap.hxx @@ -132,7 +132,7 @@ private: const mapped_type* getRef( key_type nKey ) const { typename container_type::const_iterator aIt = this->find( nKey ); - return (aIt == this->end()) ? 0 : &aIt->second; + return (aIt == this->end()) ? nullptr : &aIt->second; } }; diff --git a/include/oox/helper/refvector.hxx b/include/oox/helper/refvector.hxx index 1084e71cecf5..01894083639d 100644 --- a/include/oox/helper/refvector.hxx +++ b/include/oox/helper/refvector.hxx @@ -151,7 +151,7 @@ private: const value_type* getRef( sal_Int32 nIndex ) const { return ((0 <= nIndex) && (static_cast< size_type >( nIndex ) < this->size())) ? - &(*this)[ static_cast< size_type >( nIndex ) ] : 0; + &(*this)[ static_cast< size_type >( nIndex ) ] : nullptr; } }; |