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)
|
||||
{
|
||||
|
@@ -51,6 +51,10 @@ public:
|
||||
|
||||
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr);
|
||||
|
||||
bool VisitParmVarDecl(ParmVarDecl const * decl);
|
||||
|
||||
bool TraverseConstructorInitializer(CXXCtorInitializer * init);
|
||||
|
||||
// bool shouldVisitTemplateInstantiations() const { return true; }
|
||||
|
||||
private:
|
||||
@@ -60,6 +64,10 @@ private:
|
||||
|
||||
bool isMacroBodyExpansion(SourceLocation location) const;
|
||||
|
||||
void visitCXXCtorInitializer(CXXCtorInitializer const * init);
|
||||
|
||||
void handleZero(Expr const * expr);
|
||||
|
||||
void handleNull(
|
||||
Expr const * expr, char const * castKind,
|
||||
Expr::NullPointerConstantKind nullPointerKind);
|
||||
@@ -142,12 +150,7 @@ bool Nullptr::VisitBinaryOperator(BinaryOperator const * expr) {
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
//TODO: detect NPCK_ZeroExpression where appropriate
|
||||
auto const lit = dyn_cast<IntegerLiteral>(e->IgnoreParenImpCasts());
|
||||
if (lit == nullptr || lit->getValue().getBoolValue()) {
|
||||
return true;
|
||||
}
|
||||
handleNull(e, nullptr, Expr::NPCK_ZeroLiteral);
|
||||
handleZero(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,15 +176,30 @@ bool Nullptr::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) {
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
//TODO: detect NPCK_ZeroExpression where appropriate
|
||||
auto const lit = dyn_cast<IntegerLiteral>(e->IgnoreParenImpCasts());
|
||||
if (lit == nullptr || lit->getValue().getBoolValue()) {
|
||||
handleZero(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Nullptr::VisitParmVarDecl(ParmVarDecl const * decl) {
|
||||
if (ignoreLocation(decl)) {
|
||||
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;
|
||||
}
|
||||
|
||||
bool Nullptr::TraverseConstructorInitializer(CXXCtorInitializer * init) {
|
||||
visitCXXCtorInitializer(init);
|
||||
return RecursiveASTVisitor::TraverseConstructorInitializer(init);
|
||||
}
|
||||
|
||||
bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
|
||||
return compiler.getSourceManager().getFilename(spellingLocation)
|
||||
.startswith(SRCDIR "/include/LibreOfficeKit/");
|
||||
@@ -204,6 +222,40 @@ bool Nullptr::isMacroBodyExpansion(SourceLocation location) const {
|
||||
#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(
|
||||
Expr const * expr, char const * castKind,
|
||||
Expr::NullPointerConstantKind nullPointerKind)
|
||||
|
@@ -30,13 +30,13 @@ private:
|
||||
unique_disposing_ptr(const unique_disposing_ptr&) = delete;
|
||||
unique_disposing_ptr& operator=(const unique_disposing_ptr&) = delete;
|
||||
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_xTerminateListener = new TerminateListener(rComponent, *this);
|
||||
}
|
||||
|
||||
virtual void reset(T * p = 0)
|
||||
virtual void reset(T * p = nullptr)
|
||||
{
|
||||
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_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)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void reset(T * p = 0) override
|
||||
virtual void reset(T * p = nullptr) override
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
unique_disposing_ptr<T>::reset(p);
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
/** Constructor...
|
||||
*/
|
||||
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
|
||||
exists, it *MUST* be terminated by an entry containing the special
|
||||
"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 ) {}
|
||||
|
||||
/** Returns the value at the specified list position.
|
||||
@@ -325,7 +325,7 @@ public:
|
||||
|
||||
/** @param pMap Optional list position <-> value map.
|
||||
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 ) {}
|
||||
|
||||
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
|
||||
/** @param pMap Optional position <-> value map.
|
||||
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 ) {}
|
||||
|
||||
virtual bool IsControlDontKnow() const SAL_OVERRIDE
|
||||
|
@@ -354,7 +354,7 @@ public:
|
||||
typedef typename ListBoxWrapperType::MapEntryType MapEntryType;
|
||||
|
||||
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;
|
||||
|
||||
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:
|
||||
explicit ScopedBitmapAccess( Bitmap& rBitmap ) :
|
||||
mpAccess( 0 ),
|
||||
mpAccess( nullptr ),
|
||||
mrBitmap( rBitmap )
|
||||
{
|
||||
mpAccess = (mrBitmap.*Acquire)();
|
||||
|
@@ -23,7 +23,7 @@ struct has_clone
|
||||
typedef struct { char a[2]; } no;
|
||||
|
||||
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>
|
||||
static no& check_sig(...);
|
||||
|
||||
|
@@ -90,9 +90,9 @@ inline LRU_Cache< t_Key, t_Val, t_KeyHash >::LRU_Cache( sal_Int32 nCachedElement
|
||||
#else
|
||||
: _nCachedElements( nCachedElements )
|
||||
#endif
|
||||
, _pBlock( 0 )
|
||||
, _pHead( 0 )
|
||||
, _pTail( 0 )
|
||||
, _pBlock( nullptr )
|
||||
, _pHead( nullptr )
|
||||
, _pTail( nullptr )
|
||||
{
|
||||
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(
|
||||
::std::size_t size )
|
||||
: m_size( 0 )
|
||||
, m_block( 0 )
|
||||
, m_tail( 0 )
|
||||
, m_block( nullptr )
|
||||
, m_tail( nullptr )
|
||||
{
|
||||
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 >
|
||||
inline lru_cache< t_key, t_val, t_hashKey, t_equalKey >::lru_cache()
|
||||
: m_size( 0 )
|
||||
, m_block( 0 )
|
||||
, m_head( 0 )
|
||||
, m_tail( 0 )
|
||||
, m_block( nullptr )
|
||||
, m_head( nullptr )
|
||||
, m_tail( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ struct RegexpMapImpl
|
||||
List< Val > m_aList[Regexp::KIND_DOMAIN + 1];
|
||||
Entry< Val > * m_pDefault;
|
||||
|
||||
RegexpMapImpl(): m_pDefault(0) {}
|
||||
RegexpMapImpl(): m_pDefault(nullptr) {}
|
||||
|
||||
~RegexpMapImpl() { delete m_pDefault; }
|
||||
};
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
template< typename Val >
|
||||
inline RegexpMapIterImpl< Val >::RegexpMapIterImpl():
|
||||
m_aEntry(rtl::OUString(), 0),
|
||||
m_pMap(0),
|
||||
m_pMap(nullptr),
|
||||
m_nList(-1),
|
||||
m_bEntrySet(false)
|
||||
{}
|
||||
|
Reference in New Issue
Block a user