Commit b70de6dd authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

kdevplatform/language/checks: use Q_DECLARE_PRIVATE/Q_D to forward constness to d

parent 13a05772
......@@ -30,7 +30,7 @@ public:
};
ControlFlowGraph::ControlFlowGraph()
: d(new ControlFlowGraphPrivate)
: d_ptr(new ControlFlowGraphPrivate)
{}
ControlFlowGraph::~ControlFlowGraph()
......@@ -40,11 +40,15 @@ ControlFlowGraph::~ControlFlowGraph()
void ControlFlowGraph::addEntry(ControlFlowNode* n)
{
Q_D(ControlFlowGraph);
d->m_nodes += n;
}
void ControlFlowGraph::addEntry(Declaration* decl, ControlFlowNode* n)
{
Q_D(ControlFlowGraph);
Q_ASSERT(d);
Q_ASSERT(decl);
d->m_funcNodes.insert(decl, n);
......@@ -52,6 +56,8 @@ void ControlFlowGraph::addEntry(Declaration* decl, ControlFlowNode* n)
void ControlFlowGraph::addDeadNode(ControlFlowNode* n)
{
Q_D(ControlFlowGraph);
d->m_deadNodes += n;
}
......@@ -70,6 +76,8 @@ void clearNodeRecursively(ControlFlowNode* node, QSet<ControlFlowNode*>& deleted
void ControlFlowGraph::clear()
{
Q_D(ControlFlowGraph);
QSet<ControlFlowNode*> deleted;
for (ControlFlowNode* node : qAsConst(d->m_funcNodes)) {
clearNodeRecursively(node, deleted);
......@@ -90,20 +98,28 @@ void ControlFlowGraph::clear()
QList<ControlFlowNode*> ControlFlowGraph::rootNodes() const
{
Q_D(const ControlFlowGraph);
return d->m_funcNodes.values() + d->m_nodes;
}
QVector<ControlFlowNode*> ControlFlowGraph::deadNodes() const
{
Q_D(const ControlFlowGraph);
return d->m_deadNodes;
}
QList<Declaration*> ControlFlowGraph::declarations() const
{
Q_D(const ControlFlowGraph);
return d->m_funcNodes.keys();
}
ControlFlowNode* ControlFlowGraph::nodeForDeclaration(Declaration* decl) const
{
Q_D(const ControlFlowGraph);
return d->m_funcNodes.value(decl);
}
......@@ -26,6 +26,7 @@
namespace KDevelop {
class Declaration;
class ControlFlowNode;
class ControlFlowGraphPrivate;
/**
* @brief The ControlFlowGraph describes the way a code interacts with the current state of a system
......@@ -71,7 +72,8 @@ private:
ControlFlowGraph(const ControlFlowGraph&);
private:
const QScopedPointer<class ControlFlowGraphPrivate> d;
const QScopedPointer<class ControlFlowGraphPrivate> d_ptr;
Q_DECLARE_PRIVATE(ControlFlowGraph)
};
}
......
......@@ -26,7 +26,7 @@ public:
};
DataAccessRepository::DataAccessRepository()
: d(new DataAccessRepositoryPrivate)
: d_ptr(new DataAccessRepositoryPrivate)
{}
DataAccessRepository::~DataAccessRepository()
......@@ -37,20 +37,31 @@ DataAccessRepository::~DataAccessRepository()
void DataAccessRepository::addModification(const CursorInRevision& cursor, DataAccess::DataAccessFlags flags,
const KDevelop::RangeInRevision& range)
{
Q_D(DataAccessRepository);
Q_ASSERT(!range.isValid() || flags == DataAccess::Write);
d->m_modifications.append(new DataAccess(cursor, flags, range));
}
void DataAccessRepository::clear()
{
Q_D(DataAccessRepository);
qDeleteAll(d->m_modifications);
d->m_modifications.clear();
}
QList<DataAccess*> DataAccessRepository::modifications() const { return d->m_modifications; }
QList<DataAccess*> DataAccessRepository::modifications() const
{
Q_D(const DataAccessRepository);
return d->m_modifications;
}
DataAccess* DataAccessRepository::accessAt(const CursorInRevision& cursor) const
{
Q_D(const DataAccessRepository);
auto it = std::find_if(d->m_modifications.constBegin(), d->m_modifications.constEnd(), [&](DataAccess* a) {
return (a->pos() == cursor);
});
......@@ -60,6 +71,8 @@ DataAccess* DataAccessRepository::accessAt(const CursorInRevision& cursor) const
QList<DataAccess*> DataAccessRepository::accessesInRange(const RangeInRevision& range) const
{
Q_D(const DataAccessRepository);
QList<DataAccess*> ret;
for (DataAccess* a : qAsConst(d->m_modifications)) {
if (range.contains(a->pos()))
......
......@@ -24,6 +24,8 @@
#include "dataaccess.h"
namespace KDevelop {
class DataAccessRepositoryPrivate;
/**
* @brief Stores all the data accesses in a file
*
......@@ -52,7 +54,8 @@ public:
QList<DataAccess*> accessesInRange(const KDevelop::RangeInRevision& range) const;
private:
const QScopedPointer<class DataAccessRepositoryPrivate> d;
const QScopedPointer<class DataAccessRepositoryPrivate> d_ptr;
Q_DECLARE_PRIVATE(DataAccessRepository)
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment