DebugSupport.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- DebugSupport.h ------------------------------------------*- 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 functions which generate more readable forms of data
  15. // structures used in the dataflow analyses, for debugging purposes.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DEBUGSUPPORT_H_
  19. #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DEBUGSUPPORT_H_
  20. #include <string>
  21. #include <vector>
  22. #include "clang/Analysis/FlowSensitive/Solver.h"
  23. #include "clang/Analysis/FlowSensitive/Value.h"
  24. #include "llvm/ADT/DenseMap.h"
  25. #include "llvm/ADT/StringRef.h"
  26. namespace clang {
  27. namespace dataflow {
  28. /// Returns a string representation of a value kind.
  29. llvm::StringRef debugString(Value::Kind Kind);
  30. /// Returns a string representation of a boolean assignment to true or false.
  31. llvm::StringRef debugString(Solver::Result::Assignment Assignment);
  32. /// Returns a string representation of the result status of a SAT check.
  33. llvm::StringRef debugString(Solver::Result::Status Status);
  34. /// Returns a string representation for the boolean value `B`.
  35. ///
  36. /// Atomic booleans appearing in the boolean value `B` are assigned to labels
  37. /// either specified in `AtomNames` or created by default rules as B0, B1, ...
  38. ///
  39. /// Requirements:
  40. ///
  41. /// Names assigned to atoms should not be repeated in `AtomNames`.
  42. std::string debugString(
  43. const BoolValue &B,
  44. llvm::DenseMap<const AtomicBoolValue *, std::string> AtomNames = {{}});
  45. /// Returns a string representation for `Constraints` - a collection of boolean
  46. /// formulas.
  47. ///
  48. /// Atomic booleans appearing in the boolean value `Constraints` are assigned to
  49. /// labels either specified in `AtomNames` or created by default rules as B0,
  50. /// B1, ...
  51. ///
  52. /// Requirements:
  53. ///
  54. /// Names assigned to atoms should not be repeated in `AtomNames`.
  55. std::string debugString(
  56. const llvm::DenseSet<BoolValue *> &Constraints,
  57. llvm::DenseMap<const AtomicBoolValue *, std::string> AtomNames = {{}});
  58. /// Returns a string representation for `Constraints` - a collection of boolean
  59. /// formulas and the `Result` of satisfiability checking.
  60. ///
  61. /// Atomic booleans appearing in `Constraints` and `Result` are assigned to
  62. /// labels either specified in `AtomNames` or created by default rules as B0,
  63. /// B1, ...
  64. ///
  65. /// Requirements:
  66. ///
  67. /// Names assigned to atoms should not be repeated in `AtomNames`.
  68. std::string debugString(
  69. ArrayRef<BoolValue *> Constraints, const Solver::Result &Result,
  70. llvm::DenseMap<const AtomicBoolValue *, std::string> AtomNames = {{}});
  71. inline std::string debugString(
  72. const llvm::DenseSet<BoolValue *> &Constraints,
  73. const Solver::Result &Result,
  74. llvm::DenseMap<const AtomicBoolValue *, std::string> AtomNames = {{}}) {
  75. std::vector<BoolValue *> ConstraintsVec(Constraints.begin(),
  76. Constraints.end());
  77. return debugString(ConstraintsVec, Result, std::move(AtomNames));
  78. }
  79. } // namespace dataflow
  80. } // namespace clang
  81. #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DEBUGSUPPORT_H_
  82. #ifdef __GNUC__
  83. #pragma GCC diagnostic pop
  84. #endif