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