]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/tools/clang/include/clang/Analysis/CFGStmtMap.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / tools / clang / include / clang / Analysis / CFGStmtMap.h
1 //===--- CFGStmtMap.h - Map from Stmt* to CFGBlock* -----------*- 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 CFGStmtMap class, which defines a mapping from
11 //  Stmt* to CFGBlock*
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_CFGSTMTMAP_H
16 #define LLVM_CLANG_CFGSTMTMAP_H
17
18 #include "clang/Analysis/CFG.h"
19
20 namespace clang {
21
22 class CFG;
23 class CFGBlock;
24 class ParentMap;
25 class Stmt;
26
27 class CFGStmtMap {
28   ParentMap *PM;
29   void *M;
30   
31   CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {}
32   
33 public:
34   ~CFGStmtMap();
35   
36   /// Returns a new CFGMap for the given CFG.  It is the caller's
37   /// responsibility to 'delete' this object when done using it.
38   static CFGStmtMap *Build(CFG* C, ParentMap *PM);
39
40   /// Returns the CFGBlock the specified Stmt* appears in.  For Stmt* that
41   /// are terminators, the CFGBlock is the block they appear as a terminator,
42   /// and not the block they appear as a block-level expression (e.g, '&&').
43   /// CaseStmts and LabelStmts map to the CFGBlock they label.
44   CFGBlock *getBlock(Stmt * S);
45
46   const CFGBlock *getBlock(const Stmt * S) const {
47     return const_cast<CFGStmtMap*>(this)->getBlock(const_cast<Stmt*>(S));
48   }
49 };
50
51 } // end clang namespace
52 #endif