Coverage Report

Created: 2023-05-31 04:38

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/StmtGraphTraits.h
Line
Count
Source (jump to first uncovered line)
1
//===- StmtGraphTraits.h - Graph Traits for the class Stmt ------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
//  This file defines a template specialization of llvm::GraphTraits to
10
//  treat ASTs (Stmt*) as graphs
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_AST_STMTGRAPHTRAITS_H
15
#define LLVM_CLANG_AST_STMTGRAPHTRAITS_H
16
17
#include "clang/AST/Stmt.h"
18
#include "llvm/ADT/DepthFirstIterator.h"
19
#include "llvm/ADT/GraphTraits.h"
20
21
namespace llvm {
22
23
template <> struct GraphTraits<clang::Stmt *> {
24
  using NodeRef = clang::Stmt *;
25
  using ChildIteratorType = clang::Stmt::child_iterator;
26
  using nodes_iterator = llvm::df_iterator<clang::Stmt *>;
27
28
0
  static NodeRef getEntryNode(clang::Stmt *S) { return S; }
29
30
0
  static ChildIteratorType child_begin(NodeRef N) {
31
0
    if (N) return N->child_begin();
32
0
    else return ChildIteratorType();
33
0
  }
34
35
0
  static ChildIteratorType child_end(NodeRef N) {
36
0
    if (N) return N->child_end();
37
0
    else return ChildIteratorType();
38
0
  }
39
40
0
  static nodes_iterator nodes_begin(clang::Stmt* S) {
41
0
    return df_begin(S);
42
0
  }
43
44
0
  static nodes_iterator nodes_end(clang::Stmt* S) {
45
0
    return df_end(S);
46
0
  }
47
};
48
49
template <> struct GraphTraits<const clang::Stmt *> {
50
  using NodeRef = const clang::Stmt *;
51
  using ChildIteratorType = clang::Stmt::const_child_iterator;
52
  using nodes_iterator = llvm::df_iterator<const clang::Stmt *>;
53
54
0
  static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
55
56
0
  static ChildIteratorType child_begin(NodeRef N) {
57
0
    if (N) return N->child_begin();
58
0
    else return ChildIteratorType();
59
0
  }
60
61
0
  static ChildIteratorType child_end(NodeRef N) {
62
0
    if (N) return N->child_end();
63
0
    else return ChildIteratorType();
64
0
  }
65
66
0
  static nodes_iterator nodes_begin(const clang::Stmt* S) {
67
0
    return df_begin(S);
68
0
  }
69
70
0
  static nodes_iterator nodes_end(const clang::Stmt* S) {
71
0
    return df_end(S);
72
0
  }
73
};
74
75
} // namespace llvm
76
77
#endif // LLVM_CLANG_AST_STMTGRAPHTRAITS_H