aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/PathSensitive/AnnotatedPath.h
blob: 3873bd45d290a6bb31ee8a378562aafa9aecb7eb (plain)
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
//=-- AnnotatedPath.h - An annotated list of ExplodedNodes -*- C++ -*-------==//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines AnnotatedPath, which represents a collection of
//  annotated ExplodedNodes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_ANALYSIS_ANNOTPATH
#define LLVM_CLANG_ANALYSIS_ANNOTPATH

#include "clang/Analysis/PathSensitive/ExplodedGraph.h"
#include <string>
#include <list>

namespace clang {

  class Expr;

template <typename STATE>
class AnnotatedNode {
  ExplodedNode<STATE> *Node;
  std::string annotation;
  Expr* E;

public:
  AnnotatedNode(ExplodedNode<STATE>* N, const std::string& annot,
                Expr* e = NULL)
  : Node(N), annotation(annot), E(e) {}

  ExplodedNode<STATE>* getNode() const { return Node; }
  
  const std::string& getString() const { return annotation; }
  
  Expr* getExpr() const { return E; }
};
  

template <typename STATE>
class AnnotatedPath {
  typedef std::list<AnnotatedNode<STATE> >  impl;
  impl path;
public:
  AnnotatedPath() {}
  
  void push_back(ExplodedNode<STATE>* N, const std::string& s, Expr* E = NULL) {
    path.push_back(AnnotatedNode<STATE>(N, s, E));
  }
  
  typedef typename impl::iterator iterator;
  
  iterator begin() { return path.begin(); }
  iterator end() { return path.end(); }
  
  AnnotatedNode<STATE>& back() { return path.back(); }
  const AnnotatedNode<STATE>& back() const { return path.back(); }
};
  
} // end clang namespace

#endif