blob: 276ac451c1f67d6dd4b02dc99f719afd2e4c9c53 [file] [log] [blame]
Chris Lattnera45664f2008-11-10 02:56:27 +00001//===--- 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 Wendlingdc817b62009-05-14 18:26:15 +000011// 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 Lattnera45664f2008-11-10 02:56:27 +000014//
15//===----------------------------------------------------------------------===//
16
Evan Cheng891415b2009-01-26 07:31:20 +000017#ifndef LLVM_ANALYSIS_DEBUGINFO_H
18#define LLVM_ANALYSIS_DEBUGINFO_H
Chris Lattnera45664f2008-11-10 02:56:27 +000019
Devang Patel13e16b62009-06-26 01:49:18 +000020#include "llvm/ADT/SmallVector.h"
Devang Pateld2f79a12009-07-28 19:55:13 +000021#include "llvm/ADT/SmallPtrSet.h"
Chris Lattnerf0908a32009-12-31 03:02:08 +000022#include "llvm/ADT/StringRef.h"
Chris Lattner210d0fe2009-12-31 03:02:42 +000023#include "llvm/Support/Dwarf.h"
Chris Lattnera45664f2008-11-10 02:56:27 +000024
25namespace llvm {
26 class BasicBlock;
27 class Constant;
28 class Function;
29 class GlobalVariable;
30 class Module;
Chris Lattner497a7a82008-11-10 04:10:34 +000031 class Type;
Chris Lattnera45664f2008-11-10 02:56:27 +000032 class Value;
Douglas Gregorb419a5c2010-01-06 17:16:00 +000033 class DbgDeclareInst;
Torok Edwin620f2802008-12-16 09:07:36 +000034 class Instruction;
Chris Lattnerf0908a32009-12-31 03:02:08 +000035 class MDNode;
Devang Patel62367042010-11-10 22:19:21 +000036 class NamedMDNode;
Chris Lattnerf0908a32009-12-31 03:02:08 +000037 class LLVMContext;
Dan Gohman50404362010-05-07 15:30:29 +000038 class raw_ostream;
Devang Patela913f4f2009-01-20 19:08:39 +000039
Devang Patel5b164b52010-08-02 22:51:46 +000040 class DIFile;
41 class DISubprogram;
42 class DILexicalBlock;
43 class DIVariable;
44 class DIType;
45
Chris Lattner784b8502009-12-29 09:15:46 +000046 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
47 /// This should not be stored in a container, because underly MDNode may
48 /// change in certain situations.
Chris Lattnera45664f2008-11-10 02:56:27 +000049 class DIDescriptor {
Devang Patel9dd2b472010-09-29 21:04:46 +000050 public:
51 enum {
52 FlagPrivate = 1 << 0,
53 FlagProtected = 1 << 1,
54 FlagFwdDecl = 1 << 2,
55 FlagAppleBlock = 1 << 3,
56 FlagBlockByrefStruct = 1 << 4,
57 FlagVirtual = 1 << 5,
Devang Patel21ea1d52010-10-01 23:31:40 +000058 FlagArtificial = 1 << 6,
Devang Patel7b172c62010-10-07 22:03:01 +000059 FlagExplicit = 1 << 7,
60 FlagPrototyped = 1 << 8
Devang Patel9dd2b472010-09-29 21:04:46 +000061 };
Daniel Dunbarf612ff62009-09-19 20:40:05 +000062 protected:
Devang Patele9f8f5e2010-05-07 20:54:48 +000063 const MDNode *DbgNode;
Devang Patela913f4f2009-01-20 19:08:39 +000064
Devang Patel65dbc902009-11-25 17:36:49 +000065 StringRef getStringField(unsigned Elt) const;
Chris Lattnera45664f2008-11-10 02:56:27 +000066 unsigned getUnsignedField(unsigned Elt) const {
67 return (unsigned)getUInt64Field(Elt);
68 }
69 uint64_t getUInt64Field(unsigned Elt) const;
70 DIDescriptor getDescriptorField(unsigned Elt) const;
Devang Patela913f4f2009-01-20 19:08:39 +000071
Chris Lattnera45664f2008-11-10 02:56:27 +000072 template <typename DescTy>
73 DescTy getFieldAs(unsigned Elt) const {
Devang Patelebe57f12010-05-07 18:36:34 +000074 return DescTy(getDescriptorField(Elt));
Chris Lattnera45664f2008-11-10 02:56:27 +000075 }
Devang Patela913f4f2009-01-20 19:08:39 +000076
Chris Lattnera45664f2008-11-10 02:56:27 +000077 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
Devang Patel27398962010-08-09 21:39:24 +000078 Constant *getConstantField(unsigned Elt) const;
Stuart Hastings215aa152010-06-11 20:08:44 +000079 Function *getFunctionField(unsigned Elt) const;
Devang Patela913f4f2009-01-20 19:08:39 +000080
Chris Lattnera45664f2008-11-10 02:56:27 +000081 public:
Devang Patele4b27562009-08-28 23:24:31 +000082 explicit DIDescriptor() : DbgNode(0) {}
Devang Patele9f8f5e2010-05-07 20:54:48 +000083 explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
Devang Patel5b164b52010-08-02 22:51:46 +000084 explicit DIDescriptor(const DIFile F);
85 explicit DIDescriptor(const DISubprogram F);
86 explicit DIDescriptor(const DILexicalBlock F);
87 explicit DIDescriptor(const DIVariable F);
88 explicit DIDescriptor(const DIType F);
Chris Lattnera45664f2008-11-10 02:56:27 +000089
Devang Patel3c91b052010-03-08 20:52:55 +000090 bool Verify() const { return DbgNode != 0; }
Chris Lattnera45664f2008-11-10 02:56:27 +000091
Devang Patele9f8f5e2010-05-07 20:54:48 +000092 operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
93 MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
Devang Patel2c1623a2009-01-05 18:06:21 +000094
Devang Patel8526cc02009-01-05 22:35:52 +000095 unsigned getVersion() const {
Devang Patel6906ba52009-01-20 19:22:03 +000096 return getUnsignedField(0) & LLVMDebugVersionMask;
Devang Patel8526cc02009-01-05 22:35:52 +000097 }
Devang Patela913f4f2009-01-20 19:08:39 +000098
Devang Patel2c1623a2009-01-05 18:06:21 +000099 unsigned getTag() const {
Devang Patel6906ba52009-01-20 19:22:03 +0000100 return getUnsignedField(0) & ~LLVMDebugVersionMask;
Devang Patel2c1623a2009-01-05 18:06:21 +0000101 }
Devang Patela913f4f2009-01-20 19:08:39 +0000102
Dan Gohman50404362010-05-07 15:30:29 +0000103 /// print - print descriptor.
104 void print(raw_ostream &OS) const;
105
106 /// dump - print descriptor to dbgs() with a newline.
Bill Wendling16de0132009-05-05 22:19:25 +0000107 void dump() const;
Devang Patel6ceea332009-08-31 18:49:10 +0000108
109 bool isDerivedType() const;
110 bool isCompositeType() const;
111 bool isBasicType() const;
112 bool isVariable() const;
113 bool isSubprogram() const;
114 bool isGlobalVariable() const;
Devang Patel43d98b32009-08-31 20:44:45 +0000115 bool isScope() const;
Devang Patel7aa81892010-03-08 22:27:22 +0000116 bool isFile() const;
Devang Patelc9f322d2009-08-31 21:34:44 +0000117 bool isCompileUnit() const;
Devang Patel6404e4e2009-12-15 19:16:48 +0000118 bool isNameSpace() const;
Devang Patel5e005d82009-08-31 22:00:15 +0000119 bool isLexicalBlock() const;
Devang Patelecbeb1a2009-09-30 22:34:41 +0000120 bool isSubrange() const;
121 bool isEnumerator() const;
122 bool isType() const;
123 bool isGlobal() const;
Devang Pateld6747df2010-10-06 20:50:40 +0000124 bool isUnspecifiedParameter() const;
Devang Patel7e2cb112011-02-02 21:38:25 +0000125 bool isTemplateTypeParameter() const;
Devang Patele7d93872011-02-02 22:35:53 +0000126 bool isTemplateValueParameter() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000127 };
Devang Patela913f4f2009-01-20 19:08:39 +0000128
Devang Patel68afdc32009-01-05 18:33:01 +0000129 /// DISubrange - This is used to represent ranges, for array bounds.
130 class DISubrange : public DIDescriptor {
131 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000132 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
Devang Patela913f4f2009-01-20 19:08:39 +0000133
Devang Patel68afdc32009-01-05 18:33:01 +0000134 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
135 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
136 };
Devang Patela913f4f2009-01-20 19:08:39 +0000137
Chris Lattnera45664f2008-11-10 02:56:27 +0000138 /// DIArray - This descriptor holds an array of descriptors.
139 class DIArray : public DIDescriptor {
140 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000141 explicit DIArray(const MDNode *N = 0)
Devang Patele4b27562009-08-28 23:24:31 +0000142 : DIDescriptor(N) {}
Devang Patela913f4f2009-01-20 19:08:39 +0000143
Chris Lattnera45664f2008-11-10 02:56:27 +0000144 unsigned getNumElements() const;
Devang Patela22d57d2009-01-05 19:55:07 +0000145 DIDescriptor getElement(unsigned Idx) const {
146 return getDescriptorField(Idx);
Devang Patel68afdc32009-01-05 18:33:01 +0000147 }
Chris Lattnera45664f2008-11-10 02:56:27 +0000148 };
Devang Patela913f4f2009-01-20 19:08:39 +0000149
Devang Patel43d98b32009-08-31 20:44:45 +0000150 /// DIScope - A base class for various scopes.
151 class DIScope : public DIDescriptor {
152 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000153 explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
Devang Patele5b14542009-09-01 05:04:28 +0000154 virtual ~DIScope() {}
Devang Patel58e7a2d2009-09-01 00:53:21 +0000155
Devang Patel65dbc902009-11-25 17:36:49 +0000156 StringRef getFilename() const;
157 StringRef getDirectory() const;
Devang Patel43d98b32009-08-31 20:44:45 +0000158 };
159
Chris Lattnera45664f2008-11-10 02:56:27 +0000160 /// DICompileUnit - A wrapper for a compile unit.
Devang Patelc9f322d2009-08-31 21:34:44 +0000161 class DICompileUnit : public DIScope {
Chris Lattnera45664f2008-11-10 02:56:27 +0000162 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000163 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
Devang Patela913f4f2009-01-20 19:08:39 +0000164
Stuart Hastings0db42712010-07-19 23:56:30 +0000165 unsigned getLanguage() const { return getUnsignedField(2); }
Devang Patel65dbc902009-11-25 17:36:49 +0000166 StringRef getFilename() const { return getStringField(3); }
167 StringRef getDirectory() const { return getStringField(4); }
168 StringRef getProducer() const { return getStringField(5); }
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000169
Devang Pateldd9db662009-01-30 18:20:31 +0000170 /// isMain - Each input file is encoded as a separate compile unit in LLVM
171 /// debugging information output. However, many target specific tool chains
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000172 /// prefer to encode only one compile unit in an object file. In this
Devang Pateldd9db662009-01-30 18:20:31 +0000173 /// situation, the LLVM code generator will include debugging information
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000174 /// entities in the compile unit that is marked as main compile unit. The
Devang Pateldd9db662009-01-30 18:20:31 +0000175 /// code generator accepts maximum one main compile unit per module. If a
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000176 /// module does not contain any main compile unit then the code generator
Devang Pateldd9db662009-01-30 18:20:31 +0000177 /// will emit multiple compile units in the output object file.
Devang Patel13319ce2009-02-17 22:43:44 +0000178
Oscar Fuentes429c75b2010-09-25 20:27:36 +0000179 bool isMain() const { return getUnsignedField(6) != 0; }
180 bool isOptimized() const { return getUnsignedField(7) != 0; }
Devang Patel65dbc902009-11-25 17:36:49 +0000181 StringRef getFlags() const { return getStringField(8); }
Devang Patel13319ce2009-02-17 22:43:44 +0000182 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
Devang Patelce31b022009-01-20 18:13:03 +0000183
Devang Patelb79b5352009-01-19 23:21:49 +0000184 /// Verify - Verify that a compile unit is well formed.
185 bool Verify() const;
Devang Patelbf3f5a02009-01-30 01:03:10 +0000186
Dan Gohman50404362010-05-07 15:30:29 +0000187 /// print - print compile unit.
188 void print(raw_ostream &OS) const;
189
190 /// dump - print compile unit to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000191 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000192 };
193
Devang Patel7aa81892010-03-08 22:27:22 +0000194 /// DIFile - This is a wrapper for a file.
195 class DIFile : public DIScope {
196 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000197 explicit DIFile(const MDNode *N = 0) : DIScope(N) {
Devang Patel7aa81892010-03-08 22:27:22 +0000198 if (DbgNode && !isFile())
199 DbgNode = 0;
200 }
201 StringRef getFilename() const { return getStringField(1); }
202 StringRef getDirectory() const { return getStringField(2); }
203 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
204 };
205
Chris Lattnera45664f2008-11-10 02:56:27 +0000206 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
207 /// FIXME: it seems strange that this doesn't have either a reference to the
208 /// type/precision or a file/line pair for location info.
209 class DIEnumerator : public DIDescriptor {
210 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000211 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
Devang Patela913f4f2009-01-20 19:08:39 +0000212
Devang Patel65dbc902009-11-25 17:36:49 +0000213 StringRef getName() const { return getStringField(1); }
Devang Patel5ccdd102009-09-29 18:40:58 +0000214 uint64_t getEnumValue() const { return getUInt64Field(2); }
Chris Lattnera45664f2008-11-10 02:56:27 +0000215 };
Devang Patela913f4f2009-01-20 19:08:39 +0000216
Chris Lattnera45664f2008-11-10 02:56:27 +0000217 /// DIType - This is a wrapper for a type.
218 /// FIXME: Types should be factored much better so that CV qualifiers and
219 /// others do not require a huge and empty descriptor full of zeros.
Devang Patel77bf2952010-03-08 22:02:50 +0000220 class DIType : public DIScope {
Devang Patel2a574662009-01-20 22:27:02 +0000221 public:
Chris Lattnera45664f2008-11-10 02:56:27 +0000222 protected:
Chris Lattnera45664f2008-11-10 02:56:27 +0000223 // This ctor is used when the Tag has already been validated by a derived
224 // ctor.
Devang Patele9f8f5e2010-05-07 20:54:48 +0000225 DIType(const MDNode *N, bool, bool) : DIScope(N) {}
Devang Patel486938f2009-01-12 21:38:43 +0000226
Devang Patelf193ff02009-01-15 19:26:23 +0000227 public:
Devang Patel486938f2009-01-12 21:38:43 +0000228
Devang Patelb79b5352009-01-19 23:21:49 +0000229 /// Verify - Verify that a type descriptor is well formed.
230 bool Verify() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000231 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000232 explicit DIType(const MDNode *N);
Chris Lattnera45664f2008-11-10 02:56:27 +0000233 explicit DIType() {}
Devang Patel8526cc02009-01-05 22:35:52 +0000234 virtual ~DIType() {}
235
Devang Patel77bf2952010-03-08 22:02:50 +0000236 DIScope getContext() const { return getFieldAs<DIScope>(1); }
Devang Patel6404e4e2009-12-15 19:16:48 +0000237 StringRef getName() const { return getStringField(2); }
Devang Patel4b945502010-03-09 00:44:10 +0000238 DICompileUnit getCompileUnit() const{
Devang Patelfb9dce32010-10-28 20:41:11 +0000239 if (getVersion() == llvm::LLVMDebugVersion7)
240 return getFieldAs<DICompileUnit>(3);
241
Devang Patel0e82ac02010-10-29 16:42:37 +0000242 return getFieldAs<DIFile>(3).getCompileUnit();
Devang Patel4b945502010-03-09 00:44:10 +0000243 }
Devang Patelab70ed42010-11-04 14:56:34 +0000244 DIFile getFile() const { return getFieldAs<DIFile>(3); }
Chris Lattnera45664f2008-11-10 02:56:27 +0000245 unsigned getLineNumber() const { return getUnsignedField(4); }
246 uint64_t getSizeInBits() const { return getUInt64Field(5); }
247 uint64_t getAlignInBits() const { return getUInt64Field(6); }
248 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
249 // carry this is just plain insane.
250 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
251 unsigned getFlags() const { return getUnsignedField(8); }
Chris Lattnere1f515e2009-08-26 04:21:30 +0000252 bool isPrivate() const {
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000253 return (getFlags() & FlagPrivate) != 0;
Devang Patele2d5a6c2009-07-27 20:30:05 +0000254 }
Chris Lattnere1f515e2009-08-26 04:21:30 +0000255 bool isProtected() const {
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000256 return (getFlags() & FlagProtected) != 0;
Devang Patele2d5a6c2009-07-27 20:30:05 +0000257 }
Chris Lattnere1f515e2009-08-26 04:21:30 +0000258 bool isForwardDecl() const {
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000259 return (getFlags() & FlagFwdDecl) != 0;
Devang Patele2d5a6c2009-07-27 20:30:05 +0000260 }
Devang Patela1ba2692009-08-27 23:51:51 +0000261 // isAppleBlock - Return true if this is the Apple Blocks extension.
262 bool isAppleBlockExtension() const {
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000263 return (getFlags() & FlagAppleBlock) != 0;
Devang Patel8af76bd2009-08-26 00:39:50 +0000264 }
Caroline Ticedc8f6042009-08-31 21:19:37 +0000265 bool isBlockByrefStruct() const {
266 return (getFlags() & FlagBlockByrefStruct) != 0;
267 }
Devang Patel5d11eb02009-12-03 19:11:07 +0000268 bool isVirtual() const {
269 return (getFlags() & FlagVirtual) != 0;
270 }
Devang Patelb4645642010-02-06 01:02:37 +0000271 bool isArtificial() const {
272 return (getFlags() & FlagArtificial) != 0;
273 }
Devang Patel3c91b052010-03-08 20:52:55 +0000274 bool isValid() const {
275 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
276 }
Devang Patelbc2bb9b2010-10-28 19:50:08 +0000277 StringRef getDirectory() const {
Devang Patel8f6a2812010-10-28 20:08:13 +0000278 if (getVersion() == llvm::LLVMDebugVersion7)
279 return getCompileUnit().getDirectory();
280
Devang Patel0e82ac02010-10-29 16:42:37 +0000281 return getFieldAs<DIFile>(3).getDirectory();
Devang Patelbc2bb9b2010-10-28 19:50:08 +0000282 }
283 StringRef getFilename() const {
Devang Patel8f6a2812010-10-28 20:08:13 +0000284 if (getVersion() == llvm::LLVMDebugVersion7)
285 return getCompileUnit().getFilename();
286
Devang Patel0e82ac02010-10-29 16:42:37 +0000287 return getFieldAs<DIFile>(3).getFilename();
Devang Patelbc2bb9b2010-10-28 19:50:08 +0000288 }
Dan Gohman50404362010-05-07 15:30:29 +0000289
Dan Gohman489b29b2010-08-20 22:02:26 +0000290 /// replaceAllUsesWith - Replace all uses of debug info referenced by
291 /// this descriptor.
292 void replaceAllUsesWith(DIDescriptor &D);
Devang Patel0a2551d2010-12-08 20:18:20 +0000293 void replaceAllUsesWith(MDNode *D);
Dan Gohman489b29b2010-08-20 22:02:26 +0000294
Dan Gohman50404362010-05-07 15:30:29 +0000295 /// print - print type.
296 void print(raw_ostream &OS) const;
297
298 /// dump - print type to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000299 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000300 };
Devang Patela913f4f2009-01-20 19:08:39 +0000301
Chris Lattnera45664f2008-11-10 02:56:27 +0000302 /// DIBasicType - A basic type, like 'int' or 'float'.
303 class DIBasicType : public DIType {
304 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000305 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
Bill Wendlingdc817b62009-05-14 18:26:15 +0000306
Chris Lattnera45664f2008-11-10 02:56:27 +0000307 unsigned getEncoding() const { return getUnsignedField(9); }
Devang Patelbf3f5a02009-01-30 01:03:10 +0000308
Devang Patel0c4720c2010-08-23 18:25:56 +0000309 /// Verify - Verify that a basic type descriptor is well formed.
310 bool Verify() const;
311
Dan Gohman50404362010-05-07 15:30:29 +0000312 /// print - print basic type.
313 void print(raw_ostream &OS) const;
314
315 /// dump - print basic type to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000316 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000317 };
Devang Patela913f4f2009-01-20 19:08:39 +0000318
Chris Lattnera45664f2008-11-10 02:56:27 +0000319 /// DIDerivedType - A simple derived type, like a const qualified type,
320 /// a typedef, a pointer or reference, etc.
321 class DIDerivedType : public DIType {
322 protected:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000323 explicit DIDerivedType(const MDNode *N, bool, bool)
Devang Patele4b27562009-08-28 23:24:31 +0000324 : DIType(N, true, true) {}
Chris Lattnera45664f2008-11-10 02:56:27 +0000325 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000326 explicit DIDerivedType(const MDNode *N = 0)
Devang Patelf17f5eb2010-03-08 21:32:10 +0000327 : DIType(N, true, true) {}
Bill Wendlingdc817b62009-05-14 18:26:15 +0000328
Chris Lattnera45664f2008-11-10 02:56:27 +0000329 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
Devang Patelbf3f5a02009-01-30 01:03:10 +0000330
Devang Patel36375ee2009-02-17 21:23:59 +0000331 /// getOriginalTypeSize - If this type is derived from a base type then
332 /// return base type size.
333 uint64_t getOriginalTypeSize() const;
Dan Gohman50404362010-05-07 15:30:29 +0000334
Devang Patel0c4720c2010-08-23 18:25:56 +0000335 /// Verify - Verify that a derived type descriptor is well formed.
336 bool Verify() const;
337
Dan Gohman50404362010-05-07 15:30:29 +0000338 /// print - print derived type.
339 void print(raw_ostream &OS) const;
340
341 /// dump - print derived type to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000342 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000343 };
344
Chris Lattnera45664f2008-11-10 02:56:27 +0000345 /// DICompositeType - This descriptor holds a type that can refer to multiple
346 /// other types, like a function or struct.
347 /// FIXME: Why is this a DIDerivedType??
348 class DICompositeType : public DIDerivedType {
349 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000350 explicit DICompositeType(const MDNode *N = 0)
Devang Patele4b27562009-08-28 23:24:31 +0000351 : DIDerivedType(N, true, true) {
Devang Patel6ceea332009-08-31 18:49:10 +0000352 if (N && !isCompositeType())
Devang Patele4b27562009-08-28 23:24:31 +0000353 DbgNode = 0;
Bill Wendlingdc817b62009-05-14 18:26:15 +0000354 }
355
Chris Lattnera45664f2008-11-10 02:56:27 +0000356 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
Devang Patel13319ce2009-02-17 22:43:44 +0000357 unsigned getRunTimeLang() const { return getUnsignedField(11); }
Devang Patel0fd7f9d2010-01-26 21:14:59 +0000358 DICompositeType getContainingType() const {
359 return getFieldAs<DICompositeType>(12);
360 }
Devang Patel7e2cb112011-02-02 21:38:25 +0000361 DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
Devang Patelb79b5352009-01-19 23:21:49 +0000362
363 /// Verify - Verify that a composite type descriptor is well formed.
364 bool Verify() const;
Devang Patelbf3f5a02009-01-30 01:03:10 +0000365
Dan Gohman50404362010-05-07 15:30:29 +0000366 /// print - print composite type.
367 void print(raw_ostream &OS) const;
368
369 /// dump - print composite type to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000370 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000371 };
Devang Patela913f4f2009-01-20 19:08:39 +0000372
Devang Patel7e2cb112011-02-02 21:38:25 +0000373 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
374 class DITemplateTypeParameter : public DIDescriptor {
375 public:
376 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
377
378 DIScope getContext() const { return getFieldAs<DIScope>(1); }
379 StringRef getName() const { return getStringField(2); }
380 DIType getType() const { return getFieldAs<DIType>(3); }
381 StringRef getFilename() const {
382 return getFieldAs<DIFile>(4).getFilename();
383 }
384 StringRef getDirectory() const {
385 return getFieldAs<DIFile>(4).getDirectory();
386 }
387 unsigned getLineNumber() const { return getUnsignedField(5); }
388 unsigned getColumnNumber() const { return getUnsignedField(6); }
389 };
390
Devang Patele7d93872011-02-02 22:35:53 +0000391 /// DITemplateValueParameter - This is a wrapper for template value parameter.
392 class DITemplateValueParameter : public DIDescriptor {
393 public:
394 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
395
396 DIScope getContext() const { return getFieldAs<DIScope>(1); }
397 StringRef getName() const { return getStringField(2); }
398 DIType getType() const { return getFieldAs<DIType>(3); }
399 uint64_t getValue() const { return getUInt64Field(4); }
400 StringRef getFilename() const {
401 return getFieldAs<DIFile>(5).getFilename();
402 }
403 StringRef getDirectory() const {
404 return getFieldAs<DIFile>(5).getDirectory();
405 }
406 unsigned getLineNumber() const { return getUnsignedField(6); }
407 unsigned getColumnNumber() const { return getUnsignedField(7); }
408 };
409
Chris Lattnera45664f2008-11-10 02:56:27 +0000410 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
Devang Patel82dfc0c2009-08-31 22:47:13 +0000411 class DISubprogram : public DIScope {
Chris Lattnera45664f2008-11-10 02:56:27 +0000412 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000413 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
Bill Wendlingdc817b62009-05-14 18:26:15 +0000414
Devang Patel77bf2952010-03-08 22:02:50 +0000415 DIScope getContext() const { return getFieldAs<DIScope>(2); }
Devang Patel65dbc902009-11-25 17:36:49 +0000416 StringRef getName() const { return getStringField(3); }
417 StringRef getDisplayName() const { return getStringField(4); }
418 StringRef getLinkageName() const { return getStringField(5); }
Devang Patel4b945502010-03-09 00:44:10 +0000419 DICompileUnit getCompileUnit() const{
420 if (getVersion() == llvm::LLVMDebugVersion7)
421 return getFieldAs<DICompileUnit>(6);
422
Devang Patel0e82ac02010-10-29 16:42:37 +0000423 return getFieldAs<DIFile>(6).getCompileUnit();
Devang Patel4b945502010-03-09 00:44:10 +0000424 }
Devang Patel82dfc0c2009-08-31 22:47:13 +0000425 unsigned getLineNumber() const { return getUnsignedField(7); }
Devang Patel86ae1422009-01-05 18:59:44 +0000426 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
Devang Patelb79b5352009-01-19 23:21:49 +0000427
Devang Patel0de4fa62009-06-23 22:07:48 +0000428 /// getReturnTypeName - Subprogram return types are encoded either as
429 /// DIType or as DICompositeType.
Devang Patel65dbc902009-11-25 17:36:49 +0000430 StringRef getReturnTypeName() const {
Devang Patel0de4fa62009-06-23 22:07:48 +0000431 DICompositeType DCT(getFieldAs<DICompositeType>(8));
Devang Patel3c91b052010-03-08 20:52:55 +0000432 if (DCT.Verify()) {
Devang Patel0de4fa62009-06-23 22:07:48 +0000433 DIArray A = DCT.getTypeArray();
Devang Patel2db49d72010-05-07 18:11:54 +0000434 DIType T(A.getElement(0));
Devang Patel5ccdd102009-09-29 18:40:58 +0000435 return T.getName();
Devang Patel0de4fa62009-06-23 22:07:48 +0000436 }
437 DIType T(getFieldAs<DIType>(8));
Devang Patel5ccdd102009-09-29 18:40:58 +0000438 return T.getName();
Devang Patel0de4fa62009-06-23 22:07:48 +0000439 }
440
Devang Patel82dfc0c2009-08-31 22:47:13 +0000441 /// isLocalToUnit - Return true if this subprogram is local to the current
442 /// compile unit, like 'static' in C.
Devang Patel5ccdd102009-09-29 18:40:58 +0000443 unsigned isLocalToUnit() const { return getUnsignedField(9); }
444 unsigned isDefinition() const { return getUnsignedField(10); }
Devang Patel5d11eb02009-12-03 19:11:07 +0000445
Chris Lattnerf0908a32009-12-31 03:02:08 +0000446 unsigned getVirtuality() const { return getUnsignedField(11); }
447 unsigned getVirtualIndex() const { return getUnsignedField(12); }
Devang Patel5d11eb02009-12-03 19:11:07 +0000448
449 DICompositeType getContainingType() const {
Devang Patel5d11eb02009-12-03 19:11:07 +0000450 return getFieldAs<DICompositeType>(13);
451 }
Devang Patel9dd2b472010-09-29 21:04:46 +0000452 unsigned isArtificial() const {
453 if (getVersion() <= llvm::LLVMDebugVersion8)
454 return getUnsignedField(14);
455 return (getUnsignedField(14) & FlagArtificial) != 0;
456 }
Devang Patel1a301232010-09-29 21:44:16 +0000457 /// isPrivate - Return true if this subprogram has "private"
458 /// access specifier.
459 bool isPrivate() const {
460 if (getVersion() <= llvm::LLVMDebugVersion8)
461 return false;
462 return (getUnsignedField(14) & FlagPrivate) != 0;
463 }
464 /// isProtected - Return true if this subprogram has "protected"
465 /// access specifier.
466 bool isProtected() const {
467 if (getVersion() <= llvm::LLVMDebugVersion8)
468 return false;
469 return (getUnsignedField(14) & FlagProtected) != 0;
470 }
Devang Patel21ea1d52010-10-01 23:31:40 +0000471 /// isExplicit - Return true if this subprogram is marked as explicit.
472 bool isExplicit() const {
473 if (getVersion() <= llvm::LLVMDebugVersion8)
474 return false;
475 return (getUnsignedField(14) & FlagExplicit) != 0;
476 }
Devang Patel7b172c62010-10-07 22:03:01 +0000477 /// isPrototyped - Return true if this subprogram is prototyped.
478 bool isPrototyped() const {
479 if (getVersion() <= llvm::LLVMDebugVersion8)
480 return false;
481 return (getUnsignedField(14) & FlagPrototyped) != 0;
482 }
Devang Patel21ea1d52010-10-01 23:31:40 +0000483
Devang Patelccff8122010-04-30 19:38:23 +0000484 unsigned isOptimized() const;
Devang Patel5d11eb02009-12-03 19:11:07 +0000485
Devang Patel8fe79792010-03-24 18:48:00 +0000486 StringRef getFilename() const {
487 if (getVersion() == llvm::LLVMDebugVersion7)
488 return getCompileUnit().getFilename();
489
Devang Patel0e82ac02010-10-29 16:42:37 +0000490 return getFieldAs<DIFile>(6).getFilename();
Devang Patel8fe79792010-03-24 18:48:00 +0000491 }
492
493 StringRef getDirectory() const {
494 if (getVersion() == llvm::LLVMDebugVersion7)
495 return getCompileUnit().getFilename();
496
Devang Patel0e82ac02010-10-29 16:42:37 +0000497 return getFieldAs<DIFile>(6).getDirectory();
Devang Patel8fe79792010-03-24 18:48:00 +0000498 }
Devang Patel58e7a2d2009-09-01 00:53:21 +0000499
Devang Patelb79b5352009-01-19 23:21:49 +0000500 /// Verify - Verify that a subprogram descriptor is well formed.
501 bool Verify() const;
Devang Patelbf3f5a02009-01-30 01:03:10 +0000502
Dan Gohman50404362010-05-07 15:30:29 +0000503 /// print - print subprogram.
504 void print(raw_ostream &OS) const;
505
506 /// dump - print subprogram to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000507 void dump() const;
Devang Patelaf5b6bb2009-04-15 00:06:07 +0000508
509 /// describes - Return true if this subprogram provides debugging
510 /// information for the function F.
511 bool describes(const Function *F);
Stuart Hastings215aa152010-06-11 20:08:44 +0000512
513 Function *getFunction() const { return getFunctionField(16); }
Devang Patelda194752011-04-05 22:52:06 +0000514 DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
Chris Lattnera45664f2008-11-10 02:56:27 +0000515 };
Devang Patela913f4f2009-01-20 19:08:39 +0000516
Chris Lattnera45664f2008-11-10 02:56:27 +0000517 /// DIGlobalVariable - This is a wrapper for a global variable.
Devang Patela49d8772010-05-07 23:19:07 +0000518 class DIGlobalVariable : public DIDescriptor {
Chris Lattnera45664f2008-11-10 02:56:27 +0000519 public:
Devang Patela49d8772010-05-07 23:19:07 +0000520 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
521
522 DIScope getContext() const { return getFieldAs<DIScope>(2); }
523 StringRef getName() const { return getStringField(3); }
524 StringRef getDisplayName() const { return getStringField(4); }
525 StringRef getLinkageName() const { return getStringField(5); }
526 DICompileUnit getCompileUnit() const{
527 if (getVersion() == llvm::LLVMDebugVersion7)
528 return getFieldAs<DICompileUnit>(6);
529
530 DIFile F = getFieldAs<DIFile>(6);
531 return F.getCompileUnit();
532 }
533
534 unsigned getLineNumber() const { return getUnsignedField(7); }
535 DIType getType() const { return getFieldAs<DIType>(8); }
536 unsigned isLocalToUnit() const { return getUnsignedField(9); }
537 unsigned isDefinition() const { return getUnsignedField(10); }
Bill Wendlingdc817b62009-05-14 18:26:15 +0000538
Chris Lattnera45664f2008-11-10 02:56:27 +0000539 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
Devang Patel27398962010-08-09 21:39:24 +0000540 Constant *getConstant() const { return getConstantField(11); }
Devang Patelb79b5352009-01-19 23:21:49 +0000541
542 /// Verify - Verify that a global variable descriptor is well formed.
543 bool Verify() const;
Devang Patelbf3f5a02009-01-30 01:03:10 +0000544
Dan Gohman50404362010-05-07 15:30:29 +0000545 /// print - print global variable.
546 void print(raw_ostream &OS) const;
547
548 /// dump - print global variable to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000549 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000550 };
Devang Patela913f4f2009-01-20 19:08:39 +0000551
Chris Lattnera45664f2008-11-10 02:56:27 +0000552 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
553 /// global etc).
554 class DIVariable : public DIDescriptor {
555 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000556 explicit DIVariable(const MDNode *N = 0)
Devang Patelf17f5eb2010-03-08 21:32:10 +0000557 : DIDescriptor(N) {}
Devang Patela913f4f2009-01-20 19:08:39 +0000558
Devang Patel77bf2952010-03-08 22:02:50 +0000559 DIScope getContext() const { return getFieldAs<DIScope>(1); }
560 StringRef getName() const { return getStringField(2); }
Devang Patel4b945502010-03-09 00:44:10 +0000561 DICompileUnit getCompileUnit() const{
562 if (getVersion() == llvm::LLVMDebugVersion7)
563 return getFieldAs<DICompileUnit>(3);
564
565 DIFile F = getFieldAs<DIFile>(3);
566 return F.getCompileUnit();
567 }
Devang Patele9e16c52011-03-01 22:58:13 +0000568 unsigned getLineNumber() const {
569 return (getUnsignedField(4) << 8) >> 8;
570 }
571 unsigned getArgNumber() const {
572 unsigned L = getUnsignedField(4);
573 return L >> 24;
574 }
Chris Lattnera45664f2008-11-10 02:56:27 +0000575 DIType getType() const { return getFieldAs<DIType>(5); }
Devang Patel3cf763d2010-09-29 23:07:21 +0000576
577 /// isArtificial - Return true if this variable is marked as "artificial".
578 bool isArtificial() const {
579 if (getVersion() <= llvm::LLVMDebugVersion8)
580 return false;
581 return (getUnsignedField(6) & FlagArtificial) != 0;
582 }
Devang Patela913f4f2009-01-20 19:08:39 +0000583
Devang Patelb79b5352009-01-19 23:21:49 +0000584
585 /// Verify - Verify that a variable descriptor is well formed.
586 bool Verify() const;
Devang Patelbf3f5a02009-01-30 01:03:10 +0000587
Mike Stump3e4c9bd2009-09-30 00:08:22 +0000588 /// HasComplexAddr - Return true if the variable has a complex address.
589 bool hasComplexAddress() const {
590 return getNumAddrElements() > 0;
591 }
592
Chris Lattnerf0908a32009-12-31 03:02:08 +0000593 unsigned getNumAddrElements() const;
594
Mike Stump3e4c9bd2009-09-30 00:08:22 +0000595 uint64_t getAddrElement(unsigned Idx) const {
596 return getUInt64Field(Idx+6);
597 }
598
Caroline Ticedc8f6042009-08-31 21:19:37 +0000599 /// isBlockByrefVariable - Return true if the variable was declared as
600 /// a "__block" variable (Apple Blocks).
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000601 bool isBlockByrefVariable() const {
602 return getType().isBlockByrefStruct();
Caroline Ticedc8f6042009-08-31 21:19:37 +0000603 }
604
Devang Patel22070e82010-04-29 20:48:12 +0000605 /// isInlinedFnArgument - Return trule if this variable provides debugging
606 /// information for an inlined function arguments.
607 bool isInlinedFnArgument(const Function *CurFn);
608
Dan Gohman50404362010-05-07 15:30:29 +0000609 /// print - print variable.
610 void print(raw_ostream &OS) const;
611
612 /// dump - print variable to dbgs() with a newline.
Devang Patelbf3f5a02009-01-30 01:03:10 +0000613 void dump() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000614 };
Devang Patela913f4f2009-01-20 19:08:39 +0000615
Devang Patel5e005d82009-08-31 22:00:15 +0000616 /// DILexicalBlock - This is a wrapper for a lexical block.
617 class DILexicalBlock : public DIScope {
Chris Lattnera45664f2008-11-10 02:56:27 +0000618 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000619 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
Devang Patel3d821aa2010-02-16 21:39:34 +0000620 DIScope getContext() const { return getFieldAs<DIScope>(1); }
Devang Patel3d821aa2010-02-16 21:39:34 +0000621 unsigned getLineNumber() const { return getUnsignedField(2); }
622 unsigned getColumnNumber() const { return getUnsignedField(3); }
Stuart Hastings0db42712010-07-19 23:56:30 +0000623 StringRef getDirectory() const {
Devang Patel0e82ac02010-10-29 16:42:37 +0000624 StringRef dir = getFieldAs<DIFile>(4).getDirectory();
Stuart Hastings0db42712010-07-19 23:56:30 +0000625 return !dir.empty() ? dir : getContext().getDirectory();
626 }
627 StringRef getFilename() const {
Devang Patel0e82ac02010-10-29 16:42:37 +0000628 StringRef filename = getFieldAs<DIFile>(4).getFilename();
Stuart Hastings0db42712010-07-19 23:56:30 +0000629 return !filename.empty() ? filename : getContext().getFilename();
630 }
Devang Patelf98d8fe2009-09-01 01:14:15 +0000631 };
Devang Patel58e7a2d2009-09-01 00:53:21 +0000632
Devang Patel6404e4e2009-12-15 19:16:48 +0000633 /// DINameSpace - A wrapper for a C++ style name space.
634 class DINameSpace : public DIScope {
635 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000636 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
Devang Patel6404e4e2009-12-15 19:16:48 +0000637 DIScope getContext() const { return getFieldAs<DIScope>(1); }
638 StringRef getName() const { return getStringField(2); }
Devang Patela514a4e2010-10-28 19:14:28 +0000639 StringRef getDirectory() const {
Devang Patel0e82ac02010-10-29 16:42:37 +0000640 return getFieldAs<DIFile>(3).getDirectory();
Devang Patela514a4e2010-10-28 19:14:28 +0000641 }
642 StringRef getFilename() const {
Devang Patel0e82ac02010-10-29 16:42:37 +0000643 return getFieldAs<DIFile>(3).getFilename();
Devang Patela514a4e2010-10-28 19:14:28 +0000644 }
Devang Patel4b945502010-03-09 00:44:10 +0000645 DICompileUnit getCompileUnit() const{
646 if (getVersion() == llvm::LLVMDebugVersion7)
647 return getFieldAs<DICompileUnit>(3);
648
Devang Patel0e82ac02010-10-29 16:42:37 +0000649 return getFieldAs<DIFile>(3).getCompileUnit();
Devang Patel4b945502010-03-09 00:44:10 +0000650 }
Devang Patel6404e4e2009-12-15 19:16:48 +0000651 unsigned getLineNumber() const { return getUnsignedField(4); }
Devang Patel47e22652010-05-07 23:04:32 +0000652 bool Verify() const;
Devang Patel6404e4e2009-12-15 19:16:48 +0000653 };
654
Devang Patelf98d8fe2009-09-01 01:14:15 +0000655 /// DILocation - This object holds location information. This object
656 /// is not associated with any DWARF tag.
657 class DILocation : public DIDescriptor {
658 public:
Devang Patele9f8f5e2010-05-07 20:54:48 +0000659 explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
Devang Patel58e7a2d2009-09-01 00:53:21 +0000660
Devang Patelf98d8fe2009-09-01 01:14:15 +0000661 unsigned getLineNumber() const { return getUnsignedField(0); }
662 unsigned getColumnNumber() const { return getUnsignedField(1); }
Devang Patel5ccdd102009-09-29 18:40:58 +0000663 DIScope getScope() const { return getFieldAs<DIScope>(2); }
664 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
Devang Patel65dbc902009-11-25 17:36:49 +0000665 StringRef getFilename() const { return getScope().getFilename(); }
666 StringRef getDirectory() const { return getScope().getDirectory(); }
Devang Patel3c91b052010-03-08 20:52:55 +0000667 bool Verify() const;
Chris Lattnera45664f2008-11-10 02:56:27 +0000668 };
Devang Patela913f4f2009-01-20 19:08:39 +0000669
Devang Patel193f7202009-11-24 01:14:22 +0000670 /// getDISubprogram - Find subprogram that is enclosing this scope.
Devang Patele9f8f5e2010-05-07 20:54:48 +0000671 DISubprogram getDISubprogram(const MDNode *Scope);
Devang Patel193f7202009-11-24 01:14:22 +0000672
673 /// getDICompositeType - Find underlying composite type.
674 DICompositeType getDICompositeType(DIType T);
675
Devang Patel62367042010-11-10 22:19:21 +0000676 /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
677 /// to hold function specific information.
678 NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, StringRef Name);
679
680 /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
681 /// suitable to hold function specific information.
682 NamedMDNode *getFnSpecificMDNode(const Module &M, StringRef Name);
683
Devang Patel98c65172009-07-30 18:25:15 +0000684 class DebugInfoFinder {
Devang Pateld2f79a12009-07-28 19:55:13 +0000685 public:
Devang Patel98c65172009-07-30 18:25:15 +0000686 /// processModule - Process entire module and collect debug info
Devang Pateld2f79a12009-07-28 19:55:13 +0000687 /// anchors.
Devang Patel98c65172009-07-30 18:25:15 +0000688 void processModule(Module &M);
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000689
Devang Pateld2f79a12009-07-28 19:55:13 +0000690 private:
Devang Patel98c65172009-07-30 18:25:15 +0000691 /// processType - Process DIType.
692 void processType(DIType DT);
Devang Pateld2f79a12009-07-28 19:55:13 +0000693
Devang Patelbeab41b2009-10-07 22:04:08 +0000694 /// processLexicalBlock - Process DILexicalBlock.
695 void processLexicalBlock(DILexicalBlock LB);
696
697 /// processSubprogram - Process DISubprogram.
Devang Patel98c65172009-07-30 18:25:15 +0000698 void processSubprogram(DISubprogram SP);
Devang Pateld2f79a12009-07-28 19:55:13 +0000699
Devang Patelb4d31302009-07-31 18:18:52 +0000700 /// processDeclare - Process DbgDeclareInst.
701 void processDeclare(DbgDeclareInst *DDI);
702
Devang Patel6daf99b2009-11-10 22:05:35 +0000703 /// processLocation - Process DILocation.
704 void processLocation(DILocation Loc);
705
Devang Pateld2f79a12009-07-28 19:55:13 +0000706 /// addCompileUnit - Add compile unit into CUs.
707 bool addCompileUnit(DICompileUnit CU);
Daniel Dunbarf612ff62009-09-19 20:40:05 +0000708
Devang Pateld2f79a12009-07-28 19:55:13 +0000709 /// addGlobalVariable - Add global variable into GVs.
710 bool addGlobalVariable(DIGlobalVariable DIG);
711
712 // addSubprogram - Add subprgoram into SPs.
713 bool addSubprogram(DISubprogram SP);
714
Devang Patel72bcdb62009-08-10 22:09:58 +0000715 /// addType - Add type into Tys.
716 bool addType(DIType DT);
717
Devang Pateld2f79a12009-07-28 19:55:13 +0000718 public:
Dan Gohman53741952010-05-07 15:36:10 +0000719 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
720 iterator compile_unit_begin() const { return CUs.begin(); }
721 iterator compile_unit_end() const { return CUs.end(); }
722 iterator subprogram_begin() const { return SPs.begin(); }
723 iterator subprogram_end() const { return SPs.end(); }
724 iterator global_variable_begin() const { return GVs.begin(); }
725 iterator global_variable_end() const { return GVs.end(); }
726 iterator type_begin() const { return TYs.begin(); }
727 iterator type_end() const { return TYs.end(); }
Devang Pateld2f79a12009-07-28 19:55:13 +0000728
Dan Gohman53741952010-05-07 15:36:10 +0000729 unsigned compile_unit_count() const { return CUs.size(); }
730 unsigned global_variable_count() const { return GVs.size(); }
731 unsigned subprogram_count() const { return SPs.size(); }
732 unsigned type_count() const { return TYs.size(); }
Devang Pateld2f79a12009-07-28 19:55:13 +0000733
734 private:
Devang Patele4b27562009-08-28 23:24:31 +0000735 SmallVector<MDNode *, 8> CUs; // Compile Units
736 SmallVector<MDNode *, 8> SPs; // Subprograms
737 SmallVector<MDNode *, 8> GVs; // Global Variables;
738 SmallVector<MDNode *, 8> TYs; // Types
739 SmallPtrSet<MDNode *, 64> NodesSeen;
Devang Pateld2f79a12009-07-28 19:55:13 +0000740 };
Chris Lattnera45664f2008-11-10 02:56:27 +0000741} // end namespace llvm
742
743#endif