File indexing completed on 2024-05-12 04:37:43
0001 /* 0002 SPDX-FileCopyrightText: 2010 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KDEVPLATFORM_CONTROLFLOWGRAPH_H 0008 #define KDEVPLATFORM_CONTROLFLOWGRAPH_H 0009 0010 #include <QVector> 0011 #include <QScopedPointer> 0012 #include <language/languageexport.h> 0013 0014 namespace KDevelop { 0015 class Declaration; 0016 class ControlFlowNode; 0017 class ControlFlowGraphPrivate; 0018 0019 /** 0020 * @brief The ControlFlowGraph describes the way a code interacts with the current state of a system 0021 * 0022 * This class will store the information regarding how is the code flow going to change depending 0023 * on what current state we have in our system. It will tell us what different code paths we have 0024 * available by listing them in different ways and it will let us know what those paths depend on 0025 * so that we can analyze it. 0026 */ 0027 0028 class KDEVPLATFORMLANGUAGE_EXPORT ControlFlowGraph 0029 { 0030 public: 0031 /** Creates an empty graph. */ 0032 ControlFlowGraph(); 0033 ~ControlFlowGraph(); 0034 0035 /** Adds an entry @p n to the graph. The graph takes the ownership of @p n */ 0036 void addEntry(KDevelop::ControlFlowNode* n); 0037 0038 /** Adds an entry @p n to the graph given @p decl declaration. The graph takes the ownership of @p n */ 0039 void addEntry(KDevelop::Declaration* d, KDevelop::ControlFlowNode* n); 0040 0041 /** 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 */ 0042 void addDeadNode(ControlFlowNode* n); 0043 0044 /** Clears the current graph as if it was just constructed */ 0045 void clear(); 0046 0047 /** @returns all declarations that have a node attached to */ 0048 QList<KDevelop::Declaration*> declarations() const; 0049 0050 /** @returns the node attached to the declaration @p d*/ 0051 ControlFlowNode* nodeForDeclaration(KDevelop::Declaration* d) const; 0052 0053 /** @returns all root nodes in the graph */ 0054 QList<ControlFlowNode*> rootNodes() const; 0055 0056 /** @returns all dead nodes in the graph */ 0057 QVector<ControlFlowNode*> deadNodes() const; 0058 0059 private: 0060 ControlFlowGraph(const ControlFlowGraph&); 0061 0062 private: 0063 const QScopedPointer<class ControlFlowGraphPrivate> d_ptr; 0064 Q_DECLARE_PRIVATE(ControlFlowGraph) 0065 }; 0066 } 0067 0068 #endif