clang 8.0.0

ParentMap.h
Go to the documentation of this file.
1 //===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ParentMap class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_AST_PARENTMAP_H
15 #define LLVM_CLANG_AST_PARENTMAP_H
16
17 namespace clang {
18 class Stmt;
19 class Expr;
20
21 class ParentMap {
22 void* Impl;
23 public:
24 ParentMap(Stmt* ASTRoot);
25 ~ParentMap();
26
27 /// Adds and/or updates the parent/child-relations of the complete
28 /// stmt tree of S. All children of S including indirect descendants are
29 /// visited and updated or inserted but not the parents of S.
30 void addStmt(Stmt* S);
31
32 /// Manually sets the parent of \p S to \p Parent.
33 ///
34 /// If \p S is already in the map, this method will update the mapping.
35 void setParent(const Stmt *S, const Stmt *Parent);
36
37 Stmt *getParent(Stmt*) const;
38 Stmt *getParentIgnoreParens(Stmt *) const;
39 Stmt *getParentIgnoreParenCasts(Stmt *) const;
40 Stmt *getParentIgnoreParenImpCasts(Stmt *) const;
41 Stmt *getOuterParenParent(Stmt *) const;
42
43 const Stmt *getParent(const Stmt* S) const {
44 return getParent(const_cast<Stmt*>(S));
45 }
46
47 const Stmt *getParentIgnoreParens(const Stmt *S) const {
48 return getParentIgnoreParens(const_cast<Stmt*>(S));
49 }
50
51 const Stmt *getParentIgnoreParenCasts(const Stmt *S) const {
52 return getParentIgnoreParenCasts(const_cast<Stmt*>(S));
53 }
54
55 bool hasParent(Stmt* S) const {
56 return getParent(S) != nullptr;
57 }
58
59 bool isConsumedExpr(Expr *E) const;
60
61 bool isConsumedExpr(const Expr *E) const {
62 return isConsumedExpr(const_cast<Expr*>(E));
63 }
64 };
65
66 } // end clang namespace
67 #endif
clang::ParentMap
Definition: ParentMap.h:21
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
clang::ParentMap::getParent
Stmt * getParent(Stmt *) const
Definition: ParentMap.cpp:123
clang::ParentMap::isConsumedExpr
bool isConsumedExpr(Expr *E) const
Definition: ParentMap.cpp:160
clang::ParentMap::getParentIgnoreParens
const Stmt * getParentIgnoreParens(const Stmt *S) const
Definition: ParentMap.h:47
clang::ParentMap::addStmt
void addStmt(Stmt *S)
Adds and/or updates the parent/child-relations of the complete stmt tree of S.
Definition: ParentMap.cpp:110
clang::ParentMap::~ParentMap
~ParentMap()
Definition: ParentMap.cpp:106
clang::ParentMap::setParent
void setParent(const Stmt *S, const Stmt *Parent)
Manually sets the parent of S to Parent.
Definition: ParentMap.cpp:116
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::ParentMap::getParentIgnoreParenCasts
const Stmt * getParentIgnoreParenCasts(const Stmt *S) const
Definition: ParentMap.h:51
clang::Expr
This represents one expression.
Definition: Expr.h:106
clang::ParentMap::hasParent
bool hasParent(Stmt *S) const
Definition: ParentMap.h:55
clang::ParentMap::getParent
const Stmt * getParent(const Stmt *S) const
Definition: ParentMap.h:43
clang::ParentMap::getParentIgnoreParens
Stmt * getParentIgnoreParens(Stmt *) const
Definition: ParentMap.cpp:129
clang::ParentMap::isConsumedExpr
bool isConsumedExpr(const Expr *E) const
Definition: ParentMap.h:61
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::ParentMap::ParentMap
ParentMap(Stmt *ASTRoot)
Definition: ParentMap.cpp:98
clang::ParentMap::getParentIgnoreParenImpCasts
Stmt * getParentIgnoreParenImpCasts(Stmt *) const
Definition: ParentMap.cpp:143
clang::ParentMap::getParentIgnoreParenCasts
Stmt * getParentIgnoreParenCasts(Stmt *) const
Definition: ParentMap.cpp:134
clang::ParentMap::getOuterParenParent
Stmt * getOuterParenParent(Stmt *) const
Definition: ParentMap.cpp:151