clang 20.0.0git
CFGStmtMap.h
Go to the documentation of this file.
1//===--- CFGStmtMap.h - Map from Stmt* to CFGBlock* -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the CFGStmtMap class, which defines a mapping from
10// Stmt* to CFGBlock*
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H
15#define LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H
16
17#include "clang/Analysis/CFG.h"
18
19namespace clang {
20
21class ParentMap;
22class Stmt;
23
25 ParentMap *PM;
26 void *M;
27
28 CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {}
29 CFGStmtMap(const CFGStmtMap &) = delete;
30 CFGStmtMap &operator=(const CFGStmtMap &) = delete;
31
32public:
34
35 /// Returns a new CFGMap for the given CFG. It is the caller's
36 /// responsibility to 'delete' this object when done using it.
37 static CFGStmtMap *Build(CFG* C, ParentMap *PM);
38
39 /// Returns the CFGBlock the specified Stmt* appears in. For Stmt* that
40 /// are terminators, the CFGBlock is the block they appear as a terminator,
41 /// and not the block they appear as a block-level expression (e.g, '&&').
42 /// CaseStmts and LabelStmts map to the CFGBlock they label.
44
45 const CFGBlock *getBlock(const Stmt * S) const {
46 return const_cast<CFGStmtMap*>(this)->getBlock(const_cast<Stmt*>(S));
47 }
48};
49
50} // end clang namespace
51#endif
Represents a single basic block in a source-level CFG.
Definition: CFG.h:604
const CFGBlock * getBlock(const Stmt *S) const
Definition: CFGStmtMap.h:45
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
Definition: CFGStmtMap.cpp:27
static CFGStmtMap * Build(CFG *C, ParentMap *PM)
Returns a new CFGMap for the given CFG.
Definition: CFGStmtMap.cpp:78
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition: CFG.h:1214
Stmt - This represents one statement.
Definition: Stmt.h:84
The JSON file list parser is used to communicate input to InstallAPI.