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 DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
40 Function *DeclareFn; ///< llvm.dbg.declare
41 Function *ValueFn; ///< llvm.dbg.value
43 SmallVector<Metadata *, 4> AllEnumTypes;
44 /// Track the RetainTypes, since they can be updated later on.
45 SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
46 SmallVector<Metadata *, 4> AllSubprograms;
47 SmallVector<Metadata *, 4> AllGVs;
48 SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
50 /// Track nodes that may be unresolved.
51 SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
52 bool AllowUnresolvedNodes;
54 /// Each subprogram's preserved local variables.
55 DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> PreservedVariables;
57 DIBuilder(const DIBuilder &) = delete;
58 void operator=(const DIBuilder &) = delete;
60 /// Create a temporary.
62 /// Create an \a temporary node and track it in \a UnresolvedNodes.
63 void trackIfUnresolved(MDNode *N);
66 /// Construct a builder for a module.
68 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
69 /// in order to resolve cycles during \a finalize().
70 explicit DIBuilder(Module &M, bool AllowUnresolved = true);
71 enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
73 /// Construct any deferred debug info descriptors.
76 /// A CompileUnit provides an anchor for all debugging
77 /// information generated during this instance of compilation.
78 /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
79 /// \param File File name
80 /// \param Dir Directory
81 /// \param Producer Identify the producer of debugging information
82 /// and code. Usually this is a compiler
84 /// \param isOptimized A boolean flag which indicates whether optimization
85 /// is enabled or not.
86 /// \param Flags This string lists command line options. This
87 /// string is directly embedded in debug info
88 /// output which may be used by a tool
89 /// analyzing generated debugging information.
90 /// \param RV This indicates runtime version for languages like
92 /// \param SplitName The name of the file that we'll split debug info
94 /// \param Kind The kind of debug information to generate.
95 /// \param DWOId The DWOId if this is a split skeleton compile unit.
96 /// \param EmitDebugInfo A boolean flag which indicates whether
97 /// debug information should be written to
98 /// the final output or not. When this is
99 /// false, debug information annotations will
100 /// be present in the IL but they are not
101 /// written to the final assembly or object
102 /// file. This supports tracking source
103 /// location information in the back end
104 /// without actually changing the output
105 /// (e.g., when using optimization remarks).
107 createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
108 StringRef Producer, bool isOptimized, StringRef Flags,
109 unsigned RV, StringRef SplitName = StringRef(),
110 DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0,
111 bool EmitDebugInfo = true);
113 /// Create a file descriptor to hold debugging information
115 DIFile *createFile(StringRef Filename, StringRef Directory);
117 /// Create a single enumerator value.
118 DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
120 /// Create a DWARF unspecified type.
121 DIBasicType *createUnspecifiedType(StringRef Name);
123 /// Create C++11 nullptr type.
124 DIBasicType *createNullPtrType();
126 /// Create debugging information entry for a basic
128 /// \param Name Type name.
129 /// \param SizeInBits Size of the type.
130 /// \param AlignInBits Type alignment.
131 /// \param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
132 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
133 uint64_t AlignInBits, unsigned Encoding);
135 /// Create debugging information entry for a qualified
136 /// type, e.g. 'const int'.
137 /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
138 /// \param FromTy Base Type.
139 DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
141 /// Create debugging information entry for a pointer.
142 /// \param PointeeTy Type pointed by this pointer.
143 /// \param SizeInBits Size.
144 /// \param AlignInBits Alignment. (optional)
145 /// \param Name Pointer type name. (optional)
146 DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
147 uint64_t AlignInBits = 0,
148 StringRef Name = "");
150 /// Create debugging information entry for a pointer to member.
151 /// \param PointeeTy Type pointed to by this pointer.
152 /// \param SizeInBits Size.
153 /// \param AlignInBits Alignment. (optional)
154 /// \param Class Type for which this pointer points to members of.
155 DIDerivedType *createMemberPointerType(DIType *PointeeTy, DIType *Class,
157 uint64_t AlignInBits = 0);
159 /// Create debugging information entry for a c++
160 /// style reference or rvalue reference type.
161 DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy);
163 /// Create debugging information entry for a typedef.
164 /// \param Ty Original type.
165 /// \param Name Typedef name.
166 /// \param File File where this type is defined.
167 /// \param LineNo Line number.
168 /// \param Context The surrounding context for the typedef.
169 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
170 unsigned LineNo, DIScope *Context);
172 /// Create debugging information entry for a 'friend'.
173 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
175 /// Create debugging information entry to establish
176 /// inheritance relationship between two types.
177 /// \param Ty Original type.
178 /// \param BaseTy Base type. Ty is inherits from base.
179 /// \param BaseOffset Base offset.
180 /// \param Flags Flags to describe inheritance attribute,
182 DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
183 uint64_t BaseOffset, unsigned Flags);
185 /// Create debugging information entry for a member.
186 /// \param Scope Member scope.
187 /// \param Name Member name.
188 /// \param File File where this member is defined.
189 /// \param LineNo Line number.
190 /// \param SizeInBits Member size.
191 /// \param AlignInBits Member alignment.
192 /// \param OffsetInBits Member offset.
193 /// \param Flags Flags to encode member attribute, e.g. private
194 /// \param Ty Parent type.
195 DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
196 DIFile *File, unsigned LineNo,
197 uint64_t SizeInBits, uint64_t AlignInBits,
198 uint64_t OffsetInBits, unsigned Flags,
201 /// Create debugging information entry for a
202 /// C++ static data member.
203 /// \param Scope Member scope.
204 /// \param Name Member name.
205 /// \param File File where this member is declared.
206 /// \param LineNo Line number.
207 /// \param Ty Type of the static member.
208 /// \param Flags Flags to encode member attribute, e.g. private.
209 /// \param Val Const initializer of the member.
210 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
211 DIFile *File, unsigned LineNo,
212 DIType *Ty, unsigned Flags,
213 llvm::Constant *Val);
215 /// Create debugging information entry for Objective-C
216 /// instance variable.
217 /// \param Name Member name.
218 /// \param File File where this member is defined.
219 /// \param LineNo Line number.
220 /// \param SizeInBits Member size.
221 /// \param AlignInBits Member alignment.
222 /// \param OffsetInBits Member offset.
223 /// \param Flags Flags to encode member attribute, e.g. private
224 /// \param Ty Parent type.
225 /// \param PropertyNode Property associated with this ivar.
226 DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
227 uint64_t SizeInBits, uint64_t AlignInBits,
228 uint64_t OffsetInBits, unsigned Flags,
229 DIType *Ty, MDNode *PropertyNode);
231 /// Create debugging information entry for Objective-C
233 /// \param Name Property name.
234 /// \param File File where this property is defined.
235 /// \param LineNumber Line number.
236 /// \param GetterName Name of the Objective C property getter selector.
237 /// \param SetterName Name of the Objective C property setter selector.
238 /// \param PropertyAttributes Objective C property attributes.
240 DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
242 StringRef GetterName,
243 StringRef SetterName,
244 unsigned PropertyAttributes, DIType *Ty);
246 /// Create debugging information entry for a class.
247 /// \param Scope Scope in which this class is defined.
248 /// \param Name class name.
249 /// \param File File where this member is defined.
250 /// \param LineNumber Line number.
251 /// \param SizeInBits Member size.
252 /// \param AlignInBits Member alignment.
253 /// \param OffsetInBits Member offset.
254 /// \param Flags Flags to encode member attribute, e.g. private
255 /// \param Elements class members.
256 /// \param VTableHolder Debug info of the base class that contains vtable
257 /// for this type. This is used in
258 /// DW_AT_containing_type. See DWARF documentation
260 /// \param TemplateParms Template type parameters.
261 /// \param UniqueIdentifier A unique identifier for the class.
262 DICompositeType *createClassType(DIScope *Scope, StringRef Name,
263 DIFile *File, unsigned LineNumber,
264 uint64_t SizeInBits, uint64_t AlignInBits,
265 uint64_t OffsetInBits, unsigned Flags,
266 DIType *DerivedFrom, DINodeArray Elements,
267 DIType *VTableHolder = nullptr,
268 MDNode *TemplateParms = nullptr,
269 StringRef UniqueIdentifier = "");
271 /// Create debugging information entry for a struct.
272 /// \param Scope Scope in which this struct is defined.
273 /// \param Name Struct name.
274 /// \param File File where this member is defined.
275 /// \param LineNumber Line number.
276 /// \param SizeInBits Member size.
277 /// \param AlignInBits Member alignment.
278 /// \param Flags Flags to encode member attribute, e.g. private
279 /// \param Elements Struct elements.
280 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
281 /// \param UniqueIdentifier A unique identifier for the struct.
282 DICompositeType *createStructType(
283 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
284 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
285 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
286 DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
288 /// Create debugging information entry for an union.
289 /// \param Scope Scope in which this union is defined.
290 /// \param Name Union name.
291 /// \param File File where this member is defined.
292 /// \param LineNumber Line number.
293 /// \param SizeInBits Member size.
294 /// \param AlignInBits Member alignment.
295 /// \param Flags Flags to encode member attribute, e.g. private
296 /// \param Elements Union elements.
297 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
298 /// \param UniqueIdentifier A unique identifier for the union.
299 DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
300 DIFile *File, unsigned LineNumber,
301 uint64_t SizeInBits, uint64_t AlignInBits,
302 unsigned Flags, DINodeArray Elements,
303 unsigned RunTimeLang = 0,
304 StringRef UniqueIdentifier = "");
306 /// Create debugging information for template
308 /// \param Scope Scope in which this type is defined.
309 /// \param Name Type parameter name.
310 /// \param Ty Parameter type.
311 DITemplateTypeParameter *
312 createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
314 /// Create debugging information for template
316 /// \param Scope Scope in which this type is defined.
317 /// \param Name Value parameter name.
318 /// \param Ty Parameter type.
319 /// \param Val Constant parameter value.
320 DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
325 /// Create debugging information for a template template parameter.
326 /// \param Scope Scope in which this type is defined.
327 /// \param Name Value parameter name.
328 /// \param Ty Parameter type.
329 /// \param Val The fully qualified name of the template.
330 DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
335 /// Create debugging information for a template parameter pack.
336 /// \param Scope Scope in which this type is defined.
337 /// \param Name Value parameter name.
338 /// \param Ty Parameter type.
339 /// \param Val An array of types in the pack.
340 DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
345 /// Create debugging information entry for an array.
346 /// \param Size Array size.
347 /// \param AlignInBits Alignment.
348 /// \param Ty Element type.
349 /// \param Subscripts Subscripts.
350 DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
351 DIType *Ty, DINodeArray Subscripts);
353 /// Create debugging information entry for a vector type.
354 /// \param Size Array size.
355 /// \param AlignInBits Alignment.
356 /// \param Ty Element type.
357 /// \param Subscripts Subscripts.
358 DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
359 DIType *Ty, DINodeArray Subscripts);
361 /// Create debugging information entry for an
363 /// \param Scope Scope in which this enumeration is defined.
364 /// \param Name Union name.
365 /// \param File File where this member is defined.
366 /// \param LineNumber Line number.
367 /// \param SizeInBits Member size.
368 /// \param AlignInBits Member alignment.
369 /// \param Elements Enumeration elements.
370 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
371 /// \param UniqueIdentifier A unique identifier for the enum.
372 DICompositeType *createEnumerationType(
373 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
374 uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
375 DIType *UnderlyingType, StringRef UniqueIdentifier = "");
377 /// Create subroutine type.
378 /// \param ParameterTypes An array of subroutine parameter types. This
379 /// includes return type at 0th index.
380 /// \param Flags E.g.: LValueReference.
381 /// These flags are used to emit dwarf attributes.
382 DISubroutineType *createSubroutineType(DITypeRefArray ParameterTypes,
385 /// Create an external type reference.
386 /// \param Tag Dwarf TAG.
387 /// \param File File in which the type is defined.
388 /// \param UniqueIdentifier A unique identifier for the type.
389 DICompositeType *createExternalTypeRef(unsigned Tag, DIFile *File,
390 StringRef UniqueIdentifier);
392 /// Create a new DIType* with "artificial" flag set.
393 DIType *createArtificialType(DIType *Ty);
395 /// Create a new DIType* with the "object pointer"
397 DIType *createObjectPointerType(DIType *Ty);
399 /// Create a permanent forward-declared type.
400 DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
401 DIScope *Scope, DIFile *F, unsigned Line,
402 unsigned RuntimeLang = 0,
403 uint64_t SizeInBits = 0,
404 uint64_t AlignInBits = 0,
405 StringRef UniqueIdentifier = "");
407 /// Create a temporary forward-declared type.
408 DICompositeType *createReplaceableCompositeType(
409 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
410 unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
411 uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl,
412 StringRef UniqueIdentifier = "");
414 /// Retain DIType* in a module even if it is not referenced
415 /// through debug info anchors.
416 void retainType(DIType *T);
418 /// Create unspecified parameter type
419 /// for a subroutine type.
420 DIBasicType *createUnspecifiedParameter();
422 /// Get a DINodeArray, create one if required.
423 DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
425 /// Get a DITypeRefArray, create one if required.
426 DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
428 /// Create a descriptor for a value range. This
429 /// implicitly uniques the values returned.
430 DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
432 /// Create a new descriptor for the specified
434 /// \param Context Variable scope.
435 /// \param Name Name of the variable.
436 /// \param LinkageName Mangled name of the variable.
437 /// \param File File where this variable is defined.
438 /// \param LineNo Line number.
439 /// \param Ty Variable Type.
440 /// \param isLocalToUnit Boolean flag indicate whether this variable is
441 /// externally visible or not.
442 /// \param Val llvm::Value of the variable.
443 /// \param Decl Reference to the corresponding declaration.
444 DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
445 StringRef LinkageName, DIFile *File,
446 unsigned LineNo, DIType *Ty,
449 MDNode *Decl = nullptr);
451 /// Identical to createGlobalVariable
452 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
453 DIGlobalVariable *createTempGlobalVariableFwdDecl(
454 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
455 unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
456 MDNode *Decl = nullptr);
458 /// Create a new descriptor for an auto variable. This is a local variable
459 /// that is not a subprogram parameter.
461 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
462 /// leads to a \a DISubprogram.
464 /// If \c AlwaysPreserve, this variable will be referenced from its
465 /// containing subprogram, and will survive some optimizations.
466 DILocalVariable *createAutoVariable(DIScope *Scope, StringRef Name,
467 DIFile *File, unsigned LineNo,
469 bool AlwaysPreserve = false,
472 /// Create a new descriptor for a parameter variable.
474 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
475 /// leads to a \a DISubprogram.
477 /// \c ArgNo is the index (starting from \c 1) of this variable in the
478 /// subprogram parameters. \c ArgNo should not conflict with other
479 /// parameters of the same subprogram.
481 /// If \c AlwaysPreserve, this variable will be referenced from its
482 /// containing subprogram, and will survive some optimizations.
483 DILocalVariable *createParameterVariable(DIScope *Scope, StringRef Name,
484 unsigned ArgNo, DIFile *File,
485 unsigned LineNo, DIType *Ty,
486 bool AlwaysPreserve = false,
489 /// Create a new descriptor for the specified
490 /// variable which has a complex address expression for its address.
491 /// \param Addr An array of complex address operations.
492 DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
493 DIExpression *createExpression(ArrayRef<int64_t> Addr);
495 /// Create a descriptor to describe one part
496 /// of aggregate variable that is fragmented across multiple Values.
498 /// \param OffsetInBits Offset of the piece in bits.
499 /// \param SizeInBits Size of the piece in bits.
500 DIExpression *createBitPieceExpression(unsigned OffsetInBits,
501 unsigned SizeInBits);
503 /// Create a new descriptor for the specified subprogram.
504 /// See comments in DISubprogram* for descriptions of these fields.
505 /// \param Scope Function scope.
506 /// \param Name Function name.
507 /// \param LinkageName Mangled function name.
508 /// \param File File where this variable is defined.
509 /// \param LineNo Line number.
510 /// \param Ty Function type.
511 /// \param isLocalToUnit True if this function is not externally visible.
512 /// \param isDefinition True if this is a function definition.
513 /// \param ScopeLine Set to the beginning of the scope this starts
514 /// \param Flags e.g. is this function prototyped or not.
515 /// These flags are used to emit dwarf attributes.
516 /// \param isOptimized True if optimization is ON.
517 /// \param Fn llvm::Function pointer.
518 /// \param TParam Function template parameters.
520 createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
521 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
522 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
523 unsigned Flags = 0, bool isOptimized = false,
524 Function *Fn = nullptr, MDNode *TParam = nullptr,
525 MDNode *Decl = nullptr);
527 /// Identical to createFunction,
528 /// except that the resulting DbgNode is meant to be RAUWed.
529 DISubprogram *createTempFunctionFwdDecl(
530 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
531 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
532 bool isDefinition, unsigned ScopeLine, unsigned Flags = 0,
533 bool isOptimized = false, Function *Fn = nullptr,
534 MDNode *TParam = nullptr, MDNode *Decl = nullptr);
536 /// FIXME: this is added for dragonegg. Once we update dragonegg
537 /// to call resolve function, this will be removed.
539 createFunction(DIScopeRef Scope, StringRef Name, StringRef LinkageName,
540 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
541 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
542 unsigned Flags = 0, bool isOptimized = false,
543 Function *Fn = nullptr, MDNode *TParam = nullptr,
544 MDNode *Decl = nullptr);
546 /// Create a new descriptor for the specified C++ method.
547 /// See comments in \a DISubprogram* for descriptions of these fields.
548 /// \param Scope Function scope.
549 /// \param Name Function name.
550 /// \param LinkageName Mangled function name.
551 /// \param File File where this variable is defined.
552 /// \param LineNo Line number.
553 /// \param Ty Function type.
554 /// \param isLocalToUnit True if this function is not externally visible..
555 /// \param isDefinition True if this is a function definition.
556 /// \param Virtuality Attributes describing virtualness. e.g. pure
557 /// virtual function.
558 /// \param VTableIndex Index no of this method in virtual table.
559 /// \param VTableHolder Type that holds vtable.
560 /// \param Flags e.g. is this function prototyped or not.
561 /// This flags are used to emit dwarf attributes.
562 /// \param isOptimized True if optimization is ON.
563 /// \param Fn llvm::Function pointer.
564 /// \param TParam Function template parameters.
566 createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
567 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
568 bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0,
569 unsigned VTableIndex = 0, DIType *VTableHolder = nullptr,
570 unsigned Flags = 0, bool isOptimized = false,
571 Function *Fn = nullptr, MDNode *TParam = nullptr);
573 /// This creates new descriptor for a namespace with the specified
575 /// \param Scope Namespace scope
576 /// \param Name Name of this namespace
577 /// \param File Source file
578 /// \param LineNo Line number
579 DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
582 /// This creates new descriptor for a module with the specified
584 /// \param Scope Parent scope
585 /// \param Name Name of this module
586 /// \param ConfigurationMacros
587 /// A space-separated shell-quoted list of -D macro
588 /// definitions as they would appear on a command line.
589 /// \param IncludePath The path to the module map file.
590 /// \param ISysRoot The clang system root (value of -isysroot).
591 DIModule *createModule(DIScope *Scope, StringRef Name,
592 StringRef ConfigurationMacros,
593 StringRef IncludePath,
596 /// This creates a descriptor for a lexical block with a new file
597 /// attached. This merely extends the existing
598 /// lexical block as it crosses a file.
599 /// \param Scope Lexical block.
600 /// \param File Source file.
601 /// \param Discriminator DWARF path discriminator value.
602 DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
603 unsigned Discriminator = 0);
605 /// This creates a descriptor for a lexical block with the
606 /// specified parent context.
607 /// \param Scope Parent lexical scope.
608 /// \param File Source file.
609 /// \param Line Line number.
610 /// \param Col Column number.
611 DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
612 unsigned Line, unsigned Col);
614 /// Create a descriptor for an imported module.
615 /// \param Context The scope this module is imported into
616 /// \param NS The namespace being imported here
617 /// \param Line Line number
618 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
621 /// Create a descriptor for an imported module.
622 /// \param Context The scope this module is imported into
623 /// \param NS An aliased namespace
624 /// \param Line Line number
625 DIImportedEntity *createImportedModule(DIScope *Context,
626 DIImportedEntity *NS, unsigned Line);
628 /// Create a descriptor for an imported module.
629 /// \param Context The scope this module is imported into
630 /// \param M The module being imported here
631 /// \param Line Line number
632 DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
635 /// Create a descriptor for an imported function.
636 /// \param Context The scope this module is imported into
637 /// \param Decl The declaration (or definition) of a function, type, or
639 /// \param Line Line number
640 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
642 StringRef Name = "");
644 /// Insert a new llvm.dbg.declare intrinsic call.
645 /// \param Storage llvm::Value of the variable
646 /// \param VarInfo Variable's debug info descriptor.
647 /// \param Expr A complex location expression.
648 /// \param DL Debug info location.
649 /// \param InsertAtEnd Location for the new intrinsic.
650 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
651 DIExpression *Expr, const DILocation *DL,
652 BasicBlock *InsertAtEnd);
654 /// Insert a new llvm.dbg.declare intrinsic call.
655 /// \param Storage llvm::Value of the variable
656 /// \param VarInfo Variable's debug info descriptor.
657 /// \param Expr A complex location expression.
658 /// \param DL Debug info location.
659 /// \param InsertBefore Location for the new intrinsic.
660 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
661 DIExpression *Expr, const DILocation *DL,
662 Instruction *InsertBefore);
664 /// Insert a new llvm.dbg.value intrinsic call.
665 /// \param Val llvm::Value of the variable
666 /// \param Offset Offset
667 /// \param VarInfo Variable's debug info descriptor.
668 /// \param Expr A complex location expression.
669 /// \param DL Debug info location.
670 /// \param InsertAtEnd Location for the new intrinsic.
671 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
672 DILocalVariable *VarInfo,
674 const DILocation *DL,
675 BasicBlock *InsertAtEnd);
677 /// Insert a new llvm.dbg.value intrinsic call.
678 /// \param Val llvm::Value of the variable
679 /// \param Offset Offset
680 /// \param VarInfo Variable's debug info descriptor.
681 /// \param Expr A complex location expression.
682 /// \param DL Debug info location.
683 /// \param InsertBefore Location for the new intrinsic.
684 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
685 DILocalVariable *VarInfo,
687 const DILocation *DL,
688 Instruction *InsertBefore);
690 /// Replace the vtable holder in the given composite type.
692 /// If this creates a self reference, it may orphan some unresolved cycles
693 /// in the operands of \c T, so \a DIBuilder needs to track that.
694 void replaceVTableHolder(DICompositeType *&T,
695 DICompositeType *VTableHolder);
697 /// Replace arrays on a composite type.
699 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
700 /// has a self-reference -- \a DIBuilder needs to track the array to
702 void replaceArrays(DICompositeType *&T, DINodeArray Elements,
703 DINodeArray TParams = DINodeArray());
705 /// Replace a temporary node.
707 /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
710 /// If \c Replacement is the same as \c N.get(), instead call \a
711 /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
712 /// have a different address, so we return the final address.
713 template <class NodeTy>
714 NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
715 if (N.get() == Replacement)
716 return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
718 N->replaceAllUsesWith(Replacement);
722 } // end namespace llvm