File: controlflowgraph.h

package info (click to toggle)
kdevelop 4%3A24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 71,888 kB
  • sloc: cpp: 290,869; python: 3,626; javascript: 3,518; sh: 1,316; ansic: 703; xml: 401; php: 95; lisp: 66; makefile: 31; sed: 12
file content (68 lines) | stat: -rw-r--r-- 2,175 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
    SPDX-FileCopyrightText: 2010 Aleix Pol Gonzalez <aleixpol@kde.org>

    SPDX-License-Identifier: LGPL-2.0-only
*/

#ifndef KDEVPLATFORM_CONTROLFLOWGRAPH_H
#define KDEVPLATFORM_CONTROLFLOWGRAPH_H

#include <QVector>
#include <QScopedPointer>
#include <language/languageexport.h>

namespace KDevelop {
class Declaration;
class ControlFlowNode;
class ControlFlowGraphPrivate;

/**
 * @brief The ControlFlowGraph describes the way a code interacts with the current state of a system
 *
 * This class will store the information regarding how is the code flow going to change depending
 * on what current state we have in our system. It will tell us what different code paths we have
 * available by listing them in different ways and it will let us know what those paths depend on
 * so that we can analyze it.
 */

class KDEVPLATFORMLANGUAGE_EXPORT ControlFlowGraph
{
public:
    /** Creates an empty graph. */
    ControlFlowGraph();
    ~ControlFlowGraph();

    /** Adds an entry @p n to the graph. The graph takes the ownership of @p n */
    void addEntry(KDevelop::ControlFlowNode* n);

    /** Adds an entry @p n to the graph given @p decl declaration. The graph takes the ownership of @p n */
    void addEntry(KDevelop::Declaration* d, KDevelop::ControlFlowNode* n);

    /** Adds a node that does belong to the graph but that can't be accessed by any means. The graph takes the ownership of @p n */
    void addDeadNode(ControlFlowNode* n);

    /** Clears the current graph as if it was just constructed */
    void clear();

    /** @returns all declarations that have a node attached to */
    QList<KDevelop::Declaration*> declarations() const;

    /** @returns  the node attached to the declaration @p d*/
    ControlFlowNode* nodeForDeclaration(KDevelop::Declaration* d) const;

    /** @returns all root nodes in the graph */
    QList<ControlFlowNode*> rootNodes() const;

    /** @returns all dead nodes in the graph */
    QVector<ControlFlowNode*> deadNodes() const;

private:
    ControlFlowGraph(const ControlFlowGraph&);

private:
    const QScopedPointer<class ControlFlowGraphPrivate> d_ptr;
    Q_DECLARE_PRIVATE(ControlFlowGraph)
};
}

#endif