Commit c0483d90 authored by Anton Anikin's avatar Anton Anikin
Browse files

clang-tidy: use-nullptr run (on whole tree)

Reviewers: #kdevelop, kfunk

Reviewed By: #kdevelop, kfunk

Subscribers: kfunk, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D3081
parent be5cd5b5
......@@ -55,7 +55,7 @@ Breakpoint::Breakpoint(BreakpointModel *model, BreakpointKind kind)
, m_state(NotStartedState)
, m_kind(kind)
, m_line(-1)
, m_movingCursor(0)
, m_movingCursor(nullptr)
, m_hitCount(0)
, m_ignoreHits(0)
{
......@@ -69,7 +69,7 @@ Breakpoint::Breakpoint(BreakpointModel *model, const KConfigGroup& config)
, m_deleted(false)
, m_state(NotStartedState)
, m_line(-1)
, m_movingCursor(0)
, m_movingCursor(nullptr)
, m_hitCount(0)
, m_ignoreHits(0)
{
......@@ -214,7 +214,7 @@ void Breakpoint::setDeleted()
if (m->breakpointIndex(this, 0).isValid()) {
m->removeRow(m->breakpointIndex(this, 0).row());
}
m_model = 0; // invalidate
m_model = nullptr; // invalidate
}
int Breakpoint::line() const {
......
......@@ -38,7 +38,7 @@
using namespace KDevelop;
BreakpointDetails::BreakpointDetails(QWidget *parent)
: QWidget(parent), m_currentBreakpoint(0)
: QWidget(parent), m_currentBreakpoint(nullptr)
{
QVBoxLayout* layout = new QVBoxLayout(this);
......@@ -69,7 +69,7 @@ BreakpointDetails::BreakpointDetails(QWidget *parent)
layout->addStretch();
setItem(0); //initialize with no breakpoint active
setItem(nullptr); //initialize with no breakpoint active
}
void KDevelop::BreakpointDetails::setIgnoreHits(int ignoreHits)
......
......@@ -153,9 +153,9 @@ void BreakpointModel::markContextMenuRequested(Document* document, Mark mark, co
}
QMenu menu;
QAction deleteAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("&Delete Breakpoint"), 0);
QAction disableAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("&Disable Breakpoint"), 0);
QAction enableAction(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18n("&Enable Breakpoint"), 0);
QAction deleteAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("&Delete Breakpoint"), nullptr);
QAction disableAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("&Disable Breakpoint"), nullptr);
QAction enableAction(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18n("&Enable Breakpoint"), nullptr);
menu.addAction(&deleteAction);
if (b->enabled()) {
menu.addAction(&disableAction);
......@@ -209,7 +209,7 @@ Qt::ItemFlags BreakpointModel::flags(const QModelIndex &index) const
{
/* FIXME: all this logic must be in item */
if (!index.isValid())
return 0;
return nullptr;
if (index.column() == 0)
return static_cast<Qt::ItemFlags>(
......@@ -245,7 +245,7 @@ bool KDevelop::BreakpointModel::removeRows(int row, int count, const QModelIndex
if (controller)
controller->breakpointAboutToBeDeleted(row);
m_breakpoints.removeAt(row);
b->m_model = 0;
b->m_model = nullptr;
// To be changed: the controller is currently still responsible for deleting the breakpoint
// object
}
......@@ -495,7 +495,7 @@ void BreakpointModel::aboutToDeleteMovingInterfaceContent(KTextEditor::Document*
{
foreach (Breakpoint *breakpoint, m_breakpoints) {
if (breakpoint->movingCursor() && breakpoint->movingCursor()->document() == document) {
breakpoint->setMovingCursor(0);
breakpoint->setMovingCursor(nullptr);
}
}
}
......@@ -547,7 +547,7 @@ QList<Breakpoint*> KDevelop::BreakpointModel::breakpoints() const
Breakpoint* BreakpointModel::breakpoint(int row)
{
if (row >= m_breakpoints.count()) return 0;
if (row >= m_breakpoints.count()) return nullptr;
return m_breakpoints.at(row);
}
......@@ -636,5 +636,5 @@ Breakpoint* BreakpointModel::breakpoint(const QUrl& url, int line) {
return b;
}
}
return 0;
return nullptr;
}
......@@ -50,7 +50,7 @@ using namespace KDevelop;
BreakpointWidget::BreakpointWidget(IDebugController *controller, QWidget *parent)
: AutoOrientedSplitter(parent), m_firstShow(true), m_debugController(controller),
m_breakpointDisableAllAction(0), m_breakpointEnableAllAction(0), m_breakpointRemoveAll(0)
m_breakpointDisableAllAction(nullptr), m_breakpointEnableAllAction(nullptr), m_breakpointRemoveAll(nullptr)
{
setWindowTitle(i18nc("@title:window", "Debugger Breakpoints"));
setWhatsThis(i18nc("@info:whatsthis", "Displays a list of breakpoints with "
......@@ -247,7 +247,7 @@ void BreakpointWidget::slotUpdateBreakpointDetail()
QModelIndexList selected = m_breakpointsView->selectionModel()->selectedIndexes();
IF_DEBUG( qCDebug(DEBUGGER) << selected; )
if (selected.isEmpty()) {
m_details->setItem(0);
m_details->setItem(nullptr);
} else {
m_details->setItem(m_debugController->breakpointModel()->breakpoint(selected.first().row()));
}
......
......@@ -70,7 +70,7 @@ void FrameStackItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem
}
FramestackWidget::FramestackWidget(IDebugController* controller, QWidget* parent)
: AutoOrientedSplitter(Qt::Horizontal, parent), m_session(0)
: AutoOrientedSplitter(Qt::Horizontal, parent), m_session(nullptr)
{
connect(controller,
&IDebugController::currentSessionChanged,
......@@ -137,8 +137,8 @@ void FramestackWidget::currentSessionChanged(KDevelop::IDebugSession* session)
{
m_session = session;
m_threadsListView->setModel(session ? session->frameStackModel() : 0);
m_framesTreeView->setModel(session ? session->frameStackModel() : 0);
m_threadsListView->setModel(session ? session->frameStackModel() : nullptr);
m_framesTreeView->setModel(session ? session->frameStackModel() : nullptr);
if (session) {
connect(session->frameStackModel(), &IFrameStackModel::dataChanged,
......
......@@ -52,7 +52,7 @@ IDebugSession* IBreakpointController::debugSession() const
BreakpointModel* IBreakpointController::breakpointModel() const
{
if (!ICore::self()) return 0;
if (!ICore::self()) return nullptr;
return ICore::self()->debugController()->breakpointModel();
}
......@@ -79,7 +79,7 @@ void IBreakpointController::notifyHit(int row, const QString& msg)
// This is a slightly odd place to issue this notification,
// but then again it's not clear which place would be more natural
Breakpoint* breakpoint = model->breakpoint(row);
KNotification* ev = 0;
KNotification* ev = nullptr;
switch(breakpoint->kind()) {
case Breakpoint::CodeBreakpoint:
ev = new KNotification(QStringLiteral("BreakpointHit"), ICore::self()->uiController()->activeMainWindow());
......
......@@ -40,7 +40,7 @@ IVariableController::IVariableController(IDebugSession* parent)
VariableCollection* IVariableController::variableCollection()
{
if (!ICore::self()) return 0;
if (!ICore::self()) return nullptr;
return ICore::self()->debugController()->variableCollection();
}
......
......@@ -30,7 +30,7 @@
using namespace KDevelop;
TreeItem::TreeItem(TreeModel* model, TreeItem *parent)
: model_(model), more_(false), ellipsis_(0), expanded_(false)
: model_(model), more_(false), ellipsis_(nullptr), expanded_(false)
{
parentItem = parent;
}
......@@ -62,7 +62,7 @@ void TreeItem::appendChild(TreeItem *item, bool initial)
model_->beginRemoveRows(index, childItems.size(), childItems.size());
more_ = false;
delete ellipsis_;
ellipsis_ = 0;
ellipsis_ = nullptr;
if (!initial)
model_->endRemoveRows();
}
......@@ -136,7 +136,7 @@ void TreeItem::clear()
childItems.clear();
more_ = false;
delete ellipsis_;
ellipsis_ = 0;
ellipsis_ = nullptr;
model_->endRemoveRows();
}
}
......@@ -148,7 +148,7 @@ TreeItem *TreeItem::child(int row)
else if (row == childItems.size() && more_)
return ellipsis_;
else
return NULL;
return nullptr;
}
......@@ -226,7 +226,7 @@ void TreeItem::setHasMore(bool more)
{
model_->beginRemoveRows(index, childItems.size(), childItems.size());
delete ellipsis_;
ellipsis_ = 0;
ellipsis_ = nullptr;
more_ = more;
model_->endRemoveRows();
}
......
......@@ -31,7 +31,7 @@ using namespace KDevelop;
TreeModel::TreeModel(const QVector<QString>& headers,
QObject *parent)
: QAbstractItemModel(parent), headers_(headers), root_(NULL)
: QAbstractItemModel(parent), headers_(headers), root_(nullptr)
{
}
......@@ -67,7 +67,7 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return nullptr;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
......@@ -142,7 +142,7 @@ TreeItem* TreeModel::itemForIndex(const QModelIndex& index) const
QModelIndex TreeModel::indexForItem(TreeItem *item, int column) const
{
if (item->parent() == 0)
if (item->parent() == nullptr)
return QModelIndex();
if (TreeItem* parent = item->parent())
......
......@@ -28,7 +28,7 @@
using namespace KDevelop;
AsyncTreeView::AsyncTreeView(TreeModel* model, QSortFilterProxyModel *proxy, QWidget *parent = 0)
AsyncTreeView::AsyncTreeView(TreeModel* model, QSortFilterProxyModel *proxy, QWidget *parent = nullptr)
: QTreeView(parent)
, m_proxy(proxy)
{
......
......@@ -240,14 +240,14 @@ QVariant Variable::data(int column, int role) const
}
Watches::Watches(TreeModel* model, TreeItem* parent)
: TreeItem(model, parent), finishResult_(0)
: TreeItem(model, parent), finishResult_(nullptr)
{
setData(QVector<QVariant>() << i18n("Auto") << QString());
}
Variable* Watches::add(const QString& expression)
{
if (!hasStartedSession()) return 0;
if (!hasStartedSession()) return nullptr;
Variable* v = currentSession()->variableController()->createVariable(
model(), this, expression);
......@@ -280,7 +280,7 @@ void Watches::removeFinishResult()
if (finishResult_)
{
finishResult_->die();
finishResult_ = 0;
finishResult_ = nullptr;
}
}
......
......@@ -258,9 +258,9 @@ void VariableTree::setupActions()
Variable* VariableTree::selectedVariable() const
{
if (selectionModel()->selectedRows().isEmpty()) return 0;
if (selectionModel()->selectedRows().isEmpty()) return nullptr;
auto item = selectionModel()->currentIndex().data(TreeModel::ItemRole).value<TreeItem*>();
if (!item) return 0;
if (!item) return nullptr;
return qobject_cast<Variable*>(item);
}
......
......@@ -38,7 +38,7 @@ namespace KDevelop
{
Context::Context()
: d(0)
: d(nullptr)
{}
Context::~Context()
......
......@@ -47,7 +47,7 @@ void IBuddyDocumentFinder::removeFinder(const QString& mimeType)
IBuddyDocumentFinder* IBuddyDocumentFinder::finderForMimeType(const QString& mimeType)
{
return Private::finders().value(mimeType, 0);
return Private::finders().value(mimeType, nullptr);
}
}
......@@ -22,18 +22,18 @@ Boston, MA 02110-1301, USA.
namespace KDevelop {
ICore *ICore::m_self = 0;
ICore *ICore::m_self = nullptr;
ICore::ICore(QObject *parent)
: QObject(parent)
{
Q_ASSERT(m_self == 0);
Q_ASSERT(m_self == nullptr);
m_self = this;
}
ICore::~ICore()
{
m_self = 0;
m_self = nullptr;
}
ICore *ICore::self()
......
......@@ -27,7 +27,7 @@ class IDocumentPrivate
{
public:
inline IDocumentPrivate(KDevelop::ICore *core)
: m_core(core), scriptWrapper(0)
: m_core(core), scriptWrapper(nullptr)
{}
KDevelop::ICore* m_core;
......@@ -133,7 +133,7 @@ void IDocument::notifyLoaded()
KTextEditor::View* IDocument::activeTextView() const
{
return 0;
return nullptr;
}
QString KDevelop::IDocument::text(const KTextEditor::Range& range) const
......
......@@ -29,7 +29,7 @@
namespace KDevelop {
IPartController::IPartController( QWidget* toplevel )
: KParts::PartManager( toplevel, 0 )
: KParts::PartManager( toplevel, nullptr )
{
}
......@@ -65,7 +65,7 @@ KPluginFactory* IPartController::findPartFactory ( const QString& mimetype, cons
return loader.factory();
}
return 0;
return nullptr;
}
......@@ -78,13 +78,13 @@ KParts::Part* IPartController::createPart ( const QString& mimetype, const QStri
/*"KParts/ReadWritePart",*/ "KParts/ReadOnlyPart"
};
KParts::Part* part = 0;
KParts::Part* part = nullptr;
for ( uint i = 0; i < length; ++i )
{
KPluginFactory* editorFactory = findPartFactory( mimetype, QString::fromLatin1(services[ i ]), prefName );
if ( editorFactory )
{
part = editorFactory->create<KParts::ReadOnlyPart>( 0, this );
part = editorFactory->create<KParts::ReadOnlyPart>( nullptr, this );
break;
}
}
......
......@@ -174,7 +174,7 @@ KXMLGUIClient* KDevelop::IPlugin::createGUIForMainWindow(Sublime::MainWindow* wi
ret->setXmlFile(file);
} else {
delete ret;
ret = 0;
ret = nullptr;
}
return ret;
}
......
......@@ -66,7 +66,7 @@ ILauncher* LaunchConfigurationType::launcherForId( const QString& id )
return l;
}
}
return 0;
return nullptr;
}
}
......
......@@ -107,7 +107,7 @@ void RenameAction::execute()
DocumentChangeSet::ChangeResult result = changes.applyAllChanges();
if (!result) {
KMessageBox::error(0, i18n("Failed to apply changes: %1", result.m_failureReason));
KMessageBox::error(nullptr, i18n("Failed to apply changes: %1", result.m_failureReason));
}
emit executed(this);
......
......@@ -62,7 +62,7 @@ Declaration* getDeclarationForChangedRange(KTextEditor::Document* doc, const KTe
//In this case, we may either not have a decl at the cursor, or we got a decl, but are editing its use.
//In either of those cases, give up and return 0
if (!declaration || !rangesConnect(declaration->rangeInCurrentRevision(), changed)) {
return 0;
return nullptr;
}
return declaration;
......
......@@ -77,7 +77,7 @@ void RenameFileAction::execute()
result = changes.applyAllChanges();
}
if(!result) {
KMessageBox::error(0, i18n("Failed to apply changes: %1", result.m_failureReason));
KMessageBox::error(nullptr, i18n("Failed to apply changes: %1", result.m_failureReason));
}
emit executed(this);
}
......@@ -806,7 +806,7 @@ DocumentChangeTracker* BackgroundParser::trackerForUrl(const KDevelop::IndexedSt
if (url.isEmpty()) {
// this happens e.g. when setting the final location of a problem that is not
// yet associated with a top ctx.
return 0;
return nullptr;
}
if ( !isValidURL(url) ) {
qWarning() << "Tracker requested for invalild URL:" << url.toUrl();
......@@ -814,7 +814,7 @@ DocumentChangeTracker* BackgroundParser::trackerForUrl(const KDevelop::IndexedSt
Q_ASSERT(isValidURL(url));
QMutexLocker l(&d->m_managedMutex);
return d->m_managed.value(url, 0);
return d->m_managed.value(url, nullptr);
}
void BackgroundParser::documentClosed(IDocument* document)
......
......@@ -62,7 +62,7 @@ namespace KDevelop
{
DocumentChangeTracker::DocumentChangeTracker( KTextEditor::Document* document )
: m_needUpdate(false), m_document(document), m_moving(0)
: m_needUpdate(false), m_document(document), m_moving(nullptr)
{
m_url = IndexedString(document->url());
Q_ASSERT(document);
......@@ -204,8 +204,8 @@ void DocumentChangeTracker::documentSavedOrUploaded(KTextEditor::Document* doc,b
void DocumentChangeTracker::documentDestroyed( QObject* )
{
m_document = 0;
m_moving = 0;
m_document = nullptr;
m_moving = nullptr;
}
DocumentChangeTracker::~DocumentChangeTracker()
......
......@@ -316,7 +316,7 @@ void TestBackgroundparser::benchmarkDocumentChanges()
doc->setText(QStringLiteral("hello world"));
// required for proper benchmark results
doc->createView(0);
doc->createView(nullptr);
QBENCHMARK {
for ( int i = 0; i < 5000; i++ ) {
{
......
......@@ -43,12 +43,12 @@ void TestParseJob::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread*)
ControlFlowGraph* TestParseJob::controlFlowGraph()
{
return 0;
return nullptr;
}
DataAccessRepository* TestParseJob::dataAccessInformation()
{
return 0;
return nullptr;
}
......
......@@ -21,7 +21,7 @@
using namespace KDevelop;
ControlFlowNode::ControlFlowNode()
: m_conditionRange(RangeInRevision::invalid()), m_next(0), m_alternative(0)
: m_conditionRange(RangeInRevision::invalid()), m_next(nullptr), m_alternative(nullptr)
{}
ControlFlowNode::Type ControlFlowNode::type() const
......
......@@ -57,7 +57,7 @@ DataAccess* DataAccessRepository::accessAt(const CursorInRevision& cursor) const
if(a->pos() == cursor)
return a;
}
return 0;
return nullptr;
}
QList<DataAccess*> DataAccessRepository::accessesInRange(const RangeInRevision& range) const
......
......@@ -187,7 +187,7 @@ QModelIndex ClassModel::index(ClassModelNodes::Node* a_node) const
}
// If no parent exists, we have an invalid index (root node or not part of a model).
if ( a_node->getParent() == 0 )
if ( a_node->getParent() == nullptr )
return QModelIndex();
return createIndex(a_node->row(), 0, a_node);
......@@ -196,7 +196,7 @@ QModelIndex ClassModel::index(ClassModelNodes::Node* a_node) const
KDevelop::DUChainBase* ClassModel::duObjectForIndex(const QModelIndex& a_index)
{
if ( !a_index.isValid() )
return 0;
return nullptr;
Node* node = static_cast<Node*>(a_index.internalPointer());
......@@ -204,13 +204,13 @@ KDevelop::DUChainBase* ClassModel::duObjectForIndex(const QModelIndex& a_index)
return identifierNode->getDeclaration();
// Non was found.
return 0;
return nullptr;
}
QModelIndex ClassModel::getIndexForIdentifier(const KDevelop::IndexedQualifiedIdentifier& a_id)
{
ClassNode* node = m_allClassesNode->findClassNode(a_id);
if ( node == 0 )
if ( node == nullptr )
return QModelIndex();
return index(node);
......
......@@ -85,7 +85,7 @@ bool EnumNode::getIcon(QIcon& a_resultIcon)
DUChainReadLocker readLock(DUChain::lock());
ClassMemberDeclaration* decl = dynamic_cast<ClassMemberDeclaration*>(getDeclaration());
if ( decl == 0 )
if ( decl == nullptr )
{
static QIcon Icon = QIcon::fromTheme(QStringLiteral("enum"));
a_resultIcon = Icon;
......@@ -185,7 +185,7 @@ bool ClassNode::updateClassDeclarations()
continue;
}
Node* newNode = 0;
Node* newNode = nullptr;
if ( EnumerationType::Ptr enumType = decl->type<EnumerationType>() )
newNode = new EnumNode( decl, m_model );
......@@ -276,14 +276,14 @@ ClassNode* ClassNode::findSubClass(const KDevelop::IndexedQualifiedIdentifier& a
foreach(Node* item, m_subIdentifiers)
{
ClassNode* classNode = dynamic_cast<ClassNode*>(item);
if ( classNode == 0 )
if ( classNode == nullptr )
continue;
if ( classNode->getIdentifier() == a_id )
return classNode;
}
return 0;
return nullptr;
}