clang API Documentation
00001 //===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the ParentMap class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_PARENTMAP_H 00015 #define LLVM_CLANG_PARENTMAP_H 00016 00017 namespace clang { 00018 class Stmt; 00019 class Expr; 00020 00021 class ParentMap { 00022 void* Impl; 00023 public: 00024 ParentMap(Stmt* ASTRoot); 00025 ~ParentMap(); 00026 00027 /// \brief Adds and/or updates the parent/child-relations of the complete 00028 /// stmt tree of S. All children of S including indirect descendants are 00029 /// visited and updated or inserted but not the parents of S. 00030 void addStmt(Stmt* S); 00031 00032 Stmt *getParent(Stmt*) const; 00033 Stmt *getParentIgnoreParens(Stmt *) const; 00034 Stmt *getParentIgnoreParenCasts(Stmt *) const; 00035 Stmt *getParentIgnoreParenImpCasts(Stmt *) const; 00036 Stmt *getOuterParenParent(Stmt *) const; 00037 00038 const Stmt *getParent(const Stmt* S) const { 00039 return getParent(const_cast<Stmt*>(S)); 00040 } 00041 00042 const Stmt *getParentIgnoreParens(const Stmt *S) const { 00043 return getParentIgnoreParens(const_cast<Stmt*>(S)); 00044 } 00045 00046 const Stmt *getParentIgnoreParenCasts(const Stmt *S) const { 00047 return getParentIgnoreParenCasts(const_cast<Stmt*>(S)); 00048 } 00049 00050 bool hasParent(Stmt* S) const { 00051 return getParent(S) != 0; 00052 } 00053 00054 bool isConsumedExpr(Expr *E) const; 00055 00056 bool isConsumedExpr(const Expr *E) const { 00057 return isConsumedExpr(const_cast<Expr*>(E)); 00058 } 00059 }; 00060 00061 } // end clang namespace 00062 #endif