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/TrackingMDRef.h"
22 #include "llvm/IR/ValueHandle.h"
23 #include "llvm/Support/DataTypes.h"
37 class DICompositeType;
43 class DIGlobalVariable;
44 class DIImportedEntity;
48 class DILexicalBlockFile;
52 class DITemplateTypeParameter;
53 class DITemplateValueParameter;
58 LLVMContext &VMContext;
60 MDNode *TempEnumTypes;
61 MDNode *TempRetainTypes;
62 MDNode *TempSubprograms;
64 MDNode *TempImportedModules;
66 Function *DeclareFn; // llvm.dbg.declare
67 Function *ValueFn; // llvm.dbg.value
69 SmallVector<Metadata *, 4> AllEnumTypes;
70 /// Track the RetainTypes, since they can be updated later on.
71 SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
72 SmallVector<Metadata *, 4> AllSubprograms;
73 SmallVector<Metadata *, 4> AllGVs;
74 SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
76 /// \brief Track nodes that may be unresolved.
77 SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
78 bool AllowUnresolvedNodes;
80 /// Each subprogram's preserved local variables.
81 DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> PreservedVariables;
83 DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION;
84 void operator=(const DIBuilder &) LLVM_DELETED_FUNCTION;
86 /// \brief Create a temporary.
88 /// Create an \a temporary node and track it in \a UnresolvedNodes.
89 void trackIfUnresolved(MDNode *N);
92 /// \brief Construct a builder for a module.
94 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
95 /// in order to resolve cycles during \a finalize().
96 explicit DIBuilder(Module &M, bool AllowUnresolved = true);
97 enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
99 /// finalize - Construct any deferred debug info descriptors.
102 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
103 /// information generated during this instance of compilation.
104 /// @param Lang Source programming language, eg. dwarf::DW_LANG_C99
105 /// @param File File name
106 /// @param Dir Directory
107 /// @param Producer Identify the producer of debugging information and code.
108 /// Usually this is a compiler version string.
109 /// @param isOptimized A boolean flag which indicates whether optimization
111 /// @param Flags This string lists command line options. This string is
112 /// directly embedded in debug info output which may be used
113 /// by a tool analyzing generated debugging information.
114 /// @param RV This indicates runtime version for languages like
116 /// @param SplitName The name of the file that we'll split debug info out
118 /// @param Kind The kind of debug information to generate.
119 /// @param EmitDebugInfo A boolean flag which indicates whether debug
120 /// information should be written to the final
121 /// output or not. When this is false, debug
122 /// information annotations will be present in
123 /// the IL but they are not written to the final
124 /// assembly or object file. This supports tracking
125 /// source location information in the back end
126 /// without actually changing the output (e.g.,
127 /// when using optimization remarks).
128 DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
129 StringRef Dir, StringRef Producer,
130 bool isOptimized, StringRef Flags,
132 StringRef SplitName = StringRef(),
133 DebugEmissionKind Kind = FullDebug,
134 bool EmitDebugInfo = true);
136 /// createFile - Create a file descriptor to hold debugging information
138 DIFile createFile(StringRef Filename, StringRef Directory);
140 /// createEnumerator - Create a single enumerator value.
141 DIEnumerator createEnumerator(StringRef Name, int64_t Val);
143 /// \brief Create a DWARF unspecified type.
144 DIBasicType createUnspecifiedType(StringRef Name);
146 /// \brief Create C++11 nullptr type.
147 DIBasicType createNullPtrType();
149 /// createBasicType - Create debugging information entry for a basic
151 /// @param Name Type name.
152 /// @param SizeInBits Size of the type.
153 /// @param AlignInBits Type alignment.
154 /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
155 DIBasicType createBasicType(StringRef Name, uint64_t SizeInBits,
156 uint64_t AlignInBits, unsigned Encoding);
158 /// createQualifiedType - Create debugging information entry for a qualified
159 /// type, e.g. 'const int'.
160 /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
161 /// @param FromTy Base Type.
162 DIDerivedType createQualifiedType(unsigned Tag, DIType FromTy);
164 /// createPointerType - Create debugging information entry for a pointer.
165 /// @param PointeeTy Type pointed by this pointer.
166 /// @param SizeInBits Size.
167 /// @param AlignInBits Alignment. (optional)
168 /// @param Name Pointer type name. (optional)
170 createPointerType(DIType PointeeTy, uint64_t SizeInBits,
171 uint64_t AlignInBits = 0, StringRef Name = StringRef());
173 /// \brief Create debugging information entry for a pointer to member.
174 /// @param PointeeTy Type pointed to by this pointer.
175 /// @param SizeInBits Size.
176 /// @param AlignInBits Alignment. (optional)
177 /// @param Class Type for which this pointer points to members of.
178 DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class,
180 uint64_t AlignInBits = 0);
182 /// createReferenceType - Create debugging information entry for a c++
183 /// style reference or rvalue reference type.
184 DIDerivedType createReferenceType(unsigned Tag, DIType RTy);
186 /// createTypedef - Create debugging information entry for a typedef.
187 /// @param Ty Original type.
188 /// @param Name Typedef name.
189 /// @param File File where this type is defined.
190 /// @param LineNo Line number.
191 /// @param Context The surrounding context for the typedef.
192 DIDerivedType createTypedef(DIType Ty, StringRef Name, DIFile File,
193 unsigned LineNo, DIDescriptor Context);
195 /// createFriend - Create debugging information entry for a 'friend'.
196 DIDerivedType createFriend(DIType Ty, DIType FriendTy);
198 /// createInheritance - Create debugging information entry to establish
199 /// inheritance relationship between two types.
200 /// @param Ty Original type.
201 /// @param BaseTy Base type. Ty is inherits from base.
202 /// @param BaseOffset Base offset.
203 /// @param Flags Flags to describe inheritance attribute,
205 DIDerivedType createInheritance(DIType Ty, DIType BaseTy,
206 uint64_t BaseOffset, unsigned Flags);
208 /// createMemberType - Create debugging information entry for a member.
209 /// @param Scope Member scope.
210 /// @param Name Member name.
211 /// @param File File where this member is defined.
212 /// @param LineNo Line number.
213 /// @param SizeInBits Member size.
214 /// @param AlignInBits Member alignment.
215 /// @param OffsetInBits Member offset.
216 /// @param Flags Flags to encode member attribute, e.g. private
217 /// @param Ty Parent type.
219 createMemberType(DIDescriptor Scope, StringRef Name, DIFile File,
220 unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits,
221 uint64_t OffsetInBits, unsigned Flags, DIType Ty);
223 /// createStaticMemberType - Create debugging information entry for a
224 /// C++ static data member.
225 /// @param Scope Member scope.
226 /// @param Name Member name.
227 /// @param File File where this member is declared.
228 /// @param LineNo Line number.
229 /// @param Ty Type of the static member.
230 /// @param Flags Flags to encode member attribute, e.g. private.
231 /// @param Val Const initializer of the member.
232 DIDerivedType createStaticMemberType(DIDescriptor Scope, StringRef Name,
233 DIFile File, unsigned LineNo,
234 DIType Ty, unsigned Flags,
235 llvm::Constant *Val);
237 /// createObjCIVar - Create debugging information entry for Objective-C
238 /// instance variable.
239 /// @param Name Member name.
240 /// @param File File where this member is defined.
241 /// @param LineNo Line number.
242 /// @param SizeInBits Member size.
243 /// @param AlignInBits Member alignment.
244 /// @param OffsetInBits Member offset.
245 /// @param Flags Flags to encode member attribute, e.g. private
246 /// @param Ty Parent type.
247 /// @param PropertyNode Property associated with this ivar.
248 DIDerivedType createObjCIVar(StringRef Name, DIFile File,
249 unsigned LineNo, uint64_t SizeInBits,
250 uint64_t AlignInBits, uint64_t OffsetInBits,
251 unsigned Flags, DIType Ty,
252 MDNode *PropertyNode);
254 /// createObjCProperty - Create debugging information entry for Objective-C
256 /// @param Name Property name.
257 /// @param File File where this property is defined.
258 /// @param LineNumber Line number.
259 /// @param GetterName Name of the Objective C property getter selector.
260 /// @param SetterName Name of the Objective C property setter selector.
261 /// @param PropertyAttributes Objective C property attributes.
263 DIObjCProperty createObjCProperty(StringRef Name,
264 DIFile File, unsigned LineNumber,
265 StringRef GetterName,
266 StringRef SetterName,
267 unsigned PropertyAttributes,
270 /// createClassType - Create debugging information entry for a class.
271 /// @param Scope Scope in which this class is defined.
272 /// @param Name class name.
273 /// @param File File where this member is defined.
274 /// @param LineNumber Line number.
275 /// @param SizeInBits Member size.
276 /// @param AlignInBits Member alignment.
277 /// @param OffsetInBits Member offset.
278 /// @param Flags Flags to encode member attribute, e.g. private
279 /// @param Elements class members.
280 /// @param VTableHolder Debug info of the base class that contains vtable
281 /// for this type. This is used in
282 /// DW_AT_containing_type. See DWARF documentation
284 /// @param TemplateParms Template type parameters.
285 /// @param UniqueIdentifier A unique identifier for the class.
286 DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
287 DIFile File, unsigned LineNumber,
288 uint64_t SizeInBits, uint64_t AlignInBits,
289 uint64_t OffsetInBits, unsigned Flags,
290 DIType DerivedFrom, DIArray Elements,
291 DIType VTableHolder = DIType(),
292 MDNode *TemplateParms = nullptr,
293 StringRef UniqueIdentifier = StringRef());
295 /// createStructType - Create debugging information entry for a struct.
296 /// @param Scope Scope in which this struct is defined.
297 /// @param Name Struct name.
298 /// @param File File where this member is defined.
299 /// @param LineNumber Line number.
300 /// @param SizeInBits Member size.
301 /// @param AlignInBits Member alignment.
302 /// @param Flags Flags to encode member attribute, e.g. private
303 /// @param Elements Struct elements.
304 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
305 /// @param UniqueIdentifier A unique identifier for the struct.
306 DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
307 DIFile File, unsigned LineNumber,
308 uint64_t SizeInBits, uint64_t AlignInBits,
309 unsigned Flags, DIType DerivedFrom,
310 DIArray Elements, unsigned RunTimeLang = 0,
311 DIType VTableHolder = DIType(),
312 StringRef UniqueIdentifier = StringRef());
314 /// createUnionType - Create debugging information entry for an union.
315 /// @param Scope Scope in which this union is defined.
316 /// @param Name Union name.
317 /// @param File File where this member is defined.
318 /// @param LineNumber Line number.
319 /// @param SizeInBits Member size.
320 /// @param AlignInBits Member alignment.
321 /// @param Flags Flags to encode member attribute, e.g. private
322 /// @param Elements Union elements.
323 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
324 /// @param UniqueIdentifier A unique identifier for the union.
325 DICompositeType createUnionType(
326 DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
327 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
328 DIArray Elements, unsigned RunTimeLang = 0,
329 StringRef UniqueIdentifier = StringRef());
331 /// createTemplateTypeParameter - Create debugging information for template
333 /// @param Scope Scope in which this type is defined.
334 /// @param Name Type parameter name.
335 /// @param Ty Parameter type.
336 /// @param File File where this type parameter is defined.
337 /// @param LineNo Line number.
338 /// @param ColumnNo Column Number.
339 DITemplateTypeParameter
340 createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
341 MDNode *File = nullptr, unsigned LineNo = 0,
342 unsigned ColumnNo = 0);
344 /// createTemplateValueParameter - Create debugging information for template
346 /// @param Scope Scope in which this type is defined.
347 /// @param Name Value parameter name.
348 /// @param Ty Parameter type.
349 /// @param Val Constant parameter value.
350 /// @param File File where this type parameter is defined.
351 /// @param LineNo Line number.
352 /// @param ColumnNo Column Number.
353 DITemplateValueParameter
354 createTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
355 Constant *Val, MDNode *File = nullptr,
356 unsigned LineNo = 0, unsigned ColumnNo = 0);
358 /// \brief Create debugging information for a template template parameter.
359 /// @param Scope Scope in which this type is defined.
360 /// @param Name Value parameter name.
361 /// @param Ty Parameter type.
362 /// @param Val The fully qualified name of the template.
363 /// @param File File where this type parameter is defined.
364 /// @param LineNo Line number.
365 /// @param ColumnNo Column Number.
366 DITemplateValueParameter
367 createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
368 DIType Ty, StringRef Val,
369 MDNode *File = nullptr, unsigned LineNo = 0,
370 unsigned ColumnNo = 0);
372 /// \brief Create debugging information for a template parameter pack.
373 /// @param Scope Scope in which this type is defined.
374 /// @param Name Value parameter name.
375 /// @param Ty Parameter type.
376 /// @param Val An array of types in the pack.
377 /// @param File File where this type parameter is defined.
378 /// @param LineNo Line number.
379 /// @param ColumnNo Column Number.
380 DITemplateValueParameter
381 createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
382 DIType Ty, DIArray Val, MDNode *File = nullptr,
383 unsigned LineNo = 0, unsigned ColumnNo = 0);
385 /// createArrayType - Create debugging information entry for an array.
386 /// @param Size Array size.
387 /// @param AlignInBits Alignment.
388 /// @param Ty Element type.
389 /// @param Subscripts Subscripts.
390 DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits,
391 DIType Ty, DIArray Subscripts);
393 /// createVectorType - Create debugging information entry for a vector type.
394 /// @param Size Array size.
395 /// @param AlignInBits Alignment.
396 /// @param Ty Element type.
397 /// @param Subscripts Subscripts.
398 DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits,
399 DIType Ty, DIArray Subscripts);
401 /// createEnumerationType - Create debugging information entry for an
403 /// @param Scope Scope in which this enumeration is defined.
404 /// @param Name Union name.
405 /// @param File File where this member is defined.
406 /// @param LineNumber Line number.
407 /// @param SizeInBits Member size.
408 /// @param AlignInBits Member alignment.
409 /// @param Elements Enumeration elements.
410 /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
411 /// @param UniqueIdentifier A unique identifier for the enum.
412 DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
413 DIFile File, unsigned LineNumber, uint64_t SizeInBits,
414 uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
415 StringRef UniqueIdentifier = StringRef());
417 /// createSubroutineType - Create subroutine type.
418 /// @param File File in which this subroutine is defined.
419 /// @param ParameterTypes An array of subroutine parameter types. This
420 /// includes return type at 0th index.
421 /// @param Flags E.g.: LValueReference.
422 /// These flags are used to emit dwarf attributes.
423 DISubroutineType createSubroutineType(DIFile File,
424 DITypeArray ParameterTypes,
427 /// createArtificialType - Create a new DIType with "artificial" flag set.
428 DIType createArtificialType(DIType Ty);
430 /// createObjectPointerType - Create a new DIType with the "object pointer"
432 DIType createObjectPointerType(DIType Ty);
434 /// \brief Create a permanent forward-declared type.
435 DICompositeType createForwardDecl(unsigned Tag, StringRef Name,
436 DIDescriptor Scope, DIFile F,
437 unsigned Line, unsigned RuntimeLang = 0,
438 uint64_t SizeInBits = 0,
439 uint64_t AlignInBits = 0,
440 StringRef UniqueIdentifier = StringRef());
442 /// \brief Create a temporary forward-declared type.
443 DICompositeType createReplaceableForwardDecl(
444 unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F,
445 unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
446 uint64_t AlignInBits = 0, StringRef UniqueIdentifier = StringRef());
448 /// retainType - Retain DIType in a module even if it is not referenced
449 /// through debug info anchors.
450 void retainType(DIType T);
452 /// createUnspecifiedParameter - Create unspecified parameter type
453 /// for a subroutine type.
454 DIBasicType createUnspecifiedParameter();
456 /// getOrCreateArray - Get a DIArray, create one if required.
457 DIArray getOrCreateArray(ArrayRef<Metadata *> Elements);
459 /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
460 DITypeArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
462 /// getOrCreateSubrange - Create a descriptor for a value range. This
463 /// implicitly uniques the values returned.
464 DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count);
467 /// createGlobalVariable - Create a new descriptor for the specified
469 /// @param Context Variable scope.
470 /// @param Name Name of the variable.
471 /// @param LinkageName Mangled name of the variable.
472 /// @param File File where this variable is defined.
473 /// @param LineNo Line number.
474 /// @param Ty Variable Type.
475 /// @param isLocalToUnit Boolean flag indicate whether this variable is
476 /// externally visible or not.
477 /// @param Val llvm::Value of the variable.
478 /// @param Decl Reference to the corresponding declaration.
479 DIGlobalVariable createGlobalVariable(DIDescriptor Context, StringRef Name,
480 StringRef LinkageName, DIFile File,
481 unsigned LineNo, DITypeRef Ty,
484 MDNode *Decl = nullptr);
486 /// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
487 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
488 DIGlobalVariable createTempGlobalVariableFwdDecl(
489 DIDescriptor Context, StringRef Name, StringRef LinkageName,
490 DIFile File, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
491 llvm::Constant *Val, MDNode *Decl = nullptr);
493 /// createLocalVariable - Create a new descriptor for the specified
495 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
496 /// DW_TAG_arg_variable.
497 /// @param Scope Variable scope.
498 /// @param Name Variable name.
499 /// @param File File where this variable is defined.
500 /// @param LineNo Line number.
501 /// @param Ty Variable Type
502 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
503 /// variable should be preserved in optimized build.
504 /// @param Flags Flags, e.g. artificial variable.
505 /// @param ArgNo If this variable is an argument then this argument's
506 /// number. 1 indicates 1st argument.
507 DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
509 DIFile File, unsigned LineNo,
510 DITypeRef Ty, bool AlwaysPreserve = false,
514 /// createExpression - Create a new descriptor for the specified
515 /// variable which has a complex address expression for its address.
516 /// @param Addr An array of complex address operations.
517 DIExpression createExpression(ArrayRef<int64_t> Addr = None);
519 /// createPieceExpression - Create a descriptor to describe one part
520 /// of aggregate variable that is fragmented across multiple Values.
522 /// @param OffsetInBytes Offset of the piece in bytes.
523 /// @param SizeInBytes Size of the piece in bytes.
524 DIExpression createPieceExpression(unsigned OffsetInBytes,
525 unsigned SizeInBytes);
527 /// createFunction - Create a new descriptor for the specified subprogram.
528 /// See comments in DISubprogram for descriptions of these fields.
529 /// @param Scope Function scope.
530 /// @param Name Function name.
531 /// @param LinkageName Mangled function name.
532 /// @param File File where this variable is defined.
533 /// @param LineNo Line number.
534 /// @param Ty Function type.
535 /// @param isLocalToUnit True if this function is not externally visible.
536 /// @param isDefinition True if this is a function definition.
537 /// @param ScopeLine Set to the beginning of the scope this starts
538 /// @param Flags e.g. is this function prototyped or not.
539 /// These flags are used to emit dwarf attributes.
540 /// @param isOptimized True if optimization is ON.
541 /// @param Fn llvm::Function pointer.
542 /// @param TParam Function template parameters.
543 DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
544 StringRef LinkageName,
545 DIFile File, unsigned LineNo,
546 DICompositeType Ty, bool isLocalToUnit,
550 bool isOptimized = false,
551 Function *Fn = nullptr,
552 MDNode *TParam = nullptr,
553 MDNode *Decl = nullptr);
555 /// createTempFunctionFwdDecl - Identical to createFunction,
556 /// except that the resulting DbgNode is meant to be RAUWed.
557 DISubprogram createTempFunctionFwdDecl(DIDescriptor Scope, StringRef Name,
558 StringRef LinkageName,
559 DIFile File, unsigned LineNo,
560 DICompositeType Ty, bool isLocalToUnit,
564 bool isOptimized = false,
565 Function *Fn = nullptr,
566 MDNode *TParam = nullptr,
567 MDNode *Decl = nullptr);
570 /// FIXME: this is added for dragonegg. Once we update dragonegg
571 /// to call resolve function, this will be removed.
572 DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
573 StringRef LinkageName,
574 DIFile File, unsigned LineNo,
575 DICompositeType Ty, bool isLocalToUnit,
579 bool isOptimized = false,
580 Function *Fn = nullptr,
581 MDNode *TParam = nullptr,
582 MDNode *Decl = nullptr);
584 /// createMethod - Create a new descriptor for the specified C++ method.
585 /// See comments in DISubprogram for descriptions of these fields.
586 /// @param Scope Function scope.
587 /// @param Name Function name.
588 /// @param LinkageName Mangled function name.
589 /// @param File File where this variable is defined.
590 /// @param LineNo Line number.
591 /// @param Ty Function type.
592 /// @param isLocalToUnit True if this function is not externally visible..
593 /// @param isDefinition True if this is a function definition.
594 /// @param Virtuality Attributes describing virtualness. e.g. pure
595 /// virtual function.
596 /// @param VTableIndex Index no of this method in virtual table.
597 /// @param VTableHolder Type that holds vtable.
598 /// @param Flags e.g. is this function prototyped or not.
599 /// This flags are used to emit dwarf attributes.
600 /// @param isOptimized True if optimization is ON.
601 /// @param Fn llvm::Function pointer.
602 /// @param TParam Function template parameters.
603 DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
604 StringRef LinkageName,
605 DIFile File, unsigned LineNo,
606 DICompositeType Ty, bool isLocalToUnit,
608 unsigned Virtuality = 0, unsigned VTableIndex = 0,
609 DIType VTableHolder = DIType(),
611 bool isOptimized = false,
612 Function *Fn = nullptr,
613 MDNode *TParam = nullptr);
615 /// createNameSpace - This creates new descriptor for a namespace
616 /// with the specified parent scope.
617 /// @param Scope Namespace scope
618 /// @param Name Name of this namespace
619 /// @param File Source file
620 /// @param LineNo Line number
621 DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
622 DIFile File, unsigned LineNo);
625 /// createLexicalBlockFile - This creates a descriptor for a lexical
626 /// block with a new file attached. This merely extends the existing
627 /// lexical block as it crosses a file.
628 /// @param Scope Lexical block.
629 /// @param File Source file.
630 /// @param Discriminator DWARF path discriminator value.
631 DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope, DIFile File,
632 unsigned Discriminator = 0);
634 /// createLexicalBlock - This creates a descriptor for a lexical block
635 /// with the specified parent context.
636 /// @param Scope Parent lexical scope.
637 /// @param File Source file.
638 /// @param Line Line number.
639 /// @param Col Column number.
640 DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
641 unsigned Line, unsigned Col);
643 /// \brief Create a descriptor for an imported module.
644 /// @param Context The scope this module is imported into
645 /// @param NS The namespace being imported here
646 /// @param Line Line number
647 DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
650 /// \brief Create a descriptor for an imported module.
651 /// @param Context The scope this module is imported into
652 /// @param NS An aliased namespace
653 /// @param Line Line number
654 DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
657 /// \brief Create a descriptor for an imported function.
658 /// @param Context The scope this module is imported into
659 /// @param Decl The declaration (or definition) of a function, type, or
661 /// @param Line Line number
662 DIImportedEntity createImportedDeclaration(DIScope Context, DIDescriptor Decl,
664 StringRef Name = StringRef());
665 DIImportedEntity createImportedDeclaration(DIScope Context,
668 StringRef Name = StringRef());
670 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
671 /// @param Storage llvm::Value of the variable
672 /// @param VarInfo Variable's debug info descriptor.
673 /// @param Expr A complex location expression.
674 /// @param InsertAtEnd Location for the new intrinsic.
675 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
676 DIExpression Expr, BasicBlock *InsertAtEnd);
678 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
679 /// @param Storage llvm::Value of the variable
680 /// @param VarInfo Variable's debug info descriptor.
681 /// @param Expr A complex location expression.
682 /// @param InsertBefore Location for the new intrinsic.
683 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
684 DIExpression Expr, Instruction *InsertBefore);
686 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
687 /// @param Val llvm::Value of the variable
688 /// @param Offset Offset
689 /// @param VarInfo Variable's debug info descriptor.
690 /// @param Expr A complex location expression.
691 /// @param InsertAtEnd Location for the new intrinsic.
692 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
693 DIVariable VarInfo, DIExpression Expr,
694 BasicBlock *InsertAtEnd);
696 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
697 /// @param Val llvm::Value of the variable
698 /// @param Offset Offset
699 /// @param VarInfo Variable's debug info descriptor.
700 /// @param Expr A complex location expression.
701 /// @param InsertBefore Location for the new intrinsic.
702 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
703 DIVariable VarInfo, DIExpression Expr,
704 Instruction *InsertBefore);
706 /// \brief Replace the vtable holder in the given composite type.
708 /// If this creates a self reference, it may orphan some unresolved cycles
709 /// in the operands of \c T, so \a DIBuilder needs to track that.
710 void replaceVTableHolder(DICompositeType &T, DICompositeType VTableHolder);
712 /// \brief Replace arrays on a composite type.
714 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
715 /// has a self-reference -- \a DIBuilder needs to track the array to
717 void replaceArrays(DICompositeType &T, DIArray Elements,
718 DIArray TParems = DIArray());
720 } // end namespace llvm