Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 1 | //===--- llvm/Analysis/DebugInfo.h - Debug Information Helpers --*- 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 bunch of datatypes that are useful for creating and |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 11 | // walking debug info in LLVM IR form. They essentially provide wrappers around |
| 12 | // the information in the global variables that's needed when constructing the |
| 13 | // DWARF information. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Evan Cheng | 891415b | 2009-01-26 07:31:20 +0000 | [diff] [blame] | 17 | #ifndef LLVM_ANALYSIS_DEBUGINFO_H |
| 18 | #define LLVM_ANALYSIS_DEBUGINFO_H |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 19 | |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 20 | #include "llvm/Metadata.h" |
Argyrios Kyrtzidis | 77eaa68 | 2009-05-03 08:50:41 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetMachine.h" |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/StringMap.h" |
| 23 | #include "llvm/ADT/DenseMap.h" |
Devang Patel | 13e16b6 | 2009-06-26 01:49:18 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/SmallVector.h" |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/SmallPtrSet.h" |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Dwarf.h" |
Daniel Dunbar | 48a097b | 2009-09-22 02:03:18 +0000 | [diff] [blame] | 27 | #include "llvm/Support/ValueHandle.h" |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 28 | |
| 29 | namespace llvm { |
| 30 | class BasicBlock; |
| 31 | class Constant; |
| 32 | class Function; |
| 33 | class GlobalVariable; |
| 34 | class Module; |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 35 | class Type; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 36 | class Value; |
Cedric Venet | aff9c27 | 2009-02-14 16:06:42 +0000 | [diff] [blame] | 37 | struct DbgStopPointInst; |
| 38 | struct DbgDeclareInst; |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 39 | struct DbgFuncStartInst; |
| 40 | struct DbgRegionStartInst; |
| 41 | struct DbgRegionEndInst; |
| 42 | class DebugLoc; |
Daniel Dunbar | 460d16e | 2009-07-12 22:46:08 +0000 | [diff] [blame] | 43 | struct DebugLocTracker; |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 44 | class Instruction; |
Benjamin Kramer | 12ddd40 | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 45 | class LLVMContext; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 46 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 47 | class DIDescriptor { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 48 | protected: |
Daniel Dunbar | 48a097b | 2009-09-22 02:03:18 +0000 | [diff] [blame] | 49 | TrackingVH<MDNode> DbgNode; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 50 | |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 51 | /// DIDescriptor constructor. If the specified node is non-null, check |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 52 | /// to make sure that the tag in the descriptor matches 'RequiredTag'. If |
| 53 | /// not, the debug info is corrupt and we ignore it. |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 54 | DIDescriptor(MDNode *N, unsigned RequiredTag); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 55 | |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 56 | const char *getStringField(unsigned Elt) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 57 | unsigned getUnsignedField(unsigned Elt) const { |
| 58 | return (unsigned)getUInt64Field(Elt); |
| 59 | } |
| 60 | uint64_t getUInt64Field(unsigned Elt) const; |
| 61 | DIDescriptor getDescriptorField(unsigned Elt) const; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 62 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 63 | template <typename DescTy> |
| 64 | DescTy getFieldAs(unsigned Elt) const { |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 65 | return DescTy(getDescriptorField(Elt).getNode()); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 66 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 67 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 68 | GlobalVariable *getGlobalVariableField(unsigned Elt) const; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 69 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 70 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 71 | explicit DIDescriptor() : DbgNode(0) {} |
| 72 | explicit DIDescriptor(MDNode *N) : DbgNode(N) {} |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 73 | |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 74 | bool isNull() const { return DbgNode == 0; } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 75 | |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 76 | MDNode *getNode() const { return DbgNode; } |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 77 | |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 78 | unsigned getVersion() const { |
Devang Patel | 6906ba5 | 2009-01-20 19:22:03 +0000 | [diff] [blame] | 79 | return getUnsignedField(0) & LLVMDebugVersionMask; |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 80 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 81 | |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 82 | unsigned getTag() const { |
Devang Patel | 6906ba5 | 2009-01-20 19:22:03 +0000 | [diff] [blame] | 83 | return getUnsignedField(0) & ~LLVMDebugVersionMask; |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 84 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 85 | |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 86 | /// ValidDebugInfo - Return true if N represents valid debug info value. |
| 87 | static bool ValidDebugInfo(MDNode *N, CodeGenOpt::Level OptLevel); |
Argyrios Kyrtzidis | 77eaa68 | 2009-05-03 08:50:41 +0000 | [diff] [blame] | 88 | |
Bill Wendling | 16de013 | 2009-05-05 22:19:25 +0000 | [diff] [blame] | 89 | /// dump - print descriptor. |
| 90 | void dump() const; |
Devang Patel | 6ceea33 | 2009-08-31 18:49:10 +0000 | [diff] [blame] | 91 | |
| 92 | bool isDerivedType() const; |
| 93 | bool isCompositeType() const; |
| 94 | bool isBasicType() const; |
| 95 | bool isVariable() const; |
| 96 | bool isSubprogram() const; |
| 97 | bool isGlobalVariable() const; |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 98 | bool isScope() const; |
Devang Patel | c9f322d | 2009-08-31 21:34:44 +0000 | [diff] [blame] | 99 | bool isCompileUnit() const; |
Devang Patel | 5e005d8 | 2009-08-31 22:00:15 +0000 | [diff] [blame] | 100 | bool isLexicalBlock() const; |
Devang Patel | ecbeb1a | 2009-09-30 22:34:41 +0000 | [diff] [blame] | 101 | bool isSubrange() const; |
| 102 | bool isEnumerator() const; |
| 103 | bool isType() const; |
| 104 | bool isGlobal() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 105 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 106 | |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 107 | /// DISubrange - This is used to represent ranges, for array bounds. |
| 108 | class DISubrange : public DIDescriptor { |
| 109 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 110 | explicit DISubrange(MDNode *N = 0) |
| 111 | : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 112 | |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 113 | int64_t getLo() const { return (int64_t)getUInt64Field(1); } |
| 114 | int64_t getHi() const { return (int64_t)getUInt64Field(2); } |
| 115 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 116 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 117 | /// DIArray - This descriptor holds an array of descriptors. |
| 118 | class DIArray : public DIDescriptor { |
| 119 | public: |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 120 | explicit DIArray(MDNode *N = 0) |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 121 | : DIDescriptor(N) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 122 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 123 | unsigned getNumElements() const; |
Devang Patel | a22d57d | 2009-01-05 19:55:07 +0000 | [diff] [blame] | 124 | DIDescriptor getElement(unsigned Idx) const { |
| 125 | return getDescriptorField(Idx); |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 126 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 127 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 128 | |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 129 | /// DIScope - A base class for various scopes. |
| 130 | class DIScope : public DIDescriptor { |
| 131 | public: |
| 132 | explicit DIScope(MDNode *N = 0) : DIDescriptor (N) { |
| 133 | if (DbgNode && !isScope()) |
| 134 | DbgNode = 0; |
| 135 | } |
Devang Patel | e5b1454 | 2009-09-01 05:04:28 +0000 | [diff] [blame] | 136 | virtual ~DIScope() {} |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 137 | |
Devang Patel | ecbeb1a | 2009-09-30 22:34:41 +0000 | [diff] [blame] | 138 | const char *getFilename() const; |
| 139 | const char *getDirectory() const; |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 142 | /// DICompileUnit - A wrapper for a compile unit. |
Devang Patel | c9f322d | 2009-08-31 21:34:44 +0000 | [diff] [blame] | 143 | class DICompileUnit : public DIScope { |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 144 | public: |
Daniel Dunbar | 7dd76a1 | 2009-09-19 20:40:28 +0000 | [diff] [blame] | 145 | explicit DICompileUnit(MDNode *N = 0) : DIScope(N) { |
Devang Patel | c9f322d | 2009-08-31 21:34:44 +0000 | [diff] [blame] | 146 | if (DbgNode && !isCompileUnit()) |
Daniel Dunbar | 3fc19bb | 2009-09-19 20:40:21 +0000 | [diff] [blame] | 147 | DbgNode = 0; |
Devang Patel | c9f322d | 2009-08-31 21:34:44 +0000 | [diff] [blame] | 148 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 149 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 150 | unsigned getLanguage() const { return getUnsignedField(2); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 151 | const char *getFilename() const { return getStringField(3); } |
| 152 | const char *getDirectory() const { return getStringField(4); } |
| 153 | const char *getProducer() const { return getStringField(5); } |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 154 | |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 155 | /// isMain - Each input file is encoded as a separate compile unit in LLVM |
| 156 | /// debugging information output. However, many target specific tool chains |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 157 | /// prefer to encode only one compile unit in an object file. In this |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 158 | /// situation, the LLVM code generator will include debugging information |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 159 | /// entities in the compile unit that is marked as main compile unit. The |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 160 | /// code generator accepts maximum one main compile unit per module. If a |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 161 | /// module does not contain any main compile unit then the code generator |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 162 | /// will emit multiple compile units in the output object file. |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 163 | |
Devang Patel | 36375ee | 2009-02-17 21:23:59 +0000 | [diff] [blame] | 164 | bool isMain() const { return getUnsignedField(6); } |
| 165 | bool isOptimized() const { return getUnsignedField(7); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 166 | const char *getFlags() const { return getStringField(8); } |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 167 | unsigned getRunTimeVersion() const { return getUnsignedField(9); } |
Devang Patel | ce31b02 | 2009-01-20 18:13:03 +0000 | [diff] [blame] | 168 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 169 | /// Verify - Verify that a compile unit is well formed. |
| 170 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 171 | |
| 172 | /// dump - print compile unit. |
| 173 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}'). |
| 177 | /// FIXME: it seems strange that this doesn't have either a reference to the |
| 178 | /// type/precision or a file/line pair for location info. |
| 179 | class DIEnumerator : public DIDescriptor { |
| 180 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 181 | explicit DIEnumerator(MDNode *N = 0) |
| 182 | : DIDescriptor(N, dwarf::DW_TAG_enumerator) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 183 | |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 184 | const char *getName() const { return getStringField(1); } |
| 185 | uint64_t getEnumValue() const { return getUInt64Field(2); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 186 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 187 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 188 | /// DIType - This is a wrapper for a type. |
| 189 | /// FIXME: Types should be factored much better so that CV qualifiers and |
| 190 | /// others do not require a huge and empty descriptor full of zeros. |
| 191 | class DIType : public DIDescriptor { |
Devang Patel | 2a57466 | 2009-01-20 22:27:02 +0000 | [diff] [blame] | 192 | public: |
| 193 | enum { |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 194 | FlagPrivate = 1 << 0, |
| 195 | FlagProtected = 1 << 1, |
| 196 | FlagFwdDecl = 1 << 2, |
| 197 | FlagAppleBlock = 1 << 3, |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 198 | FlagBlockByrefStruct = 1 << 4 |
Devang Patel | 2a57466 | 2009-01-20 22:27:02 +0000 | [diff] [blame] | 199 | }; |
| 200 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 201 | protected: |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 202 | DIType(MDNode *N, unsigned Tag) |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 203 | : DIDescriptor(N, Tag) {} |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 204 | // This ctor is used when the Tag has already been validated by a derived |
| 205 | // ctor. |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 206 | DIType(MDNode *N, bool, bool) : DIDescriptor(N) {} |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 207 | |
Devang Patel | f193ff0 | 2009-01-15 19:26:23 +0000 | [diff] [blame] | 208 | public: |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 209 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 210 | /// Verify - Verify that a type descriptor is well formed. |
| 211 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 212 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 213 | explicit DIType(MDNode *N); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 214 | explicit DIType() {} |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 215 | virtual ~DIType() {} |
| 216 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 217 | DIDescriptor getContext() const { return getDescriptorField(1); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 218 | const char *getName() const { return getStringField(2); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 219 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); } |
| 220 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 221 | uint64_t getSizeInBits() const { return getUInt64Field(5); } |
| 222 | uint64_t getAlignInBits() const { return getUInt64Field(6); } |
| 223 | // FIXME: Offset is only used for DW_TAG_member nodes. Making every type |
| 224 | // carry this is just plain insane. |
| 225 | uint64_t getOffsetInBits() const { return getUInt64Field(7); } |
| 226 | unsigned getFlags() const { return getUnsignedField(8); } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 227 | bool isPrivate() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 228 | return (getFlags() & FlagPrivate) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 229 | } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 230 | bool isProtected() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 231 | return (getFlags() & FlagProtected) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 232 | } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 233 | bool isForwardDecl() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 234 | return (getFlags() & FlagFwdDecl) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 235 | } |
Devang Patel | a1ba269 | 2009-08-27 23:51:51 +0000 | [diff] [blame] | 236 | // isAppleBlock - Return true if this is the Apple Blocks extension. |
| 237 | bool isAppleBlockExtension() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 238 | return (getFlags() & FlagAppleBlock) != 0; |
Devang Patel | 8af76bd | 2009-08-26 00:39:50 +0000 | [diff] [blame] | 239 | } |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 240 | bool isBlockByrefStruct() const { |
| 241 | return (getFlags() & FlagBlockByrefStruct) != 0; |
| 242 | } |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 243 | |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 244 | /// dump - print type. |
| 245 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 246 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 247 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 248 | /// DIBasicType - A basic type, like 'int' or 'float'. |
| 249 | class DIBasicType : public DIType { |
| 250 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 251 | explicit DIBasicType(MDNode *N = 0) |
| 252 | : DIType(N, dwarf::DW_TAG_base_type) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 253 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 254 | unsigned getEncoding() const { return getUnsignedField(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 255 | |
| 256 | /// dump - print basic type. |
| 257 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 258 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 259 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 260 | /// DIDerivedType - A simple derived type, like a const qualified type, |
| 261 | /// a typedef, a pointer or reference, etc. |
| 262 | class DIDerivedType : public DIType { |
| 263 | protected: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 264 | explicit DIDerivedType(MDNode *N, bool, bool) |
| 265 | : DIType(N, true, true) {} |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 266 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 267 | explicit DIDerivedType(MDNode *N = 0) |
| 268 | : DIType(N, true, true) { |
Devang Patel | 6ceea33 | 2009-08-31 18:49:10 +0000 | [diff] [blame] | 269 | if (DbgNode && !isDerivedType()) |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 270 | DbgNode = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 273 | DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 274 | |
Devang Patel | 36375ee | 2009-02-17 21:23:59 +0000 | [diff] [blame] | 275 | /// getOriginalTypeSize - If this type is derived from a base type then |
| 276 | /// return base type size. |
| 277 | uint64_t getOriginalTypeSize() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 278 | /// dump - print derived type. |
| 279 | void dump() const; |
Devang Patel | c4999d7 | 2009-07-22 18:23:44 +0000 | [diff] [blame] | 280 | |
| 281 | /// replaceAllUsesWith - Replace all uses of debug info referenced by |
| 282 | /// this descriptor. After this completes, the current debug info value |
| 283 | /// is erased. |
| 284 | void replaceAllUsesWith(DIDescriptor &D); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 285 | }; |
| 286 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 287 | /// DICompositeType - This descriptor holds a type that can refer to multiple |
| 288 | /// other types, like a function or struct. |
| 289 | /// FIXME: Why is this a DIDerivedType?? |
| 290 | class DICompositeType : public DIDerivedType { |
| 291 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 292 | explicit DICompositeType(MDNode *N = 0) |
| 293 | : DIDerivedType(N, true, true) { |
Devang Patel | 6ceea33 | 2009-08-31 18:49:10 +0000 | [diff] [blame] | 294 | if (N && !isCompositeType()) |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 295 | DbgNode = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 298 | DIArray getTypeArray() const { return getFieldAs<DIArray>(10); } |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 299 | unsigned getRunTimeLang() const { return getUnsignedField(11); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 300 | |
| 301 | /// Verify - Verify that a composite type descriptor is well formed. |
| 302 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 303 | |
| 304 | /// dump - print composite type. |
| 305 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 306 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 307 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 308 | /// DIGlobal - This is a common class for global variables and subprograms. |
| 309 | class DIGlobal : public DIDescriptor { |
| 310 | protected: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 311 | explicit DIGlobal(MDNode *N, unsigned RequiredTag) |
| 312 | : DIDescriptor(N, RequiredTag) {} |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 313 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 314 | public: |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 315 | virtual ~DIGlobal() {} |
| 316 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 317 | DIDescriptor getContext() const { return getDescriptorField(2); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 318 | const char *getName() const { return getStringField(3); } |
| 319 | const char *getDisplayName() const { return getStringField(4); } |
| 320 | const char *getLinkageName() const { return getStringField(5); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 321 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); } |
| 322 | unsigned getLineNumber() const { return getUnsignedField(7); } |
| 323 | DIType getType() const { return getFieldAs<DIType>(8); } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 324 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 325 | /// isLocalToUnit - Return true if this subprogram is local to the current |
| 326 | /// compile unit, like 'static' in C. |
| 327 | unsigned isLocalToUnit() const { return getUnsignedField(9); } |
| 328 | unsigned isDefinition() const { return getUnsignedField(10); } |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 329 | |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 330 | /// dump - print global. |
| 331 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 332 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 333 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 334 | /// DISubprogram - This is a wrapper for a subprogram (e.g. a function). |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 335 | class DISubprogram : public DIScope { |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 336 | public: |
Daniel Dunbar | 7dd76a1 | 2009-09-19 20:40:28 +0000 | [diff] [blame] | 337 | explicit DISubprogram(MDNode *N = 0) : DIScope(N) { |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 338 | if (DbgNode && !isSubprogram()) |
Daniel Dunbar | 3fc19bb | 2009-09-19 20:40:21 +0000 | [diff] [blame] | 339 | DbgNode = 0; |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 340 | } |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 341 | |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 342 | DIDescriptor getContext() const { return getDescriptorField(2); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 343 | const char *getName() const { return getStringField(3); } |
| 344 | const char *getDisplayName() const { return getStringField(4); } |
| 345 | const char *getLinkageName() const { return getStringField(5); } |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 346 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); } |
| 347 | unsigned getLineNumber() const { return getUnsignedField(7); } |
Devang Patel | 86ae142 | 2009-01-05 18:59:44 +0000 | [diff] [blame] | 348 | DICompositeType getType() const { return getFieldAs<DICompositeType>(8); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 349 | |
Devang Patel | 0de4fa6 | 2009-06-23 22:07:48 +0000 | [diff] [blame] | 350 | /// getReturnTypeName - Subprogram return types are encoded either as |
| 351 | /// DIType or as DICompositeType. |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 352 | const char *getReturnTypeName() const { |
Devang Patel | 0de4fa6 | 2009-06-23 22:07:48 +0000 | [diff] [blame] | 353 | DICompositeType DCT(getFieldAs<DICompositeType>(8)); |
| 354 | if (!DCT.isNull()) { |
| 355 | DIArray A = DCT.getTypeArray(); |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 356 | DIType T(A.getElement(0).getNode()); |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 357 | return T.getName(); |
Devang Patel | 0de4fa6 | 2009-06-23 22:07:48 +0000 | [diff] [blame] | 358 | } |
| 359 | DIType T(getFieldAs<DIType>(8)); |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 360 | return T.getName(); |
Devang Patel | 0de4fa6 | 2009-06-23 22:07:48 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 363 | /// isLocalToUnit - Return true if this subprogram is local to the current |
| 364 | /// compile unit, like 'static' in C. |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 365 | unsigned isLocalToUnit() const { return getUnsignedField(9); } |
| 366 | unsigned isDefinition() const { return getUnsignedField(10); } |
| 367 | const char *getFilename() const { return getCompileUnit().getFilename();} |
| 368 | const char *getDirectory() const { return getCompileUnit().getDirectory();} |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 369 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 370 | /// Verify - Verify that a subprogram descriptor is well formed. |
| 371 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 372 | |
| 373 | /// dump - print subprogram. |
| 374 | void dump() const; |
Devang Patel | af5b6bb | 2009-04-15 00:06:07 +0000 | [diff] [blame] | 375 | |
| 376 | /// describes - Return true if this subprogram provides debugging |
| 377 | /// information for the function F. |
| 378 | bool describes(const Function *F); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 379 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 380 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 381 | /// DIGlobalVariable - This is a wrapper for a global variable. |
| 382 | class DIGlobalVariable : public DIGlobal { |
| 383 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 384 | explicit DIGlobalVariable(MDNode *N = 0) |
| 385 | : DIGlobal(N, dwarf::DW_TAG_variable) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 386 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 387 | GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 388 | |
| 389 | /// Verify - Verify that a global variable descriptor is well formed. |
| 390 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 391 | |
| 392 | /// dump - print global variable. |
| 393 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 394 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 395 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 396 | /// DIVariable - This is a wrapper for a variable (e.g. parameter, local, |
| 397 | /// global etc). |
| 398 | class DIVariable : public DIDescriptor { |
| 399 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 400 | explicit DIVariable(MDNode *N = 0) |
| 401 | : DIDescriptor(N) { |
Devang Patel | 6ceea33 | 2009-08-31 18:49:10 +0000 | [diff] [blame] | 402 | if (DbgNode && !isVariable()) |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 403 | DbgNode = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 404 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 405 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 406 | DIDescriptor getContext() const { return getDescriptorField(1); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 407 | const char *getName() const { return getStringField(2); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 408 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); } |
| 409 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 410 | DIType getType() const { return getFieldAs<DIType>(5); } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 411 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 412 | |
| 413 | /// Verify - Verify that a variable descriptor is well formed. |
| 414 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 415 | |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 416 | /// HasComplexAddr - Return true if the variable has a complex address. |
| 417 | bool hasComplexAddress() const { |
| 418 | return getNumAddrElements() > 0; |
| 419 | } |
| 420 | |
| 421 | unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; } |
| 422 | |
| 423 | uint64_t getAddrElement(unsigned Idx) const { |
| 424 | return getUInt64Field(Idx+6); |
| 425 | } |
| 426 | |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 427 | /// isBlockByrefVariable - Return true if the variable was declared as |
| 428 | /// a "__block" variable (Apple Blocks). |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 429 | bool isBlockByrefVariable() const { |
| 430 | return getType().isBlockByrefStruct(); |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 433 | /// dump - print variable. |
| 434 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 435 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 436 | |
Devang Patel | 5e005d8 | 2009-08-31 22:00:15 +0000 | [diff] [blame] | 437 | /// DILexicalBlock - This is a wrapper for a lexical block. |
| 438 | class DILexicalBlock : public DIScope { |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 439 | public: |
Daniel Dunbar | 7dd76a1 | 2009-09-19 20:40:28 +0000 | [diff] [blame] | 440 | explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 441 | if (DbgNode && !isLexicalBlock()) |
Daniel Dunbar | 3fc19bb | 2009-09-19 20:40:21 +0000 | [diff] [blame] | 442 | DbgNode = 0; |
Devang Patel | 5e005d8 | 2009-08-31 22:00:15 +0000 | [diff] [blame] | 443 | } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 444 | DIScope getContext() const { return getFieldAs<DIScope>(1); } |
Devang Patel | ecbeb1a | 2009-09-30 22:34:41 +0000 | [diff] [blame] | 445 | const char *getDirectory() const { return getContext().getDirectory(); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 446 | const char *getFilename() const { return getContext().getFilename(); } |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 447 | }; |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 448 | |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 449 | /// DILocation - This object holds location information. This object |
| 450 | /// is not associated with any DWARF tag. |
| 451 | class DILocation : public DIDescriptor { |
| 452 | public: |
Daniel Dunbar | 7dd76a1 | 2009-09-19 20:40:28 +0000 | [diff] [blame] | 453 | explicit DILocation(MDNode *N) : DIDescriptor(N) { ; } |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 454 | |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 455 | unsigned getLineNumber() const { return getUnsignedField(0); } |
| 456 | unsigned getColumnNumber() const { return getUnsignedField(1); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 457 | DIScope getScope() const { return getFieldAs<DIScope>(2); } |
| 458 | DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); } |
| 459 | const char *getFilename() const { return getScope().getFilename(); } |
| 460 | const char *getDirectory() const { return getScope().getDirectory(); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 461 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 462 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 463 | /// DIFactory - This object assists with the construction of the various |
| 464 | /// descriptors. |
| 465 | class DIFactory { |
| 466 | Module &M; |
Owen Anderson | 9903527 | 2009-07-07 17:12:53 +0000 | [diff] [blame] | 467 | LLVMContext& VMContext; |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 468 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 469 | // Cached values for uniquing and faster lookups. |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 470 | const Type *EmptyStructPtr; // "{}*". |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 471 | Function *StopPointFn; // llvm.dbg.stoppoint |
| 472 | Function *FuncStartFn; // llvm.dbg.func.start |
| 473 | Function *RegionStartFn; // llvm.dbg.region.start |
| 474 | Function *RegionEndFn; // llvm.dbg.region.end |
| 475 | Function *DeclareFn; // llvm.dbg.declare |
| 476 | StringMap<Constant*> StringCache; |
| 477 | DenseMap<Constant*, DIDescriptor> SimpleConstantCache; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 478 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 479 | DIFactory(const DIFactory &); // DO NOT IMPLEMENT |
| 480 | void operator=(const DIFactory&); // DO NOT IMPLEMENT |
| 481 | public: |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 482 | enum ComplexAddrKind { OpPlus=1, OpDeref }; |
| 483 | |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 484 | explicit DIFactory(Module &m); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 485 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 486 | /// GetOrCreateArray - Create an descriptor for an array of descriptors. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 487 | /// This implicitly uniques the arrays created. |
| 488 | DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys); |
| 489 | |
| 490 | /// GetOrCreateSubrange - Create a descriptor for a value range. This |
| 491 | /// implicitly uniques the values returned. |
| 492 | DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 493 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 494 | /// CreateCompileUnit - Create a new descriptor for the specified compile |
| 495 | /// unit. |
| 496 | DICompileUnit CreateCompileUnit(unsigned LangID, |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 497 | StringRef Filenae, |
| 498 | StringRef Directory, |
| 499 | StringRef Producer, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 500 | bool isMain = false, |
Devang Patel | 3b64c6b | 2009-01-23 22:33:47 +0000 | [diff] [blame] | 501 | bool isOptimized = false, |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 502 | const char *Flags = "", |
| 503 | unsigned RunTimeVer = 0); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 504 | |
| 505 | /// CreateEnumerator - Create a single enumerator value. |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 506 | DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 507 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 508 | /// CreateBasicType - Create a basic type like int, float, etc. |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 509 | DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 510 | DICompileUnit CompileUnit, unsigned LineNumber, |
| 511 | uint64_t SizeInBits, uint64_t AlignInBits, |
| 512 | uint64_t OffsetInBits, unsigned Flags, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 513 | unsigned Encoding); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 514 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 515 | /// CreateDerivedType - Create a derived type like const qualified type, |
| 516 | /// pointer, typedef, etc. |
| 517 | DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 518 | StringRef Name, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 519 | DICompileUnit CompileUnit, |
| 520 | unsigned LineNumber, |
| 521 | uint64_t SizeInBits, uint64_t AlignInBits, |
| 522 | uint64_t OffsetInBits, unsigned Flags, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 523 | DIType DerivedFrom); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 524 | |
| 525 | /// CreateCompositeType - Create a composite type like array, struct, etc. |
| 526 | DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 527 | StringRef Name, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 528 | DICompileUnit CompileUnit, |
| 529 | unsigned LineNumber, |
| 530 | uint64_t SizeInBits, |
| 531 | uint64_t AlignInBits, |
| 532 | uint64_t OffsetInBits, unsigned Flags, |
| 533 | DIType DerivedFrom, |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 534 | DIArray Elements, |
| 535 | unsigned RunTimeLang = 0); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 536 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 537 | /// CreateSubprogram - Create a new descriptor for the specified subprogram. |
| 538 | /// See comments in DISubprogram for descriptions of these fields. |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 539 | DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name, |
| 540 | StringRef DisplayName, |
| 541 | StringRef LinkageName, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 542 | DICompileUnit CompileUnit, unsigned LineNo, |
| 543 | DIType Type, bool isLocalToUnit, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 544 | bool isDefinition); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 545 | |
| 546 | /// CreateGlobalVariable - Create a new descriptor for the specified global. |
| 547 | DIGlobalVariable |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 548 | CreateGlobalVariable(DIDescriptor Context, StringRef Name, |
| 549 | StringRef DisplayName, |
| 550 | StringRef LinkageName, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 551 | DICompileUnit CompileUnit, |
| 552 | unsigned LineNo, DIType Type, bool isLocalToUnit, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 553 | bool isDefinition, llvm::GlobalVariable *GV); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 554 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 555 | /// CreateVariable - Create a new descriptor for the specified variable. |
| 556 | DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 557 | StringRef Name, |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 558 | DICompileUnit CompileUnit, unsigned LineNo, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 559 | DIType Type); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 560 | |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 561 | /// CreateComplexVariable - Create a new descriptor for the specified |
| 562 | /// variable which has a complex address expression for its address. |
| 563 | DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context, |
| 564 | const std::string &Name, |
| 565 | DICompileUnit CompileUnit, unsigned LineNo, |
| 566 | DIType Type, |
| 567 | SmallVector<Value *, 9> &addr); |
| 568 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 569 | /// CreateLexicalBlock - This creates a descriptor for a lexical block |
Devang Patel | 5e005d8 | 2009-08-31 22:00:15 +0000 | [diff] [blame] | 570 | /// with the specified parent context. |
| 571 | DILexicalBlock CreateLexicalBlock(DIDescriptor Context); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 572 | |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 573 | /// CreateLocation - Creates a debug info location. |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 574 | DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo, |
Daniel Dunbar | 3fc19bb | 2009-09-19 20:40:21 +0000 | [diff] [blame] | 575 | DIScope S, DILocation OrigLoc); |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 576 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 577 | /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation, |
| 578 | /// inserting it at the end of the specified basic block. |
| 579 | void InsertStopPoint(DICompileUnit CU, unsigned LineNo, unsigned ColNo, |
| 580 | BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 581 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 582 | /// InsertSubprogramStart - Create a new llvm.dbg.func.start intrinsic to |
| 583 | /// mark the start of the specified subprogram. |
| 584 | void InsertSubprogramStart(DISubprogram SP, BasicBlock *BB); |
| 585 | |
| 586 | /// InsertRegionStart - Insert a new llvm.dbg.region.start intrinsic call to |
| 587 | /// mark the start of a region for the specified scoping descriptor. |
| 588 | void InsertRegionStart(DIDescriptor D, BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 589 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 590 | /// InsertRegionEnd - Insert a new llvm.dbg.region.end intrinsic call to |
| 591 | /// mark the end of a region for the specified scoping descriptor. |
| 592 | void InsertRegionEnd(DIDescriptor D, BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 593 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 594 | /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. |
Mike Stump | e425039 | 2009-10-01 22:08:58 +0000 | [diff] [blame^] | 595 | void InsertDeclare(llvm::Value *Storage, DIVariable D, |
| 596 | BasicBlock *InsertAtEnd); |
| 597 | |
| 598 | /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. |
| 599 | void InsertDeclare(llvm::Value *Storage, DIVariable D, |
| 600 | Instruction *InsertBefore); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 601 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 602 | private: |
| 603 | Constant *GetTagConstant(unsigned TAG); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 604 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 605 | |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 606 | /// Finds the stoppoint coressponding to this instruction, that is the |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 607 | /// stoppoint that dominates this instruction |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 608 | const DbgStopPointInst *findStopPoint(const Instruction *Inst); |
| 609 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 610 | /// Finds the stoppoint corresponding to first real (non-debug intrinsic) |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 611 | /// instruction in this Basic Block, and returns the stoppoint for it. |
| 612 | const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB); |
| 613 | |
| 614 | /// Finds the dbg.declare intrinsic corresponding to this value if any. |
| 615 | /// It looks through pointer casts too. |
| 616 | const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); |
Torok Edwin | ff7d0e9 | 2009-03-10 13:41:26 +0000 | [diff] [blame] | 617 | |
| 618 | /// Find the debug info descriptor corresponding to this global variable. |
| 619 | Value *findDbgGlobalDeclare(GlobalVariable *V); |
| 620 | |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 621 | bool getLocationInfo(const Value *V, std::string &DisplayName, |
| 622 | std::string &Type, unsigned &LineNo, std::string &File, |
| 623 | std::string &Dir); |
Devang Patel | 13e16b6 | 2009-06-26 01:49:18 +0000 | [diff] [blame] | 624 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 625 | /// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 626 | /// info intrinsic. |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 627 | bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI, |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 628 | CodeGenOpt::Level OptLev); |
| 629 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 630 | /// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 631 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 632 | bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI, |
| 633 | CodeGenOpt::Level OptLev); |
| 634 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 635 | /// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 636 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 637 | bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI, |
| 638 | CodeGenOpt::Level OptLev); |
| 639 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 640 | /// isValidDebugInfoIntrinsic - Return true if REI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 641 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 642 | bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI, |
| 643 | CodeGenOpt::Level OptLev); |
| 644 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 645 | /// isValidDebugInfoIntrinsic - Return true if DI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 646 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 647 | bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI, |
| 648 | CodeGenOpt::Level OptLev); |
| 649 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 650 | /// ExtractDebugLocation - Extract debug location information |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 651 | /// from llvm.dbg.stoppoint intrinsic. |
| 652 | DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI, |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 653 | DebugLocTracker &DebugLocInfo); |
| 654 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 655 | /// ExtractDebugLocation - Extract debug location information |
Devang Patel | 1b75f44 | 2009-09-16 18:20:05 +0000 | [diff] [blame] | 656 | /// from DILocation. |
| 657 | DebugLoc ExtractDebugLocation(DILocation &Loc, |
| 658 | DebugLocTracker &DebugLocInfo); |
| 659 | |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 660 | /// ExtractDebugLocation - Extract debug location information |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 661 | /// from llvm.dbg.func_start intrinsic. |
| 662 | DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI, |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 663 | DebugLocTracker &DebugLocInfo); |
| 664 | |
| 665 | /// isInlinedFnStart - Return true if FSI is starting an inlined function. |
| 666 | bool isInlinedFnStart(DbgFuncStartInst &FSI, const Function *CurrentFn); |
| 667 | |
| 668 | /// isInlinedFnEnd - Return true if REI is ending an inlined function. |
| 669 | bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn); |
Devang Patel | 27a201d | 2009-08-06 15:39:34 +0000 | [diff] [blame] | 670 | /// DebugInfoFinder - This object collects DebugInfo from a module. |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 671 | class DebugInfoFinder { |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 672 | |
| 673 | public: |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 674 | /// processModule - Process entire module and collect debug info |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 675 | /// anchors. |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 676 | void processModule(Module &M); |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 677 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 678 | private: |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 679 | /// processType - Process DIType. |
| 680 | void processType(DIType DT); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 681 | |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 682 | /// processSubprogram - Enumberate DISubprogram. |
| 683 | void processSubprogram(DISubprogram SP); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 684 | |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 685 | /// processStopPoint - Process DbgStopPointInst. |
| 686 | void processStopPoint(DbgStopPointInst *SPI); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 687 | |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 688 | /// processFuncStart - Process DbgFuncStartInst. |
| 689 | void processFuncStart(DbgFuncStartInst *FSI); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 690 | |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 691 | /// processRegionStart - Process DbgRegionStart. |
| 692 | void processRegionStart(DbgRegionStartInst *DRS); |
Devang Patel | e802f1c | 2009-07-30 17:30:23 +0000 | [diff] [blame] | 693 | |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 694 | /// processRegionEnd - Process DbgRegionEnd. |
| 695 | void processRegionEnd(DbgRegionEndInst *DRE); |
Devang Patel | e802f1c | 2009-07-30 17:30:23 +0000 | [diff] [blame] | 696 | |
Devang Patel | b4d3130 | 2009-07-31 18:18:52 +0000 | [diff] [blame] | 697 | /// processDeclare - Process DbgDeclareInst. |
| 698 | void processDeclare(DbgDeclareInst *DDI); |
| 699 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 700 | /// addCompileUnit - Add compile unit into CUs. |
| 701 | bool addCompileUnit(DICompileUnit CU); |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 702 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 703 | /// addGlobalVariable - Add global variable into GVs. |
| 704 | bool addGlobalVariable(DIGlobalVariable DIG); |
| 705 | |
| 706 | // addSubprogram - Add subprgoram into SPs. |
| 707 | bool addSubprogram(DISubprogram SP); |
| 708 | |
Devang Patel | 72bcdb6 | 2009-08-10 22:09:58 +0000 | [diff] [blame] | 709 | /// addType - Add type into Tys. |
| 710 | bool addType(DIType DT); |
| 711 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 712 | public: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 713 | typedef SmallVector<MDNode *, 8>::iterator iterator; |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 714 | iterator compile_unit_begin() { return CUs.begin(); } |
| 715 | iterator compile_unit_end() { return CUs.end(); } |
| 716 | iterator subprogram_begin() { return SPs.begin(); } |
| 717 | iterator subprogram_end() { return SPs.end(); } |
| 718 | iterator global_variable_begin() { return GVs.begin(); } |
| 719 | iterator global_variable_end() { return GVs.end(); } |
Devang Patel | 72bcdb6 | 2009-08-10 22:09:58 +0000 | [diff] [blame] | 720 | iterator type_begin() { return TYs.begin(); } |
| 721 | iterator type_end() { return TYs.end(); } |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 722 | |
| 723 | unsigned compile_unit_count() { return CUs.size(); } |
| 724 | unsigned global_variable_count() { return GVs.size(); } |
| 725 | unsigned subprogram_count() { return SPs.size(); } |
Devang Patel | 72bcdb6 | 2009-08-10 22:09:58 +0000 | [diff] [blame] | 726 | unsigned type_count() { return TYs.size(); } |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 727 | |
| 728 | private: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 729 | SmallVector<MDNode *, 8> CUs; // Compile Units |
| 730 | SmallVector<MDNode *, 8> SPs; // Subprograms |
| 731 | SmallVector<MDNode *, 8> GVs; // Global Variables; |
| 732 | SmallVector<MDNode *, 8> TYs; // Types |
| 733 | SmallPtrSet<MDNode *, 64> NodesSeen; |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 734 | }; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 735 | } // end namespace llvm |
| 736 | |
| 737 | #endif |