1 //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a DIBuilder that is useful for creating debugging
11 // information entries in LLVM IR form.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_IR_DIBUILDER_H
16 #define LLVM_IR_DIBUILDER_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/IR/DebugInfo.h"
21 #include "llvm/IR/ValueHandle.h"
22 #include "llvm/Support/DataTypes.h"
35 class DICompositeType;
41 class DIGlobalVariable;
42 class DIImportedEntity;
46 class DILexicalBlockFile;
50 class DITemplateTypeParameter;
51 class DITemplateValueParameter;
57 LLVMContext &VMContext;
59 MDNode *TempEnumTypes;
60 MDNode *TempRetainTypes;
61 MDNode *TempSubprograms;
63 MDNode *TempImportedModules;
65 Function *DeclareFn; // llvm.dbg.declare
66 Function *ValueFn; // llvm.dbg.value
68 SmallVector<Value *, 4> AllEnumTypes;
69 /// Use TrackingVH to collect RetainTypes, since they can be updated
71 SmallVector<TrackingVH<MDNode>, 4> AllRetainTypes;
72 SmallVector<Value *, 4> AllSubprograms;
73 SmallVector<Value *, 4> AllGVs;
74 SmallVector<TrackingVH<MDNode>, 4> AllImportedModules;
76 // Private use for multiple types of template parameters.
77 DITemplateValueParameter
78 createTemplateValueParameter(unsigned Tag, DIDescriptor Scope,
79 StringRef Name, DIType Ty, Value *Val,
80 MDNode *File = nullptr, unsigned LineNo = 0,
81 unsigned ColumnNo = 0);
83 DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION;
84 void operator=(const DIBuilder &) LLVM_DELETED_FUNCTION;
87 explicit DIBuilder(Module &M);
88 enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
89 enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
91 /// finalize - Construct any deferred debug info descriptors.
94 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
95 /// information generated during this instance of compilation.
96 /// @param Lang Source programming language, eg. dwarf::DW_LANG_C99
97 /// @param File File name
98 /// @param Dir Directory
99 /// @param Producer Identify the producer of debugging information and code.
100 /// Usually this is a compiler version string.
101 /// @param isOptimized A boolean flag which indicates whether optimization
103 /// @param Flags This string lists command line options. This string is
104 /// directly embedded in debug info output which may be used
105 /// by a tool analyzing generated debugging information.
106 /// @param RV This indicates runtime version for languages like
108 /// @param SplitName The name of the file that we'll split debug info out
110 /// @param Kind The kind of debug information to generate.
111 /// @param EmitDebugInfo A boolean flag which indicates whether debug
112 /// information should be written to the final
113 /// output or not. When this is false, debug
114 /// information annotations will be present in
115 /// the IL but they are not written to the final
116 /// assembly or object file. This supports tracking
117 /// source location information in the back end
118 /// without actually changing the output (e.g.,
119 /// when using optimization remarks).
120 DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
121 StringRef Dir, StringRef Producer,
122 bool isOptimized, StringRef Flags,
124 StringRef SplitName = StringRef(),
125 DebugEmissionKind Kind = FullDebug,
126 bool EmitDebugInfo = true);
128 /// createFile - Create a file descriptor to hold debugging information
130 DIFile createFile(StringRef Filename, StringRef Directory);
132 /// createEnumerator - Create a single enumerator value.
133 DIEnumerator createEnumerator(StringRef Name, int64_t Val);
135 /// \brief Create a DWARF unspecified type.
136 DIBasicType createUnspecifiedType(StringRef Name);
138 /// \brief Create C++11 nullptr type.
139 DIBasicType createNullPtrType();
141 /// createBasicType - Create debugging information entry for a basic
143 /// @param Name Type name.
144 /// @param SizeInBits Size of the type.
145 /// @param AlignInBits Type alignment.
146 /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
147 DIBasicType createBasicType(StringRef Name, uint64_t SizeInBits,
148 uint64_t AlignInBits, unsigned Encoding);
150 /// createQualifiedType - Create debugging information entry for a qualified
151 /// type, e.g. 'const int'.
152 /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
153 /// @param FromTy Base Type.
154 DIDerivedType createQualifiedType(unsigned Tag, DIType FromTy);
156 /// createPointerType - Create debugging information entry for a pointer.
157 /// @param PointeeTy Type pointed by this pointer.
158 /// @param SizeInBits Size.
159 /// @param AlignInBits Alignment. (optional)
160 /// @param Name Pointer type name. (optional)
162 createPointerType(DIType PointeeTy, uint64_t SizeInBits,
163 uint64_t AlignInBits = 0, StringRef Name = StringRef());
165 /// \brief Create debugging information entry for a pointer to member.
166 /// @param PointeeTy Type pointed to by this pointer.
167 /// @param Class Type for which this pointer points to members of.
168 DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class);
170 /// createReferenceType - Create debugging information entry for a c++
171 /// style reference or rvalue reference type.
172 DIDerivedType createReferenceType(unsigned Tag, DIType RTy);
174 /// createTypedef - Create debugging information entry for a typedef.
175 /// @param Ty Original type.
176 /// @param Name Typedef name.
177 /// @param File File where this type is defined.
178 /// @param LineNo Line number.
179 /// @param Context The surrounding context for the typedef.
180 DIDerivedType createTypedef(DIType Ty, StringRef Name, DIFile File,
181 unsigned LineNo, DIDescriptor Context);
183 /// createFriend - Create debugging information entry for a 'friend'.
184 DIDerivedType createFriend(DIType Ty, DIType FriendTy);
186 /// createInheritance - Create debugging information entry to establish
187 /// inheritance relationship between two types.
188 /// @param Ty Original type.
189 /// @param BaseTy Base type. Ty is inherits from base.
190 /// @param BaseOffset Base offset.
191 /// @param Flags Flags to describe inheritance attribute,
193 DIDerivedType createInheritance(DIType Ty, DIType BaseTy,
194 uint64_t BaseOffset, unsigned Flags);
196 /// createMemberType - Create debugging information entry for a member.
197 /// @param Scope Member scope.
198 /// @param Name Member name.
199 /// @param File File where this member is defined.
200 /// @param LineNo Line number.
201 /// @param SizeInBits Member size.
202 /// @param AlignInBits Member alignment.
203 /// @param OffsetInBits Member offset.
204 /// @param Flags Flags to encode member attribute, e.g. private
205 /// @param Ty Parent type.
207 createMemberType(DIDescriptor Scope, StringRef Name, DIFile File,
208 unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits,
209 uint64_t OffsetInBits, unsigned Flags, DIType Ty);
211 /// createStaticMemberType - Create debugging information entry for a
212 /// C++ static data member.
213 /// @param Scope Member scope.
214 /// @param Name Member name.
215 /// @param File File where this member is declared.
216 /// @param LineNo Line number.
217 /// @param Ty Type of the static member.
218 /// @param Flags Flags to encode member attribute, e.g. private.
219 /// @param Val Const initializer of the member.
221 createStaticMemberType(DIDescriptor Scope, StringRef Name,
222 DIFile File, unsigned LineNo, DIType Ty,
223 unsigned Flags, llvm::Value *Val);
225 /// createObjCIVar - Create debugging information entry for Objective-C
226 /// instance variable.
227 /// @param Name Member name.
228 /// @param File File where this member is defined.
229 /// @param LineNo Line number.
230 /// @param SizeInBits Member size.
231 /// @param AlignInBits Member alignment.
232 /// @param OffsetInBits Member offset.
233 /// @param Flags Flags to encode member attribute, e.g. private
234 /// @param Ty Parent type.
235 /// @param PropertyName Name of the Objective C property associated with
237 /// @param PropertyGetterName Name of the Objective C property getter
239 /// @param PropertySetterName Name of the Objective C property setter
241 /// @param PropertyAttributes Objective C property attributes.
242 DIDerivedType createObjCIVar(StringRef Name, DIFile File,
243 unsigned LineNo, uint64_t SizeInBits,
244 uint64_t AlignInBits, uint64_t OffsetInBits,
245 unsigned Flags, DIType Ty,
246 StringRef PropertyName = StringRef(),
247 StringRef PropertyGetterName = StringRef(),
248 StringRef PropertySetterName = StringRef(),
249 unsigned PropertyAttributes = 0);
251 /// createObjCIVar - Create debugging information entry for Objective-C
252 /// instance variable.
253 /// @param Name Member name.
254 /// @param File File where this member is defined.
255 /// @param LineNo Line number.
256 /// @param SizeInBits Member size.
257 /// @param AlignInBits Member alignment.
258 /// @param OffsetInBits Member offset.
259 /// @param Flags Flags to encode member attribute, e.g. private
260 /// @param Ty Parent type.
261 /// @param PropertyNode Property associated with this ivar.
262 DIDerivedType createObjCIVar(StringRef Name, DIFile File,
263 unsigned LineNo, uint64_t SizeInBits,
264 uint64_t AlignInBits, uint64_t OffsetInBits,
265 unsigned Flags, DIType Ty,
266 MDNode *PropertyNode);
268 /// createObjCProperty - Create debugging information entry for Objective-C
270 /// @param Name Property name.
271 /// @param File File where this property is defined.
272 /// @param LineNumber Line number.
273 /// @param GetterName Name of the Objective C property getter selector.
274 /// @param SetterName Name of the Objective C property setter selector.
275 /// @param PropertyAttributes Objective C property attributes.
277 DIObjCProperty createObjCProperty(StringRef Name,
278 DIFile File, unsigned LineNumber,
279 StringRef GetterName,
280 StringRef SetterName,
281 unsigned PropertyAttributes,
284 /// createClassType - Create debugging information entry for a class.
285 /// @param Scope Scope in which this class is defined.
286 /// @param Name class name.
287 /// @param File File where this member is defined.
288 /// @param LineNumber Line number.
289 /// @param SizeInBits Member size.
290 /// @param AlignInBits Member alignment.
291 /// @param OffsetInBits Member offset.
292 /// @param Flags Flags to encode member attribute, e.g. private
293 /// @param Elements class members.
294 /// @param VTableHolder Debug info of the base class that contains vtable
295 /// for this type. This is used in
296 /// DW_AT_containing_type. See DWARF documentation
298 /// @param TemplateParms Template type parameters.
299 /// @param UniqueIdentifier A unique identifier for the class.
300 DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
301 DIFile File, unsigned LineNumber,
302 uint64_t SizeInBits, uint64_t AlignInBits,
303 uint64_t OffsetInBits, unsigned Flags,
304 DIType DerivedFrom, DIArray Elements,
305 DIType VTableHolder = DIType(),
306 MDNode *TemplateParms = nullptr,
307 StringRef UniqueIdentifier = StringRef());
309 /// createStructType - Create debugging information entry for a struct.
310 /// @param Scope Scope in which this struct is defined.
311 /// @param Name Struct name.
312 /// @param File File where this member is defined.
313 /// @param LineNumber Line number.
314 /// @param SizeInBits Member size.
315 /// @param AlignInBits Member alignment.
316 /// @param Flags Flags to encode member attribute, e.g. private
317 /// @param Elements Struct elements.
318 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
319 /// @param UniqueIdentifier A unique identifier for the struct.
320 DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
321 DIFile File, unsigned LineNumber,
322 uint64_t SizeInBits, uint64_t AlignInBits,
323 unsigned Flags, DIType DerivedFrom,
324 DIArray Elements, unsigned RunTimeLang = 0,
325 DIType VTableHolder = DIType(),
326 StringRef UniqueIdentifier = StringRef());
328 /// createUnionType - Create debugging information entry for an union.
329 /// @param Scope Scope in which this union is defined.
330 /// @param Name Union name.
331 /// @param File File where this member is defined.
332 /// @param LineNumber Line number.
333 /// @param SizeInBits Member size.
334 /// @param AlignInBits Member alignment.
335 /// @param Flags Flags to encode member attribute, e.g. private
336 /// @param Elements Union elements.
337 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
338 /// @param UniqueIdentifier A unique identifier for the union.
339 DICompositeType createUnionType(
340 DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
341 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
342 DIArray Elements, unsigned RunTimeLang = 0,
343 StringRef UniqueIdentifier = StringRef());
345 /// createTemplateTypeParameter - Create debugging information for template
347 /// @param Scope Scope in which this type is defined.
348 /// @param Name Type parameter name.
349 /// @param Ty Parameter type.
350 /// @param File File where this type parameter is defined.
351 /// @param LineNo Line number.
352 /// @param ColumnNo Column Number.
353 DITemplateTypeParameter
354 createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
355 MDNode *File = nullptr, unsigned LineNo = 0,
356 unsigned ColumnNo = 0);
358 /// createTemplateValueParameter - Create debugging information for template
360 /// @param Scope Scope in which this type is defined.
361 /// @param Name Value parameter name.
362 /// @param Ty Parameter type.
363 /// @param Val Constant parameter value.
364 /// @param File File where this type parameter is defined.
365 /// @param LineNo Line number.
366 /// @param ColumnNo Column Number.
367 DITemplateValueParameter
368 createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
369 DIType Ty, Value *Val, MDNode *File = nullptr,
370 unsigned LineNo = 0, unsigned ColumnNo = 0);
372 /// \brief Create debugging information for a template template parameter.
373 /// @param Scope Scope in which this type is defined.
374 /// @param Name Value parameter name.
375 /// @param Ty Parameter type.
376 /// @param Val The fully qualified name of the template.
377 /// @param File File where this type parameter is defined.
378 /// @param LineNo Line number.
379 /// @param ColumnNo Column Number.
380 DITemplateValueParameter
381 createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
382 DIType Ty, StringRef Val,
383 MDNode *File = nullptr, unsigned LineNo = 0,
384 unsigned ColumnNo = 0);
386 /// \brief Create debugging information for a template parameter pack.
387 /// @param Scope Scope in which this type is defined.
388 /// @param Name Value parameter name.
389 /// @param Ty Parameter type.
390 /// @param Val An array of types in the pack.
391 /// @param File File where this type parameter is defined.
392 /// @param LineNo Line number.
393 /// @param ColumnNo Column Number.
394 DITemplateValueParameter
395 createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
396 DIType Ty, DIArray Val, MDNode *File = nullptr,
397 unsigned LineNo = 0, unsigned ColumnNo = 0);
399 /// createArrayType - Create debugging information entry for an array.
400 /// @param Size Array size.
401 /// @param AlignInBits Alignment.
402 /// @param Ty Element type.
403 /// @param Subscripts Subscripts.
404 DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits,
405 DIType Ty, DIArray Subscripts);
407 /// createVectorType - Create debugging information entry for a vector type.
408 /// @param Size Array size.
409 /// @param AlignInBits Alignment.
410 /// @param Ty Element type.
411 /// @param Subscripts Subscripts.
412 DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits,
413 DIType Ty, DIArray Subscripts);
415 /// createEnumerationType - Create debugging information entry for an
417 /// @param Scope Scope in which this enumeration is defined.
418 /// @param Name Union name.
419 /// @param File File where this member is defined.
420 /// @param LineNumber Line number.
421 /// @param SizeInBits Member size.
422 /// @param AlignInBits Member alignment.
423 /// @param Elements Enumeration elements.
424 /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
425 /// @param UniqueIdentifier A unique identifier for the enum.
426 DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
427 DIFile File, unsigned LineNumber, uint64_t SizeInBits,
428 uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
429 StringRef UniqueIdentifier = StringRef());
431 /// createSubroutineType - Create subroutine type.
432 /// @param File File in which this subroutine is defined.
433 /// @param ParameterTypes An array of subroutine parameter types. This
434 /// includes return type at 0th index.
435 /// @param Flags E.g.: LValueReference.
436 /// These flags are used to emit dwarf attributes.
437 DISubroutineType createSubroutineType(DIFile File,
438 DITypeArray ParameterTypes,
441 /// createArtificialType - Create a new DIType with "artificial" flag set.
442 DIType createArtificialType(DIType Ty);
444 /// createObjectPointerType - Create a new DIType with the "object pointer"
446 DIType createObjectPointerType(DIType Ty);
448 /// \brief Create a permanent forward-declared type.
449 DICompositeType createForwardDecl(unsigned Tag, StringRef Name,
450 DIDescriptor Scope, DIFile F,
451 unsigned Line, unsigned RuntimeLang = 0,
452 uint64_t SizeInBits = 0,
453 uint64_t AlignInBits = 0,
454 StringRef UniqueIdentifier = StringRef());
456 /// \brief Create a temporary forward-declared type.
457 DICompositeType createReplaceableForwardDecl(
458 unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F,
459 unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
460 uint64_t AlignInBits = 0, StringRef UniqueIdentifier = StringRef());
462 /// retainType - Retain DIType in a module even if it is not referenced
463 /// through debug info anchors.
464 void retainType(DIType T);
466 /// createUnspecifiedParameter - Create unspecified parameter type
467 /// for a subroutine type.
468 DIBasicType createUnspecifiedParameter();
470 /// getOrCreateArray - Get a DIArray, create one if required.
471 DIArray getOrCreateArray(ArrayRef<Value *> Elements);
473 /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
474 DITypeArray getOrCreateTypeArray(ArrayRef<Value *> Elements);
476 /// getOrCreateSubrange - Create a descriptor for a value range. This
477 /// implicitly uniques the values returned.
478 DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count);
480 /// createGlobalVariable - Create a new descriptor for the specified global.
481 /// @param Name Name of the variable.
482 /// @param File File where this variable is defined.
483 /// @param LineNo Line number.
484 /// @param Ty Variable Type.
485 /// @param isLocalToUnit Boolean flag indicate whether this variable is
486 /// externally visible or not.
487 /// @param Val llvm::Value of the variable.
489 createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
490 DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val);
492 /// \brief Create a new descriptor for the specified global.
493 /// @param Name Name of the variable.
494 /// @param LinkageName Mangled variable name.
495 /// @param File File where this variable is defined.
496 /// @param LineNo Line number.
497 /// @param Ty Variable Type.
498 /// @param isLocalToUnit Boolean flag indicate whether this variable is
499 /// externally visible or not.
500 /// @param Val llvm::Value of the variable.
502 createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile File,
503 unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
506 /// createStaticVariable - Create a new descriptor for the specified
508 /// @param Context Variable scope.
509 /// @param Name Name of the variable.
510 /// @param LinkageName Mangled name of the variable.
511 /// @param File File where this variable is defined.
512 /// @param LineNo Line number.
513 /// @param Ty Variable Type.
514 /// @param isLocalToUnit Boolean flag indicate whether this variable is
515 /// externally visible or not.
516 /// @param Val llvm::Value of the variable.
517 /// @param Decl Reference to the corresponding declaration.
519 createStaticVariable(DIDescriptor Context, StringRef Name,
520 StringRef LinkageName, DIFile File, unsigned LineNo,
521 DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
522 MDNode *Decl = nullptr);
525 /// createLocalVariable - Create a new descriptor for the specified
527 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
528 /// DW_TAG_arg_variable.
529 /// @param Scope Variable scope.
530 /// @param Name Variable name.
531 /// @param File File where this variable is defined.
532 /// @param LineNo Line number.
533 /// @param Ty Variable Type
534 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
535 /// variable should be preserved in optimized build.
536 /// @param Flags Flags, e.g. artificial variable.
537 /// @param ArgNo If this variable is an argument then this argument's
538 /// number. 1 indicates 1st argument.
539 DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
541 DIFile File, unsigned LineNo,
542 DITypeRef Ty, bool AlwaysPreserve = false,
547 /// createComplexVariable - Create a new descriptor for the specified
548 /// variable which has a complex address expression for its address.
549 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
550 /// DW_TAG_arg_variable.
551 /// @param Scope Variable scope.
552 /// @param Name Variable name.
553 /// @param F File where this variable is defined.
554 /// @param LineNo Line number.
555 /// @param Ty Variable Type
556 /// @param Addr An array of complex address operations.
557 /// @param ArgNo If this variable is an argument then this argument's
558 /// number. 1 indicates 1st argument.
559 DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
560 StringRef Name, DIFile F, unsigned LineNo,
561 DITypeRef Ty, ArrayRef<Value *> Addr,
564 /// createVariablePiece - Create a descriptor to describe one part
565 /// of aggregate variable that is fragmented across multiple Values.
567 /// @param Variable Variable that is partially represented by this.
568 /// @param OffsetInBytes Offset of the piece in bytes.
569 /// @param SizeInBytes Size of the piece in bytes.
570 DIVariable createVariablePiece(DIVariable Variable,
571 unsigned OffsetInBytes,
572 unsigned SizeInBytes);
574 /// createFunction - Create a new descriptor for the specified subprogram.
575 /// See comments in DISubprogram for descriptions of these fields.
576 /// @param Scope Function scope.
577 /// @param Name Function name.
578 /// @param LinkageName Mangled function name.
579 /// @param File File where this variable is defined.
580 /// @param LineNo Line number.
581 /// @param Ty Function type.
582 /// @param isLocalToUnit True if this function is not externally visible.
583 /// @param isDefinition True if this is a function definition.
584 /// @param ScopeLine Set to the beginning of the scope this starts
585 /// @param Flags e.g. is this function prototyped or not.
586 /// These flags are used to emit dwarf attributes.
587 /// @param isOptimized True if optimization is ON.
588 /// @param Fn llvm::Function pointer.
589 /// @param TParam Function template parameters.
590 DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
591 StringRef LinkageName,
592 DIFile File, unsigned LineNo,
593 DICompositeType Ty, bool isLocalToUnit,
597 bool isOptimized = false,
598 Function *Fn = nullptr,
599 MDNode *TParam = nullptr,
600 MDNode *Decl = nullptr);
602 /// FIXME: this is added for dragonegg. Once we update dragonegg
603 /// to call resolve function, this will be removed.
604 DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
605 StringRef LinkageName,
606 DIFile File, unsigned LineNo,
607 DICompositeType Ty, bool isLocalToUnit,
611 bool isOptimized = false,
612 Function *Fn = nullptr,
613 MDNode *TParam = nullptr,
614 MDNode *Decl = nullptr);
616 /// createMethod - Create a new descriptor for the specified C++ method.
617 /// See comments in DISubprogram for descriptions of these fields.
618 /// @param Scope Function scope.
619 /// @param Name Function name.
620 /// @param LinkageName Mangled function name.
621 /// @param File File where this variable is defined.
622 /// @param LineNo Line number.
623 /// @param Ty Function type.
624 /// @param isLocalToUnit True if this function is not externally visible..
625 /// @param isDefinition True if this is a function definition.
626 /// @param Virtuality Attributes describing virtualness. e.g. pure
627 /// virtual function.
628 /// @param VTableIndex Index no of this method in virtual table.
629 /// @param VTableHolder Type that holds vtable.
630 /// @param Flags e.g. is this function prototyped or not.
631 /// This flags are used to emit dwarf attributes.
632 /// @param isOptimized True if optimization is ON.
633 /// @param Fn llvm::Function pointer.
634 /// @param TParam Function template parameters.
635 DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
636 StringRef LinkageName,
637 DIFile File, unsigned LineNo,
638 DICompositeType Ty, bool isLocalToUnit,
640 unsigned Virtuality = 0, unsigned VTableIndex = 0,
641 DIType VTableHolder = DIType(),
643 bool isOptimized = false,
644 Function *Fn = nullptr,
645 MDNode *TParam = nullptr);
647 /// createNameSpace - This creates new descriptor for a namespace
648 /// with the specified parent scope.
649 /// @param Scope Namespace scope
650 /// @param Name Name of this namespace
651 /// @param File Source file
652 /// @param LineNo Line number
653 DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
654 DIFile File, unsigned LineNo);
657 /// createLexicalBlockFile - This creates a descriptor for a lexical
658 /// block with a new file attached. This merely extends the existing
659 /// lexical block as it crosses a file.
660 /// @param Scope Lexical block.
661 /// @param File Source file.
662 DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope,
665 /// createLexicalBlock - This creates a descriptor for a lexical block
666 /// with the specified parent context.
667 /// @param Scope Parent lexical scope.
668 /// @param File Source file.
669 /// @param Line Line number.
670 /// @param Col Column number.
671 /// @param Discriminator DWARF path discriminator value.
672 DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
673 unsigned Line, unsigned Col,
674 unsigned Discriminator);
676 /// \brief Create a descriptor for an imported module.
677 /// @param Context The scope this module is imported into
678 /// @param NS The namespace being imported here
679 /// @param Line Line number
680 DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
683 /// \brief Create a descriptor for an imported module.
684 /// @param Context The scope this module is imported into
685 /// @param NS An aliased namespace
686 /// @param Line Line number
687 DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
690 /// \brief Create a descriptor for an imported function.
691 /// @param Context The scope this module is imported into
692 /// @param Decl The declaration (or definition) of a function, type, or
694 /// @param Line Line number
695 DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
697 StringRef Name = StringRef());
698 DIImportedEntity createImportedDeclaration(DIScope Context,
701 StringRef Name = StringRef());
703 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
704 /// @param Storage llvm::Value of the variable
705 /// @param VarInfo Variable's debug info descriptor.
706 /// @param InsertAtEnd Location for the new intrinsic.
707 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
708 BasicBlock *InsertAtEnd);
710 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
711 /// @param Storage llvm::Value of the variable
712 /// @param VarInfo Variable's debug info descriptor.
713 /// @param InsertBefore Location for the new intrinsic.
714 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
715 Instruction *InsertBefore);
718 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
719 /// @param Val llvm::Value of the variable
720 /// @param Offset Offset
721 /// @param VarInfo Variable's debug info descriptor.
722 /// @param InsertAtEnd Location for the new intrinsic.
723 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
725 BasicBlock *InsertAtEnd);
727 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
728 /// @param Val llvm::Value of the variable
729 /// @param Offset Offset
730 /// @param VarInfo Variable's debug info descriptor.
731 /// @param InsertBefore Location for the new intrinsic.
732 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
734 Instruction *InsertBefore);
737 } // end namespace llvm