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