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);
524 /// createTempStaticVariableFwdDecl - Identical to createStaticVariable
525 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
527 createTempStaticVariableFwdDecl(DIDescriptor Context, StringRef Name,
528 StringRef LinkageName, DIFile File,
529 unsigned LineNo, DITypeRef Ty,
530 bool isLocalToUnit, llvm::Value *Val,
531 MDNode *Decl = nullptr);
534 /// createLocalVariable - Create a new descriptor for the specified
536 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
537 /// DW_TAG_arg_variable.
538 /// @param Scope Variable scope.
539 /// @param Name Variable name.
540 /// @param File File where this variable is defined.
541 /// @param LineNo Line number.
542 /// @param Ty Variable Type
543 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
544 /// variable should be preserved in optimized build.
545 /// @param Flags Flags, e.g. artificial variable.
546 /// @param ArgNo If this variable is an argument then this argument's
547 /// number. 1 indicates 1st argument.
548 DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
550 DIFile File, unsigned LineNo,
551 DITypeRef Ty, bool AlwaysPreserve = false,
556 /// createComplexVariable - Create a new descriptor for the specified
557 /// variable which has a complex address expression for its address.
558 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
559 /// DW_TAG_arg_variable.
560 /// @param Scope Variable scope.
561 /// @param Name Variable name.
562 /// @param F File where this variable is defined.
563 /// @param LineNo Line number.
564 /// @param Ty Variable Type
565 /// @param Addr An array of complex address operations.
566 /// @param ArgNo If this variable is an argument then this argument's
567 /// number. 1 indicates 1st argument.
568 DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
569 StringRef Name, DIFile F, unsigned LineNo,
570 DITypeRef Ty, ArrayRef<Value *> Addr,
573 /// createVariablePiece - Create a descriptor to describe one part
574 /// of aggregate variable that is fragmented across multiple Values.
576 /// @param Variable Variable that is partially represented by this.
577 /// @param OffsetInBytes Offset of the piece in bytes.
578 /// @param SizeInBytes Size of the piece in bytes.
579 DIVariable createVariablePiece(DIVariable Variable,
580 unsigned OffsetInBytes,
581 unsigned SizeInBytes);
583 /// createFunction - Create a new descriptor for the specified subprogram.
584 /// See comments in DISubprogram for descriptions of these fields.
585 /// @param Scope Function scope.
586 /// @param Name Function name.
587 /// @param LinkageName Mangled function name.
588 /// @param File File where this variable is defined.
589 /// @param LineNo Line number.
590 /// @param Ty Function type.
591 /// @param isLocalToUnit True if this function is not externally visible.
592 /// @param isDefinition True if this is a function definition.
593 /// @param ScopeLine Set to the beginning of the scope this starts
594 /// @param Flags e.g. is this function prototyped or not.
595 /// These flags are used to emit dwarf attributes.
596 /// @param isOptimized True if optimization is ON.
597 /// @param Fn llvm::Function pointer.
598 /// @param TParam Function template parameters.
599 DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
600 StringRef LinkageName,
601 DIFile File, unsigned LineNo,
602 DICompositeType Ty, bool isLocalToUnit,
606 bool isOptimized = false,
607 Function *Fn = nullptr,
608 MDNode *TParam = nullptr,
609 MDNode *Decl = nullptr);
611 /// createTempFunctionFwdDecl - Identical to createFunction,
612 /// except that the resulting DbgNode is meant to be RAUWed.
613 DISubprogram createTempFunctionFwdDecl(DIDescriptor Scope, StringRef Name,
614 StringRef LinkageName,
615 DIFile File, unsigned LineNo,
616 DICompositeType Ty, bool isLocalToUnit,
620 bool isOptimized = false,
621 Function *Fn = nullptr,
622 MDNode *TParam = nullptr,
623 MDNode *Decl = nullptr);
626 /// FIXME: this is added for dragonegg. Once we update dragonegg
627 /// to call resolve function, this will be removed.
628 DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
629 StringRef LinkageName,
630 DIFile File, unsigned LineNo,
631 DICompositeType Ty, bool isLocalToUnit,
635 bool isOptimized = false,
636 Function *Fn = nullptr,
637 MDNode *TParam = nullptr,
638 MDNode *Decl = nullptr);
640 /// createMethod - Create a new descriptor for the specified C++ method.
641 /// See comments in DISubprogram for descriptions of these fields.
642 /// @param Scope Function scope.
643 /// @param Name Function name.
644 /// @param LinkageName Mangled function name.
645 /// @param File File where this variable is defined.
646 /// @param LineNo Line number.
647 /// @param Ty Function type.
648 /// @param isLocalToUnit True if this function is not externally visible..
649 /// @param isDefinition True if this is a function definition.
650 /// @param Virtuality Attributes describing virtualness. e.g. pure
651 /// virtual function.
652 /// @param VTableIndex Index no of this method in virtual table.
653 /// @param VTableHolder Type that holds vtable.
654 /// @param Flags e.g. is this function prototyped or not.
655 /// This flags are used to emit dwarf attributes.
656 /// @param isOptimized True if optimization is ON.
657 /// @param Fn llvm::Function pointer.
658 /// @param TParam Function template parameters.
659 DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
660 StringRef LinkageName,
661 DIFile File, unsigned LineNo,
662 DICompositeType Ty, bool isLocalToUnit,
664 unsigned Virtuality = 0, unsigned VTableIndex = 0,
665 DIType VTableHolder = DIType(),
667 bool isOptimized = false,
668 Function *Fn = nullptr,
669 MDNode *TParam = nullptr);
671 /// createNameSpace - This creates new descriptor for a namespace
672 /// with the specified parent scope.
673 /// @param Scope Namespace scope
674 /// @param Name Name of this namespace
675 /// @param File Source file
676 /// @param LineNo Line number
677 DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
678 DIFile File, unsigned LineNo);
681 /// createLexicalBlockFile - This creates a descriptor for a lexical
682 /// block with a new file attached. This merely extends the existing
683 /// lexical block as it crosses a file.
684 /// @param Scope Lexical block.
685 /// @param File Source file.
686 /// @param Discriminator DWARF path discriminator value.
687 DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope, DIFile File,
688 unsigned Discriminator = 0);
690 /// createLexicalBlock - This creates a descriptor for a lexical block
691 /// with the specified parent context.
692 /// @param Scope Parent lexical scope.
693 /// @param File Source file.
694 /// @param Line Line number.
695 /// @param Col Column number.
696 DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
697 unsigned Line, unsigned Col);
699 /// \brief Create a descriptor for an imported module.
700 /// @param Context The scope this module is imported into
701 /// @param NS The namespace being imported here
702 /// @param Line Line number
703 DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
706 /// \brief Create a descriptor for an imported module.
707 /// @param Context The scope this module is imported into
708 /// @param NS An aliased namespace
709 /// @param Line Line number
710 DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
713 /// \brief Create a descriptor for an imported function.
714 /// @param Context The scope this module is imported into
715 /// @param Decl The declaration (or definition) of a function, type, or
717 /// @param Line Line number
718 DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
720 StringRef Name = StringRef());
721 DIImportedEntity createImportedDeclaration(DIScope Context,
724 StringRef Name = StringRef());
726 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
727 /// @param Storage llvm::Value of the variable
728 /// @param VarInfo Variable's debug info descriptor.
729 /// @param InsertAtEnd Location for the new intrinsic.
730 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
731 BasicBlock *InsertAtEnd);
733 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
734 /// @param Storage llvm::Value of the variable
735 /// @param VarInfo Variable's debug info descriptor.
736 /// @param InsertBefore Location for the new intrinsic.
737 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
738 Instruction *InsertBefore);
741 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
742 /// @param Val llvm::Value of the variable
743 /// @param Offset Offset
744 /// @param VarInfo Variable's debug info descriptor.
745 /// @param InsertAtEnd Location for the new intrinsic.
746 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
748 BasicBlock *InsertAtEnd);
750 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
751 /// @param Val llvm::Value of the variable
752 /// @param Offset Offset
753 /// @param VarInfo Variable's debug info descriptor.
754 /// @param InsertBefore Location for the new intrinsic.
755 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
757 Instruction *InsertBefore);
759 } // end namespace llvm