bridges/source/cpp_uno/shared/vtables.cxx |    2 +-
 compilerplugins/clang/nullptr.cxx         |    5 ++++-
 forms/source/xforms/propertysetbase.hxx   |    2 +-
 include/com/sun/star/uno/Any.hxx          |    2 +-
 include/com/sun/star/uno/Sequence.hxx     |    6 +++---
 include/comphelper/newarray.hxx           |    2 +-
 include/cppu/unotype.hxx                  |    4 ++--
 include/cppuhelper/interfacecontainer.hxx |    2 +-
 include/oox/drawingml/chart/modelbase.hxx |    2 +-
 include/oox/helper/containerhelper.hxx    |    6 +++---
 include/oox/helper/refmap.hxx             |    2 +-
 include/oox/helper/refvector.hxx          |    2 +-
 include/registry/registry.hxx             |    2 +-
 lotuswordpro/source/filter/clone.hxx      |    4 ++--
 oox/source/drawingml/theme.cxx            |    2 +-
 stoc/source/security/lru_cache.h          |    2 +-
 store/source/storbase.hxx                 |    6 +++---
 store/source/store.cxx                    |    2 +-
 sw/source/filter/ww8/sortedarray.hxx      |    2 +-
 sw/source/filter/ww8/writerwordglue.cxx   |    8 ++++----
 ucb/source/inc/regexpmap.hxx              |    8 ++++----
 21 files changed, 38 insertions(+), 35 deletions(-)

New commits:
commit 29bc12777ceffd00ed0ae103b8f2affa26897b4e
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Sat Jan 15 13:50:26 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sat Jan 15 15:58:07 2022 +0100

    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 <sberg...@redhat.com>

diff --git a/bridges/source/cpp_uno/shared/vtables.cxx 
b/bridges/source/cpp_uno/shared/vtables.cxx
index beda5ad29d44..9a7d7b376882 100644
--- a/bridges/source/cpp_uno/shared/vtables.cxx
+++ b/bridges/source/cpp_uno/shared/vtables.cxx
@@ -82,7 +82,7 @@ template< typename T > bridges::cpp_uno::shared::VtableSlot 
doGetVtableSlot(
     bridges::cpp_uno::shared::VtableSlot slot;
     slot.offset = 0;
     T * member = const_cast< T * >(ifcMember);
-    while (member->pBaseRef != 0) {
+    while (member->pBaseRef != nullptr) {
         assert(member->nIndex < member->pInterface->nBaseTypes);
         for (sal_Int32 i = 0; i < member->nIndex; ++i) {
             slot.offset += getVtableCount(member->pInterface->ppBaseTypes[i]);
diff --git a/compilerplugins/clang/nullptr.cxx 
b/compilerplugins/clang/nullptr.cxx
index b4a40b408a6c..55551ac09292 100644
--- a/compilerplugins/clang/nullptr.cxx
+++ b/compilerplugins/clang/nullptr.cxx
@@ -75,7 +75,7 @@ public:
 
     bool TraverseInitListExpr(InitListExpr * expr, DataRecursionQueue * queue 
= nullptr);
 
-    // bool shouldVisitTemplateInstantiations() const { return true; }
+    bool shouldVisitTemplateInstantiations() const { return true; }
 
 private:
     bool isInLokIncludeFile(SourceLocation spellingLocation) const;
@@ -209,6 +209,9 @@ bool Nullptr::VisitParmVarDecl(ParmVarDecl const * decl) {
     if (!isAnyKindOfPointerType(decl->getType())) {
         return true;
     }
+    if (decl->hasUninstantiatedDefaultArg()) {
+        return true; //TODO
+    }
     auto e = decl->getDefaultArg();
     if (e == nullptr) {
         return true;
diff --git a/forms/source/xforms/propertysetbase.hxx 
b/forms/source/xforms/propertysetbase.hxx
index d4b4212c45c7..2ad685c66322 100644
--- a/forms/source/xforms/propertysetbase.hxx
+++ b/forms/source/xforms/propertysetbase.hxx
@@ -93,7 +93,7 @@ public:
 
     virtual bool isWriteable() const override
     {
-        return m_pWriter != 0;
+        return m_pWriter != nullptr;
     }
 };
 
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index 28d45f1ec21d..f1e5f86c8af2 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -202,7 +202,7 @@ inline bool Any::isExtractableTo( const Type & rType ) const
 template <typename T>
 inline bool Any::has() const
 {
-    Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
+    Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * 
>(NULL));
     return ::uno_type_isAssignableFromData(
         rType.getTypeLibType(), pData, pType,
         cpp_queryInterface,
diff --git a/include/com/sun/star/uno/Sequence.hxx 
b/include/com/sun/star/uno/Sequence.hxx
index e6643a2ec2f4..34d5def3b4f7 100644
--- a/include/com/sun/star/uno/Sequence.hxx
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -326,13 +326,13 @@ template< typename T > inline ::com::sun::star::uno::Type 
const &
 getTypeFavourUnsigned(
     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
 {
-    if (::com::sun::star::uno::Sequence< T >::s_pType == 0) {
+    if (::com::sun::star::uno::Sequence< T >::s_pType == NULL) {
         ::typelib_static_sequence_type_init(
             &::com::sun::star::uno::Sequence< T >::s_pType,
             (::cppu::getTypeFavourUnsigned(
                 static_cast<
                 typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
-                    0)).
+                    NULL)).
              getTypeLibType()));
     }
     return detail::getTypeFromTypeDescriptionReference(
@@ -352,7 +352,7 @@ getTypeFavourChar(
             (::cppu::getTypeFavourChar(
                 static_cast<
                 typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
-                    0)).
+                    NULL)).
              getTypeLibType()));
     }
     return detail::getTypeFromTypeDescriptionReference(&td);
diff --git a/include/comphelper/newarray.hxx b/include/comphelper/newarray.hxx
index 6764cb3bfe3b..d3eaccd77ee5 100644
--- a/include/comphelper/newarray.hxx
+++ b/include/comphelper/newarray.hxx
@@ -30,7 +30,7 @@ template<typename T> T *
 newArray_null(size_t const n) noexcept
 {
     if ((::std::numeric_limits<size_t>::max() / sizeof(T)) <= n) {
-        return 0;
+        return nullptr;
     }
     return new (::std::nothrow) T[n];
 }
diff --git a/include/cppu/unotype.hxx b/include/cppu/unotype.hxx
index 81e59de5993d..e794747ba097 100644
--- a/include/cppu/unotype.hxx
+++ b/include/cppu/unotype.hxx
@@ -241,7 +241,7 @@ cppu_detail_getUnoType(
     SAL_UNUSED_PARAMETER css::uno::Sequence< T > const *)
 {
     return cppu_detail_getUnoType(
-        static_cast< ::cppu::UnoSequenceType< T > * >(0));
+        static_cast< ::cppu::UnoSequenceType< T > * >(NULL));
 }
 
 inline css::uno::Type const & cppu_detail_getUnoType(
@@ -297,7 +297,7 @@ public:
 #else
         typedef T T1;
 #endif
-        return cppu_detail_getUnoType(static_cast< T1 * >(0));
+        return cppu_detail_getUnoType(static_cast< T1 * >(NULL));
     }
 
 private:
diff --git a/include/cppuhelper/interfacecontainer.hxx 
b/include/cppuhelper/interfacecontainer.hxx
index 09b47b5ffb72..a3bb65e4d0cc 100644
--- a/include/cppuhelper/interfacecontainer.hxx
+++ b/include/cppuhelper/interfacecontainer.hxx
@@ -50,7 +50,7 @@ inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl 
, equalImpl >::~OMu
     while( iter != end )
     {
         delete static_cast<OInterfaceContainerHelper*>((*iter).second);
-        (*iter).second = 0;
+        (*iter).second = NULL;
         ++iter;
     }
     delete m_pMap;
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;
                         }
 };
 
