Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.9 KiB

  1. //===---- llvm/Support/DebugLoc.h - Debug Location Information --*- 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 a number of light weight data structures used
  11. // to describe and track debug location information.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_SUPPORT_DEBUGLOC_H
  15. #define LLVM_SUPPORT_DEBUGLOC_H
  16. namespace llvm {
  17. template <typename T> struct DenseMapInfo;
  18. class MDNode;
  19. class LLVMContext;
  20. /// DebugLoc - Debug location id. This is carried by Instruction, SDNode,
  21. /// and MachineInstr to compactly encode file/line/scope information for an
  22. /// operation.
  23. class DebugLoc {
  24. friend struct DenseMapInfo<DebugLoc>;
  25. /// getEmptyKey() - A private constructor that returns an unknown that is
  26. /// not equal to the tombstone key or DebugLoc().
  27. static DebugLoc getEmptyKey() {
  28. DebugLoc DL;
  29. DL.LineCol = 1;
  30. return DL;
  31. }
  32. /// getTombstoneKey() - A private constructor that returns an unknown that
  33. /// is not equal to the empty key or DebugLoc().
  34. static DebugLoc getTombstoneKey() {
  35. DebugLoc DL;
  36. DL.LineCol = 2;
  37. return DL;
  38. }
  39. /// LineCol - This 32-bit value encodes the line and column number for the
  40. /// location, encoded as 24-bits for line and 8 bits for col. A value of 0
  41. /// for either means unknown.
  42. unsigned LineCol;
  43. /// ScopeIdx - This is an opaque ID# for Scope/InlinedAt information,
  44. /// decoded by LLVMContext. 0 is unknown.
  45. int ScopeIdx;
  46. public:
  47. DebugLoc() : LineCol(0), ScopeIdx(0) {} // Defaults to unknown.
  48. /// get - Get a new DebugLoc that corresponds to the specified line/col
  49. /// scope/inline location.
  50. static DebugLoc get(unsigned Line, unsigned Col,
  51. MDNode *Scope, MDNode *InlinedAt = 0);
  52. /// getFromDILocation - Translate the DILocation quad into a DebugLoc.
  53. static DebugLoc getFromDILocation(MDNode *N);
  54. /// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
  55. static DebugLoc getFromDILexicalBlock(MDNode *N);
  56. /// isUnknown - Return true if this is an unknown location.
  57. bool isUnknown() const { return ScopeIdx == 0; }
  58. unsigned getLine() const {
  59. return (LineCol << 8) >> 8; // Mask out column.
  60. }
  61. unsigned getCol() const {
  62. return LineCol >> 24;
  63. }
  64. /// getScope - This returns the scope pointer for this DebugLoc, or null if
  65. /// invalid.
  66. MDNode *getScope(const LLVMContext &Ctx) const;
  67. /// getInlinedAt - This returns the InlinedAt pointer for this DebugLoc, or
  68. /// null if invalid or not present.
  69. MDNode *getInlinedAt(const LLVMContext &Ctx) const;
  70. /// getScopeAndInlinedAt - Return both the Scope and the InlinedAt values.
  71. void getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA,
  72. const LLVMContext &Ctx) const;
  73. /// getAsMDNode - This method converts the compressed DebugLoc node into a
  74. /// DILocation compatible MDNode.
  75. MDNode *getAsMDNode(const LLVMContext &Ctx) const;
  76. bool operator==(const DebugLoc &DL) const {
  77. return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx;
  78. }
  79. bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
  80. void dump(const LLVMContext &Ctx) const;
  81. };
  82. template <>
  83. struct DenseMapInfo<DebugLoc> {
  84. static DebugLoc getEmptyKey() { return DebugLoc::getEmptyKey(); }
  85. static DebugLoc getTombstoneKey() { return DebugLoc::getTombstoneKey(); }
  86. static unsigned getHashValue(const DebugLoc &Key);
  87. static bool isEqual(DebugLoc LHS, DebugLoc RHS) { return LHS == RHS; }
  88. };
  89. } // end namespace llvm
  90. #endif /* LLVM_SUPPORT_DEBUGLOC_H */