ROSE  0.11.96.11
Defect.h
1 #ifndef ROSE_AST_Defect_H
2 #define ROSE_AST_Defect_H
3 
4 namespace Rose {
5 namespace AST {
6 
16 namespace Defects {
17 
19  enum class Kind {
20  any,
25  };
26 
28  template <Kind kind> struct defect_t;
29 
38  template <>
39  struct defect_t<Kind::any> {
41 
43  static std::set<self_t *> all;
44 
46  template <Kind k, typename... Args>
47  static defect_t<k> const & record(Args... args) {
48  defect_t<k> * defect = new defect_t<k>(args...);
49  all.insert(defect);
50  return *defect;
51  }
52 
54  template <typename DefectT, typename... Args>
55  static DefectT const & record(Args... args) {
56  return record<DefectT::__kind>(args...);
57  }
58 
59  Kind kind;
60 
62  virtual ~defect_t<Kind::any>();
63 
64  static void clear();
65  static void display(std::ostream & out); //<! Calls print on all stored defects
66 
67  virtual void print(std::ostream & out) const = 0;
68  };
69 }
70 
79 
80 namespace Defects {
81 
83  template <>
84  struct defect_t<Kind::integrity_edges> : defect_t<Kind::any> {
85  static constexpr Kind __kind = Kind::integrity_edges;
86 
89 
90  std::string label;
91  bool traversed;
92  bool container;
93 
94  VariantT expected;
95  VariantT found;
96 
97  enum class Reason {
98  invalid,
99  incompatible,
100  unallocated,
101  } reason;
102 
104  SgNode * source_,
105  SgNode * target_,
106  std::string label_,
107  bool traversed_,
108  bool container_,
109  VariantT expected_,
110  VariantT found_,
111  Reason reason_
112  );
113 
114  virtual void print(std::ostream & out) const;
115  };
116 }
117 using IntegrityEdgeDefect = Defects::defect_t<Defects::Kind::integrity_edges>;
118 
119 } }
120 
121 #endif
Rose::AST::Defects::defect_t< Kind::integrity_edges >::label
std::string label
Label of this edge in the grammar.
Definition: Defect.h:90
Rose::AST::Defects::defect_t< Kind::integrity_edges >::Reason
Reason
Definition: Defect.h:97
Rose::AST::Defects::defect_t< Kind::integrity_edges >::expected
VariantT expected
The expected variant for target (like V_SgExpression)
Definition: Defect.h:94
Rose::AST::Defects::defect_t
The generic defect descriptor.
Definition: Defect.h:28
Rose::AST::Defects::Kind::integrity_declarations
@ integrity_declarations
Declarations integrity:
Rose::AST::Defects::defect_t< Kind::integrity_edges >::target
SgNode * target
Pointer to the target node of the edge. Either the pointer or the node are invalid.
Definition: Defect.h:88
Rose::AST::Defects::Kind
Kind
List of the supported kind of defects. Kind::any.
Definition: Defect.h:19
Rose::AST::Defects::Kind::integrity_edges
@ integrity_edges
Edges integrity: for any node in the memory pool, check that all edges point to valid nodes.
Rose::AST::Defects::Kind::integrity_types
@ integrity_types
Types integrity:
Rose::AST::Defects::defect_t< Kind::integrity_edges >::found
VariantT found
The actual variant of target if the pointer is valid (obtained by finding the pointer in the memory p...
Definition: Defect.h:95
Rose::AST::Defects::defect_t< Kind::integrity_edges >::traversed
bool traversed
Traversed edges forms the structure of the AST while the other one represent relations like types and...
Definition: Defect.h:91
Rose::AST::Defects::Kind::any
@ any
base kind for any defect
Rose::AST::Defects::defect_t< Kind::integrity_edges >::source
SgNode * source
Pointer to the source node of the edge (always a valid pointer and node)
Definition: Defect.h:87
Rose::AST::Defects::Kind::integrity_symbols
@ integrity_symbols
Symbols integrity:
Rose::AST::Defects::defect_t< Kind::any >
Defect descriptor specialization for the default kind "any".
Definition: Defect.h:39
Rose::AST::Defects::defect_t< Kind::any >::record
static const defect_t< k > & record(Args... args)
Call new for the specific kind of defect, forwards all argument to the constructor....
Definition: Defect.h:47
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739
Rose::AST::Defects::defect_t< Kind::any >::all
static std::set< self_t * > all
Set of all defects.
Definition: Defect.h:43
Rose
Main namespace for the ROSE library.
Definition: BinaryTutorial.dox:3
Rose::AST::Defects::defect_t< Kind::integrity_edges >::container
bool container
If the edge have multiplicity (like a node with a std::vector<SgExpression*>)
Definition: Defect.h:92
Rose::AST::Defects::defect_t< Kind::integrity_edges >
Specialization of the defect_t template for the case of an edge integrity defect.
Definition: Defect.h:84
Rose::AST::Defects::defect_t< Kind::any >::record
static const DefectT & record(Args... args)
Call new for the specific defect type, forwards all argument to the constructor (requires the special...
Definition: Defect.h:55