diff --git a/include/registry/registry.hxx b/include/registry/registry.hxx
index 3190b13ca66c..b98b1e936a4f 100644
--- a/include/registry/registry.hxx
+++ b/include/registry/registry.hxx
@@ -298,7 +298,7 @@ public:
             return m_pValueList[index];
         } else
         {
-            return 0;
+            return {};
         }
     }
 
diff --git a/lotuswordpro/source/filter/clone.hxx 
b/lotuswordpro/source/filter/clone.hxx
index a6747c005a86..fe4c6451989d 100644
--- a/lotuswordpro/source/filter/clone.hxx
+++ b/lotuswordpro/source/filter/clone.hxx
@@ -29,7 +29,7 @@ struct has_clone
 
     enum
     {
-        value = sizeof(check_sig<T>(0)) == sizeof(yes)
+        value = sizeof(check_sig<T>(nullptr)) == sizeof(yes)
     };
 };
 
@@ -63,7 +63,7 @@ struct cloner<T, true>
 template<typename T>
 T* clone(T* const other)
 {
-    return other ? ::detail::cloner<T, 
::detail::has_clone<T>::value>::clone(other) : 0;
+    return other ? ::detail::cloner<T, 
::detail::has_clone<T>::value>::clone(other) : nullptr;
 }
 
 #endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx
index 56df9941169c..acadb1be77e3 100644
--- a/oox/source/drawingml/theme.cxx
+++ b/oox/source/drawingml/theme.cxx
@@ -34,7 +34,7 @@ namespace {
 template< typename Type >
 const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 
nIndex )
 {
-    return (rVector.empty() || (nIndex < 1)) ? 0 :
+    return (rVector.empty() || (nIndex < 1)) ? nullptr :
         rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), 
static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get();
 }
 
diff --git a/stoc/source/security/lru_cache.h b/stoc/source/security/lru_cache.h
index bbde657de4dc..402b41d58745 100644
--- a/stoc/source/security/lru_cache.h
+++ b/stoc/source/security/lru_cache.h
@@ -156,7 +156,7 @@ inline t_val const * lru_cache< t_key, t_val, t_hashKey, 
t_equalKey >::lookup(
             return &entry->m_val;
         }
     }
-    return 0;
+    return nullptr;
 }
 
 template< typename t_key, typename t_val, typename t_hashKey, typename 
