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