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/IR/DebugInfo.h"
19 #include "llvm/IR/TrackingMDRef.h"
20 #include "llvm/IR/ValueHandle.h"
21 #include "llvm/Support/DataTypes.h"
32 template <typename T> class ArrayRef;
36 LLVMContext &VMContext;
38 DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
39 Function *DeclareFn; ///< llvm.dbg.declare
40 Function *ValueFn; ///< llvm.dbg.value
42 SmallVector<Metadata *, 4> AllEnumTypes;
43 /// Track the RetainTypes, since they can be updated later on.
44 SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
45 SmallVector<Metadata *, 4> AllSubprograms;
46 SmallVector<Metadata *, 4> AllGVs;
47 SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
49 /// Track nodes that may be unresolved.
50 SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
51 bool AllowUnresolvedNodes;
53 /// Each subprogram's preserved local variables.
55 /// Do not use a std::vector. Some versions of libc++ apparently copy
56 /// instead of move on grow operations, and TrackingMDRef is expensive to
58 DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
60 DIBuilder(const DIBuilder &) = delete;
61 void operator=(const DIBuilder &) = delete;
63 /// Create a temporary.
65 /// Create an \a temporary node and track it in \a UnresolvedNodes.
66 void trackIfUnresolved(MDNode *N);
69 /// Construct a builder for a module.
71 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
72 /// in order to resolve cycles during \a finalize().
73 explicit DIBuilder(Module &M, bool AllowUnresolved = true);
75 /// Construct any deferred debug info descriptors.
78 /// A CompileUnit provides an anchor for all debugging
79 /// information generated during this instance of compilation.
80 /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
81 /// \param File File name
82 /// \param Dir Directory
83 /// \param Producer Identify the producer of debugging information
84 /// and code. Usually this is a compiler
86 /// \param isOptimized A boolean flag which indicates whether optimization
87 /// is enabled or not.
88 /// \param Flags This string lists command line options. This
89 /// string is directly embedded in debug info
90 /// output which may be used by a tool
91 /// analyzing generated debugging information.
92 /// \param RV This indicates runtime version for languages like
94 /// \param SplitName The name of the file that we'll split debug info
96 /// \param Kind The kind of debug information to generate.
97 /// \param DWOId The DWOId if this is a split skeleton compile unit.
99 createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
100 StringRef Producer, bool isOptimized, StringRef Flags,
101 unsigned RV, StringRef SplitName = StringRef(),
102 DICompileUnit::DebugEmissionKind Kind =
103 DICompileUnit::DebugEmissionKind::FullDebug,
104 uint64_t DWOId = 0, bool SplitDebugInlining = true);
106 /// Create a file descriptor to hold debugging information
108 DIFile *createFile(StringRef Filename, StringRef Directory);
110 /// Create a single enumerator value.
111 DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
113 /// Create a DWARF unspecified type.
114 DIBasicType *createUnspecifiedType(StringRef Name);
116 /// Create C++11 nullptr type.
117 DIBasicType *createNullPtrType();
119 /// Create debugging information entry for a basic
121 /// \param Name Type name.
122 /// \param SizeInBits Size of the type.
123 /// \param AlignInBits Type alignment.
124 /// \param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
125 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
126 uint64_t AlignInBits, unsigned Encoding);
128 /// Create debugging information entry for a qualified
129 /// type, e.g. 'const int'.
130 /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
131 /// \param FromTy Base Type.
132 DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
134 /// Create debugging information entry for a pointer.
135 /// \param PointeeTy Type pointed by this pointer.
136 /// \param SizeInBits Size.
137 /// \param AlignInBits Alignment. (optional)
138 /// \param Name Pointer type name. (optional)
139 DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
140 uint64_t AlignInBits = 0,
141 StringRef Name = "");
143 /// Create debugging information entry for a pointer to member.
144 /// \param PointeeTy Type pointed to by this pointer.
145 /// \param SizeInBits Size.
146 /// \param AlignInBits Alignment. (optional)
147 /// \param Class Type for which this pointer points to members of.
149 createMemberPointerType(DIType *PointeeTy, DIType *Class,
150 uint64_t SizeInBits, uint64_t AlignInBits = 0,
151 DINode::DIFlags Flags = DINode::FlagZero);
153 /// Create debugging information entry for a c++
154 /// style reference or rvalue reference type.
155 DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy,
156 uint64_t SizeInBits = 0,
157 uint64_t AlignInBits = 0);
159 /// Create debugging information entry for a typedef.
160 /// \param Ty Original type.
161 /// \param Name Typedef name.
162 /// \param File File where this type is defined.
163 /// \param LineNo Line number.
164 /// \param Context The surrounding context for the typedef.
165 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
166 unsigned LineNo, DIScope *Context);
168 /// Create debugging information entry for a 'friend'.
169 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
171 /// Create debugging information entry to establish
172 /// inheritance relationship between two types.
173 /// \param Ty Original type.
174 /// \param BaseTy Base type. Ty is inherits from base.
175 /// \param BaseOffset Base offset.
176 /// \param Flags Flags to describe inheritance attribute,
178 DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
180 DINode::DIFlags Flags);
182 /// Create debugging information entry for a member.
183 /// \param Scope Member scope.
184 /// \param Name Member name.
185 /// \param File File where this member is defined.
186 /// \param LineNo Line number.
187 /// \param SizeInBits Member size.
188 /// \param AlignInBits Member alignment.
189 /// \param OffsetInBits Member offset.
190 /// \param Flags Flags to encode member attribute, e.g. private
191 /// \param Ty Parent type.
192 DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
193 DIFile *File, unsigned LineNo,
194 uint64_t SizeInBits, uint64_t AlignInBits,
195 uint64_t OffsetInBits,
196 DINode::DIFlags Flags, DIType *Ty);
198 /// Create debugging information entry for a bit field member.
199 /// \param Scope Member scope.
200 /// \param Name Member name.
201 /// \param File File where this member is defined.
202 /// \param LineNo Line number.
203 /// \param SizeInBits Member size.
204 /// \param AlignInBits Member alignment.
205 /// \param OffsetInBits Member offset.
206 /// \param StorageOffsetInBits Member storage offset.
207 /// \param Flags Flags to encode member attribute.
208 /// \param Ty Parent type.
209 DIDerivedType *createBitFieldMemberType(
210 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
211 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
212 uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty);
214 /// Create debugging information entry for a
215 /// C++ static data member.
216 /// \param Scope Member scope.
217 /// \param Name Member name.
218 /// \param File File where this member is declared.
219 /// \param LineNo Line number.
220 /// \param Ty Type of the static member.
221 /// \param Flags Flags to encode member attribute, e.g. private.
222 /// \param Val Const initializer of the member.
223 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
224 DIFile *File, unsigned LineNo,
225 DIType *Ty, DINode::DIFlags Flags,
226 llvm::Constant *Val);
228 /// Create debugging information entry for Objective-C
229 /// instance variable.
230 /// \param Name Member name.
231 /// \param File File where this member is defined.
232 /// \param LineNo Line number.
233 /// \param SizeInBits Member size.
234 /// \param AlignInBits Member alignment.
235 /// \param OffsetInBits Member offset.
236 /// \param Flags Flags to encode member attribute, e.g. private
237 /// \param Ty Parent type.
238 /// \param PropertyNode Property associated with this ivar.
239 DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
240 uint64_t SizeInBits, uint64_t AlignInBits,
241 uint64_t OffsetInBits, DINode::DIFlags Flags,
242 DIType *Ty, MDNode *PropertyNode);
244 /// Create debugging information entry for Objective-C
246 /// \param Name Property name.
247 /// \param File File where this property is defined.
248 /// \param LineNumber Line number.
249 /// \param GetterName Name of the Objective C property getter selector.
250 /// \param SetterName Name of the Objective C property setter selector.
251 /// \param PropertyAttributes Objective C property attributes.
253 DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
255 StringRef GetterName,
256 StringRef SetterName,
257 unsigned PropertyAttributes, DIType *Ty);
259 /// Create debugging information entry for a class.
260 /// \param Scope Scope in which this class is defined.
261 /// \param Name class name.
262 /// \param File File where this member is defined.
263 /// \param LineNumber Line number.
264 /// \param SizeInBits Member size.
265 /// \param AlignInBits Member alignment.
266 /// \param OffsetInBits Member offset.
267 /// \param Flags Flags to encode member attribute, e.g. private
268 /// \param Elements class members.
269 /// \param VTableHolder Debug info of the base class that contains vtable
270 /// for this type. This is used in
271 /// DW_AT_containing_type. See DWARF documentation
273 /// \param TemplateParms Template type parameters.
274 /// \param UniqueIdentifier A unique identifier for the class.
275 DICompositeType *createClassType(
276 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
277 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
278 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
279 DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
280 StringRef UniqueIdentifier = "");
282 /// Create debugging information entry for a struct.
283 /// \param Scope Scope in which this struct is defined.
284 /// \param Name Struct name.
285 /// \param File File where this member is defined.
286 /// \param LineNumber Line number.
287 /// \param SizeInBits Member size.
288 /// \param AlignInBits Member alignment.
289 /// \param Flags Flags to encode member attribute, e.g. private
290 /// \param Elements Struct elements.
291 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
292 /// \param UniqueIdentifier A unique identifier for the struct.
293 DICompositeType *createStructType(
294 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
295 uint64_t SizeInBits, uint64_t AlignInBits, DINode::DIFlags Flags,
296 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
297 DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
299 /// Create debugging information entry for an union.
300 /// \param Scope Scope in which this union is defined.
301 /// \param Name Union name.
302 /// \param File File where this member is defined.
303 /// \param LineNumber Line number.
304 /// \param SizeInBits Member size.
305 /// \param AlignInBits Member alignment.
306 /// \param Flags Flags to encode member attribute, e.g. private
307 /// \param Elements Union elements.
308 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
309 /// \param UniqueIdentifier A unique identifier for the union.
310 DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
311 DIFile *File, unsigned LineNumber,
312 uint64_t SizeInBits, uint64_t AlignInBits,
313 DINode::DIFlags Flags,
314 DINodeArray Elements,
315 unsigned RunTimeLang = 0,
316 StringRef UniqueIdentifier = "");
318 /// Create debugging information for template
320 /// \param Scope Scope in which this type is defined.
321 /// \param Name Type parameter name.
322 /// \param Ty Parameter type.
323 DITemplateTypeParameter *
324 createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
326 /// Create debugging information for template
328 /// \param Scope Scope in which this type is defined.
329 /// \param Name Value parameter name.
330 /// \param Ty Parameter type.
331 /// \param Val Constant parameter value.
332 DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
337 /// Create debugging information for a template template parameter.
338 /// \param Scope Scope in which this type is defined.
339 /// \param Name Value parameter name.
340 /// \param Ty Parameter type.
341 /// \param Val The fully qualified name of the template.
342 DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
347 /// Create debugging information for a template parameter pack.
348 /// \param Scope Scope in which this type is defined.
349 /// \param Name Value parameter name.
350 /// \param Ty Parameter type.
351 /// \param Val An array of types in the pack.
352 DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
357 /// Create debugging information entry for an array.
358 /// \param Size Array size.
359 /// \param AlignInBits Alignment.
360 /// \param Ty Element type.
361 /// \param Subscripts Subscripts.
362 DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
363 DIType *Ty, DINodeArray Subscripts);
365 /// Create debugging information entry for a vector type.
366 /// \param Size Array size.
367 /// \param AlignInBits Alignment.
368 /// \param Ty Element type.
369 /// \param Subscripts Subscripts.
370 DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
371 DIType *Ty, DINodeArray Subscripts);
373 /// Create debugging information entry for an
375 /// \param Scope Scope in which this enumeration is defined.
376 /// \param Name Union name.
377 /// \param File File where this member is defined.
378 /// \param LineNumber Line number.
379 /// \param SizeInBits Member size.
380 /// \param AlignInBits Member alignment.
381 /// \param Elements Enumeration elements.
382 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
383 /// \param UniqueIdentifier A unique identifier for the enum.
384 DICompositeType *createEnumerationType(
385 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
386 uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
387 DIType *UnderlyingType, StringRef UniqueIdentifier = "");
389 /// Create subroutine type.
390 /// \param ParameterTypes An array of subroutine parameter types. This
391 /// includes return type at 0th index.
392 /// \param Flags E.g.: LValueReference.
393 /// These flags are used to emit dwarf attributes.
394 /// \param CC Calling convention, e.g. dwarf::DW_CC_normal
396 createSubroutineType(DITypeRefArray ParameterTypes,
397 DINode::DIFlags Flags = DINode::FlagZero,
400 /// Create an external type reference.
401 /// \param Tag Dwarf TAG.
402 /// \param File File in which the type is defined.
403 /// \param UniqueIdentifier A unique identifier for the type.
404 DICompositeType *createExternalTypeRef(unsigned Tag, DIFile *File,
405 StringRef UniqueIdentifier);
407 /// Create a new DIType* with "artificial" flag set.
408 DIType *createArtificialType(DIType *Ty);
410 /// Create a new DIType* with the "object pointer"
412 DIType *createObjectPointerType(DIType *Ty);
414 /// Create a permanent forward-declared type.
415 DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
416 DIScope *Scope, DIFile *F, unsigned Line,
417 unsigned RuntimeLang = 0,
418 uint64_t SizeInBits = 0,
419 uint64_t AlignInBits = 0,
420 StringRef UniqueIdentifier = "");
422 /// Create a temporary forward-declared type.
423 DICompositeType *createReplaceableCompositeType(
424 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
425 unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
426 uint64_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
427 StringRef UniqueIdentifier = "");
429 /// Retain DIScope* in a module even if it is not referenced
430 /// through debug info anchors.
431 void retainType(DIScope *T);
433 /// Create unspecified parameter type
434 /// for a subroutine type.
435 DIBasicType *createUnspecifiedParameter();
437 /// Get a DINodeArray, create one if required.
438 DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
440 /// Get a DITypeRefArray, create one if required.
441 DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
443 /// Create a descriptor for a value range. This
444 /// implicitly uniques the values returned.
445 DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
447 /// Create a new descriptor for the specified
449 /// \param Context Variable scope.
450 /// \param Name Name of the variable.
451 /// \param LinkageName Mangled name of the variable.
452 /// \param File File where this variable is defined.
453 /// \param LineNo Line number.
454 /// \param Ty Variable Type.
455 /// \param isLocalToUnit Boolean flag indicate whether this variable is
456 /// externally visible or not.
457 /// \param Expr The location of the global relative to the attached
459 /// \param Decl Reference to the corresponding declaration.
460 DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
461 StringRef LinkageName, DIFile *File,
462 unsigned LineNo, DIType *Ty,
464 DIExpression *Expr = nullptr,
465 MDNode *Decl = nullptr);
467 /// Identical to createGlobalVariable
468 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
469 DIGlobalVariable *createTempGlobalVariableFwdDecl(
470 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
471 unsigned LineNo, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
472 MDNode *Decl = nullptr);
474 /// Create a new descriptor for an auto variable. This is a local variable
475 /// that is not a subprogram parameter.
477 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
478 /// leads to a \a DISubprogram.
480 /// If \c AlwaysPreserve, this variable will be referenced from its
481 /// containing subprogram, and will survive some optimizations.
483 createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
484 unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
485 DINode::DIFlags Flags = DINode::FlagZero);
487 /// Create a new descriptor for a parameter variable.
489 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
490 /// leads to a \a DISubprogram.
492 /// \c ArgNo is the index (starting from \c 1) of this variable in the
493 /// subprogram parameters. \c ArgNo should not conflict with other
494 /// parameters of the same subprogram.
496 /// If \c AlwaysPreserve, this variable will be referenced from its
497 /// containing subprogram, and will survive some optimizations.
499 createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
500 DIFile *File, unsigned LineNo, DIType *Ty,
501 bool AlwaysPreserve = false,
502 DINode::DIFlags Flags = DINode::FlagZero);
504 /// Create a new descriptor for the specified
505 /// variable which has a complex address expression for its address.
506 /// \param Addr An array of complex address operations.
507 DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
508 DIExpression *createExpression(ArrayRef<int64_t> Addr);
510 /// Create a descriptor to describe one part
511 /// of aggregate variable that is fragmented across multiple Values.
513 /// \param OffsetInBits Offset of the piece in bits.
514 /// \param SizeInBits Size of the piece in bits.
515 DIExpression *createBitPieceExpression(unsigned OffsetInBits,
516 unsigned SizeInBits);
518 /// Create an expression for a variable that does not have an address, but
519 /// does have a constant value.
520 DIExpression *createConstantValueExpression(uint64_t Val) {
521 return DIExpression::get(
522 VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
525 /// Create a new descriptor for the specified subprogram.
526 /// See comments in DISubprogram* for descriptions of these fields.
527 /// \param Scope Function scope.
528 /// \param Name Function name.
529 /// \param LinkageName Mangled function name.
530 /// \param File File where this variable is defined.
531 /// \param LineNo Line number.
532 /// \param Ty Function type.
533 /// \param isLocalToUnit True if this function is not externally visible.
534 /// \param isDefinition True if this is a function definition.
535 /// \param ScopeLine Set to the beginning of the scope this starts
536 /// \param Flags e.g. is this function prototyped or not.
537 /// These flags are used to emit dwarf attributes.
538 /// \param isOptimized True if optimization is ON.
539 /// \param TParams Function template parameters.
540 DISubprogram *createFunction(DIScope *Scope, StringRef Name,
541 StringRef LinkageName, DIFile *File,
542 unsigned LineNo, DISubroutineType *Ty,
543 bool isLocalToUnit, bool isDefinition,
545 DINode::DIFlags Flags = DINode::FlagZero,
546 bool isOptimized = false,
547 DITemplateParameterArray TParams = nullptr,
548 DISubprogram *Decl = nullptr);
550 /// Identical to createFunction,
551 /// except that the resulting DbgNode is meant to be RAUWed.
552 DISubprogram *createTempFunctionFwdDecl(
553 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
554 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
555 bool isDefinition, unsigned ScopeLine,
556 DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
557 DITemplateParameterArray TParams = nullptr,
558 DISubprogram *Decl = nullptr);
560 /// Create a new descriptor for the specified C++ method.
561 /// See comments in \a DISubprogram* for descriptions of these fields.
562 /// \param Scope Function scope.
563 /// \param Name Function name.
564 /// \param LinkageName Mangled function name.
565 /// \param File File where this variable is defined.
566 /// \param LineNo Line number.
567 /// \param Ty Function type.
568 /// \param isLocalToUnit True if this function is not externally visible..
569 /// \param isDefinition True if this is a function definition.
570 /// \param Virtuality Attributes describing virtualness. e.g. pure
571 /// virtual function.
572 /// \param VTableIndex Index no of this method in virtual table, or -1u if
574 /// \param ThisAdjustment
575 /// MS ABI-specific adjustment of 'this' that occurs
577 /// \param VTableHolder Type that holds vtable.
578 /// \param Flags e.g. is this function prototyped or not.
579 /// This flags are used to emit dwarf attributes.
580 /// \param isOptimized True if optimization is ON.
581 /// \param TParams Function template parameters.
582 DISubprogram *createMethod(
583 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
584 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
585 bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0,
586 int ThisAdjustment = 0, DIType *VTableHolder = nullptr,
587 DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
588 DITemplateParameterArray TParams = nullptr);
590 /// This creates new descriptor for a namespace with the specified
592 /// \param Scope Namespace scope
593 /// \param Name Name of this namespace
594 /// \param File Source file
595 /// \param LineNo Line number
596 DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
599 /// This creates new descriptor for a module with the specified
601 /// \param Scope Parent scope
602 /// \param Name Name of this module
603 /// \param ConfigurationMacros
604 /// A space-separated shell-quoted list of -D macro
605 /// definitions as they would appear on a command line.
606 /// \param IncludePath The path to the module map file.
607 /// \param ISysRoot The clang system root (value of -isysroot).
608 DIModule *createModule(DIScope *Scope, StringRef Name,
609 StringRef ConfigurationMacros,
610 StringRef IncludePath,
613 /// This creates a descriptor for a lexical block with a new file
614 /// attached. This merely extends the existing
615 /// lexical block as it crosses a file.
616 /// \param Scope Lexical block.
617 /// \param File Source file.
618 /// \param Discriminator DWARF path discriminator value.
619 DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
620 unsigned Discriminator = 0);
622 /// This creates a descriptor for a lexical block with the
623 /// specified parent context.
624 /// \param Scope Parent lexical scope.
625 /// \param File Source file.
626 /// \param Line Line number.
627 /// \param Col Column number.
628 DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
629 unsigned Line, unsigned Col);
631 /// Create a descriptor for an imported module.
632 /// \param Context The scope this module is imported into
633 /// \param NS The namespace being imported here
634 /// \param Line Line number
635 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
638 /// Create a descriptor for an imported module.
639 /// \param Context The scope this module is imported into
640 /// \param NS An aliased namespace
641 /// \param Line Line number
642 DIImportedEntity *createImportedModule(DIScope *Context,
643 DIImportedEntity *NS, unsigned Line);
645 /// Create a descriptor for an imported module.
646 /// \param Context The scope this module is imported into
647 /// \param M The module being imported here
648 /// \param Line Line number
649 DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
652 /// Create a descriptor for an imported function.
653 /// \param Context The scope this module is imported into
654 /// \param Decl The declaration (or definition) of a function, type, or
656 /// \param Line Line number
657 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
659 StringRef Name = "");
661 /// Insert a new llvm.dbg.declare intrinsic call.
662 /// \param Storage llvm::Value of the variable
663 /// \param VarInfo Variable's debug info descriptor.
664 /// \param Expr A complex location expression.
665 /// \param DL Debug info location.
666 /// \param InsertAtEnd Location for the new intrinsic.
667 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
668 DIExpression *Expr, const DILocation *DL,
669 BasicBlock *InsertAtEnd);
671 /// Insert a new llvm.dbg.declare intrinsic call.
672 /// \param Storage llvm::Value of the variable
673 /// \param VarInfo Variable's debug info descriptor.
674 /// \param Expr A complex location expression.
675 /// \param DL Debug info location.
676 /// \param InsertBefore Location for the new intrinsic.
677 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
678 DIExpression *Expr, const DILocation *DL,
679 Instruction *InsertBefore);
681 /// Insert a new llvm.dbg.value intrinsic call.
682 /// \param Val llvm::Value of the variable
683 /// \param Offset Offset
684 /// \param VarInfo Variable's debug info descriptor.
685 /// \param Expr A complex location expression.
686 /// \param DL Debug info location.
687 /// \param InsertAtEnd Location for the new intrinsic.
688 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
689 DILocalVariable *VarInfo,
691 const DILocation *DL,
692 BasicBlock *InsertAtEnd);
694 /// Insert a new llvm.dbg.value intrinsic call.
695 /// \param Val llvm::Value of the variable
696 /// \param Offset Offset
697 /// \param VarInfo Variable's debug info descriptor.
698 /// \param Expr A complex location expression.
699 /// \param DL Debug info location.
700 /// \param InsertBefore Location for the new intrinsic.
701 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
702 DILocalVariable *VarInfo,
704 const DILocation *DL,
705 Instruction *InsertBefore);
707 /// Replace the vtable holder in the given composite type.
709 /// If this creates a self reference, it may orphan some unresolved cycles
710 /// in the operands of \c T, so \a DIBuilder needs to track that.
711 void replaceVTableHolder(DICompositeType *&T,
712 DICompositeType *VTableHolder);
714 /// Replace arrays on a composite type.
716 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
717 /// has a self-reference -- \a DIBuilder needs to track the array to
719 void replaceArrays(DICompositeType *&T, DINodeArray Elements,
720 DINodeArray TParams = DINodeArray());
722 /// Replace a temporary node.
724 /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
727 /// If \c Replacement is the same as \c N.get(), instead call \a
728 /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
729 /// have a different address, so we return the final address.
730 template <class NodeTy>
731 NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
732 if (N.get() == Replacement)
733 return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
735 N->replaceAllUsesWith(Replacement);
739 } // end namespace llvm