forked from qt-creator/qt-creator
Valgrind: Modernize
modernize-* Change-Id: I6db60dce78cf2575e36caa597b1f095adba34fd9 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -38,12 +38,7 @@ namespace XmlProtocol {
|
||||
class AnnounceThread::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: hThreadId( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
qint64 hThreadId;
|
||||
qint64 hThreadId = -1;
|
||||
QVector<Frame> stack;
|
||||
};
|
||||
|
||||
@@ -52,14 +47,9 @@ AnnounceThread::AnnounceThread()
|
||||
{
|
||||
}
|
||||
|
||||
AnnounceThread::AnnounceThread(const AnnounceThread &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
AnnounceThread::AnnounceThread(const AnnounceThread &other) = default;
|
||||
|
||||
AnnounceThread::~AnnounceThread()
|
||||
{
|
||||
}
|
||||
AnnounceThread::~AnnounceThread() = default;
|
||||
|
||||
void AnnounceThread::swap(AnnounceThread &other)
|
||||
{
|
||||
|
||||
@@ -42,24 +42,15 @@ namespace XmlProtocol {
|
||||
class Error::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
explicit Private() :
|
||||
unique(0),
|
||||
tid(0),
|
||||
kind(0),
|
||||
leakedBytes(0),
|
||||
leakedBlocks(0),
|
||||
hThreadId(-1)
|
||||
{}
|
||||
|
||||
qint64 unique;
|
||||
qint64 tid;
|
||||
qint64 unique = 0;
|
||||
qint64 tid = 0;
|
||||
QString what;
|
||||
int kind;
|
||||
int kind = 0;
|
||||
QVector<Stack> stacks;
|
||||
Suppression suppression;
|
||||
quint64 leakedBytes;
|
||||
qint64 leakedBlocks;
|
||||
qint64 hThreadId;
|
||||
quint64 leakedBytes = 0;
|
||||
qint64 leakedBlocks = 0;
|
||||
qint64 hThreadId = -1;
|
||||
|
||||
bool operator==(const Private &other) const
|
||||
{
|
||||
@@ -80,14 +71,9 @@ Error::Error() :
|
||||
{
|
||||
}
|
||||
|
||||
Error::~Error()
|
||||
{
|
||||
}
|
||||
Error::~Error() = default;
|
||||
|
||||
Error::Error(const Error &other) :
|
||||
d( other.d )
|
||||
{
|
||||
}
|
||||
Error::Error(const Error &other) = default;
|
||||
|
||||
void Error::swap(Error &other)
|
||||
{
|
||||
|
||||
@@ -288,7 +288,7 @@ QVariant FrameItem::data(int column, int role) const
|
||||
const ErrorItem *FrameItem::getErrorItem() const
|
||||
{
|
||||
for (const TreeItem *parentItem = parent(); parentItem; parentItem = parentItem->parent()) {
|
||||
const ErrorItem * const errorItem = dynamic_cast<const ErrorItem *>(parentItem);
|
||||
auto const errorItem = dynamic_cast<const ErrorItem *>(parentItem);
|
||||
if (errorItem)
|
||||
return errorItem;
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
ErrorRole = Debugger::DetailedErrorView::FullTextRole + 1,
|
||||
};
|
||||
|
||||
explicit ErrorListModel(QObject *parent = 0);
|
||||
explicit ErrorListModel(QObject *parent = nullptr);
|
||||
|
||||
typedef std::function<Frame(const Error &)> RelevantFrameFinder;
|
||||
using RelevantFrameFinder = std::function<Frame (const Error &)>;
|
||||
RelevantFrameFinder relevantFrameFinder() const;
|
||||
void setRelevantFrameFinder(const RelevantFrameFinder &relevantFrameFinder);
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace XmlProtocol {
|
||||
class Frame::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private() : ip(0), line(-1) {}
|
||||
|
||||
bool operator==(const Private &other) const
|
||||
{
|
||||
return ip == other.ip
|
||||
@@ -48,26 +46,21 @@ public:
|
||||
&& line == other.line;
|
||||
}
|
||||
|
||||
quint64 ip;
|
||||
quint64 ip = 0;
|
||||
QString object;
|
||||
QString functionName;
|
||||
QString fileName;
|
||||
QString directory;
|
||||
int line;
|
||||
int line = -1;
|
||||
};
|
||||
|
||||
Frame::Frame() : d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
}
|
||||
Frame::~Frame() = default;
|
||||
|
||||
Frame::Frame(const Frame &other) :
|
||||
d(other.d)
|
||||
{
|
||||
}
|
||||
Frame::Frame(const Frame &other) = default;
|
||||
|
||||
Frame &Frame::operator=(const Frame &other)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ QString toolTipForFrame(const Frame &frame)
|
||||
location += ':' + QString::number(frame.line());
|
||||
}
|
||||
|
||||
typedef QPair<QString, QString> StringPair;
|
||||
using StringPair = QPair<QString, QString>;
|
||||
QList<StringPair> lines;
|
||||
|
||||
if (!frame.functionName().isEmpty())
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace {
|
||||
: m_message(message)
|
||||
{}
|
||||
|
||||
~ParserException() throw() {}
|
||||
~ParserException() noexcept = default;
|
||||
|
||||
QString message() const { return m_message; }
|
||||
|
||||
@@ -60,23 +60,21 @@ namespace {
|
||||
|
||||
struct XWhat
|
||||
{
|
||||
XWhat() : leakedblocks(0), leakedbytes(0), hthreadid(-1) {}
|
||||
QString text;
|
||||
qint64 leakedblocks;
|
||||
qint64 leakedbytes;
|
||||
qint64 hthreadid;
|
||||
qint64 leakedblocks = 0;
|
||||
qint64 leakedbytes = 0;
|
||||
qint64 hthreadid = -1;
|
||||
};
|
||||
|
||||
struct XauxWhat
|
||||
{
|
||||
XauxWhat() : line(-1), hthreadid(-1) {}
|
||||
void clear() { *this = XauxWhat(); }
|
||||
|
||||
QString text;
|
||||
QString file;
|
||||
QString dir;
|
||||
qint64 line;
|
||||
qint64 hthreadid;
|
||||
qint64 line = -1;
|
||||
qint64 hthreadid = -1;
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
@@ -215,7 +213,7 @@ QXmlStreamReader::TokenType Parser::Private::blockingReadNext()
|
||||
// ...so we fall back to knowing it might be a QAbstractSocket.
|
||||
|
||||
QIODevice *dev = reader.device();
|
||||
QAbstractSocket *sock = qobject_cast<QAbstractSocket *>(dev);
|
||||
auto sock = qobject_cast<const QAbstractSocket *>(dev);
|
||||
|
||||
if (!sock || sock->state() != QAbstractSocket::ConnectedState)
|
||||
throw ParserException(dev->errorString());
|
||||
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
Helgrind
|
||||
};
|
||||
|
||||
explicit Parser(QObject *parent=0);
|
||||
~Parser();
|
||||
explicit Parser(QObject *parent = nullptr);
|
||||
~Parser() override;
|
||||
|
||||
QString errorString() const;
|
||||
void parse(QIODevice *stream);
|
||||
|
||||
@@ -37,17 +37,11 @@ namespace XmlProtocol {
|
||||
class Stack::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: line(-1)
|
||||
, hthreadid(-1)
|
||||
{
|
||||
}
|
||||
|
||||
QString auxwhat;
|
||||
QString file;
|
||||
QString dir;
|
||||
qint64 line;
|
||||
qint64 hthreadid;
|
||||
qint64 line = -1;
|
||||
qint64 hthreadid = -1;
|
||||
QVector<Frame> frames;
|
||||
};
|
||||
|
||||
@@ -56,14 +50,9 @@ Stack::Stack()
|
||||
{
|
||||
}
|
||||
|
||||
Stack::Stack(const Stack &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
Stack::Stack(const Stack &other) = default;
|
||||
|
||||
Stack::~Stack()
|
||||
{
|
||||
}
|
||||
Stack::~Stack() = default;
|
||||
|
||||
void Stack::swap(Stack &other)
|
||||
{
|
||||
|
||||
@@ -56,15 +56,15 @@ public:
|
||||
LineRole
|
||||
};
|
||||
|
||||
explicit StackModel(QObject *parent = 0);
|
||||
~StackModel();
|
||||
explicit StackModel(QObject *parent = nullptr);
|
||||
~StackModel() override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
void clear();
|
||||
void setError(const Valgrind::XmlProtocol::Error &error);
|
||||
|
||||
@@ -35,12 +35,7 @@ namespace XmlProtocol {
|
||||
class Status::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: state(Running)
|
||||
{
|
||||
}
|
||||
|
||||
State state;
|
||||
State state = Running;
|
||||
QString time;
|
||||
};
|
||||
|
||||
@@ -49,14 +44,9 @@ Status::Status()
|
||||
{
|
||||
}
|
||||
|
||||
Status::Status(const Status &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
Status::Status(const Status &other) = default;
|
||||
|
||||
Status::~Status()
|
||||
{
|
||||
}
|
||||
Status::~Status() = default;
|
||||
|
||||
void Status::swap(Status &other)
|
||||
{
|
||||
|
||||
@@ -39,10 +39,6 @@ using namespace Valgrind::XmlProtocol;
|
||||
class SuppressionFrame::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
{
|
||||
}
|
||||
|
||||
QString obj;
|
||||
QString fun;
|
||||
};
|
||||
@@ -52,14 +48,9 @@ SuppressionFrame::SuppressionFrame()
|
||||
{
|
||||
}
|
||||
|
||||
SuppressionFrame::SuppressionFrame(const SuppressionFrame &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
SuppressionFrame::SuppressionFrame(const SuppressionFrame &other) = default;
|
||||
|
||||
SuppressionFrame::~SuppressionFrame()
|
||||
{
|
||||
}
|
||||
SuppressionFrame::~SuppressionFrame() = default;
|
||||
|
||||
void SuppressionFrame::swap(SuppressionFrame &other)
|
||||
{
|
||||
@@ -110,12 +101,7 @@ QString SuppressionFrame::toString() const
|
||||
class Suppression::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: isNull(true)
|
||||
{
|
||||
}
|
||||
|
||||
bool isNull;
|
||||
bool isNull = true;
|
||||
QString name;
|
||||
QString kind;
|
||||
QString auxkind;
|
||||
@@ -128,14 +114,9 @@ Suppression::Suppression()
|
||||
{
|
||||
}
|
||||
|
||||
Suppression::Suppression(const Suppression &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
Suppression::Suppression(const Suppression &other) = default;
|
||||
|
||||
Suppression::~Suppression()
|
||||
{
|
||||
}
|
||||
Suppression::~Suppression() = default;
|
||||
|
||||
void Suppression::swap(Suppression &other)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
QSharedDataPointer<Private> d;
|
||||
};
|
||||
|
||||
typedef QVector<SuppressionFrame> SuppressionFrames;
|
||||
using SuppressionFrames = QVector<SuppressionFrame>;
|
||||
|
||||
class Suppression
|
||||
{
|
||||
|
||||
@@ -42,20 +42,18 @@ namespace {
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
Thread() : parser(0) , device(0) {}
|
||||
|
||||
void run()
|
||||
void run() override
|
||||
{
|
||||
QTC_ASSERT(QThread::currentThread() == this, return);
|
||||
parser->parse(device);
|
||||
delete parser;
|
||||
parser = 0;
|
||||
parser = nullptr;
|
||||
delete device;
|
||||
device = 0;
|
||||
device = nullptr;
|
||||
}
|
||||
|
||||
Valgrind::XmlProtocol::Parser *parser;
|
||||
QIODevice *device;
|
||||
Valgrind::XmlProtocol::Parser *parser = nullptr;
|
||||
QIODevice *device = nullptr;
|
||||
};
|
||||
|
||||
} // namespace anon
|
||||
@@ -67,9 +65,6 @@ namespace XmlProtocol {
|
||||
class ThreadedParser::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
{}
|
||||
|
||||
QPointer<Thread> parserThread;
|
||||
QString errorString;
|
||||
};
|
||||
@@ -93,14 +88,14 @@ QString ThreadedParser::errorString() const
|
||||
|
||||
bool ThreadedParser::isRunning() const
|
||||
{
|
||||
return d->parserThread ? d->parserThread.data()->isRunning() : 0;
|
||||
return d->parserThread ? d->parserThread.data()->isRunning() : false;
|
||||
}
|
||||
|
||||
void ThreadedParser::parse(QIODevice *device)
|
||||
{
|
||||
QTC_ASSERT(!d->parserThread, return);
|
||||
|
||||
Parser *parser = new Parser;
|
||||
auto parser = new Parser;
|
||||
qRegisterMetaType<Valgrind::XmlProtocol::Status>();
|
||||
qRegisterMetaType<Valgrind::XmlProtocol::Error>();
|
||||
connect(parser, &Parser::status,
|
||||
@@ -123,11 +118,11 @@ void ThreadedParser::parse(QIODevice *device)
|
||||
Qt::QueuedConnection);
|
||||
|
||||
|
||||
Thread *thread = new Thread;
|
||||
auto thread = new Thread;
|
||||
d->parserThread = thread;
|
||||
connect(thread, &QThread::finished,
|
||||
thread, &QObject::deleteLater);
|
||||
device->setParent(0);
|
||||
device->setParent(nullptr);
|
||||
device->moveToThread(thread);
|
||||
parser->moveToThread(thread);
|
||||
thread->device = device;
|
||||
|
||||
@@ -46,8 +46,8 @@ class ThreadedParser : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ThreadedParser(QObject *parent = 0);
|
||||
~ThreadedParser();
|
||||
explicit ThreadedParser(QObject *parent = nullptr);
|
||||
~ThreadedParser() override;
|
||||
|
||||
QString errorString() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user