Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/ParentMap.h
Line
Count
Source (jump to first uncovered line)
1
//===--- ParentMap.h - Mappings from Stmts to their Parents -----*- 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 the ParentMap class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_AST_PARENTMAP_H
14
#define LLVM_CLANG_AST_PARENTMAP_H
15
16
namespace clang {
17
class Stmt;
18
class Expr;
19
20
class ParentMap {
21
  void* Impl;
22
public:
23
  ParentMap(Stmt* ASTRoot);
24
  ~ParentMap();
25
26
  /// Adds and/or updates the parent/child-relations of the complete
27
  /// stmt tree of S. All children of S including indirect descendants are
28
  /// visited and updated or inserted but not the parents of S.
29
  void addStmt(Stmt* S);
30
31
  /// Manually sets the parent of \p S to \p Parent.
32
  ///
33
  /// If \p S is already in the map, this method will update the mapping.
34
  void setParent(const Stmt *S, const Stmt *Parent);
35
36
  Stmt *getParent(Stmt*) const;
37
  Stmt *getParentIgnoreParens(Stmt *) const;
38
  Stmt *getParentIgnoreParenCasts(Stmt *) const;
39
  Stmt *getParentIgnoreParenImpCasts(Stmt *) const;
40
  Stmt *getOuterParenParent(Stmt *) const;
41
42
947k
  const Stmt *getParent(const Stmt* S) const {
43
947k
    return getParent(const_cast<Stmt*>(S));
44
947k
  }
45
46
60.3k
  const Stmt *getParentIgnoreParens(const Stmt *S) const {
47
60.3k
    return getParentIgnoreParens(const_cast<Stmt*>(S));
48
60.3k
  }
49
50
3.78k
  const Stmt *getParentIgnoreParenCasts(const Stmt *S) const {
51
3.78k
    return getParentIgnoreParenCasts(const_cast<Stmt*>(S));
52
3.78k
  }
53
54
0
  bool hasParent(Stmt* S) const {
55
0
    return getParent(S) != nullptr;
56
0
  }
57
58
  bool isConsumedExpr(Expr *E) const;
59
60
1.06M
  bool isConsumedExpr(const Expr *E) const {
61
1.06M
    return isConsumedExpr(const_cast<Expr*>(E));
62
1.06M
  }
63
};
64
65
} // end clang namespace
66
#endif