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>
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
virtual bool isWriteable() const override
|
||||
{
|
||||
return m_pWriter != 0;
|
||||
return m_pWriter != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 >
|
||||
|
||||
@@ -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 >
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
return m_pValueList[index];
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 >
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
{
|
||||
return store::query (
|
||||
static_cast<OStoreObject*>(pHandle),
|
||||
static_cast<store_handle_type*>(0));
|
||||
static_cast<store_handle_type*>(nullptr));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user