freebsd_amp_hwpstate/include/clang/AST/StmtGraphTraits.h

84 lines
2.3 KiB
C
Raw Normal View History

2009-06-02 17:58:47 +00:00
//===--- StmtGraphTraits.h - Graph Traits for the class Stmt ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
2009-10-14 18:03:49 +00:00
// This file defines a template specialization of llvm::GraphTraits to
2009-06-02 17:58:47 +00:00
// treat ASTs (Stmt*) as graphs
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_STMT_GRAPHTRAITS_H
#define LLVM_CLANG_AST_STMT_GRAPHTRAITS_H
#include "clang/AST/Stmt.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/DepthFirstIterator.h"
namespace llvm {
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
//template <typename T> struct GraphTraits;
template <> struct GraphTraits<clang::Stmt*> {
typedef clang::Stmt NodeType;
typedef clang::Stmt::child_iterator ChildIteratorType;
typedef llvm::df_iterator<clang::Stmt*> nodes_iterator;
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static NodeType* getEntryNode(clang::Stmt* S) { return S; }
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static inline ChildIteratorType child_begin(NodeType* N) {
if (N) return N->child_begin();
else return ChildIteratorType();
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static inline ChildIteratorType child_end(NodeType* N) {
if (N) return N->child_end();
else return ChildIteratorType();
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static nodes_iterator nodes_begin(clang::Stmt* S) {
return df_begin(S);
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static nodes_iterator nodes_end(clang::Stmt* S) {
return df_end(S);
}
};
template <> struct GraphTraits<const clang::Stmt*> {
typedef const clang::Stmt NodeType;
typedef clang::Stmt::const_child_iterator ChildIteratorType;
typedef llvm::df_iterator<const clang::Stmt*> nodes_iterator;
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static NodeType* getEntryNode(const clang::Stmt* S) { return S; }
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static inline ChildIteratorType child_begin(NodeType* N) {
if (N) return N->child_begin();
2009-10-14 18:03:49 +00:00
else return ChildIteratorType();
2009-06-02 17:58:47 +00:00
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static inline ChildIteratorType child_end(NodeType* N) {
if (N) return N->child_end();
else return ChildIteratorType();
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static nodes_iterator nodes_begin(const clang::Stmt* S) {
return df_begin(S);
}
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
static nodes_iterator nodes_end(const clang::Stmt* S) {
return df_end(S);
}
};
2009-10-14 18:03:49 +00:00
2009-06-02 17:58:47 +00:00
} // end namespace llvm
#endif