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 LLVMContext &VMContext;
39 TempMDTuple TempEnumTypes;
40 TempMDTuple TempRetainTypes;
41 TempMDTuple TempSubprograms;
43 TempMDTuple TempImportedModules;
45 Function *DeclareFn; // llvm.dbg.declare
46 Function *ValueFn; // llvm.dbg.value
48 SmallVector<Metadata *, 4> AllEnumTypes;
49 /// Track the RetainTypes, since they can be updated later on.
50 SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
51 SmallVector<Metadata *, 4> AllSubprograms;
52 SmallVector<Metadata *, 4> AllGVs;
53 SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
55 /// \brief Track nodes that may be unresolved.
56 SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
57 bool AllowUnresolvedNodes;
59 /// Each subprogram's preserved local variables.
60 DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> PreservedVariables;
62 DIBuilder(const DIBuilder &) = delete;
63 void operator=(const DIBuilder &) = delete;
65 /// \brief Create a temporary.
67 /// Create an \a temporary node and track it in \a UnresolvedNodes.
68 void trackIfUnresolved(MDNode *N);
71 /// \brief Construct a builder for a module.
73 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
74 /// in order to resolve cycles during \a finalize().
75 explicit DIBuilder(Module &M, bool AllowUnresolved = true);
76 enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
78 /// finalize - Construct any deferred debug info descriptors.
81 /// createCompileUnit - A CompileUnit provides an anchor for all debugging
82 /// information generated during this instance of compilation.
83 /// @param Lang Source programming language, eg. dwarf::DW_LANG_C99
84 /// @param File File name
85 /// @param Dir Directory
86 /// @param Producer Identify the producer of debugging information and code.
87 /// Usually this is a compiler version string.
88 /// @param isOptimized A boolean flag which indicates whether optimization
90 /// @param Flags This string lists command line options. This string is
91 /// directly embedded in debug info output which may be used
92 /// by a tool analyzing generated debugging information.
93 /// @param RV This indicates runtime version for languages like
95 /// @param SplitName The name of the file that we'll split debug info out
97 /// @param Kind The kind of debug information to generate.
98 /// @param DWOId The DWOId if this is a split skeleton compile unit.
99 /// @param EmitDebugInfo A boolean flag which indicates whether debug
100 /// information should be written to the final
101 /// output or not. When this is false, debug
102 /// information annotations will be present in
103 /// the IL but they are not written to the final
104 /// assembly or object file. This supports tracking
105 /// source location information in the back end
106 /// without actually changing the output (e.g.,
107 /// when using optimization remarks).
109 createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
110 StringRef Producer, bool isOptimized, StringRef Flags,
111 unsigned RV, StringRef SplitName = StringRef(),
112 DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0,
113 bool EmitDebugInfo = true);
115 /// createFile - Create a file descriptor to hold debugging information
117 DIFile *createFile(StringRef Filename, StringRef Directory);
119 /// createEnumerator - Create a single enumerator value.
120 DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
122 /// \brief Create a DWARF unspecified type.
123 DIBasicType *createUnspecifiedType(StringRef Name);
125 /// \brief Create C++11 nullptr type.
126 DIBasicType *createNullPtrType();
128 /// createBasicType - Create debugging information entry for a basic
130 /// @param Name Type name.
131 /// @param SizeInBits Size of the type.
132 /// @param AlignInBits Type alignment.
133 /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
134 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
135 uint64_t AlignInBits, unsigned Encoding);
137 /// createQualifiedType - Create debugging information entry for a qualified
138 /// type, e.g. 'const int'.
139 /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
140 /// @param FromTy Base Type.
141 DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
143 /// createPointerType - Create debugging information entry for a pointer.
144 /// @param PointeeTy Type pointed by this pointer.
145 /// @param SizeInBits Size.
146 /// @param AlignInBits Alignment. (optional)
147 /// @param Name Pointer type name. (optional)
148 DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
149 uint64_t AlignInBits = 0,
150 StringRef Name = "");
152 /// \brief Create debugging information entry for a pointer to member.
153 /// @param PointeeTy Type pointed to by this pointer.
154 /// @param SizeInBits Size.
155 /// @param AlignInBits Alignment. (optional)
156 /// @param Class Type for which this pointer points to members of.
157 DIDerivedType *createMemberPointerType(DIType *PointeeTy, DIType *Class,
159 uint64_t AlignInBits = 0);
161 /// createReferenceType - Create debugging information entry for a c++
162 /// style reference or rvalue reference type.
163 DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy);
165 /// createTypedef - Create debugging information entry for a typedef.
166 /// @param Ty Original type.
167 /// @param Name Typedef name.
168 /// @param File File where this type is defined.
169 /// @param LineNo Line number.
170 /// @param Context The surrounding context for the typedef.
171 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
172 unsigned LineNo, DIScope *Context);
174 /// createFriend - Create debugging information entry for a 'friend'.
175 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
177 /// createInheritance - Create debugging information entry to establish
178 /// inheritance relationship between two types.
179 /// @param Ty Original type.
180 /// @param BaseTy Base type. Ty is inherits from base.
181 /// @param BaseOffset Base offset.
182 /// @param Flags Flags to describe inheritance attribute,
184 DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
185 uint64_t BaseOffset, unsigned Flags);
187 /// createMemberType - Create debugging information entry for a member.
188 /// @param Scope Member scope.
189 /// @param Name Member name.
190 /// @param File File where this member is defined.
191 /// @param LineNo Line number.
192 /// @param SizeInBits Member size.
193 /// @param AlignInBits Member alignment.
194 /// @param OffsetInBits Member offset.
195 /// @param Flags Flags to encode member attribute, e.g. private
196 /// @param Ty Parent type.
197 DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
198 DIFile *File, unsigned LineNo,
199 uint64_t SizeInBits, uint64_t AlignInBits,
200 uint64_t OffsetInBits, unsigned Flags,
203 /// createStaticMemberType - Create debugging information entry for a
204 /// C++ static data member.
205 /// @param Scope Member scope.
206 /// @param Name Member name.
207 /// @param File File where this member is declared.
208 /// @param LineNo Line number.
209 /// @param Ty Type of the static member.
210 /// @param Flags Flags to encode member attribute, e.g. private.
211 /// @param Val Const initializer of the member.
212 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
213 DIFile *File, unsigned LineNo,
214 DIType *Ty, unsigned Flags,
215 llvm::Constant *Val);
217 /// createObjCIVar - Create debugging information entry for Objective-C
218 /// instance variable.
219 /// @param Name Member name.
220 /// @param File File where this member is defined.
221 /// @param LineNo Line number.
222 /// @param SizeInBits Member size.
223 /// @param AlignInBits Member alignment.
224 /// @param OffsetInBits Member offset.
225 /// @param Flags Flags to encode member attribute, e.g. private
226 /// @param Ty Parent type.
227 /// @param PropertyNode Property associated with this ivar.
228 DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
229 uint64_t SizeInBits, uint64_t AlignInBits,
230 uint64_t OffsetInBits, unsigned Flags,
231 DIType *Ty, MDNode *PropertyNode);
233 /// createObjCProperty - Create debugging information entry for Objective-C
235 /// @param Name Property name.
236 /// @param File File where this property is defined.
237 /// @param LineNumber Line number.
238 /// @param GetterName Name of the Objective C property getter selector.
239 /// @param SetterName Name of the Objective C property setter selector.
240 /// @param PropertyAttributes Objective C property attributes.
242 DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
244 StringRef GetterName,
245 StringRef SetterName,
246 unsigned PropertyAttributes, DIType *Ty);
248 /// createClassType - Create debugging information entry for a class.
249 /// @param Scope Scope in which this class is defined.
250 /// @param Name class name.
251 /// @param File File where this member is defined.
252 /// @param LineNumber Line number.
253 /// @param SizeInBits Member size.
254 /// @param AlignInBits Member alignment.
255 /// @param OffsetInBits Member offset.
256 /// @param Flags Flags to encode member attribute, e.g. private
257 /// @param Elements class members.
258 /// @param VTableHolder Debug info of the base class that contains vtable
259 /// for this type. This is used in
260 /// DW_AT_containing_type. See DWARF documentation
262 /// @param TemplateParms Template type parameters.
263 /// @param UniqueIdentifier A unique identifier for the class.
264 DICompositeType *createClassType(DIScope *Scope, StringRef Name,
265 DIFile *File, unsigned LineNumber,
266 uint64_t SizeInBits, uint64_t AlignInBits,
267 uint64_t OffsetInBits, unsigned Flags,
268 DIType *DerivedFrom, DINodeArray Elements,
269 DIType *VTableHolder = nullptr,
270 MDNode *TemplateParms = nullptr,
271 StringRef UniqueIdentifier = "");
273 /// createStructType - Create debugging information entry for a struct.
274 /// @param Scope Scope in which this struct is defined.
275 /// @param Name Struct name.
276 /// @param File File where this member is defined.
277 /// @param LineNumber Line number.
278 /// @param SizeInBits Member size.
279 /// @param AlignInBits Member alignment.
280 /// @param Flags Flags to encode member attribute, e.g. private
281 /// @param Elements Struct elements.
282 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
283 /// @param UniqueIdentifier A unique identifier for the struct.
284 DICompositeType *createStructType(
285 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
286 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
287 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
288 DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
290 /// createUnionType - Create debugging information entry for an union.
291 /// @param Scope Scope in which this union is defined.
292 /// @param Name Union name.
293 /// @param File File where this member is defined.
294 /// @param LineNumber Line number.
295 /// @param SizeInBits Member size.
296 /// @param AlignInBits Member alignment.
297 /// @param Flags Flags to encode member attribute, e.g. private
298 /// @param Elements Union elements.
299 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
300 /// @param UniqueIdentifier A unique identifier for the union.
301 DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
302 DIFile *File, unsigned LineNumber,
303 uint64_t SizeInBits, uint64_t AlignInBits,
304 unsigned Flags, DINodeArray Elements,
305 unsigned RunTimeLang = 0,
306 StringRef UniqueIdentifier = "");
308 /// createTemplateTypeParameter - Create debugging information for template
310 /// @param Scope Scope in which this type is defined.
311 /// @param Name Type parameter name.
312 /// @param Ty Parameter type.
313 DITemplateTypeParameter *
314 createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
316 /// createTemplateValueParameter - Create debugging information for template
318 /// @param Scope Scope in which this type is defined.
319 /// @param Name Value parameter name.
320 /// @param Ty Parameter type.
321 /// @param Val Constant parameter value.
322 DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
327 /// \brief Create debugging information for a template template parameter.
328 /// @param Scope Scope in which this type is defined.
329 /// @param Name Value parameter name.
330 /// @param Ty Parameter type.
331 /// @param Val The fully qualified name of the template.
332 DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
337 /// \brief Create debugging information for a template parameter pack.
338 /// @param Scope Scope in which this type is defined.
339 /// @param Name Value parameter name.
340 /// @param Ty Parameter type.
341 /// @param Val An array of types in the pack.
342 DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
347 /// createArrayType - Create debugging information entry for an array.
348 /// @param Size Array size.
349 /// @param AlignInBits Alignment.
350 /// @param Ty Element type.
351 /// @param Subscripts Subscripts.
352 DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
353 DIType *Ty, DINodeArray Subscripts);
355 /// createVectorType - Create debugging information entry for a vector type.
356 /// @param Size Array size.
357 /// @param AlignInBits Alignment.
358 /// @param Ty Element type.
359 /// @param Subscripts Subscripts.
360 DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
361 DIType *Ty, DINodeArray Subscripts);
363 /// createEnumerationType - Create debugging information entry for an
365 /// @param Scope Scope in which this enumeration is defined.
366 /// @param Name Union name.
367 /// @param File File where this member is defined.
368 /// @param LineNumber Line number.
369 /// @param SizeInBits Member size.
370 /// @param AlignInBits Member alignment.
371 /// @param Elements Enumeration elements.
372 /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
373 /// @param UniqueIdentifier A unique identifier for the enum.
374 DICompositeType *createEnumerationType(
375 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
376 uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
377 DIType *UnderlyingType, StringRef UniqueIdentifier = "");
379 /// createSubroutineType - Create subroutine type.
380 /// @param File File in which this subroutine is defined.
381 /// @param ParameterTypes An array of subroutine parameter types. This
382 /// includes return type at 0th index.
383 /// @param Flags E.g.: LValueReference.
384 /// These flags are used to emit dwarf attributes.
385 DISubroutineType *createSubroutineType(DIFile *File,
386 DITypeRefArray ParameterTypes,
389 /// createArtificialType - Create a new DIType* with "artificial" flag set.
390 DIType *createArtificialType(DIType *Ty);
392 /// createObjectPointerType - Create a new DIType* with the "object pointer"
394 DIType *createObjectPointerType(DIType *Ty);
396 /// \brief Create a permanent forward-declared type.
397 DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
398 DIScope *Scope, DIFile *F, unsigned Line,
399 unsigned RuntimeLang = 0,
400 uint64_t SizeInBits = 0,
401 uint64_t AlignInBits = 0,
402 StringRef UniqueIdentifier = "");
404 /// \brief Create a temporary forward-declared type.
405 DICompositeType *createReplaceableCompositeType(
406 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
407 unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
408 uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl,
409 StringRef UniqueIdentifier = "");
411 /// retainType - Retain DIType* in a module even if it is not referenced
412 /// through debug info anchors.
413 void retainType(DIType *T);
415 /// createUnspecifiedParameter - Create unspecified parameter type
416 /// for a subroutine type.
417 DIBasicType *createUnspecifiedParameter();
419 /// getOrCreateArray - Get a DINodeArray, create one if required.
420 DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
422 /// getOrCreateTypeArray - Get a DITypeRefArray, create one if required.
423 DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
425 /// getOrCreateSubrange - Create a descriptor for a value range. This
426 /// implicitly uniques the values returned.
427 DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
429 /// createGlobalVariable - Create a new descriptor for the specified
431 /// @param Context Variable scope.
432 /// @param Name Name of the variable.
433 /// @param LinkageName Mangled name of the variable.
434 /// @param File File where this variable is defined.
435 /// @param LineNo Line number.
436 /// @param Ty Variable Type.
437 /// @param isLocalToUnit Boolean flag indicate whether this variable is
438 /// externally visible or not.
439 /// @param Val llvm::Value of the variable.
440 /// @param Decl Reference to the corresponding declaration.
441 DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
442 StringRef LinkageName, DIFile *File,
443 unsigned LineNo, DIType *Ty,
446 MDNode *Decl = nullptr);
448 /// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
449 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
450 DIGlobalVariable *createTempGlobalVariableFwdDecl(
451 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
452 unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
453 MDNode *Decl = nullptr);
455 /// createLocalVariable - Create a new descriptor for the specified
457 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
458 /// DW_TAG_arg_variable.
459 /// @param Scope Variable scope.
460 /// @param Name Variable name.
461 /// @param File File where this variable is defined.
462 /// @param LineNo Line number.
463 /// @param Ty Variable Type
464 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
465 /// variable should be preserved in optimized build.
466 /// @param Flags Flags, e.g. artificial variable.
467 /// @param ArgNo If this variable is an argument then this argument's
468 /// number. 1 indicates 1st argument.
469 DILocalVariable *createLocalVariable(unsigned Tag, DIScope *Scope,
470 StringRef Name, DIFile *File,
471 unsigned LineNo, DIType *Ty,
472 bool AlwaysPreserve = false,
476 /// createExpression - Create a new descriptor for the specified
477 /// variable which has a complex address expression for its address.
478 /// @param Addr An array of complex address operations.
479 DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
480 DIExpression *createExpression(ArrayRef<int64_t> Addr);
482 /// createBitPieceExpression - Create a descriptor to describe one part
483 /// of aggregate variable that is fragmented across multiple Values.
485 /// @param OffsetInBits Offset of the piece in bits.
486 /// @param SizeInBits Size of the piece in bits.
487 DIExpression *createBitPieceExpression(unsigned OffsetInBits,
488 unsigned SizeInBits);
490 /// createFunction - Create a new descriptor for the specified subprogram.
491 /// See comments in DISubprogram* for descriptions of these fields.
492 /// @param Scope Function scope.
493 /// @param Name Function name.
494 /// @param LinkageName Mangled function name.
495 /// @param File File where this variable is defined.
496 /// @param LineNo Line number.
497 /// @param Ty Function type.
498 /// @param isLocalToUnit True if this function is not externally visible.
499 /// @param isDefinition True if this is a function definition.
500 /// @param ScopeLine Set to the beginning of the scope this starts
501 /// @param Flags e.g. is this function prototyped or not.
502 /// These flags are used to emit dwarf attributes.
503 /// @param isOptimized True if optimization is ON.
504 /// @param Fn llvm::Function pointer.
505 /// @param TParam Function template parameters.
507 createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
508 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
509 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
510 unsigned Flags = 0, bool isOptimized = false,
511 Function *Fn = nullptr, MDNode *TParam = nullptr,
512 MDNode *Decl = nullptr);
514 /// createTempFunctionFwdDecl - Identical to createFunction,
515 /// except that the resulting DbgNode is meant to be RAUWed.
516 DISubprogram *createTempFunctionFwdDecl(
517 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
518 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
519 bool isDefinition, unsigned ScopeLine, unsigned Flags = 0,
520 bool isOptimized = false, Function *Fn = nullptr,
521 MDNode *TParam = nullptr, MDNode *Decl = nullptr);
523 /// FIXME: this is added for dragonegg. Once we update dragonegg
524 /// to call resolve function, this will be removed.
526 createFunction(DIScopeRef Scope, StringRef Name, StringRef LinkageName,
527 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
528 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
529 unsigned Flags = 0, bool isOptimized = false,
530 Function *Fn = nullptr, MDNode *TParam = nullptr,
531 MDNode *Decl = nullptr);
533 /// createMethod - Create a new descriptor for the specified C++ method.
534 /// See comments in DISubprogram* for descriptions of these fields.
535 /// @param Scope Function scope.
536 /// @param Name Function name.
537 /// @param LinkageName Mangled function name.
538 /// @param File File where this variable is defined.
539 /// @param LineNo Line number.
540 /// @param Ty Function type.
541 /// @param isLocalToUnit True if this function is not externally visible..
542 /// @param isDefinition True if this is a function definition.
543 /// @param Virtuality Attributes describing virtualness. e.g. pure
544 /// virtual function.
545 /// @param VTableIndex Index no of this method in virtual table.
546 /// @param VTableHolder Type that holds vtable.
547 /// @param Flags e.g. is this function prototyped or not.
548 /// This flags are used to emit dwarf attributes.
549 /// @param isOptimized True if optimization is ON.
550 /// @param Fn llvm::Function pointer.
551 /// @param TParam Function template parameters.
553 createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
554 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
555 bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0,
556 unsigned VTableIndex = 0, DIType *VTableHolder = nullptr,
557 unsigned Flags = 0, bool isOptimized = false,
558 Function *Fn = nullptr, MDNode *TParam = nullptr);
560 /// createNameSpace - This creates new descriptor for a namespace
561 /// with the specified parent scope.
562 /// @param Scope Namespace scope
563 /// @param Name Name of this namespace
564 /// @param File Source file
565 /// @param LineNo Line number
566 DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
569 /// createLexicalBlockFile - This creates a descriptor for a lexical
570 /// block with a new file attached. This merely extends the existing
571 /// lexical block as it crosses a file.
572 /// @param Scope Lexical block.
573 /// @param File Source file.
574 /// @param Discriminator DWARF path discriminator value.
575 DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
576 unsigned Discriminator = 0);
578 /// createLexicalBlock - This creates a descriptor for a lexical block
579 /// with the specified parent context.
580 /// @param Scope Parent lexical scope.
581 /// @param File Source file.
582 /// @param Line Line number.
583 /// @param Col Column number.
584 DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
585 unsigned Line, unsigned Col);
587 /// \brief Create a descriptor for an imported module.
588 /// @param Context The scope this module is imported into
589 /// @param NS The namespace being imported here
590 /// @param Line Line number
591 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
594 /// \brief Create a descriptor for an imported module.
595 /// @param Context The scope this module is imported into
596 /// @param NS An aliased namespace
597 /// @param Line Line number
598 DIImportedEntity *createImportedModule(DIScope *Context,
599 DIImportedEntity *NS, unsigned Line);
601 /// \brief Create a descriptor for an imported function.
602 /// @param Context The scope this module is imported into
603 /// @param Decl The declaration (or definition) of a function, type, or
605 /// @param Line Line number
606 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
608 StringRef Name = "");
610 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
611 /// @param Storage llvm::Value of the variable
612 /// @param VarInfo Variable's debug info descriptor.
613 /// @param Expr A complex location expression.
614 /// @param DL Debug info location.
615 /// @param InsertAtEnd Location for the new intrinsic.
616 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
617 DIExpression *Expr, const DILocation *DL,
618 BasicBlock *InsertAtEnd);
620 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
621 /// @param Storage llvm::Value of the variable
622 /// @param VarInfo Variable's debug info descriptor.
623 /// @param Expr A complex location expression.
624 /// @param DL Debug info location.
625 /// @param InsertBefore Location for the new intrinsic.
626 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
627 DIExpression *Expr, const DILocation *DL,
628 Instruction *InsertBefore);
630 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
631 /// @param Val llvm::Value of the variable
632 /// @param Offset Offset
633 /// @param VarInfo Variable's debug info descriptor.
634 /// @param Expr A complex location expression.
635 /// @param DL Debug info location.
636 /// @param InsertAtEnd Location for the new intrinsic.
637 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
638 DILocalVariable *VarInfo,
640 const DILocation *DL,
641 BasicBlock *InsertAtEnd);
643 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
644 /// @param Val llvm::Value of the variable
645 /// @param Offset Offset
646 /// @param VarInfo Variable's debug info descriptor.
647 /// @param Expr A complex location expression.
648 /// @param DL Debug info location.
649 /// @param InsertBefore Location for the new intrinsic.
650 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
651 DILocalVariable *VarInfo,
653 const DILocation *DL,
654 Instruction *InsertBefore);
656 /// \brief Replace the vtable holder in the given composite type.
658 /// If this creates a self reference, it may orphan some unresolved cycles
659 /// in the operands of \c T, so \a DIBuilder needs to track that.
660 void replaceVTableHolder(DICompositeType *&T,
661 DICompositeType *VTableHolder);
663 /// \brief Replace arrays on a composite type.
665 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
666 /// has a self-reference -- \a DIBuilder needs to track the array to
668 void replaceArrays(DICompositeType *&T, DINodeArray Elements,
669 DINodeArray TParems = DINodeArray());
671 /// \brief Replace a temporary node.
673 /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
676 /// If \c Replacement is the same as \c N.get(), instead call \a
677 /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
678 /// have a different address, so we return the final address.
679 template <class NodeTy>
680 NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
681 if (N.get() == Replacement)
682 return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
684 N->replaceAllUsesWith(Replacement);
688 } // end namespace llvm