t_equalKey >
diff --git a/store/source/storbase.hxx b/store/source/storbase.hxx
index f4745d7c6885..20f6f3245638 100644
--- a/store/source/storbase.hxx
+++ b/store/source/storbase.hxx
@@ -290,7 +290,7 @@ struct PageData
             {
                 return new(page) T(nSize);
             }
-            return 0;
+            return nullptr;
         }
 
         bool allocate (void ** ppPage, sal_uInt16 * pnSize)
@@ -406,13 +406,13 @@ class PageHolderObject
     template< class U >
     static U * dynamic_page_cast (PageData * p)
     {
-        return isA<U>(p) ? static_cast<U*>(p) : 0;
+        return isA<U>(p) ? static_cast<U*>(p) : nullptr;
     }
 
     template< class U >
     static U const * dynamic_page_cast (PageData const * p)
     {
-        return isA<U>(p) ? static_cast<U const *>(p) : 0;
+        return isA<U>(p) ? static_cast<U const *>(p) : nullptr;
     }
 
 public:
diff --git a/store/source/store.cxx b/store/source/store.cxx
index dfd41571e2dd..566efda73769 100644
--- a/store/source/store.cxx
+++ b/store/source/store.cxx
@@ -52,7 +52,7 @@ public:
     {
         return store::query (
             static_cast<OStoreObject*>(pHandle),
-            static_cast<store_handle_type*>(0));
+            static_cast<store_handle_type*>(nullptr));
     }
 };
 
diff --git a/sw/source/filter/ww8/sortedarray.hxx 
b/sw/source/filter/ww8/sortedarray.hxx
index 1229b83df057..40affc5a413d 100644
--- a/sw/source/filter/ww8/sortedarray.hxx
+++ b/sw/source/filter/ww8/sortedarray.hxx
@@ -49,7 +49,7 @@ namespace ww
             if (aPair.first != aPair.second)
                 return aPair.first;
             else
-                return 0;
+                return nullptr;
         }
 
         SortedArray(C *pWwSprmTab, size_t nNoElems)
diff --git a/sw/source/filter/ww8/writerwordglue.cxx 
b/sw/source/filter/ww8/writerwordglue.cxx
index 80fcb68c4e06..3d4a06e5cce3 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -289,9 +289,9 @@ namespace myImplHelpers
     C* StyleMapperImpl<C>::MakeNonCollidingStyle(const OUString& rName)
     {
         OUString aName(rName);
-        C* pColl = 0;
+        C* pColl = nullptr;
 
-        if (0 != (pColl = maHelper.GetStyle(aName)))
+        if (nullptr != (pColl = maHelper.GetStyle(aName)))
         {
             //If the style collides first stick WW- in front of it, unless
             //it already has it and then successively add a larger and
@@ -302,7 +302,7 @@ namespace myImplHelpers
             sal_Int32 nI = 1;
             OUString aBaseName = aName;
             while (
-                    0 != (pColl = maHelper.GetStyle(aName)) &&
+                    nullptr != (pColl = maHelper.GetStyle(aName)) &&
                     (nI < SAL_MAX_INT32)
                   )
             {
@@ -310,7 +310,7 @@ namespace myImplHelpers
             }
         }
 
-        return pColl ? 0 : maHelper.MakeStyle(aName);
+        return pColl ? nullptr : maHelper.MakeStyle(aName);
     }
 
     static OUString FindBestMSSubstituteFont(const OUString &rFont)
diff --git a/ucb/source/inc/regexpmap.hxx b/ucb/source/inc/regexpmap.hxx
index a0477857ee9f..36e778043d68 100644
--- a/ucb/source/inc/regexpmap.hxx
+++ b/ucb/source/inc/regexpmap.hxx
@@ -106,7 +106,7 @@ private:
 
 template< typename Val >
 RegexpMapConstIter< Val >::RegexpMapConstIter():
-    m_aEntry(OUString(), 0),
+    m_aEntry(OUString(), nullptr),
     m_pMap(nullptr),
     m_nList(-1),
     m_bEntrySet(false)
@@ -115,7 +115,7 @@ RegexpMapConstIter< Val >::RegexpMapConstIter():
 template< typename Val >
 RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMap< Val > * pTheMap,
                                             bool bBegin):
-    m_aEntry(OUString(), 0),
+    m_aEntry(OUString(), nullptr),
     m_pMap(pTheMap),
     m_bEntrySet(false)
 {
@@ -136,7 +136,7 @@ template< typename Val >
 inline RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMap< Val > * 
pTheMap,
                                                    int nTheList,
                                                    ListIterator aTheIndex):
-    m_aEntry(OUString(), 0),
+    m_aEntry(OUString(), nullptr),
     m_aIndex(aTheIndex),
     m_pMap(pTheMap),
     m_nList(nTheList),
@@ -411,7 +411,7 @@ Val const * RegexpMap< Val >::map(OUString const & rString) 
const
     if (m_pDefault
         && m_pDefault->m_aRegexp.matches(rString))
         return &m_pDefault->m_aValue;
-    return 0;
+    return nullptr;
 }
 
 }

Reply via email to