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