clang  6.0.0svn
CFGStmtMap.h
Go to the documentation of this file.
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_ANALYSIS_CFGSTMTMAP_H
16 #define LLVM_CLANG_ANALYSIS_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
Stmt - This represents one statement.
Definition: Stmt.h:60
CFGBlock - Represents a single basic block in a source-level CFG.
Definition: CFG.h:401
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
Definition: CFG.h:808
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
Definition: CFGStmtMap.cpp:27
Dataflow Directional Tag Classes.
static CFGStmtMap * Build(CFG *C, ParentMap *PM)
Returns a new CFGMap for the given CFG.
Definition: CFGStmtMap.cpp:78
const CFGBlock * getBlock(const Stmt *S) const
Definition: CFGStmtMap.h:46