1 //===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the ParentMap class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_PARENTMAP_H
15 #define LLVM_CLANG_PARENTMAP_H
24 ParentMap(Stmt* ASTRoot);
27 /// \brief 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);
32 Stmt *getParent(Stmt*) const;
33 Stmt *getParentIgnoreParens(Stmt *) const;
34 Stmt *getParentIgnoreParenCasts(Stmt *) const;
35 Stmt *getOuterParenParent(Stmt *) const;
37 const Stmt *getParent(const Stmt* S) const {
38 return getParent(const_cast<Stmt*>(S));
41 const Stmt *getParentIgnoreParens(const Stmt *S) const {
42 return getParentIgnoreParens(const_cast<Stmt*>(S));
45 const Stmt *getParentIgnoreParenCasts(const Stmt *S) const {
46 return getParentIgnoreParenCasts(const_cast<Stmt*>(S));
49 bool hasParent(Stmt* S) const {
50 return getParent(S) != 0;
53 bool isConsumedExpr(Expr *E) const;
55 bool isConsumedExpr(const Expr *E) const {
56 return isConsumedExpr(const_cast<Expr*>(E));
60 } // end clang namespace