CFGStmtMap.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- CFGStmtMap.h - Map from Stmt* to CFGBlock* -----------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the CFGStmtMap class, which defines a mapping from
  15. // Stmt* to CFGBlock*
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H
  19. #define LLVM_CLANG_ANALYSIS_CFGSTMTMAP_H
  20. #include "clang/Analysis/CFG.h"
  21. namespace clang {
  22. class ParentMap;
  23. class Stmt;
  24. class CFGStmtMap {
  25. ParentMap *PM;
  26. void *M;
  27. CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {}
  28. public:
  29. ~CFGStmtMap();
  30. /// Returns a new CFGMap for the given CFG. It is the caller's
  31. /// responsibility to 'delete' this object when done using it.
  32. static CFGStmtMap *Build(CFG* C, ParentMap *PM);
  33. /// Returns the CFGBlock the specified Stmt* appears in. For Stmt* that
  34. /// are terminators, the CFGBlock is the block they appear as a terminator,
  35. /// and not the block they appear as a block-level expression (e.g, '&&').
  36. /// CaseStmts and LabelStmts map to the CFGBlock they label.
  37. CFGBlock *getBlock(Stmt * S);
  38. const CFGBlock *getBlock(const Stmt * S) const {
  39. return const_cast<CFGStmtMap*>(this)->getBlock(const_cast<Stmt*>(S));
  40. }
  41. };
  42. } // end clang namespace
  43. #endif
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif