llvm.org GIT mirror llvm / 50d280c
Follow LLVM coding style. clang uses DBuilder, so it requries corresponding change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126231 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 9 years ago
2 changed file(s) with 165 addition(s) and 165 deletion(s). Raw diff Collapse all Expand all
5757 const MDNode *getCU() { return TheCU; }
5858 enum ComplexAddrKind { OpPlus=1, OpDeref };
5959
60 /// CreateCompileUnit - A CompileUnit provides an anchor for all debugging
60 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
6161 /// information generated during this instance of compilation.
6262 /// @param Lang Source programming language, eg. dwarf::DW_LANG_C99
6363 /// @param File File name
7171 /// by a tool analyzing generated debugging information.
7272 /// @param RV This indicates runtime version for languages like
7373 /// Objective-C.
74 void CreateCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
74 void createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
7575 StringRef Producer,
7676 bool isOptimized, StringRef Flags, unsigned RV);
7777
78 /// CreateFile - Create a file descriptor to hold debugging information
78 /// createFile - Create a file descriptor to hold debugging information
7979 /// for a file.
80 DIFile CreateFile(StringRef Filename, StringRef Directory);
80 DIFile createFile(StringRef Filename, StringRef Directory);
8181
82 /// CreateEnumerator - Create a single enumerator value.
83 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
84
85 /// CreateBasicType - Create debugging information entry for a basic
82 /// createEnumerator - Create a single enumerator value.
83 DIEnumerator createEnumerator(StringRef Name, uint64_t Val);
84
85 /// createBasicType - Create debugging information entry for a basic
8686 /// type.
8787 /// @param Name Type name.
8888 /// @param SizeInBits Size of the type.
8989 /// @param AlignInBits Type alignment.
9090 /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
91 DIType CreateBasicType(StringRef Name, uint64_t SizeInBits,
91 DIType createBasicType(StringRef Name, uint64_t SizeInBits,
9292 uint64_t AlignInBits, unsigned Encoding);
9393
94 /// CreateQualifiedType - Create debugging information entry for a qualified
94 /// createQualifiedType - Create debugging information entry for a qualified
9595 /// type, e.g. 'const int'.
9696 /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
9797 /// @param FromTy Base Type.
98 DIType CreateQualifiedType(unsigned Tag, DIType FromTy);
99
100 /// CreatePointerType - Create debugging information entry for a pointer.
98 DIType createQualifiedType(unsigned Tag, DIType FromTy);
99
100 /// createPointerType - Create debugging information entry for a pointer.
101101 /// @param PointeeTy Type pointed by this pointer.
102102 /// @param SizeInBits Size.
103103 /// @param AlignInBits Alignment. (optional)
104104 /// @param Name Pointer type name. (optional)
105 DIType CreatePointerType(DIType PointeeTy, uint64_t SizeInBits,
105 DIType createPointerType(DIType PointeeTy, uint64_t SizeInBits,
106106 uint64_t AlignInBits = 0,
107107 StringRef Name = StringRef());
108108
109 /// CreateReferenceType - Create debugging information entry for a c++
109 /// createReferenceType - Create debugging information entry for a c++
110110 /// style reference.
111 DIType CreateReferenceType(DIType RTy);
112
113 /// CreateTypedef - Create debugging information entry for a typedef.
111 DIType createReferenceType(DIType RTy);
112
113 /// createTypedef - Create debugging information entry for a typedef.
114114 /// @param Ty Original type.
115115 /// @param Name Typedef name.
116116 /// @param File File where this type is defined.
117117 /// @param LineNo Line number.
118 DIType CreateTypedef(DIType Ty, StringRef Name, DIFile File,
118 DIType createTypedef(DIType Ty, StringRef Name, DIFile File,
119119 unsigned LineNo);
120120
121 /// CreateFriend - Create debugging information entry for a 'friend'.
122 DIType CreateFriend(DIType Ty, DIType FriendTy);
123
124 /// CreateInheritance - Create debugging information entry to establish
121 /// createFriend - Create debugging information entry for a 'friend'.
122 DIType createFriend(DIType Ty, DIType FriendTy);
123
124 /// createInheritance - Create debugging information entry to establish
125125 /// inheritance relationship between two types.
126126 /// @param Ty Original type.
127127 /// @param BaseTy Base type. Ty is inherits from base.
128128 /// @param BaseOffset Base offset.
129129 /// @param Flags Flags to describe inheritance attribute,
130130 /// e.g. private
131 DIType CreateInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset,
131 DIType createInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset,
132132 unsigned Flags);
133133
134 /// CreateMemberType - Create debugging information entry for a member.
134 /// createMemberType - Create debugging information entry for a member.
135135 /// @param Name Member name.
136136 /// @param File File where this member is defined.
137137 /// @param LineNo Line number.
140140 /// @param OffsetInBits Member offset.
141141 /// @param Flags Flags to encode member attribute, e.g. private
142142 /// @param Ty Parent type.
143 DIType CreateMemberType(StringRef Name, DIFile File,
143 DIType createMemberType(StringRef Name, DIFile File,
144144 unsigned LineNo, uint64_t SizeInBits,
145145 uint64_t AlignInBits, uint64_t OffsetInBits,
146146 unsigned Flags, DIType Ty);
147147
148 /// CreateClassType - Create debugging information entry for a class.
148 /// createClassType - Create debugging information entry for a class.
149149 /// @param Scope Scope in which this class is defined.
150150 /// @param Name class name.
151151 /// @param File File where this member is defined.
160160 /// DW_AT_containing_type. See DWARF documentation
161161 /// for more info.
162162 /// @param TemplateParms Template type parameters.
163 DIType CreateClassType(DIDescriptor Scope, StringRef Name, DIFile File,
163 DIType createClassType(DIDescriptor Scope, StringRef Name, DIFile File,
164164 unsigned LineNumber, uint64_t SizeInBits,
165165 uint64_t AlignInBits, uint64_t OffsetInBits,
166166 unsigned Flags, DIType DerivedFrom,
167167 DIArray Elements, MDNode *VTableHolder = 0,
168168 MDNode *TemplateParms = 0);
169169
170 /// CreateStructType - Create debugging information entry for a struct.
170 /// createStructType - Create debugging information entry for a struct.
171171 /// @param Scope Scope in which this struct is defined.
172172 /// @param Name Struct name.
173173 /// @param File File where this member is defined.
177177 /// @param Flags Flags to encode member attribute, e.g. private
178178 /// @param Elements Struct elements.
179179 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
180 DIType CreateStructType(DIDescriptor Scope, StringRef Name, DIFile File,
180 DIType createStructType(DIDescriptor Scope, StringRef Name, DIFile File,
181181 unsigned LineNumber, uint64_t SizeInBits,
182182 uint64_t AlignInBits, unsigned Flags,
183183 DIArray Elements, unsigned RunTimeLang = 0);
184184
185 /// CreateUnionType - Create debugging information entry for an union.
185 /// createUnionType - Create debugging information entry for an union.
186186 /// @param Scope Scope in which this union is defined.
187187 /// @param Name Union name.
188188 /// @param File File where this member is defined.
192192 /// @param Flags Flags to encode member attribute, e.g. private
193193 /// @param Elements Union elements.
194194 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
195 DIType CreateUnionType(DIDescriptor Scope, StringRef Name, DIFile File,
195 DIType createUnionType(DIDescriptor Scope, StringRef Name, DIFile File,
196196 unsigned LineNumber, uint64_t SizeInBits,
197197 uint64_t AlignInBits, unsigned Flags,
198198 DIArray Elements, unsigned RunTimeLang = 0);
199199
200 /// CreateTemplateTypeParameter - Create debugging information for template
200 /// createTemplateTypeParameter - Create debugging information for template
201201 /// type parameter.
202202 /// @param Scope Scope in which this type is defined.
203203 /// @param Name Type parameter name.
206206 /// @param LineNo Line number.
207207 /// @param ColumnNo Column Number.
208208 DITemplateTypeParameter
209 CreateTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
209 createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
210210 MDNode *File = 0, unsigned LineNo = 0,
211211 unsigned ColumnNo = 0);
212212
213 /// CreateTemplateValueParameter - Create debugging information for template
213 /// createTemplateValueParameter - Create debugging information for template
214214 /// value parameter.
215215 /// @param Scope Scope in which this type is defined.
216216 /// @param Name Value parameter name.
220220 /// @param LineNo Line number.
221221 /// @param ColumnNo Column Number.
222222 DITemplateValueParameter
223 CreateTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
223 createTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
224224 uint64_t Value,
225225 MDNode *File = 0, unsigned LineNo = 0,
226226 unsigned ColumnNo = 0);
227227
228 /// CreateArrayType - Create debugging information entry for an array.
228 /// createArrayType - Create debugging information entry for an array.
229229 /// @param Size Array size.
230230 /// @param AlignInBits Alignment.
231231 /// @param Ty Element type.
232232 /// @param Subscripts Subscripts.
233 DIType CreateArrayType(uint64_t Size, uint64_t AlignInBits,
233 DIType createArrayType(uint64_t Size, uint64_t AlignInBits,
234234 DIType Ty, DIArray Subscripts);
235235
236 /// CreateVectorType - Create debugging information entry for a vector type.
236 /// createVectorType - Create debugging information entry for a vector type.
237237 /// @param Size Array size.
238238 /// @param AlignInBits Alignment.
239239 /// @param Ty Element type.
240240 /// @param Subscripts Subscripts.
241 DIType CreateVectorType(uint64_t Size, uint64_t AlignInBits,
241 DIType createVectorType(uint64_t Size, uint64_t AlignInBits,
242242 DIType Ty, DIArray Subscripts);
243243
244 /// CreateEnumerationType - Create debugging information entry for an
244 /// createEnumerationType - Create debugging information entry for an
245245 /// enumeration.
246246 /// @param Scope Scope in which this enumeration is defined.
247247 /// @param Name Union name.
250250 /// @param SizeInBits Member size.
251251 /// @param AlignInBits Member alignment.
252252 /// @param Elements Enumeration elements.
253 DIType CreateEnumerationType(DIDescriptor Scope, StringRef Name,
253 DIType createEnumerationType(DIDescriptor Scope, StringRef Name,
254254 DIFile File, unsigned LineNumber,
255255 uint64_t SizeInBits,
256256 uint64_t AlignInBits, DIArray Elements);
257257
258 /// CreateSubroutineType - Create subroutine type.
258 /// createSubroutineType - Create subroutine type.
259259 /// @param File File in which this subroutine is defined.
260260 /// @param ParamterTypes An array of subroutine parameter types. This
261261 /// includes return type at 0th index.
262 DIType CreateSubroutineType(DIFile File, DIArray ParameterTypes);
263
264 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
265 DIType CreateArtificialType(DIType Ty);
266
267 /// CreateTemporaryType - Create a temporary forward-declared type.
268 DIType CreateTemporaryType();
269 DIType CreateTemporaryType(DIFile F);
270
271 /// RetainType - Retain DIType in a module even if it is not referenced
262 DIType createSubroutineType(DIFile File, DIArray ParameterTypes);
263
264 /// createArtificialType - Create a new DIType with "artificial" flag set.
265 DIType createArtificialType(DIType Ty);
266
267 /// createTemporaryType - Create a temporary forward-declared type.
268 DIType createTemporaryType();
269 DIType createTemporaryType(DIFile F);
270
271 /// retainType - Retain DIType in a module even if it is not referenced
272272 /// through debug info anchors.
273 void RetainType(DIType T);
274
275 /// CreateUnspecifiedParameter - Create unspeicified type descriptor
273 void retainType(DIType T);
274
275 /// createUnspecifiedParameter - Create unspeicified type descriptor
276276 /// for a subroutine type.
277 DIDescriptor CreateUnspecifiedParameter();
278
279 /// GetOrCreateArray - Get a DIArray, create one if required.
280 DIArray GetOrCreateArray(Value *const *Elements, unsigned NumElements);
281
282 /// GetOrCreateSubrange - Create a descriptor for a value range. This
277 DIDescriptor createUnspecifiedParameter();
278
279 /// getOrCreateArray - Get a DIArray, create one if required.
280 DIArray getOrCreateArray(Value *const *Elements, unsigned NumElements);
281
282 /// getOrCreateSubrange - Create a descriptor for a value range. This
283283 /// implicitly uniques the values returned.
284 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
285
286 /// CreateGlobalVariable - Create a new descriptor for the specified global.
284 DISubrange getOrCreateSubrange(int64_t Lo, int64_t Hi);
285
286 /// createGlobalVariable - Create a new descriptor for the specified global.
287287 /// @param Name Name of the variable.
288288 /// @param File File where this variable is defined.
289289 /// @param LineNo Line number.
292292 /// externally visible or not.
293293 /// @param Val llvm::Value of the variable.
294294 DIGlobalVariable
295 CreateGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
295 createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
296296 DIType Ty, bool isLocalToUnit, llvm::Value *Val);
297297
298298
299 /// CreateStaticVariable - Create a new descriptor for the specified
299 /// createStaticVariable - Create a new descriptor for the specified
300300 /// variable.
301301 /// @param Conext Variable scope.
302302 /// @param Name Name of the variable.
308308 /// externally visible or not.
309309 /// @param Val llvm::Value of the variable.
310310 DIGlobalVariable
311 CreateStaticVariable(DIDescriptor Context, StringRef Name,
311 createStaticVariable(DIDescriptor Context, StringRef Name,
312312 StringRef LinkageName, DIFile File, unsigned LineNo,
313313 DIType Ty, bool isLocalToUnit, llvm::Value *Val);
314314
315315
316 /// CreateLocalVariable - Create a new descriptor for the specified
316 /// createLocalVariable - Create a new descriptor for the specified
317317 /// local variable.
318318 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
319319 /// DW_TAG_arg_variable.
325325 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
326326 /// variable should be preserved in optimized build.
327327 /// @param Flags Flags, e.g. artificial variable.
328 DIVariable CreateLocalVariable(unsigned Tag, DIDescriptor Scope,
328 DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
329329 StringRef Name,
330330 DIFile File, unsigned LineNo,
331331 DIType Ty, bool AlwaysPreserve = false,
332332 unsigned Flags = 0);
333333
334334
335 /// CreateComplexVariable - Create a new descriptor for the specified
335 /// createComplexVariable - Create a new descriptor for the specified
336336 /// variable which has a complex address expression for its address.
337337 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
338338 /// DW_TAG_arg_variable.
343343 /// @param Ty Variable Type
344344 /// @param Addr A pointer to a vector of complex address operations.
345345 /// @param NumAddr Num of address operations in the vector.
346 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Scope,
346 DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
347347 StringRef Name, DIFile F, unsigned LineNo,
348348 DIType Ty, Value *const *Addr,
349349 unsigned NumAddr);
350350
351 /// CreateFunction - Create a new descriptor for the specified subprogram.
351 /// createFunction - Create a new descriptor for the specified subprogram.
352352 /// See comments in DISubprogram for descriptions of these fields.
353353 /// @param Scope Function scope.
354354 /// @param Name Function name.
362362 /// This flags are used to emit dwarf attributes.
363363 /// @param isOptimized True if optimization is ON.
364364 /// @param Fn llvm::Function pointer.
365 DISubprogram CreateFunction(DIDescriptor Scope, StringRef Name,
365 DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
366366 StringRef LinkageName,
367367 DIFile File, unsigned LineNo,
368368 DIType Ty, bool isLocalToUnit,
371371 bool isOptimized = false,
372372 Function *Fn = 0);
373373
374 /// CreateMethod - Create a new descriptor for the specified C++ method.
374 /// createMethod - Create a new descriptor for the specified C++ method.
375375 /// See comments in DISubprogram for descriptions of these fields.
376376 /// @param Scope Function scope.
377377 /// @param Name Function name.
389389 /// This flags are used to emit dwarf attributes.
390390 /// @param isOptimized True if optimization is ON.
391391 /// @param Fn llvm::Function pointer.
392 DISubprogram CreateMethod(DIDescriptor Scope, StringRef Name,
392 DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
393393 StringRef LinkageName,
394394 DIFile File, unsigned LineNo,
395395 DIType Ty, bool isLocalToUnit,
400400 bool isOptimized = false,
401401 Function *Fn = 0);
402402
403 /// CreateNameSpace - This creates new descriptor for a namespace
403 /// createNameSpace - This creates new descriptor for a namespace
404404 /// with the specified parent scope.
405405 /// @param Scope Namespace scope
406406 /// @param Name Name of this namespace
407407 /// @param File Source file
408408 /// @param LineNo Line number
409 DINameSpace CreateNameSpace(DIDescriptor Scope, StringRef Name,
409 DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
410410 DIFile File, unsigned LineNo);
411411
412412
413 /// CreateLexicalBlock - This creates a descriptor for a lexical block
413 /// createLexicalBlock - This creates a descriptor for a lexical block
414414 /// with the specified parent context.
415415 /// @param Scope Parent lexical scope.
416416 /// @param File Source file
417417 /// @param Line Line number
418418 /// @param Col Column number
419 DILexicalBlock CreateLexicalBlock(DIDescriptor Scope, DIFile File,
419 DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
420420 unsigned Line, unsigned Col);
421421
422 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
422 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
423423 /// @param Storage llvm::Value of the variable
424424 /// @param VarInfo Variable's debug info descriptor.
425425 /// @param InsertAtEnd Location for the new intrinsic.
426 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable VarInfo,
426 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
427427 BasicBlock *InsertAtEnd);
428428
429 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
429 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
430430 /// @param Storage llvm::Value of the variable
431431 /// @param VarInfo Variable's debug info descriptor.
432432 /// @param InsertBefore Location for the new intrinsic.
433 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable VarInfo,
433 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
434434 Instruction *InsertBefore);
435435
436436
437 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
437 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
438438 /// @param Val llvm::Value of the variable
439439 /// @param Offset Offset
440440 /// @param VarInfo Variable's debug info descriptor.
441441 /// @param InsertAtEnd Location for the new intrinsic.
442 Instruction *InsertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
442 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
443443 DIVariable VarInfo,
444444 BasicBlock *InsertAtEnd);
445445
446 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
446 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
447447 /// @param Val llvm::Value of the variable
448448 /// @param Offset Offset
449449 /// @param VarInfo Variable's debug info descriptor.
450450 /// @param InsertBefore Location for the new intrinsic.
451 Instruction *InsertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
451 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
452452 DIVariable VarInfo,
453453 Instruction *InsertBefore);
454454
3030 DIBuilder::DIBuilder(Module &m)
3131 : M(m), VMContext(M.getContext()), TheCU(0), DeclareFn(0), ValueFn(0) {}
3232
33 /// CreateCompileUnit - A CompileUnit provides an anchor for all debugging
33 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
3434 /// information generated during this instance of compilation.
35 void DIBuilder::CreateCompileUnit(unsigned Lang, StringRef Filename,
35 void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
3636 StringRef Directory, StringRef Producer,
3737 bool isOptimized, StringRef Flags,
3838 unsigned RunTimeVer) {
5252 TheCU = DICompileUnit(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
5353 }
5454
55 /// CreateFile - Create a file descriptor to hold debugging information
55 /// createFile - Create a file descriptor to hold debugging information
5656 /// for a file.
57 DIFile DIBuilder::CreateFile(StringRef Filename, StringRef Directory) {
57 DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
5858 assert(TheCU && "Unable to create DW_TAG_file_type without CompileUnit");
5959 Value *Elts[] = {
6060 GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
6565 return DIFile(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
6666 }
6767
68 /// CreateEnumerator - Create a single enumerator value.
69 DIEnumerator DIBuilder::CreateEnumerator(StringRef Name, uint64_t Val) {
68 /// createEnumerator - Create a single enumerator value.
69 DIEnumerator DIBuilder::createEnumerator(StringRef Name, uint64_t Val) {
7070 Value *Elts[] = {
7171 GetTagConstant(VMContext, dwarf::DW_TAG_enumerator),
7272 MDString::get(VMContext, Name),
7575 return DIEnumerator(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
7676 }
7777
78 /// CreateBasicType - Create debugging information entry for a basic
78 /// createBasicType - Create debugging information entry for a basic
7979 /// type, e.g 'char'.
80 DIType DIBuilder::CreateBasicType(StringRef Name, uint64_t SizeInBits,
80 DIType DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
8181 uint64_t AlignInBits,
8282 unsigned Encoding) {
8383 // Basic types are encoded in DIBasicType format. Line number, filename,
9797 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
9898 }
9999
100 /// CreateQaulifiedType - Create debugging information entry for a qualified
100 /// createQaulifiedType - Create debugging information entry for a qualified
101101 /// type, e.g. 'const int'.
102 DIType DIBuilder::CreateQualifiedType(unsigned Tag, DIType FromTy) {
102 DIType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
103103 // Qualified types are encoded in DIDerivedType format.
104104 Value *Elts[] = {
105105 GetTagConstant(VMContext, Tag),
116116 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
117117 }
118118
119 /// CreatePointerType - Create debugging information entry for a pointer.
120 DIType DIBuilder::CreatePointerType(DIType PointeeTy, uint64_t SizeInBits,
119 /// createPointerType - Create debugging information entry for a pointer.
120 DIType DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
121121 uint64_t AlignInBits, StringRef Name) {
122122 // Pointer types are encoded in DIDerivedType format.
123123 Value *Elts[] = {
135135 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
136136 }
137137
138 /// CreateReferenceType - Create debugging information entry for a reference.
139 DIType DIBuilder::CreateReferenceType(DIType RTy) {
138 /// createReferenceType - Create debugging information entry for a reference.
139 DIType DIBuilder::createReferenceType(DIType RTy) {
140140 // References are encoded in DIDerivedType format.
141141 Value *Elts[] = {
142142 GetTagConstant(VMContext, dwarf::DW_TAG_reference_type),
153153 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
154154 }
155155
156 /// CreateTypedef - Create debugging information entry for a typedef.
157 DIType DIBuilder::CreateTypedef(DIType Ty, StringRef Name, DIFile File,
156 /// createTypedef - Create debugging information entry for a typedef.
157 DIType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
158158 unsigned LineNo) {
159159 // typedefs are encoded in DIDerivedType format.
160160 assert(Ty.Verify() && "Invalid typedef type!");
173173 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
174174 }
175175
176 /// CreateFriend - Create debugging information entry for a 'friend'.
177 DIType DIBuilder::CreateFriend(DIType Ty, DIType FriendTy) {
176 /// createFriend - Create debugging information entry for a 'friend'.
177 DIType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
178178 // typedefs are encoded in DIDerivedType format.
179179 assert(Ty.Verify() && "Invalid type!");
180180 assert(FriendTy.Verify() && "Invalid friend type!");
193193 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
194194 }
195195
196 /// CreateInheritance - Create debugging information entry to establish
196 /// createInheritance - Create debugging information entry to establish
197197 /// inheritnace relationship between two types.
198 DIType DIBuilder::CreateInheritance(DIType Ty, DIType BaseTy,
198 DIType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
199199 uint64_t BaseOffset, unsigned Flags) {
200200 // TAG_inheritance is encoded in DIDerivedType format.
201201 Value *Elts[] = {
213213 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
214214 }
215215
216 /// CreateMemberType - Create debugging information entry for a member.
217 DIType DIBuilder::CreateMemberType(StringRef Name,
216 /// createMemberType - Create debugging information entry for a member.
217 DIType DIBuilder::createMemberType(StringRef Name,
218218 DIFile File, unsigned LineNumber,
219219 uint64_t SizeInBits, uint64_t AlignInBits,
220220 uint64_t OffsetInBits, unsigned Flags,
235235 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
236236 }
237237
238 /// CreateClassType - Create debugging information entry for a class.
239 DIType DIBuilder::CreateClassType(DIDescriptor Context, StringRef Name,
238 /// createClassType - Create debugging information entry for a class.
239 DIType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
240240 DIFile File, unsigned LineNumber,
241241 uint64_t SizeInBits, uint64_t AlignInBits,
242242 uint64_t OffsetInBits, unsigned Flags,
262262 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
263263 }
264264
265 /// CreateTemplateTypeParameter - Create debugging information for template
265 /// createTemplateTypeParameter - Create debugging information for template
266266 /// type parameter.
267267 DITemplateTypeParameter
268 DIBuilder::CreateTemplateTypeParameter(DIDescriptor Context, StringRef Name,
268 DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
269269 DIType Ty, MDNode *File, unsigned LineNo,
270270 unsigned ColumnNo) {
271271 Value *Elts[] = {
281281 array_lengthof(Elts)));
282282 }
283283
284 /// CreateTemplateValueParameter - Create debugging information for template
284 /// createTemplateValueParameter - Create debugging information for template
285285 /// value parameter.
286286 DITemplateValueParameter
287 DIBuilder::CreateTemplateValueParameter(DIDescriptor Context, StringRef Name,
287 DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
288288 DIType Ty, uint64_t Val,
289289 MDNode *File, unsigned LineNo,
290290 unsigned ColumnNo) {
302302 array_lengthof(Elts)));
303303 }
304304
305 /// CreateStructType - Create debugging information entry for a struct.
306 DIType DIBuilder::CreateStructType(DIDescriptor Context, StringRef Name,
305 /// createStructType - Create debugging information entry for a struct.
306 DIType DIBuilder::createStructType(DIDescriptor Context, StringRef Name,
307307 DIFile File, unsigned LineNumber,
308308 uint64_t SizeInBits, uint64_t AlignInBits,
309309 unsigned Flags, DIArray Elements,
327327 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
328328 }
329329
330 /// CreateUnionType - Create debugging information entry for an union.
331 DIType DIBuilder::CreateUnionType(DIDescriptor Scope, StringRef Name,
330 /// createUnionType - Create debugging information entry for an union.
331 DIType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
332332 DIFile File,
333333 unsigned LineNumber, uint64_t SizeInBits,
334334 uint64_t AlignInBits, unsigned Flags,
352352 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
353353 }
354354
355 /// CreateSubroutineType - Create subroutine type.
356 DIType DIBuilder::CreateSubroutineType(DIFile File, DIArray ParameterTypes) {
355 /// createSubroutineType - Create subroutine type.
356 DIType DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
357357 // TAG_subroutine_type is encoded in DICompositeType format.
358358 Value *Elts[] = {
359359 GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type),
373373 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
374374 }
375375
376 /// CreateEnumerationType - Create debugging information entry for an
376 /// createEnumerationType - Create debugging information entry for an
377377 /// enumeration.
378 DIType DIBuilder::CreateEnumerationType(DIDescriptor Scope, StringRef Name,
378 DIType DIBuilder::createEnumerationType(DIDescriptor Scope, StringRef Name,
379379 DIFile File, unsigned LineNumber,
380380 uint64_t SizeInBits,
381381 uint64_t AlignInBits, DIArray Elements) {
401401 return DIType(Node);
402402 }
403403
404 /// CreateArrayType - Create debugging information entry for an array.
405 DIType DIBuilder::CreateArrayType(uint64_t Size, uint64_t AlignInBits,
404 /// createArrayType - Create debugging information entry for an array.
405 DIType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
406406 DIType Ty, DIArray Subscripts) {
407407 // TAG_array_type is encoded in DICompositeType format.
408408 Value *Elts[] = {
423423 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
424424 }
425425
426 /// CreateVectorType - Create debugging information entry for a vector.
427 DIType DIBuilder::CreateVectorType(uint64_t Size, uint64_t AlignInBits,
426 /// createVectorType - Create debugging information entry for a vector.
427 DIType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
428428 DIType Ty, DIArray Subscripts) {
429429 // TAG_vector_type is encoded in DICompositeType format.
430430 Value *Elts[] = {
445445 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
446446 }
447447
448 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
449 DIType DIBuilder::CreateArtificialType(DIType Ty) {
448 /// createArtificialType - Create a new DIType with "artificial" flag set.
449 DIType DIBuilder::createArtificialType(DIType Ty) {
450450 if (Ty.isArtificial())
451451 return Ty;
452452
469469 return DIType(MDNode::get(VMContext, Elts.data(), Elts.size()));
470470 }
471471
472 /// RetainType - Retain DIType in a module even if it is not referenced
472 /// retainType - Retain DIType in a module even if it is not referenced
473473 /// through debug info anchors.
474 void DIBuilder::RetainType(DIType T) {
474 void DIBuilder::retainType(DIType T) {
475475 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.ty");
476476 NMD->addOperand(T);
477477 }
478478
479 /// CreateUnspecifiedParameter - Create unspeicified type descriptor
479 /// createUnspecifiedParameter - Create unspeicified type descriptor
480480 /// for the subroutine type.
481 DIDescriptor DIBuilder::CreateUnspecifiedParameter() {
481 DIDescriptor DIBuilder::createUnspecifiedParameter() {
482482 Value *Elts[] = {
483483 GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
484484 };
485485 return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1));
486486 }
487487
488 /// CreateTemporaryType - Create a temporary forward-declared type.
489 DIType DIBuilder::CreateTemporaryType() {
488 /// createTemporaryType - Create a temporary forward-declared type.
489 DIType DIBuilder::createTemporaryType() {
490490 // Give the temporary MDNode a tag. It doesn't matter what tag we
491491 // use here as long as DIType accepts it.
492492 Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
494494 return DIType(Node);
495495 }
496496
497 /// CreateTemporaryType - Create a temporary forward-declared type.
498 DIType DIBuilder::CreateTemporaryType(DIFile F) {
497 /// createTemporaryType - Create a temporary forward-declared type.
498 DIType DIBuilder::createTemporaryType(DIFile F) {
499499 // Give the temporary MDNode a tag. It doesn't matter what tag we
500500 // use here as long as DIType accepts it.
501501 Value *Elts[] = {
508508 return DIType(Node);
509509 }
510510
511 /// GetOrCreateArray - Get a DIArray, create one if required.
512 DIArray DIBuilder::GetOrCreateArray(Value *const *Elements, unsigned NumElements) {
511 /// getOrCreateArray - Get a DIArray, create one if required.
512 DIArray DIBuilder::getOrCreateArray(Value *const *Elements, unsigned NumElements) {
513513 if (NumElements == 0) {
514514 Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
515515 return DIArray(MDNode::get(VMContext, &Null, 1));
517517 return DIArray(MDNode::get(VMContext, Elements, NumElements));
518518 }
519519
520 /// GetOrCreateSubrange - Create a descriptor for a value range. This
520 /// getOrCreateSubrange - Create a descriptor for a value range. This
521521 /// implicitly uniques the values returned.
522 DISubrange DIBuilder::GetOrCreateSubrange(int64_t Lo, int64_t Hi) {
522 DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Hi) {
523523 Value *Elts[] = {
524524 GetTagConstant(VMContext, dwarf::DW_TAG_subrange_type),
525525 ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
529529 return DISubrange(MDNode::get(VMContext, &Elts[0], 3));
530530 }
531531
532 /// CreateGlobalVariable - Create a new descriptor for the specified global.
532 /// createGlobalVariable - Create a new descriptor for the specified global.
533533 DIGlobalVariable DIBuilder::
534 CreateGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber,
534 createGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber,
535535 DIType Ty, bool isLocalToUnit, llvm::Value *Val) {
536536 Value *Elts[] = {
537537 GetTagConstant(VMContext, dwarf::DW_TAG_variable),
554554 return DIGlobalVariable(Node);
555555 }
556556
557 /// CreateStaticVariable - Create a new descriptor for the specified static
557 /// createStaticVariable - Create a new descriptor for the specified static
558558 /// variable.
559559 DIGlobalVariable DIBuilder::
560 CreateStaticVariable(DIDescriptor Context, StringRef Name,
560 createStaticVariable(DIDescriptor Context, StringRef Name,
561561 StringRef LinkageName, DIFile F, unsigned LineNumber,
562562 DIType Ty, bool isLocalToUnit, llvm::Value *Val) {
563563 Value *Elts[] = {
581581 return DIGlobalVariable(Node);
582582 }
583583
584 /// CreateVariable - Create a new descriptor for the specified variable.
585 DIVariable DIBuilder::CreateLocalVariable(unsigned Tag, DIDescriptor Scope,
584 /// createVariable - Create a new descriptor for the specified variable.
585 DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
586586 StringRef Name, DIFile File,
587587 unsigned LineNo, DIType Ty,
588588 bool AlwaysPreserve, unsigned Flags) {
613613 return DIVariable(Node);
614614 }
615615
616 /// CreateComplexVariable - Create a new descriptor for the specified variable
616 /// createComplexVariable - Create a new descriptor for the specified variable
617617 /// which has a complex address expression for its address.
618 DIVariable DIBuilder::CreateComplexVariable(unsigned Tag, DIDescriptor Scope,
618 DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope,
619619 StringRef Name, DIFile F,
620620 unsigned LineNo,
621621 DIType Ty, Value *const *Addr,
632632 return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size()));
633633 }
634634
635 /// CreateFunction - Create a new descriptor for the specified function.
636 DISubprogram DIBuilder::CreateFunction(DIDescriptor Context,
635 /// createFunction - Create a new descriptor for the specified function.
636 DISubprogram DIBuilder::createFunction(DIDescriptor Context,
637637 StringRef Name,
638638 StringRef LinkageName,
639639 DIFile File, unsigned LineNo,
669669 return DISubprogram(Node);
670670 }
671671
672 /// CreateMethod - Create a new descriptor for the specified C++ method.
673 DISubprogram DIBuilder::CreateMethod(DIDescriptor Context,
672 /// createMethod - Create a new descriptor for the specified C++ method.
673 DISubprogram DIBuilder::createMethod(DIDescriptor Context,
674674 StringRef Name,
675675 StringRef LinkageName,
676676 DIFile F,
709709 return DISubprogram(Node);
710710 }
711711
712 /// CreateNameSpace - This creates new descriptor for a namespace
712 /// createNameSpace - This creates new descriptor for a namespace
713713 /// with the specified parent scope.
714 DINameSpace DIBuilder::CreateNameSpace(DIDescriptor Scope, StringRef Name,
714 DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
715715 DIFile File, unsigned LineNo) {
716716 Value *Elts[] = {
717717 GetTagConstant(VMContext, dwarf::DW_TAG_namespace),
723723 return DINameSpace(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
724724 }
725725
726 DILexicalBlock DIBuilder::CreateLexicalBlock(DIDescriptor Scope, DIFile File,
726 DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
727727 unsigned Line, unsigned Col) {
728728 // Defeat MDNode uniqing for lexical blocks by using unique id.
729729 static unsigned int unique_id = 0;
738738 return DILexicalBlock(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
739739 }
740740
741 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
742 Instruction *DIBuilder::InsertDeclare(Value *Storage, DIVariable VarInfo,
741 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
742 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
743743 Instruction *InsertBefore) {
744744 assert(Storage && "no storage passed to dbg.declare");
745745 assert(VarInfo.Verify() && "empty DIVariable passed to dbg.declare");
750750 return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
751751 }
752752
753 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
754 Instruction *DIBuilder::InsertDeclare(Value *Storage, DIVariable VarInfo,
753 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
754 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
755755 BasicBlock *InsertAtEnd) {
756756 assert(Storage && "no storage passed to dbg.declare");
757757 assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.declare");
768768 return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);
769769 }
770770
771 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
772 Instruction *DIBuilder::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
771 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
772 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
773773 DIVariable VarInfo,
774774 Instruction *InsertBefore) {
775775 assert(V && "no value passed to dbg.value");
783783 return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
784784 }
785785
786 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
787 Instruction *DIBuilder::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
786 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
787 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
788788 DIVariable VarInfo,
789789 BasicBlock *InsertAtEnd) {
790790 assert(V && "no value passed to dbg.value");