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 | |
Jakub Staszak | 674be02 | 2013-01-10 00:45:19 +0000 | [diff] [blame] | 17 | #ifndef LLVM_DEBUGINFO_H |
| 18 | #define LLVM_DEBUGINFO_H |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 19 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/SmallPtrSet.h" |
Chandler Carruth | 255f89f | 2012-12-03 17:02:12 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallVector.h" |
Chris Lattner | f0908a3 | 2009-12-31 03:02:08 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/StringRef.h" |
Chris Lattner | 210d0fe | 2009-12-31 03:02:42 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Dwarf.h" |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | class BasicBlock; |
| 27 | class Constant; |
| 28 | class Function; |
| 29 | class GlobalVariable; |
| 30 | class Module; |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 31 | class Type; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 32 | class Value; |
Douglas Gregor | b419a5c | 2010-01-06 17:16:00 +0000 | [diff] [blame] | 33 | class DbgDeclareInst; |
Manman Ren | 0e29eee | 2013-07-23 00:22:51 +0000 | [diff] [blame] | 34 | class DbgValueInst; |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 35 | class Instruction; |
Chris Lattner | f0908a3 | 2009-12-31 03:02:08 +0000 | [diff] [blame] | 36 | class MDNode; |
Devang Patel | 6236704 | 2010-11-10 22:19:21 +0000 | [diff] [blame] | 37 | class NamedMDNode; |
Chris Lattner | f0908a3 | 2009-12-31 03:02:08 +0000 | [diff] [blame] | 38 | class LLVMContext; |
Dan Gohman | 5040436 | 2010-05-07 15:30:29 +0000 | [diff] [blame] | 39 | class raw_ostream; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 40 | |
Devang Patel | 5b164b5 | 2010-08-02 22:51:46 +0000 | [diff] [blame] | 41 | class DIFile; |
| 42 | class DISubprogram; |
| 43 | class DILexicalBlock; |
Eric Christopher | 6618a24 | 2011-10-11 22:59:11 +0000 | [diff] [blame] | 44 | class DILexicalBlockFile; |
Devang Patel | 5b164b5 | 2010-08-02 22:51:46 +0000 | [diff] [blame] | 45 | class DIVariable; |
| 46 | class DIType; |
Devang Patel | 6588abf | 2012-02-06 17:49:43 +0000 | [diff] [blame] | 47 | class DIObjCProperty; |
Devang Patel | 5b164b5 | 2010-08-02 22:51:46 +0000 | [diff] [blame] | 48 | |
Chris Lattner | 784b850 | 2009-12-29 09:15:46 +0000 | [diff] [blame] | 49 | /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. |
Eric Christopher | 599da5e | 2012-05-08 18:55:57 +0000 | [diff] [blame] | 50 | /// This should not be stored in a container, because the underlying MDNode |
| 51 | /// may change in certain situations. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 52 | class DIDescriptor { |
Devang Patel | 9dd2b47 | 2010-09-29 21:04:46 +0000 | [diff] [blame] | 53 | public: |
| 54 | enum { |
Devang Patel | b11f80e | 2011-05-12 19:06:16 +0000 | [diff] [blame] | 55 | FlagPrivate = 1 << 0, |
| 56 | FlagProtected = 1 << 1, |
| 57 | FlagFwdDecl = 1 << 2, |
| 58 | FlagAppleBlock = 1 << 3, |
| 59 | FlagBlockByrefStruct = 1 << 4, |
| 60 | FlagVirtual = 1 << 5, |
| 61 | FlagArtificial = 1 << 6, |
| 62 | FlagExplicit = 1 << 7, |
| 63 | FlagPrototyped = 1 << 8, |
Eric Christopher | e521278 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 64 | FlagObjcClassComplete = 1 << 9, |
Eric Christopher | 9a1e0e2 | 2013-01-08 01:53:52 +0000 | [diff] [blame] | 65 | FlagObjectPointer = 1 << 10, |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 66 | FlagVector = 1 << 11, |
David Blaikie | c971cb8 | 2013-06-19 21:52:48 +0000 | [diff] [blame] | 67 | FlagStaticMember = 1 << 12, |
| 68 | FlagIndirectVariable = 1 << 13 |
Devang Patel | 9dd2b47 | 2010-09-29 21:04:46 +0000 | [diff] [blame] | 69 | }; |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 70 | protected: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 71 | const MDNode *DbgNode; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 72 | |
Devang Patel | 65dbc90 | 2009-11-25 17:36:49 +0000 | [diff] [blame] | 73 | StringRef getStringField(unsigned Elt) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 74 | unsigned getUnsignedField(unsigned Elt) const { |
| 75 | return (unsigned)getUInt64Field(Elt); |
| 76 | } |
| 77 | uint64_t getUInt64Field(unsigned Elt) const; |
Bill Wendling | 9127be8 | 2012-12-03 19:44:25 +0000 | [diff] [blame] | 78 | int64_t getInt64Field(unsigned Elt) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 79 | DIDescriptor getDescriptorField(unsigned Elt) const; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 80 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 81 | template <typename DescTy> |
| 82 | DescTy getFieldAs(unsigned Elt) const { |
Devang Patel | ebe57f1 | 2010-05-07 18:36:34 +0000 | [diff] [blame] | 83 | return DescTy(getDescriptorField(Elt)); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 84 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 85 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 86 | GlobalVariable *getGlobalVariableField(unsigned Elt) const; |
Devang Patel | 2739896 | 2010-08-09 21:39:24 +0000 | [diff] [blame] | 87 | Constant *getConstantField(unsigned Elt) const; |
Stuart Hastings | 215aa15 | 2010-06-11 20:08:44 +0000 | [diff] [blame] | 88 | Function *getFunctionField(unsigned Elt) const; |
Alexey Samsonov | e97a3a4 | 2012-10-09 08:13:15 +0000 | [diff] [blame] | 89 | void replaceFunctionField(unsigned Elt, Function *F); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 90 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 91 | public: |
Eric Christopher | 2d3adad | 2013-07-24 01:21:02 +0000 | [diff] [blame^] | 92 | explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {} |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 93 | |
David Blaikie | c0ec8a4 | 2013-03-11 23:39:23 +0000 | [diff] [blame] | 94 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 95 | |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 96 | operator MDNode *() const { return const_cast<MDNode*>(DbgNode); } |
| 97 | MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); } |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 98 | |
Eric Christopher | b479870 | 2013-07-17 22:53:05 +0000 | [diff] [blame] | 99 | // An explicit operator bool so that we can do testing of DI values |
| 100 | // easily. |
| 101 | // FIXME: This operator bool isn't actually protecting anything at the |
| 102 | // moment due to the conversion operator above making DIDescriptor nodes |
Eric Christopher | 04b2995 | 2013-07-18 00:23:50 +0000 | [diff] [blame] | 103 | // implicitly convertable to bool. |
Eric Christopher | b479870 | 2013-07-17 22:53:05 +0000 | [diff] [blame] | 104 | LLVM_EXPLICIT operator bool() const { return DbgNode != 0; } |
| 105 | |
Eric Christopher | 36ee010 | 2013-07-17 23:25:22 +0000 | [diff] [blame] | 106 | bool operator==(DIDescriptor Other) const { |
Eric Christopher | 960d6d9 | 2013-07-18 19:11:41 +0000 | [diff] [blame] | 107 | return DbgNode == Other.DbgNode; |
Eric Christopher | 36ee010 | 2013-07-17 23:25:22 +0000 | [diff] [blame] | 108 | } |
| 109 | bool operator!=(DIDescriptor Other) const { |
| 110 | return !operator==(Other); |
| 111 | } |
| 112 | |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 113 | unsigned getTag() const { |
Devang Patel | 6906ba5 | 2009-01-20 19:22:03 +0000 | [diff] [blame] | 114 | return getUnsignedField(0) & ~LLVMDebugVersionMask; |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 115 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 116 | |
Devang Patel | 6ceea33 | 2009-08-31 18:49:10 +0000 | [diff] [blame] | 117 | bool isDerivedType() const; |
| 118 | bool isCompositeType() const; |
| 119 | bool isBasicType() const; |
| 120 | bool isVariable() const; |
| 121 | bool isSubprogram() const; |
| 122 | bool isGlobalVariable() const; |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 123 | bool isScope() const; |
Devang Patel | 7aa8189 | 2010-03-08 22:27:22 +0000 | [diff] [blame] | 124 | bool isFile() const; |
Devang Patel | c9f322d | 2009-08-31 21:34:44 +0000 | [diff] [blame] | 125 | bool isCompileUnit() const; |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 126 | bool isNameSpace() const; |
Eric Christopher | 6618a24 | 2011-10-11 22:59:11 +0000 | [diff] [blame] | 127 | bool isLexicalBlockFile() const; |
Devang Patel | 5e005d8 | 2009-08-31 22:00:15 +0000 | [diff] [blame] | 128 | bool isLexicalBlock() const; |
Devang Patel | ecbeb1a | 2009-09-30 22:34:41 +0000 | [diff] [blame] | 129 | bool isSubrange() const; |
| 130 | bool isEnumerator() const; |
| 131 | bool isType() const; |
| 132 | bool isGlobal() const; |
Devang Patel | d6747df | 2010-10-06 20:50:40 +0000 | [diff] [blame] | 133 | bool isUnspecifiedParameter() const; |
Devang Patel | 7e2cb11 | 2011-02-02 21:38:25 +0000 | [diff] [blame] | 134 | bool isTemplateTypeParameter() const; |
Devang Patel | e7d9387 | 2011-02-02 22:35:53 +0000 | [diff] [blame] | 135 | bool isTemplateValueParameter() const; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 136 | bool isObjCProperty() const; |
David Blaikie | 20d9e41 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 137 | bool isImportedEntity() const; |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 138 | |
| 139 | /// print - print descriptor. |
| 140 | void print(raw_ostream &OS) const; |
| 141 | |
| 142 | /// dump - print descriptor to dbgs() with a newline. |
| 143 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 144 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 145 | |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 146 | /// DISubrange - This is used to represent ranges, for array bounds. |
| 147 | class DISubrange : public DIDescriptor { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 148 | friend class DIDescriptor; |
| 149 | void printInternal(raw_ostream &OS) const; |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 150 | public: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 151 | explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 152 | |
Bill Wendling | 222c2fd | 2012-12-06 07:38:10 +0000 | [diff] [blame] | 153 | int64_t getLo() const { return getInt64Field(1); } |
Bill Wendling | 9493dae | 2012-12-04 21:34:03 +0000 | [diff] [blame] | 154 | int64_t getCount() const { return getInt64Field(2); } |
David Blaikie | c0ec8a4 | 2013-03-11 23:39:23 +0000 | [diff] [blame] | 155 | bool Verify() const; |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 156 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 157 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 158 | /// DIArray - This descriptor holds an array of descriptors. |
| 159 | class DIArray : public DIDescriptor { |
| 160 | public: |
Eric Christopher | 2d3adad | 2013-07-24 01:21:02 +0000 | [diff] [blame^] | 161 | explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 162 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 163 | unsigned getNumElements() const; |
Devang Patel | a22d57d | 2009-01-05 19:55:07 +0000 | [diff] [blame] | 164 | DIDescriptor getElement(unsigned Idx) const { |
| 165 | return getDescriptorField(Idx); |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 166 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 167 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 168 | |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 169 | /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}'). |
| 170 | /// FIXME: it seems strange that this doesn't have either a reference to the |
| 171 | /// type/precision or a file/line pair for location info. |
| 172 | class DIEnumerator : public DIDescriptor { |
| 173 | friend class DIDescriptor; |
| 174 | void printInternal(raw_ostream &OS) const; |
| 175 | public: |
| 176 | explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {} |
| 177 | |
| 178 | StringRef getName() const { return getStringField(1); } |
| 179 | int64_t getEnumValue() const { return getInt64Field(2); } |
| 180 | bool Verify() const; |
| 181 | }; |
| 182 | |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 183 | /// DIScope - A base class for various scopes. |
| 184 | class DIScope : public DIDescriptor { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 185 | protected: |
| 186 | friend class DIDescriptor; |
| 187 | void printInternal(raw_ostream &OS) const; |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 188 | public: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 189 | explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 190 | |
Devang Patel | 65dbc90 | 2009-11-25 17:36:49 +0000 | [diff] [blame] | 191 | StringRef getFilename() const; |
| 192 | StringRef getDirectory() const; |
Devang Patel | 43d98b3 | 2009-08-31 20:44:45 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 195 | /// DIType - This is a wrapper for a type. |
| 196 | /// FIXME: Types should be factored much better so that CV qualifiers and |
| 197 | /// others do not require a huge and empty descriptor full of zeros. |
Devang Patel | 77bf295 | 2010-03-08 22:02:50 +0000 | [diff] [blame] | 198 | class DIType : public DIScope { |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 199 | protected: |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 200 | friend class DIDescriptor; |
| 201 | void printInternal(raw_ostream &OS) const; |
Eric Christopher | 28a485b | 2013-07-24 00:13:02 +0000 | [diff] [blame] | 202 | |
Devang Patel | f193ff0 | 2009-01-15 19:26:23 +0000 | [diff] [blame] | 203 | public: |
Eric Christopher | e72a4d4 | 2013-07-24 01:06:21 +0000 | [diff] [blame] | 204 | DIType(const MDNode *N = 0) : DIScope(N) {} |
| 205 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 206 | /// Verify - Verify that a type descriptor is well formed. |
| 207 | bool Verify() const; |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 208 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 209 | DIScope getContext() const { return getFieldAs<DIScope>(2); } |
| 210 | StringRef getName() const { return getStringField(3); } |
| 211 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 212 | uint64_t getSizeInBits() const { return getUInt64Field(5); } |
| 213 | uint64_t getAlignInBits() const { return getUInt64Field(6); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 214 | // FIXME: Offset is only used for DW_TAG_member nodes. Making every type |
| 215 | // carry this is just plain insane. |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 216 | uint64_t getOffsetInBits() const { return getUInt64Field(7); } |
| 217 | unsigned getFlags() const { return getUnsignedField(8); } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 218 | bool isPrivate() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 219 | return (getFlags() & FlagPrivate) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 220 | } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 221 | bool isProtected() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 222 | return (getFlags() & FlagProtected) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 223 | } |
Chris Lattner | e1f515e | 2009-08-26 04:21:30 +0000 | [diff] [blame] | 224 | bool isForwardDecl() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 225 | return (getFlags() & FlagFwdDecl) != 0; |
Devang Patel | e2d5a6c | 2009-07-27 20:30:05 +0000 | [diff] [blame] | 226 | } |
Devang Patel | a1ba269 | 2009-08-27 23:51:51 +0000 | [diff] [blame] | 227 | // isAppleBlock - Return true if this is the Apple Blocks extension. |
| 228 | bool isAppleBlockExtension() const { |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 229 | return (getFlags() & FlagAppleBlock) != 0; |
Devang Patel | 8af76bd | 2009-08-26 00:39:50 +0000 | [diff] [blame] | 230 | } |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 231 | bool isBlockByrefStruct() const { |
| 232 | return (getFlags() & FlagBlockByrefStruct) != 0; |
| 233 | } |
Devang Patel | 5d11eb0 | 2009-12-03 19:11:07 +0000 | [diff] [blame] | 234 | bool isVirtual() const { |
| 235 | return (getFlags() & FlagVirtual) != 0; |
| 236 | } |
Devang Patel | b464564 | 2010-02-06 01:02:37 +0000 | [diff] [blame] | 237 | bool isArtificial() const { |
| 238 | return (getFlags() & FlagArtificial) != 0; |
| 239 | } |
Eric Christopher | e521278 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 240 | bool isObjectPointer() const { |
| 241 | return (getFlags() & FlagObjectPointer) != 0; |
| 242 | } |
Devang Patel | 201e6cd | 2011-05-12 21:29:42 +0000 | [diff] [blame] | 243 | bool isObjcClassComplete() const { |
| 244 | return (getFlags() & FlagObjcClassComplete) != 0; |
Devang Patel | b11f80e | 2011-05-12 19:06:16 +0000 | [diff] [blame] | 245 | } |
Eric Christopher | 9a1e0e2 | 2013-01-08 01:53:52 +0000 | [diff] [blame] | 246 | bool isVector() const { |
| 247 | return (getFlags() & FlagVector) != 0; |
| 248 | } |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 249 | bool isStaticMember() const { |
| 250 | return (getFlags() & FlagStaticMember) != 0; |
| 251 | } |
Devang Patel | 3c91b05 | 2010-03-08 20:52:55 +0000 | [diff] [blame] | 252 | bool isValid() const { |
Adrian Prantl | 88c7440 | 2013-05-29 17:33:31 +0000 | [diff] [blame] | 253 | return DbgNode && isType(); |
Devang Patel | 3c91b05 | 2010-03-08 20:52:55 +0000 | [diff] [blame] | 254 | } |
Dan Gohman | 5040436 | 2010-05-07 15:30:29 +0000 | [diff] [blame] | 255 | |
Devang Patel | 6f9d8ff | 2011-08-15 17:57:41 +0000 | [diff] [blame] | 256 | /// isUnsignedDIType - Return true if type encoding is unsigned. |
| 257 | bool isUnsignedDIType(); |
| 258 | |
Dan Gohman | 489b29b | 2010-08-20 22:02:26 +0000 | [diff] [blame] | 259 | /// replaceAllUsesWith - Replace all uses of debug info referenced by |
| 260 | /// this descriptor. |
| 261 | void replaceAllUsesWith(DIDescriptor &D); |
Devang Patel | 0a2551d | 2010-12-08 20:18:20 +0000 | [diff] [blame] | 262 | void replaceAllUsesWith(MDNode *D); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 263 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 264 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 265 | /// DIBasicType - A basic type, like 'int' or 'float'. |
| 266 | class DIBasicType : public DIType { |
| 267 | public: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 268 | explicit DIBasicType(const MDNode *N = 0) : DIType(N) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 269 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 270 | unsigned getEncoding() const { return getUnsignedField(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 271 | |
Devang Patel | 0c4720c | 2010-08-23 18:25:56 +0000 | [diff] [blame] | 272 | /// Verify - Verify that a basic type descriptor is well formed. |
| 273 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 274 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 275 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 276 | /// DIDerivedType - A simple derived type, like a const qualified type, |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 277 | /// a typedef, a pointer or reference, et cetera. Or, a data member of |
| 278 | /// a class/struct/union. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 279 | class DIDerivedType : public DIType { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 280 | friend class DIDescriptor; |
| 281 | void printInternal(raw_ostream &OS) const; |
Eric Christopher | 28a485b | 2013-07-24 00:13:02 +0000 | [diff] [blame] | 282 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 283 | public: |
Eric Christopher | 2d3adad | 2013-07-24 01:21:02 +0000 | [diff] [blame^] | 284 | explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 285 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 286 | DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 287 | |
Devang Patel | 36375ee | 2009-02-17 21:23:59 +0000 | [diff] [blame] | 288 | /// getOriginalTypeSize - If this type is derived from a base type then |
| 289 | /// return base type size. |
| 290 | uint64_t getOriginalTypeSize() const; |
Dan Gohman | 5040436 | 2010-05-07 15:30:29 +0000 | [diff] [blame] | 291 | |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 292 | /// getObjCProperty - Return property node, if this ivar is |
Devang Patel | 6588abf | 2012-02-06 17:49:43 +0000 | [diff] [blame] | 293 | /// associated with one. |
| 294 | MDNode *getObjCProperty() const; |
| 295 | |
David Blaikie | 62fdfb5 | 2013-01-07 05:51:15 +0000 | [diff] [blame] | 296 | DIType getClassType() const { |
| 297 | assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 298 | return getFieldAs<DIType>(10); |
David Blaikie | 62fdfb5 | 2013-01-07 05:51:15 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 301 | Constant *getConstant() const { |
| 302 | assert((getTag() == dwarf::DW_TAG_member) && isStaticMember()); |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 303 | return getConstantField(10); |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Devang Patel | 0c4720c | 2010-08-23 18:25:56 +0000 | [diff] [blame] | 306 | /// Verify - Verify that a derived type descriptor is well formed. |
| 307 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 308 | }; |
| 309 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 310 | /// DICompositeType - This descriptor holds a type that can refer to multiple |
| 311 | /// other types, like a function or struct. |
Adrian Prantl | 2f445be | 2013-04-19 19:56:02 +0000 | [diff] [blame] | 312 | /// DICompositeType is derived from DIDerivedType because some |
| 313 | /// composite types (such as enums) can be derived from basic types |
| 314 | // FIXME: Make this derive from DIType directly & just store the |
| 315 | // base type in a single DIType field. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 316 | class DICompositeType : public DIDerivedType { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 317 | friend class DIDescriptor; |
| 318 | void printInternal(raw_ostream &OS) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 319 | public: |
Eric Christopher | 2d3adad | 2013-07-24 01:21:02 +0000 | [diff] [blame^] | 320 | explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 321 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 322 | DIArray getTypeArray() const { return getFieldAs<DIArray>(10); } |
David Blaikie | d072a16 | 2013-03-26 21:59:17 +0000 | [diff] [blame] | 323 | void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 324 | unsigned getRunTimeLang() const { return getUnsignedField(11); } |
Devang Patel | 0fd7f9d | 2010-01-26 21:14:59 +0000 | [diff] [blame] | 325 | DICompositeType getContainingType() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 326 | return getFieldAs<DICompositeType>(12); |
Devang Patel | 0fd7f9d | 2010-01-26 21:14:59 +0000 | [diff] [blame] | 327 | } |
David Blaikie | f34ea64 | 2013-03-26 23:46:36 +0000 | [diff] [blame] | 328 | void setContainingType(DICompositeType ContainingType); |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 329 | DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 330 | |
| 331 | /// Verify - Verify that a composite type descriptor is well formed. |
| 332 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 333 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 334 | |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 335 | /// DIFile - This is a wrapper for a file. |
| 336 | class DIFile : public DIScope { |
| 337 | friend class DIDescriptor; |
Devang Patel | 7e2cb11 | 2011-02-02 21:38:25 +0000 | [diff] [blame] | 338 | public: |
Eric Christopher | e389cc5 | 2013-07-24 00:36:11 +0000 | [diff] [blame] | 339 | explicit DIFile(const MDNode *N = 0) : DIScope(N) {} |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 340 | MDNode *getFileNode() const; |
David Blaikie | c0ec8a4 | 2013-03-11 23:39:23 +0000 | [diff] [blame] | 341 | bool Verify() const; |
Devang Patel | 7e2cb11 | 2011-02-02 21:38:25 +0000 | [diff] [blame] | 342 | }; |
| 343 | |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 344 | /// DICompileUnit - A wrapper for a compile unit. |
| 345 | class DICompileUnit : public DIScope { |
| 346 | friend class DIDescriptor; |
| 347 | void printInternal(raw_ostream &OS) const; |
Devang Patel | e7d9387 | 2011-02-02 22:35:53 +0000 | [diff] [blame] | 348 | public: |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 349 | explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {} |
Devang Patel | e7d9387 | 2011-02-02 22:35:53 +0000 | [diff] [blame] | 350 | |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 351 | unsigned getLanguage() const { return getUnsignedField(2); } |
| 352 | StringRef getProducer() const { return getStringField(3); } |
| 353 | |
| 354 | bool isOptimized() const { return getUnsignedField(4) != 0; } |
| 355 | StringRef getFlags() const { return getStringField(5); } |
| 356 | unsigned getRunTimeVersion() const { return getUnsignedField(6); } |
| 357 | |
| 358 | DIArray getEnumTypes() const; |
| 359 | DIArray getRetainedTypes() const; |
| 360 | DIArray getSubprograms() const; |
| 361 | DIArray getGlobalVariables() const; |
| 362 | DIArray getImportedEntities() const; |
| 363 | |
| 364 | StringRef getSplitDebugFilename() const { return getStringField(12); } |
| 365 | |
| 366 | /// Verify - Verify that a compile unit is well formed. |
David Blaikie | c0ec8a4 | 2013-03-11 23:39:23 +0000 | [diff] [blame] | 367 | bool Verify() const; |
Devang Patel | e7d9387 | 2011-02-02 22:35:53 +0000 | [diff] [blame] | 368 | }; |
| 369 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 370 | /// DISubprogram - This is a wrapper for a subprogram (e.g. a function). |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 371 | class DISubprogram : public DIScope { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 372 | friend class DIDescriptor; |
| 373 | void printInternal(raw_ostream &OS) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 374 | public: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 375 | explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {} |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 376 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 377 | DIScope getContext() const { return getFieldAs<DIScope>(2); } |
| 378 | StringRef getName() const { return getStringField(3); } |
| 379 | StringRef getDisplayName() const { return getStringField(4); } |
| 380 | StringRef getLinkageName() const { return getStringField(5); } |
| 381 | unsigned getLineNumber() const { return getUnsignedField(6); } |
| 382 | DICompositeType getType() const { return getFieldAs<DICompositeType>(7); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 383 | |
Devang Patel | 82dfc0c | 2009-08-31 22:47:13 +0000 | [diff] [blame] | 384 | /// isLocalToUnit - Return true if this subprogram is local to the current |
| 385 | /// compile unit, like 'static' in C. |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 386 | unsigned isLocalToUnit() const { return getUnsignedField(8); } |
| 387 | unsigned isDefinition() const { return getUnsignedField(9); } |
Devang Patel | 5d11eb0 | 2009-12-03 19:11:07 +0000 | [diff] [blame] | 388 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 389 | unsigned getVirtuality() const { return getUnsignedField(10); } |
| 390 | unsigned getVirtualIndex() const { return getUnsignedField(11); } |
Devang Patel | 5d11eb0 | 2009-12-03 19:11:07 +0000 | [diff] [blame] | 391 | |
| 392 | DICompositeType getContainingType() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 393 | return getFieldAs<DICompositeType>(12); |
Devang Patel | 5d11eb0 | 2009-12-03 19:11:07 +0000 | [diff] [blame] | 394 | } |
Eric Christopher | 6126a1e | 2012-04-03 00:43:49 +0000 | [diff] [blame] | 395 | |
David Blaikie | e2952f9 | 2013-02-18 08:04:16 +0000 | [diff] [blame] | 396 | unsigned getFlags() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 397 | return getUnsignedField(13); |
David Blaikie | e2952f9 | 2013-02-18 08:04:16 +0000 | [diff] [blame] | 398 | } |
| 399 | |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 400 | unsigned isArtificial() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 401 | return (getUnsignedField(13) & FlagArtificial) != 0; |
Devang Patel | 9dd2b47 | 2010-09-29 21:04:46 +0000 | [diff] [blame] | 402 | } |
Devang Patel | 1a30123 | 2010-09-29 21:44:16 +0000 | [diff] [blame] | 403 | /// isPrivate - Return true if this subprogram has "private" |
| 404 | /// access specifier. |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 405 | bool isPrivate() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 406 | return (getUnsignedField(13) & FlagPrivate) != 0; |
Devang Patel | 1a30123 | 2010-09-29 21:44:16 +0000 | [diff] [blame] | 407 | } |
| 408 | /// isProtected - Return true if this subprogram has "protected" |
| 409 | /// access specifier. |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 410 | bool isProtected() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 411 | return (getUnsignedField(13) & FlagProtected) != 0; |
Devang Patel | 1a30123 | 2010-09-29 21:44:16 +0000 | [diff] [blame] | 412 | } |
Devang Patel | 21ea1d5 | 2010-10-01 23:31:40 +0000 | [diff] [blame] | 413 | /// isExplicit - Return true if this subprogram is marked as explicit. |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 414 | bool isExplicit() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 415 | return (getUnsignedField(13) & FlagExplicit) != 0; |
Devang Patel | 21ea1d5 | 2010-10-01 23:31:40 +0000 | [diff] [blame] | 416 | } |
Devang Patel | 7b172c6 | 2010-10-07 22:03:01 +0000 | [diff] [blame] | 417 | /// isPrototyped - Return true if this subprogram is prototyped. |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 418 | bool isPrototyped() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 419 | return (getUnsignedField(13) & FlagPrototyped) != 0; |
Devang Patel | 7b172c6 | 2010-10-07 22:03:01 +0000 | [diff] [blame] | 420 | } |
Devang Patel | 21ea1d5 | 2010-10-01 23:31:40 +0000 | [diff] [blame] | 421 | |
Devang Patel | ccff812 | 2010-04-30 19:38:23 +0000 | [diff] [blame] | 422 | unsigned isOptimized() const; |
Devang Patel | 5d11eb0 | 2009-12-03 19:11:07 +0000 | [diff] [blame] | 423 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 424 | /// Verify - Verify that a subprogram descriptor is well formed. |
| 425 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 426 | |
Devang Patel | af5b6bb | 2009-04-15 00:06:07 +0000 | [diff] [blame] | 427 | /// describes - Return true if this subprogram provides debugging |
| 428 | /// information for the function F. |
| 429 | bool describes(const Function *F); |
Stuart Hastings | 215aa15 | 2010-06-11 20:08:44 +0000 | [diff] [blame] | 430 | |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 431 | Function *getFunction() const { return getFunctionField(15); } |
| 432 | void replaceFunction(Function *F) { replaceFunctionField(15, F); } |
| 433 | DIArray getTemplateParams() const { return getFieldAs<DIArray>(16); } |
Devang Patel | 5e06bb8 | 2011-04-22 23:10:17 +0000 | [diff] [blame] | 434 | DISubprogram getFunctionDeclaration() const { |
David Blaikie | 72dfb05 | 2013-03-28 02:44:59 +0000 | [diff] [blame] | 435 | return getFieldAs<DISubprogram>(17); |
Devang Patel | 5e06bb8 | 2011-04-22 23:10:17 +0000 | [diff] [blame] | 436 | } |
Devang Patel | 93d39be | 2011-08-19 23:28:12 +0000 | [diff] [blame] | 437 | MDNode *getVariablesNodes() const; |
| 438 | DIArray getVariables() const; |
David Blaikie | 4af9230 | 2013-05-29 02:05:07 +0000 | [diff] [blame] | 439 | |
| 440 | /// getScopeLineNumber - Get the beginning of the scope of the |
| 441 | /// function, not necessarily where the name of the program |
| 442 | /// starts. |
| 443 | unsigned getScopeLineNumber() const { return getUnsignedField(19); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 444 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 445 | |
Eric Christopher | 00d92ee | 2013-07-23 22:29:19 +0000 | [diff] [blame] | 446 | /// DILexicalBlock - This is a wrapper for a lexical block. |
| 447 | class DILexicalBlock : public DIScope { |
| 448 | public: |
| 449 | explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {} |
| 450 | DIScope getContext() const { return getFieldAs<DIScope>(2); } |
| 451 | unsigned getLineNumber() const { return getUnsignedField(3); } |
| 452 | unsigned getColumnNumber() const { return getUnsignedField(4); } |
| 453 | bool Verify() const; |
| 454 | }; |
| 455 | |
| 456 | /// DILexicalBlockFile - This is a wrapper for a lexical block with |
| 457 | /// a filename change. |
| 458 | class DILexicalBlockFile : public DIScope { |
| 459 | public: |
| 460 | explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {} |
| 461 | DIScope getContext() const { |
| 462 | if (getScope().isSubprogram()) |
| 463 | return getScope(); |
| 464 | return getScope().getContext(); |
| 465 | } |
| 466 | unsigned getLineNumber() const { return getScope().getLineNumber(); } |
| 467 | unsigned getColumnNumber() const { return getScope().getColumnNumber(); } |
| 468 | DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(2); } |
| 469 | bool Verify() const; |
| 470 | }; |
| 471 | |
| 472 | /// DINameSpace - A wrapper for a C++ style name space. |
| 473 | class DINameSpace : public DIScope { |
| 474 | friend class DIDescriptor; |
| 475 | void printInternal(raw_ostream &OS) const; |
| 476 | public: |
| 477 | explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {} |
| 478 | DIScope getContext() const { return getFieldAs<DIScope>(2); } |
| 479 | StringRef getName() const { return getStringField(3); } |
| 480 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 481 | bool Verify() const; |
| 482 | }; |
| 483 | |
| 484 | /// DITemplateTypeParameter - This is a wrapper for template type parameter. |
| 485 | class DITemplateTypeParameter : public DIDescriptor { |
| 486 | public: |
| 487 | explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {} |
| 488 | |
| 489 | DIScope getContext() const { return getFieldAs<DIScope>(1); } |
| 490 | StringRef getName() const { return getStringField(2); } |
| 491 | DIType getType() const { return getFieldAs<DIType>(3); } |
| 492 | StringRef getFilename() const { |
| 493 | return getFieldAs<DIFile>(4).getFilename(); |
| 494 | } |
| 495 | StringRef getDirectory() const { |
| 496 | return getFieldAs<DIFile>(4).getDirectory(); |
| 497 | } |
| 498 | unsigned getLineNumber() const { return getUnsignedField(5); } |
| 499 | unsigned getColumnNumber() const { return getUnsignedField(6); } |
| 500 | bool Verify() const; |
| 501 | }; |
| 502 | |
| 503 | /// DITemplateValueParameter - This is a wrapper for template value parameter. |
| 504 | class DITemplateValueParameter : public DIDescriptor { |
| 505 | public: |
| 506 | explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {} |
| 507 | |
| 508 | DIScope getContext() const { return getFieldAs<DIScope>(1); } |
| 509 | StringRef getName() const { return getStringField(2); } |
| 510 | DIType getType() const { return getFieldAs<DIType>(3); } |
| 511 | Value *getValue() const; |
| 512 | StringRef getFilename() const { |
| 513 | return getFieldAs<DIFile>(5).getFilename(); |
| 514 | } |
| 515 | StringRef getDirectory() const { |
| 516 | return getFieldAs<DIFile>(5).getDirectory(); |
| 517 | } |
| 518 | unsigned getLineNumber() const { return getUnsignedField(6); } |
| 519 | unsigned getColumnNumber() const { return getUnsignedField(7); } |
| 520 | bool Verify() const; |
| 521 | }; |
| 522 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 523 | /// DIGlobalVariable - This is a wrapper for a global variable. |
Devang Patel | a49d877 | 2010-05-07 23:19:07 +0000 | [diff] [blame] | 524 | class DIGlobalVariable : public DIDescriptor { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 525 | friend class DIDescriptor; |
| 526 | void printInternal(raw_ostream &OS) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 527 | public: |
Devang Patel | a49d877 | 2010-05-07 23:19:07 +0000 | [diff] [blame] | 528 | explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {} |
| 529 | |
| 530 | DIScope getContext() const { return getFieldAs<DIScope>(2); } |
| 531 | StringRef getName() const { return getStringField(3); } |
| 532 | StringRef getDisplayName() const { return getStringField(4); } |
| 533 | StringRef getLinkageName() const { return getStringField(5); } |
James Molloy | 439780e | 2011-09-26 17:40:42 +0000 | [diff] [blame] | 534 | StringRef getFilename() const { |
James Molloy | 439780e | 2011-09-26 17:40:42 +0000 | [diff] [blame] | 535 | return getFieldAs<DIFile>(6).getFilename(); |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 536 | } |
James Molloy | 439780e | 2011-09-26 17:40:42 +0000 | [diff] [blame] | 537 | StringRef getDirectory() const { |
James Molloy | 439780e | 2011-09-26 17:40:42 +0000 | [diff] [blame] | 538 | return getFieldAs<DIFile>(6).getDirectory(); |
| 539 | |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 540 | } |
Devang Patel | a49d877 | 2010-05-07 23:19:07 +0000 | [diff] [blame] | 541 | |
| 542 | unsigned getLineNumber() const { return getUnsignedField(7); } |
| 543 | DIType getType() const { return getFieldAs<DIType>(8); } |
| 544 | unsigned isLocalToUnit() const { return getUnsignedField(9); } |
| 545 | unsigned isDefinition() const { return getUnsignedField(10); } |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 546 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 547 | GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } |
Devang Patel | 2739896 | 2010-08-09 21:39:24 +0000 | [diff] [blame] | 548 | Constant *getConstant() const { return getConstantField(11); } |
Eric Christopher | 6b6061f | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 549 | DIDerivedType getStaticDataMemberDeclaration() const { |
| 550 | return getFieldAs<DIDerivedType>(12); |
| 551 | } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 552 | |
| 553 | /// Verify - Verify that a global variable descriptor is well formed. |
| 554 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 555 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 556 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 557 | /// DIVariable - This is a wrapper for a variable (e.g. parameter, local, |
| 558 | /// global etc). |
| 559 | class DIVariable : public DIDescriptor { |
Bill Wendling | 494f8c6 | 2012-06-26 22:57:33 +0000 | [diff] [blame] | 560 | friend class DIDescriptor; |
| 561 | void printInternal(raw_ostream &OS) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 562 | public: |
Eric Christopher | 2d3adad | 2013-07-24 01:21:02 +0000 | [diff] [blame^] | 563 | explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 564 | |
Devang Patel | 77bf295 | 2010-03-08 22:02:50 +0000 | [diff] [blame] | 565 | DIScope getContext() const { return getFieldAs<DIScope>(1); } |
| 566 | StringRef getName() const { return getStringField(2); } |
Alexey Samsonov | 1afbb51 | 2012-12-12 14:31:53 +0000 | [diff] [blame] | 567 | DIFile getFile() const { return getFieldAs<DIFile>(3); } |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 568 | unsigned getLineNumber() const { |
| 569 | return (getUnsignedField(4) << 8) >> 8; |
Devang Patel | e9e16c5 | 2011-03-01 22:58:13 +0000 | [diff] [blame] | 570 | } |
| 571 | unsigned getArgNumber() const { |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 572 | unsigned L = getUnsignedField(4); |
Devang Patel | e9e16c5 | 2011-03-01 22:58:13 +0000 | [diff] [blame] | 573 | return L >> 24; |
| 574 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 575 | DIType getType() const { return getFieldAs<DIType>(5); } |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 576 | |
Devang Patel | 3cf763d | 2010-09-29 23:07:21 +0000 | [diff] [blame] | 577 | /// isArtificial - Return true if this variable is marked as "artificial". |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 578 | bool isArtificial() const { |
Devang Patel | 3cf763d | 2010-09-29 23:07:21 +0000 | [diff] [blame] | 579 | return (getUnsignedField(6) & FlagArtificial) != 0; |
| 580 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 581 | |
Eric Christopher | e521278 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 582 | bool isObjectPointer() const { |
| 583 | return (getUnsignedField(6) & FlagObjectPointer) != 0; |
| 584 | } |
| 585 | |
David Blaikie | c971cb8 | 2013-06-19 21:52:48 +0000 | [diff] [blame] | 586 | /// \brief Return true if this variable is represented as a pointer. |
| 587 | bool isIndirect() const { |
| 588 | return (getUnsignedField(6) & FlagIndirectVariable) != 0; |
| 589 | } |
| 590 | |
Devang Patel | 40c7e41 | 2011-07-20 22:18:50 +0000 | [diff] [blame] | 591 | /// getInlinedAt - If this variable is inlined then return inline location. |
Devang Patel | 48d726f | 2011-08-09 01:03:14 +0000 | [diff] [blame] | 592 | MDNode *getInlinedAt() const; |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 593 | |
| 594 | /// Verify - Verify that a variable descriptor is well formed. |
| 595 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 596 | |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 597 | /// HasComplexAddr - Return true if the variable has a complex address. |
| 598 | bool hasComplexAddress() const { |
| 599 | return getNumAddrElements() > 0; |
| 600 | } |
| 601 | |
Chris Lattner | f0908a3 | 2009-12-31 03:02:08 +0000 | [diff] [blame] | 602 | unsigned getNumAddrElements() const; |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 603 | |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 604 | uint64_t getAddrElement(unsigned Idx) const { |
Devang Patel | 23336b4 | 2011-07-19 19:41:54 +0000 | [diff] [blame] | 605 | return getUInt64Field(Idx+8); |
Mike Stump | 3e4c9bd | 2009-09-30 00:08:22 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 608 | /// isBlockByrefVariable - Return true if the variable was declared as |
| 609 | /// a "__block" variable (Apple Blocks). |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 610 | bool isBlockByrefVariable() const { |
| 611 | return getType().isBlockByrefStruct(); |
Caroline Tice | dc8f604 | 2009-08-31 21:19:37 +0000 | [diff] [blame] | 612 | } |
| 613 | |
David Blaikie | a506b00 | 2013-01-25 20:47:58 +0000 | [diff] [blame] | 614 | /// isInlinedFnArgument - Return true if this variable provides debugging |
Devang Patel | 22070e8 | 2010-04-29 20:48:12 +0000 | [diff] [blame] | 615 | /// information for an inlined function arguments. |
| 616 | bool isInlinedFnArgument(const Function *CurFn); |
| 617 | |
Devang Patel | 48d726f | 2011-08-09 01:03:14 +0000 | [diff] [blame] | 618 | void printExtendedName(raw_ostream &OS) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 619 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 620 | |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 621 | /// DILocation - This object holds location information. This object |
| 622 | /// is not associated with any DWARF tag. |
| 623 | class DILocation : public DIDescriptor { |
| 624 | public: |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 625 | explicit DILocation(const MDNode *N) : DIDescriptor(N) { } |
Devang Patel | 58e7a2d | 2009-09-01 00:53:21 +0000 | [diff] [blame] | 626 | |
Devang Patel | f98d8fe | 2009-09-01 01:14:15 +0000 | [diff] [blame] | 627 | unsigned getLineNumber() const { return getUnsignedField(0); } |
| 628 | unsigned getColumnNumber() const { return getUnsignedField(1); } |
Devang Patel | 5ccdd10 | 2009-09-29 18:40:58 +0000 | [diff] [blame] | 629 | DIScope getScope() const { return getFieldAs<DIScope>(2); } |
| 630 | DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); } |
Devang Patel | 65dbc90 | 2009-11-25 17:36:49 +0000 | [diff] [blame] | 631 | StringRef getFilename() const { return getScope().getFilename(); } |
| 632 | StringRef getDirectory() const { return getScope().getDirectory(); } |
Devang Patel | 3c91b05 | 2010-03-08 20:52:55 +0000 | [diff] [blame] | 633 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 634 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 635 | |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 636 | class DIObjCProperty : public DIDescriptor { |
Bill Wendling | 2da1a16 | 2012-07-06 19:12:31 +0000 | [diff] [blame] | 637 | friend class DIDescriptor; |
| 638 | void printInternal(raw_ostream &OS) const; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 639 | public: |
| 640 | explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { } |
| 641 | |
| 642 | StringRef getObjCPropertyName() const { return getStringField(1); } |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 643 | DIFile getFile() const { return getFieldAs<DIFile>(2); } |
| 644 | unsigned getLineNumber() const { return getUnsignedField(3); } |
| 645 | |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 646 | StringRef getObjCPropertyGetterName() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 647 | return getStringField(4); |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 648 | } |
| 649 | StringRef getObjCPropertySetterName() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 650 | return getStringField(5); |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 651 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 652 | bool isReadOnlyObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 653 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 654 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 655 | bool isReadWriteObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 656 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 657 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 658 | bool isAssignObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 659 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 660 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 661 | bool isRetainObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 662 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 663 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 664 | bool isCopyObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 665 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 666 | } |
Manman Ren | eda4b8e | 2013-06-07 18:53:29 +0000 | [diff] [blame] | 667 | bool isNonAtomicObjCProperty() const { |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 668 | return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 669 | } |
| 670 | |
Eric Christopher | b8ca988 | 2012-03-29 08:42:56 +0000 | [diff] [blame] | 671 | DIType getType() const { return getFieldAs<DIType>(7); } |
| 672 | |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 673 | /// Verify - Verify that a derived type descriptor is well formed. |
| 674 | bool Verify() const; |
Devang Patel | 1ea02d4 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 675 | }; |
| 676 | |
David Blaikie | c462db6 | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 677 | /// \brief An imported module (C++ using directive or similar). |
David Blaikie | 20d9e41 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 678 | class DIImportedEntity : public DIDescriptor { |
David Blaikie | c462db6 | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 679 | friend class DIDescriptor; |
| 680 | void printInternal(raw_ostream &OS) const; |
| 681 | public: |
David Blaikie | 20d9e41 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 682 | explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { } |
David Blaikie | c462db6 | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 683 | DIScope getContext() const { return getFieldAs<DIScope>(1); } |
David Blaikie | 20d9e41 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 684 | DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); } |
David Blaikie | c462db6 | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 685 | unsigned getLineNumber() const { return getUnsignedField(3); } |
David Blaikie | 7b72cc7 | 2013-05-20 22:50:35 +0000 | [diff] [blame] | 686 | StringRef getName() const { return getStringField(4); } |
David Blaikie | c462db6 | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 687 | bool Verify() const; |
| 688 | }; |
| 689 | |
Devang Patel | 193f720 | 2009-11-24 01:14:22 +0000 | [diff] [blame] | 690 | /// getDISubprogram - Find subprogram that is enclosing this scope. |
Devang Patel | e9f8f5e | 2010-05-07 20:54:48 +0000 | [diff] [blame] | 691 | DISubprogram getDISubprogram(const MDNode *Scope); |
Devang Patel | 193f720 | 2009-11-24 01:14:22 +0000 | [diff] [blame] | 692 | |
Eric Christopher | 7bb386a | 2013-07-09 00:16:56 +0000 | [diff] [blame] | 693 | /// getDICompositeType - Find underlying composite type. |
| 694 | DICompositeType getDICompositeType(DIType T); |
| 695 | |
Devang Patel | 6f9d8ff | 2011-08-15 17:57:41 +0000 | [diff] [blame] | 696 | /// isSubprogramContext - Return true if Context is either a subprogram |
| 697 | /// or another context nested inside a subprogram. |
| 698 | bool isSubprogramContext(const MDNode *Context); |
| 699 | |
Devang Patel | 6236704 | 2010-11-10 22:19:21 +0000 | [diff] [blame] | 700 | /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable |
| 701 | /// to hold function specific information. |
Devang Patel | 93d39be | 2011-08-19 23:28:12 +0000 | [diff] [blame] | 702 | NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP); |
Devang Patel | 6236704 | 2010-11-10 22:19:21 +0000 | [diff] [blame] | 703 | |
Eric Christopher | 5f214ae | 2012-11-20 00:15:36 +0000 | [diff] [blame] | 704 | /// getFnSpecificMDNode - Return a NameMDNode, if available, that is |
Devang Patel | 6236704 | 2010-11-10 22:19:21 +0000 | [diff] [blame] | 705 | /// suitable to hold function specific information. |
Devang Patel | 93d39be | 2011-08-19 23:28:12 +0000 | [diff] [blame] | 706 | NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP); |
Devang Patel | 6236704 | 2010-11-10 22:19:21 +0000 | [diff] [blame] | 707 | |
Devang Patel | 23336b4 | 2011-07-19 19:41:54 +0000 | [diff] [blame] | 708 | /// createInlinedVariable - Create a new inlined variable based on current |
| 709 | /// variable. |
| 710 | /// @param DV Current Variable. |
| 711 | /// @param InlinedScope Location at current variable is inlined. |
| 712 | DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope, |
| 713 | LLVMContext &VMContext); |
| 714 | |
Devang Patel | b549bcf | 2011-08-10 21:50:54 +0000 | [diff] [blame] | 715 | /// cleanseInlinedVariable - Remove inlined scope from the variable. |
| 716 | DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext); |
| 717 | |
Manman Ren | 0e29eee | 2013-07-23 00:22:51 +0000 | [diff] [blame] | 718 | /// DebugInfoFinder tries to list all debug info MDNodes in a module. To |
| 719 | /// list debug info MDNodes used by an instruction, DebugInfoFinder uses |
| 720 | /// processDeclare and processValue. processModule will go through |
| 721 | /// all DICompileUnits and list debug info MDNodes used by the CUs. |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 722 | class DebugInfoFinder { |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 723 | public: |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 724 | /// processModule - Process entire module and collect debug info |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 725 | /// anchors. |
Eric Christopher | c4639d6 | 2012-11-19 22:42:15 +0000 | [diff] [blame] | 726 | void processModule(const Module &M); |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 727 | |
Manman Ren | 0e29eee | 2013-07-23 00:22:51 +0000 | [diff] [blame] | 728 | /// processDeclare - Process DbgDeclareInst. |
| 729 | void processDeclare(const DbgDeclareInst *DDI); |
| 730 | /// Process DbgValueInst. |
| 731 | void processValue(const DbgValueInst *DVI); |
| 732 | |
| 733 | /// Clear all lists. |
| 734 | void reset(); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 735 | private: |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 736 | /// processType - Process DIType. |
| 737 | void processType(DIType DT); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 738 | |
Devang Patel | beab41b | 2009-10-07 22:04:08 +0000 | [diff] [blame] | 739 | /// processLexicalBlock - Process DILexicalBlock. |
| 740 | void processLexicalBlock(DILexicalBlock LB); |
| 741 | |
| 742 | /// processSubprogram - Process DISubprogram. |
Devang Patel | 98c6517 | 2009-07-30 18:25:15 +0000 | [diff] [blame] | 743 | void processSubprogram(DISubprogram SP); |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 744 | |
Devang Patel | 6daf99b | 2009-11-10 22:05:35 +0000 | [diff] [blame] | 745 | /// processLocation - Process DILocation. |
| 746 | void processLocation(DILocation Loc); |
| 747 | |
Manman Ren | fdd16bb | 2013-07-22 20:28:53 +0000 | [diff] [blame] | 748 | void processScope(DIScope Scope); |
| 749 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 750 | /// addCompileUnit - Add compile unit into CUs. |
| 751 | bool addCompileUnit(DICompileUnit CU); |
Daniel Dunbar | f612ff6 | 2009-09-19 20:40:05 +0000 | [diff] [blame] | 752 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 753 | /// addGlobalVariable - Add global variable into GVs. |
| 754 | bool addGlobalVariable(DIGlobalVariable DIG); |
| 755 | |
Eric Christopher | ecfd04b | 2011-11-09 18:53:37 +0000 | [diff] [blame] | 756 | // addSubprogram - Add subprogram into SPs. |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 757 | bool addSubprogram(DISubprogram SP); |
| 758 | |
Devang Patel | 72bcdb6 | 2009-08-10 22:09:58 +0000 | [diff] [blame] | 759 | /// addType - Add type into Tys. |
| 760 | bool addType(DIType DT); |
| 761 | |
Manman Ren | 96ea038 | 2013-07-20 00:38:46 +0000 | [diff] [blame] | 762 | bool addScope(DIScope Scope); |
| 763 | |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 764 | public: |
Craig Topper | 365ef0b | 2013-07-03 15:07:05 +0000 | [diff] [blame] | 765 | typedef SmallVectorImpl<MDNode *>::const_iterator iterator; |
Dan Gohman | 5374195 | 2010-05-07 15:36:10 +0000 | [diff] [blame] | 766 | iterator compile_unit_begin() const { return CUs.begin(); } |
| 767 | iterator compile_unit_end() const { return CUs.end(); } |
| 768 | iterator subprogram_begin() const { return SPs.begin(); } |
| 769 | iterator subprogram_end() const { return SPs.end(); } |
| 770 | iterator global_variable_begin() const { return GVs.begin(); } |
| 771 | iterator global_variable_end() const { return GVs.end(); } |
| 772 | iterator type_begin() const { return TYs.begin(); } |
| 773 | iterator type_end() const { return TYs.end(); } |
Manman Ren | 96ea038 | 2013-07-20 00:38:46 +0000 | [diff] [blame] | 774 | iterator scope_begin() const { return Scopes.begin(); } |
| 775 | iterator scope_end() const { return Scopes.end(); } |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 776 | |
Dan Gohman | 5374195 | 2010-05-07 15:36:10 +0000 | [diff] [blame] | 777 | unsigned compile_unit_count() const { return CUs.size(); } |
| 778 | unsigned global_variable_count() const { return GVs.size(); } |
| 779 | unsigned subprogram_count() const { return SPs.size(); } |
| 780 | unsigned type_count() const { return TYs.size(); } |
Manman Ren | 96ea038 | 2013-07-20 00:38:46 +0000 | [diff] [blame] | 781 | unsigned scope_count() const { return Scopes.size(); } |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 782 | |
| 783 | private: |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 784 | SmallVector<MDNode *, 8> CUs; // Compile Units |
| 785 | SmallVector<MDNode *, 8> SPs; // Subprograms |
| 786 | SmallVector<MDNode *, 8> GVs; // Global Variables; |
| 787 | SmallVector<MDNode *, 8> TYs; // Types |
Manman Ren | 96ea038 | 2013-07-20 00:38:46 +0000 | [diff] [blame] | 788 | SmallVector<MDNode *, 8> Scopes; // Scopes |
Devang Patel | e4b2756 | 2009-08-28 23:24:31 +0000 | [diff] [blame] | 789 | SmallPtrSet<MDNode *, 64> NodesSeen; |
Devang Patel | d2f79a1 | 2009-07-28 19:55:13 +0000 | [diff] [blame] | 790 | }; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 791 | } // end namespace llvm |
| 792 | |
| 793 | #endif |