clang API Documentation
00001 //===--- CFGStmtMap.h - Map from Stmt* to CFGBlock* -----------*- 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 CFGStmtMap class, which defines a mapping from 00011 // Stmt* to CFGBlock* 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H 00016 #define LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H 00017 00018 #include "clang/Analysis/CFG.h" 00019 00020 namespace clang { 00021 00022 class CFG; 00023 class CFGBlock; 00024 class ParentMap; 00025 class Stmt; 00026 00027 class CFGStmtMap { 00028 ParentMap *PM; 00029 void *M; 00030 00031 CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {} 00032 00033 public: 00034 ~CFGStmtMap(); 00035 00036 /// Returns a new CFGMap for the given CFG. It is the caller's 00037 /// responsibility to 'delete' this object when done using it. 00038 static CFGStmtMap *Build(CFG* C, ParentMap *PM); 00039 00040 /// Returns the CFGBlock the specified Stmt* appears in. For Stmt* that 00041 /// are terminators, the CFGBlock is the block they appear as a terminator, 00042 /// and not the block they appear as a block-level expression (e.g, '&&'). 00043 /// CaseStmts and LabelStmts map to the CFGBlock they label. 00044 CFGBlock *getBlock(Stmt * S); 00045 00046 const CFGBlock *getBlock(const Stmt * S) const { 00047 return const_cast<CFGStmtMap*>(this)->getBlock(const_cast<Stmt*>(S)); 00048 } 00049 }; 00050 00051 } // end clang namespace 00052 #endif