loplugin:nullptr: Find some more cases in templates
Change-Id: I1f127d56e40b04f2b4df85c0afbcfd424d68a8cc
This commit is contained in:
@@ -48,7 +48,7 @@ namespace basegfx
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit ImplMatLine(sal_uInt16 nRow, ImplMatLine< RowSize >* pToBeCopied = 0L)
|
explicit ImplMatLine(sal_uInt16 nRow, ImplMatLine< RowSize >* pToBeCopied = nullptr)
|
||||||
{
|
{
|
||||||
if(pToBeCopied)
|
if(pToBeCopied)
|
||||||
{
|
{
|
||||||
|
@@ -51,6 +51,10 @@ public:
|
|||||||
|
|
||||||
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
|
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
|
||||||
|
|
||||||
|
bool VisitParmVarDecl(ParmVarDecl const * decl);
|
||||||
|
|
||||||
|
bool TraverseConstructorInitializer(CXXCtorInitializer * init);
|
||||||
|
|
||||||
// bool shouldVisitTemplateInstantiations() const { return true; }
|
// bool shouldVisitTemplateInstantiations() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -60,6 +64,10 @@ private:
|
|||||||
|
|
||||||
bool isMacroBodyExpansion(SourceLocation location) const;
|
bool isMacroBodyExpansion(SourceLocation location) const;
|
||||||
|
|
||||||
|
void visitCXXCtorInitializer(CXXCtorInitializer const * init);
|
||||||
|
|
||||||
|
void handleZero(Expr const * expr);
|
||||||
|
|
||||||
void handleNull(
|
void handleNull(
|
||||||
Expr const * expr, char const * castKind,
|
Expr const * expr, char const * castKind,
|
||||||
Expr::NullPointerConstantKind nullPointerKind);
|
Expr::NullPointerConstantKind nullPointerKind);
|
||||||
@@ -142,12 +150,7 @@ bool Nullptr::VisitBinaryOperator(BinaryOperator const * expr) {
|
|||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//TODO: detect NPCK_ZeroExpression where appropriate
|
handleZero(e);
|
||||||
auto const lit = dyn_cast<IntegerLiteral>(e->IgnoreParenImpCasts());
|
|
||||||
if (lit == nullptr || lit->getValue().getBoolValue()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
handleNull(e, nullptr, Expr::NPCK_ZeroLiteral);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,15 +176,30 @@ bool Nullptr::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) {
|
|||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//TODO: detect NPCK_ZeroExpression where appropriate
|
handleZero(e);
|
||||||
auto const lit = dyn_cast<IntegerLiteral>(e->IgnoreParenImpCasts());
|
return true;
|
||||||
if (lit == nullptr || lit->getValue().getBoolValue()) {
|
}
|
||||||
|
|
||||||
|
bool Nullptr::VisitParmVarDecl(ParmVarDecl const * decl) {
|
||||||
|
if (ignoreLocation(decl)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
handleNull(e, nullptr, Expr::NPCK_ZeroLiteral);
|
if (!decl->getType()->isPointerType()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto e = decl->getDefaultArg();
|
||||||
|
if (e == nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
handleZero(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Nullptr::TraverseConstructorInitializer(CXXCtorInitializer * init) {
|
||||||
|
visitCXXCtorInitializer(init);
|
||||||
|
return RecursiveASTVisitor::TraverseConstructorInitializer(init);
|
||||||
|
}
|
||||||
|
|
||||||
bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
|
bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
|
||||||
return compiler.getSourceManager().getFilename(spellingLocation)
|
return compiler.getSourceManager().getFilename(spellingLocation)
|
||||||
.startswith(SRCDIR "/include/LibreOfficeKit/");
|
.startswith(SRCDIR "/include/LibreOfficeKit/");
|
||||||
@@ -204,6 +222,40 @@ bool Nullptr::isMacroBodyExpansion(SourceLocation location) const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Nullptr::visitCXXCtorInitializer(CXXCtorInitializer const * init) {
|
||||||
|
if (!init->isWritten()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto e = init->getInit();
|
||||||
|
if (ignoreLocation(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto d = init->getAnyMember();
|
||||||
|
if (d == nullptr || !d->getType()->isPointerType()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (auto e2 = dyn_cast<ParenListExpr>(e)) {
|
||||||
|
if (e2->getNumExprs() != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e = e2->getExpr(0);
|
||||||
|
} else if (auto e2 = dyn_cast<InitListExpr>(e)) {
|
||||||
|
if (e2->getNumInits() != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e = e2->getInit(0);
|
||||||
|
}
|
||||||
|
handleZero(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Nullptr::handleZero(Expr const * expr) {
|
||||||
|
//TODO: detect NPCK_ZeroExpression where appropriate
|
||||||
|
auto const lit = dyn_cast<IntegerLiteral>(expr->IgnoreParenImpCasts());
|
||||||
|
if (lit != nullptr && !lit->getValue().getBoolValue()) {
|
||||||
|
handleNull(expr, nullptr, Expr::NPCK_ZeroLiteral);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Nullptr::handleNull(
|
void Nullptr::handleNull(
|
||||||
Expr const * expr, char const * castKind,
|
Expr const * expr, char const * castKind,
|
||||||
Expr::NullPointerConstantKind nullPointerKind)
|
Expr::NullPointerConstantKind nullPointerKind)
|
||||||
|
@@ -30,13 +30,13 @@ private:
|
|||||||
unique_disposing_ptr(const unique_disposing_ptr&) = delete;
|
unique_disposing_ptr(const unique_disposing_ptr&) = delete;
|
||||||
unique_disposing_ptr& operator=(const unique_disposing_ptr&) = delete;
|
unique_disposing_ptr& operator=(const unique_disposing_ptr&) = delete;
|
||||||
public:
|
public:
|
||||||
unique_disposing_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = 0 )
|
unique_disposing_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr )
|
||||||
: m_xItem(p)
|
: m_xItem(p)
|
||||||
{
|
{
|
||||||
m_xTerminateListener = new TerminateListener(rComponent, *this);
|
m_xTerminateListener = new TerminateListener(rComponent, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void reset(T * p = 0)
|
virtual void reset(T * p = nullptr)
|
||||||
{
|
{
|
||||||
m_xItem.reset(p);
|
m_xItem.reset(p);
|
||||||
}
|
}
|
||||||
@@ -141,12 +141,12 @@ template<class T> class unique_disposing_solar_mutex_reset_ptr
|
|||||||
: public unique_disposing_ptr<T>
|
: public unique_disposing_ptr<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unique_disposing_solar_mutex_reset_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = 0 )
|
unique_disposing_solar_mutex_reset_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr )
|
||||||
: unique_disposing_ptr<T>(rComponent, p)
|
: unique_disposing_ptr<T>(rComponent, p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void reset(T * p = 0) override
|
virtual void reset(T * p = nullptr) override
|
||||||
{
|
{
|
||||||
SolarMutexGuard aGuard;
|
SolarMutexGuard aGuard;
|
||||||
unique_disposing_ptr<T>::reset(p);
|
unique_disposing_ptr<T>::reset(p);
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
/** Constructor...
|
/** Constructor...
|
||||||
*/
|
*/
|
||||||
inline Reference()
|
inline Reference()
|
||||||
: m_pBody (0)
|
: m_pBody (NULL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
is used (simply casting between list position and values). If the map
|
is used (simply casting between list position and values). If the map
|
||||||
exists, it *MUST* be terminated by an entry containing the special
|
exists, it *MUST* be terminated by an entry containing the special
|
||||||
"not found" list position. */
|
"not found" list position. */
|
||||||
inline explicit PosValueMapper( PosT nNFPos, const MapEntryType* pMap = 0 ) :
|
inline explicit PosValueMapper( PosT nNFPos, const MapEntryType* pMap = nullptr ) :
|
||||||
mpMap( pMap ), mnNFPos( nNFPos ) {}
|
mpMap( pMap ), mnNFPos( nNFPos ) {}
|
||||||
|
|
||||||
/** Returns the value at the specified list position.
|
/** Returns the value at the specified list position.
|
||||||
@@ -325,7 +325,7 @@ public:
|
|||||||
|
|
||||||
/** @param pMap Optional list position <-> value map.
|
/** @param pMap Optional list position <-> value map.
|
||||||
See PosValueMapper documentation for details. */
|
See PosValueMapper documentation for details. */
|
||||||
inline explicit ListBoxWrapper( ListBox& rListBox, const MapEntryType* pMap = 0 ) :
|
inline explicit ListBoxWrapper( ListBox& rListBox, const MapEntryType* pMap = nullptr ) :
|
||||||
SingleControlWrapper< ListBox, ValueT >( rListBox ), MapperType( WRAPPER_LISTBOX_ENTRY_NOTFOUND, pMap ) {}
|
SingleControlWrapper< ListBox, ValueT >( rListBox ), MapperType( WRAPPER_LISTBOX_ENTRY_NOTFOUND, pMap ) {}
|
||||||
|
|
||||||
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
||||||
@@ -358,7 +358,7 @@ public:
|
|||||||
|
|
||||||
/** @param pMap Optional position <-> value map.
|
/** @param pMap Optional position <-> value map.
|
||||||
See PosValueMapper documentation for details. */
|
See PosValueMapper documentation for details. */
|
||||||
inline explicit ValueSetWrapper( ValueSet& rValueSet, const MapEntryType* pMap = 0 ) :
|
inline explicit ValueSetWrapper( ValueSet& rValueSet, const MapEntryType* pMap = nullptr ) :
|
||||||
SingleControlWrapper< ValueSet, ValueT >( rValueSet ), MapperType( WRAPPER_VALUESET_ITEM_NOTFOUND, pMap ) {}
|
SingleControlWrapper< ValueSet, ValueT >( rValueSet ), MapperType( WRAPPER_VALUESET_ITEM_NOTFOUND, pMap ) {}
|
||||||
|
|
||||||
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
||||||
|
@@ -354,7 +354,7 @@ public:
|
|||||||
typedef typename ListBoxWrapperType::MapEntryType MapEntryType;
|
typedef typename ListBoxWrapperType::MapEntryType MapEntryType;
|
||||||
|
|
||||||
explicit ListBoxConnection( sal_uInt16 nSlot, ListBox& rListBox,
|
explicit ListBoxConnection( sal_uInt16 nSlot, ListBox& rListBox,
|
||||||
const MapEntryType* pMap = 0, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
|
const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ public:
|
|||||||
typedef typename ValueSetWrapperType::MapEntryType MapEntryType;
|
typedef typename ValueSetWrapperType::MapEntryType MapEntryType;
|
||||||
|
|
||||||
explicit ValueSetConnection( sal_uInt16 nSlot, ValueSet& rValueSet,
|
explicit ValueSetConnection( sal_uInt16 nSlot, ValueSet& rValueSet,
|
||||||
const MapEntryType* pMap = 0, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
|
const MapEntryType* pMap = nullptr, ItemConnFlags nFlags = ITEMCONN_DEFAULT );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ template < class Access, class Bitmap, Access* (Bitmap::* Acquire)() > class Sco
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScopedBitmapAccess( Bitmap& rBitmap ) :
|
explicit ScopedBitmapAccess( Bitmap& rBitmap ) :
|
||||||
mpAccess( 0 ),
|
mpAccess( nullptr ),
|
||||||
mrBitmap( rBitmap )
|
mrBitmap( rBitmap )
|
||||||
{
|
{
|
||||||
mpAccess = (mrBitmap.*Acquire)();
|
mpAccess = (mrBitmap.*Acquire)();
|
||||||
|
@@ -23,7 +23,7 @@ struct has_clone
|
|||||||
typedef struct { char a[2]; } no;
|
typedef struct { char a[2]; } no;
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
static yes& check_sig(U*, test<U* (U::*)() const, &U::clone>* = 0);
|
static yes& check_sig(U*, test<U* (U::*)() const, &U::clone>* = nullptr);
|
||||||
template<typename U>
|
template<typename U>
|
||||||
static no& check_sig(...);
|
static no& check_sig(...);
|
||||||
|
|
||||||
|
@@ -90,9 +90,9 @@ inline LRU_Cache< t_Key, t_Val, t_KeyHash >::LRU_Cache( sal_Int32 nCachedElement
|
|||||||
#else
|
#else
|
||||||
: _nCachedElements( nCachedElements )
|
: _nCachedElements( nCachedElements )
|
||||||
#endif
|
#endif
|
||||||
, _pBlock( 0 )
|
, _pBlock( nullptr )
|
||||||
, _pHead( 0 )
|
, _pHead( nullptr )
|
||||||
, _pTail( 0 )
|
, _pTail( nullptr )
|
||||||
{
|
{
|
||||||
if (_nCachedElements > 0)
|
if (_nCachedElements > 0)
|
||||||
{
|
{
|
||||||
|
@@ -115,8 +115,8 @@ template< typename t_key, typename t_val, typename t_hashKey, typename t_equalKe
|
|||||||
inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache(
|
inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache(
|
||||||
::std::size_t size )
|
::std::size_t size )
|
||||||
: m_size( 0 )
|
: m_size( 0 )
|
||||||
, m_block( 0 )
|
, m_block( nullptr )
|
||||||
, m_tail( 0 )
|
, m_tail( nullptr )
|
||||||
{
|
{
|
||||||
setSize( size );
|
setSize( size );
|
||||||
}
|
}
|
||||||
@@ -124,9 +124,9 @@ inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache(
|
|||||||
template< typename t_key, typename t_val, typename t_hashKey, typename t_equalKey >
|
template< typename t_key, typename t_val, typename t_hashKey, typename t_equalKey >
|
||||||
inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache()
|
inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache()
|
||||||
: m_size( 0 )
|
: m_size( 0 )
|
||||||
, m_block( 0 )
|
, m_block( nullptr )
|
||||||
, m_head( 0 )
|
, m_head( nullptr )
|
||||||
, m_tail( 0 )
|
, m_tail( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,7 +75,7 @@ struct RegexpMapImpl
|
|||||||
List< Val > m_aList[Regexp::KIND_DOMAIN + 1];
|
List< Val > m_aList[Regexp::KIND_DOMAIN + 1];
|
||||||
Entry< Val > * m_pDefault;
|
Entry< Val > * m_pDefault;
|
||||||
|
|
||||||
RegexpMapImpl(): m_pDefault(0) {}
|
RegexpMapImpl(): m_pDefault(nullptr) {}
|
||||||
|
|
||||||
~RegexpMapImpl() { delete m_pDefault; }
|
~RegexpMapImpl() { delete m_pDefault; }
|
||||||
};
|
};
|
||||||
@@ -126,7 +126,7 @@ private:
|
|||||||
template< typename Val >
|
template< typename Val >
|
||||||
inline RegexpMapIterImpl< Val >::RegexpMapIterImpl():
|
inline RegexpMapIterImpl< Val >::RegexpMapIterImpl():
|
||||||
m_aEntry(rtl::OUString(), 0),
|
m_aEntry(rtl::OUString(), 0),
|
||||||
m_pMap(0),
|
m_pMap(nullptr),
|
||||||
m_nList(-1),
|
m_nList(-1),
|
||||||
m_bEntrySet(false)
|
m_bEntrySet(false)
|
||||||
{}
|
{}
|
||||||
|
Reference in New Issue
Block a user