Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:40

0001 //===--- ParentMap.h - Mappings from Stmts to their Parents -----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines the ParentMap class.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CLANG_AST_PARENTMAP_H
0014 #define LLVM_CLANG_AST_PARENTMAP_H
0015 
0016 namespace clang {
0017 class Stmt;
0018 class Expr;
0019 
0020 class ParentMap {
0021   void* Impl;
0022 public:
0023   ParentMap(Stmt* ASTRoot);
0024   ~ParentMap();
0025 
0026   /// Adds and/or updates the parent/child-relations of the complete
0027   /// stmt tree of S. All children of S including indirect descendants are
0028   /// visited and updated or inserted but not the parents of S.
0029   void addStmt(Stmt* S);
0030 
0031   /// Manually sets the parent of \p S to \p Parent.
0032   ///
0033   /// If \p S is already in the map, this method will update the mapping.
0034   void setParent(const Stmt *S, const Stmt *Parent);
0035 
0036   Stmt *getParent(Stmt*) const;
0037   Stmt *getParentIgnoreParens(Stmt *) const;
0038   Stmt *getParentIgnoreParenCasts(Stmt *) const;
0039   Stmt *getParentIgnoreParenImpCasts(Stmt *) const;
0040   Stmt *getOuterParenParent(Stmt *) const;
0041 
0042   const Stmt *getParent(const Stmt* S) const {
0043     return getParent(const_cast<Stmt*>(S));
0044   }
0045 
0046   const Stmt *getParentIgnoreParens(const Stmt *S) const {
0047     return getParentIgnoreParens(const_cast<Stmt*>(S));
0048   }
0049 
0050   const Stmt *getParentIgnoreParenCasts(const Stmt *S) const {
0051     return getParentIgnoreParenCasts(const_cast<Stmt*>(S));
0052   }
0053 
0054   bool hasParent(const Stmt *S) const { return getParent(S) != nullptr; }
0055 
0056   bool isConsumedExpr(Expr *E) const;
0057 
0058   bool isConsumedExpr(const Expr *E) const {
0059     return isConsumedExpr(const_cast<Expr*>(E));
0060   }
0061 };
0062 
0063 } // end clang namespace
0064 #endif