mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
ab125b35b0
Change company name to "rev.ng Labs Srl" in all license headers to reflect changed company name and legal status Add missing license headers to files that didn't have one
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#pragma once
|
|
|
|
//
|
|
// Copyright (c) rev.ng Labs Srl. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/Support/DOTGraphTraits.h"
|
|
#include "llvm/Support/GraphWriter.h"
|
|
|
|
#include "revng/ADT/GenericGraph.h"
|
|
#include "revng/Model/Type.h"
|
|
|
|
/// Represents a model::Type in the DependencyGraph
|
|
struct TypeNode {
|
|
|
|
/// A pointer to the associated model::Type
|
|
const model::Type *T;
|
|
|
|
/// For each model::Type we'll have nodes representing the type name or
|
|
/// the full type, depending on this enum.
|
|
enum Kind { TypeName, FullType } K;
|
|
};
|
|
|
|
using TypeDependencyNode = BidirectionalNode<TypeNode>;
|
|
using TypeKindPair = std::pair<const model::Type *, TypeNode::Kind>;
|
|
using TypeToDependencyNodeMap = std::map<TypeKindPair, TypeDependencyNode *>;
|
|
using TypeVector = SortedVector<UpcastablePointer<model::Type>>;
|
|
|
|
/// Represents the graph of dependencies among types
|
|
struct DependencyGraph : public GenericGraph<TypeDependencyNode> {
|
|
|
|
void addNode(const model::Type *T);
|
|
|
|
const TypeToDependencyNodeMap &TypeNodes() const { return TypeToNode; }
|
|
|
|
private:
|
|
TypeToDependencyNodeMap TypeToNode;
|
|
};
|
|
|
|
std::string getNodeLabel(const TypeDependencyNode *N);
|
|
|
|
template<>
|
|
struct llvm::DOTGraphTraits<DependencyGraph *>
|
|
: public llvm::DefaultDOTGraphTraits {
|
|
using llvm::DefaultDOTGraphTraits::DefaultDOTGraphTraits;
|
|
|
|
std::string
|
|
getNodeLabel(const TypeDependencyNode *N, const DependencyGraph *G);
|
|
};
|
|
|
|
DependencyGraph buildDependencyGraph(const TypeVector &Types);
|