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 /// \brief 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 /// \brief Create a temporary.
62 /// Create an \a temporary node and track it in \a UnresolvedNodes.
63 void trackIfUnresolved(MDNode *N);
66 /// \brief 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 /// finalize - Construct any deferred debug info descriptors.
76 /// createCompileUnit - 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 and code.
82 /// Usually this is a compiler version string.
83 /// @param isOptimized A boolean flag which indicates whether optimization
85 /// @param Flags This string lists command line options. This string is
86 /// directly embedded in debug info output which may be used
87 /// by a tool analyzing generated debugging information.
88 /// @param RV This indicates runtime version for languages like
90 /// @param SplitName The name of the file that we'll split debug info out
92 /// @param Kind The kind of debug information to generate.
93 /// @param DWOId The DWOId if this is a split skeleton compile unit.
94 /// @param EmitDebugInfo A boolean flag which indicates whether debug
95 /// information should be written to the final
96 /// output or not. When this is false, debug
97 /// information annotations will be present in
98 /// the IL but they are not written to the final
99 /// assembly or object file. This supports tracking
100 /// source location information in the back end
101 /// without actually changing the output (e.g.,
102 /// when using optimization remarks).
104 createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
105 StringRef Producer, bool isOptimized, StringRef Flags,
106 unsigned RV, StringRef SplitName = StringRef(),
107 DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0,
108 bool EmitDebugInfo = true);
110 /// createFile - Create a file descriptor to hold debugging information
112 DIFile *createFile(StringRef Filename, StringRef Directory);
114 /// createEnumerator - Create a single enumerator value.
115 DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
117 /// \brief Create a DWARF unspecified type.
118 DIBasicType *createUnspecifiedType(StringRef Name);
120 /// \brief Create C++11 nullptr type.
121 DIBasicType *createNullPtrType();
123 /// createBasicType - Create debugging information entry for a basic
125 /// @param Name Type name.
126 /// @param SizeInBits Size of the type.
127 /// @param AlignInBits Type alignment.
128 /// @param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
129 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
130 uint64_t AlignInBits, unsigned Encoding);
132 /// createQualifiedType - Create debugging information entry for a qualified
133 /// type, e.g. 'const int'.
134 /// @param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
135 /// @param FromTy Base Type.
136 DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
138 /// createPointerType - Create debugging information entry for a pointer.
139 /// @param PointeeTy Type pointed by this pointer.
140 /// @param SizeInBits Size.
141 /// @param AlignInBits Alignment. (optional)
142 /// @param Name Pointer type name. (optional)
143 DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
144 uint64_t AlignInBits = 0,
145 StringRef Name = "");
147 /// \brief Create debugging information entry for a pointer to member.
148 /// @param PointeeTy Type pointed to by this pointer.
149 /// @param SizeInBits Size.
150 /// @param AlignInBits Alignment. (optional)
151 /// @param Class Type for which this pointer points to members of.
152 DIDerivedType *createMemberPointerType(DIType *PointeeTy, DIType *Class,
154 uint64_t AlignInBits = 0);
156 /// createReferenceType - Create debugging information entry for a c++
157 /// style reference or rvalue reference type.
158 DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy);
160 /// createTypedef - Create debugging information entry for a typedef.
161 /// @param Ty Original type.
162 /// @param Name Typedef name.
163 /// @param File File where this type is defined.
164 /// @param LineNo Line number.
165 /// @param Context The surrounding context for the typedef.
166 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
167 unsigned LineNo, DIScope *Context);
169 /// createFriend - Create debugging information entry for a 'friend'.
170 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
172 /// createInheritance - Create debugging information entry to establish
173 /// inheritance relationship between two types.
174 /// @param Ty Original type.
175 /// @param BaseTy Base type. Ty is inherits from base.
176 /// @param BaseOffset Base offset.
177 /// @param Flags Flags to describe inheritance attribute,
179 DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
180 uint64_t BaseOffset, unsigned Flags);
182 /// createMemberType - 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, unsigned Flags,
198 /// createStaticMemberType - Create debugging information entry for a
199 /// C++ static data member.
200 /// @param Scope Member scope.
201 /// @param Name Member name.
202 /// @param File File where this member is declared.
203 /// @param LineNo Line number.
204 /// @param Ty Type of the static member.
205 /// @param Flags Flags to encode member attribute, e.g. private.
206 /// @param Val Const initializer of the member.
207 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
208 DIFile *File, unsigned LineNo,
209 DIType *Ty, unsigned Flags,
210 llvm::Constant *Val);
212 /// createObjCIVar - Create debugging information entry for Objective-C
213 /// instance variable.
214 /// @param Name Member name.
215 /// @param File File where this member is defined.
216 /// @param LineNo Line number.
217 /// @param SizeInBits Member size.
218 /// @param AlignInBits Member alignment.
219 /// @param OffsetInBits Member offset.
220 /// @param Flags Flags to encode member attribute, e.g. private
221 /// @param Ty Parent type.
222 /// @param PropertyNode Property associated with this ivar.
223 DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
224 uint64_t SizeInBits, uint64_t AlignInBits,
225 uint64_t OffsetInBits, unsigned Flags,
226 DIType *Ty, MDNode *PropertyNode);
228 /// createObjCProperty - Create debugging information entry for Objective-C
230 /// @param Name Property name.
231 /// @param File File where this property is defined.
232 /// @param LineNumber Line number.
233 /// @param GetterName Name of the Objective C property getter selector.
234 /// @param SetterName Name of the Objective C property setter selector.
235 /// @param PropertyAttributes Objective C property attributes.
237 DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
239 StringRef GetterName,
240 StringRef SetterName,
241 unsigned PropertyAttributes, DIType *Ty);
243 /// createClassType - Create debugging information entry for a class.
244 /// @param Scope Scope in which this class is defined.
245 /// @param Name class name.
246 /// @param File File where this member is defined.
247 /// @param LineNumber Line number.
248 /// @param SizeInBits Member size.
249 /// @param AlignInBits Member alignment.
250 /// @param OffsetInBits Member offset.
251 /// @param Flags Flags to encode member attribute, e.g. private
252 /// @param Elements class members.
253 /// @param VTableHolder Debug info of the base class that contains vtable
254 /// for this type. This is used in
255 /// DW_AT_containing_type. See DWARF documentation
257 /// @param TemplateParms Template type parameters.
258 /// @param UniqueIdentifier A unique identifier for the class.
259 DICompositeType *createClassType(DIScope *Scope, StringRef Name,
260 DIFile *File, unsigned LineNumber,
261 uint64_t SizeInBits, uint64_t AlignInBits,
262 uint64_t OffsetInBits, unsigned Flags,
263 DIType *DerivedFrom, DINodeArray Elements,
264 DIType *VTableHolder = nullptr,
265 MDNode *TemplateParms = nullptr,
266 StringRef UniqueIdentifier = "");
268 /// createStructType - Create debugging information entry for a struct.
269 /// @param Scope Scope in which this struct is defined.
270 /// @param Name Struct name.
271 /// @param File File where this member is defined.
272 /// @param LineNumber Line number.
273 /// @param SizeInBits Member size.
274 /// @param AlignInBits Member alignment.
275 /// @param Flags Flags to encode member attribute, e.g. private
276 /// @param Elements Struct elements.
277 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
278 /// @param UniqueIdentifier A unique identifier for the struct.
279 DICompositeType *createStructType(
280 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
281 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
282 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
283 DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
285 /// createUnionType - Create debugging information entry for an union.
286 /// @param Scope Scope in which this union is defined.
287 /// @param Name Union name.
288 /// @param File File where this member is defined.
289 /// @param LineNumber Line number.
290 /// @param SizeInBits Member size.
291 /// @param AlignInBits Member alignment.
292 /// @param Flags Flags to encode member attribute, e.g. private
293 /// @param Elements Union elements.
294 /// @param RunTimeLang Optional parameter, Objective-C runtime version.
295 /// @param UniqueIdentifier A unique identifier for the union.
296 DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
297 DIFile *File, unsigned LineNumber,
298 uint64_t SizeInBits, uint64_t AlignInBits,
299 unsigned Flags, DINodeArray Elements,
300 unsigned RunTimeLang = 0,
301 StringRef UniqueIdentifier = "");
303 /// createTemplateTypeParameter - Create debugging information for template
305 /// @param Scope Scope in which this type is defined.
306 /// @param Name Type parameter name.
307 /// @param Ty Parameter type.
308 DITemplateTypeParameter *
309 createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
311 /// createTemplateValueParameter - Create debugging information for template
313 /// @param Scope Scope in which this type is defined.
314 /// @param Name Value parameter name.
315 /// @param Ty Parameter type.
316 /// @param Val Constant parameter value.
317 DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
322 /// \brief Create debugging information for a template template parameter.
323 /// @param Scope Scope in which this type is defined.
324 /// @param Name Value parameter name.
325 /// @param Ty Parameter type.
326 /// @param Val The fully qualified name of the template.
327 DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
332 /// \brief Create debugging information for a template parameter pack.
333 /// @param Scope Scope in which this type is defined.
334 /// @param Name Value parameter name.
335 /// @param Ty Parameter type.
336 /// @param Val An array of types in the pack.
337 DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
342 /// createArrayType - Create debugging information entry for an array.
343 /// @param Size Array size.
344 /// @param AlignInBits Alignment.
345 /// @param Ty Element type.
346 /// @param Subscripts Subscripts.
347 DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
348 DIType *Ty, DINodeArray Subscripts);
350 /// createVectorType - Create debugging information entry for a vector type.
351 /// @param Size Array size.
352 /// @param AlignInBits Alignment.
353 /// @param Ty Element type.
354 /// @param Subscripts Subscripts.
355 DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
356 DIType *Ty, DINodeArray Subscripts);
358 /// createEnumerationType - Create debugging information entry for an
360 /// @param Scope Scope in which this enumeration is defined.
361 /// @param Name Union name.
362 /// @param File File where this member is defined.
363 /// @param LineNumber Line number.
364 /// @param SizeInBits Member size.
365 /// @param AlignInBits Member alignment.
366 /// @param Elements Enumeration elements.
367 /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
368 /// @param UniqueIdentifier A unique identifier for the enum.
369 DICompositeType *createEnumerationType(
370 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
371 uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
372 DIType *UnderlyingType, StringRef UniqueIdentifier = "");
374 /// createSubroutineType - Create subroutine type.
375 /// @param File File in which this subroutine is defined.
376 /// @param ParameterTypes An array of subroutine parameter types. This
377 /// includes return type at 0th index.
378 /// @param Flags E.g.: LValueReference.
379 /// These flags are used to emit dwarf attributes.
380 DISubroutineType *createSubroutineType(DIFile *File,
381 DITypeRefArray ParameterTypes,
384 /// createArtificialType - Create a new DIType* with "artificial" flag set.
385 DIType *createArtificialType(DIType *Ty);
387 /// createObjectPointerType - Create a new DIType* with the "object pointer"
389 DIType *createObjectPointerType(DIType *Ty);
391 /// \brief Create a permanent forward-declared type.
392 DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
393 DIScope *Scope, DIFile *F, unsigned Line,
394 unsigned RuntimeLang = 0,
395 uint64_t SizeInBits = 0,
396 uint64_t AlignInBits = 0,
397 StringRef UniqueIdentifier = "");
399 /// \brief Create a temporary forward-declared type.
400 DICompositeType *createReplaceableCompositeType(
401 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
402 unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
403 uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl,
404 StringRef UniqueIdentifier = "");
406 /// retainType - Retain DIType* in a module even if it is not referenced
407 /// through debug info anchors.
408 void retainType(DIType *T);
410 /// createUnspecifiedParameter - Create unspecified parameter type
411 /// for a subroutine type.
412 DIBasicType *createUnspecifiedParameter();
414 /// getOrCreateArray - Get a DINodeArray, create one if required.
415 DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
417 /// getOrCreateTypeArray - Get a DITypeRefArray, create one if required.
418 DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
420 /// getOrCreateSubrange - Create a descriptor for a value range. This
421 /// implicitly uniques the values returned.
422 DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
424 /// createGlobalVariable - Create a new descriptor for the specified
426 /// @param Context Variable scope.
427 /// @param Name Name of the variable.
428 /// @param LinkageName Mangled name of the variable.
429 /// @param File File where this variable is defined.
430 /// @param LineNo Line number.
431 /// @param Ty Variable Type.
432 /// @param isLocalToUnit Boolean flag indicate whether this variable is
433 /// externally visible or not.
434 /// @param Val llvm::Value of the variable.
435 /// @param Decl Reference to the corresponding declaration.
436 DIGlobalVariable *createGlobalVariable(DIScope *Context, StringRef Name,
437 StringRef LinkageName, DIFile *File,
438 unsigned LineNo, DIType *Ty,
441 MDNode *Decl = nullptr);
443 /// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
444 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
445 DIGlobalVariable *createTempGlobalVariableFwdDecl(
446 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
447 unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
448 MDNode *Decl = nullptr);
450 /// createLocalVariable - Create a new descriptor for the specified
452 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
453 /// DW_TAG_arg_variable.
454 /// @param Scope Variable scope.
455 /// @param Name Variable name.
456 /// @param File File where this variable is defined.
457 /// @param LineNo Line number.
458 /// @param Ty Variable Type
459 /// @param AlwaysPreserve Boolean. Set to true if debug info for this
460 /// variable should be preserved in optimized build.
461 /// @param Flags Flags, e.g. artificial variable.
462 /// @param ArgNo If this variable is an argument then this argument's
463 /// number. 1 indicates 1st argument.
464 DILocalVariable *createLocalVariable(unsigned Tag, DIScope *Scope,
465 StringRef Name, DIFile *File,
466 unsigned LineNo, DIType *Ty,
467 bool AlwaysPreserve = false,
471 /// createExpression - Create a new descriptor for the specified
472 /// variable which has a complex address expression for its address.
473 /// @param Addr An array of complex address operations.
474 DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
475 DIExpression *createExpression(ArrayRef<int64_t> Addr);
477 /// createBitPieceExpression - Create a descriptor to describe one part
478 /// of aggregate variable that is fragmented across multiple Values.
480 /// @param OffsetInBits Offset of the piece in bits.
481 /// @param SizeInBits Size of the piece in bits.
482 DIExpression *createBitPieceExpression(unsigned OffsetInBits,
483 unsigned SizeInBits);
485 /// createFunction - Create a new descriptor for the specified subprogram.
486 /// See comments in DISubprogram* for descriptions of these fields.
487 /// @param Scope Function scope.
488 /// @param Name Function name.
489 /// @param LinkageName Mangled function name.
490 /// @param File File where this variable is defined.
491 /// @param LineNo Line number.
492 /// @param Ty Function type.
493 /// @param isLocalToUnit True if this function is not externally visible.
494 /// @param isDefinition True if this is a function definition.
495 /// @param ScopeLine Set to the beginning of the scope this starts
496 /// @param Flags e.g. is this function prototyped or not.
497 /// These flags are used to emit dwarf attributes.
498 /// @param isOptimized True if optimization is ON.
499 /// @param Fn llvm::Function pointer.
500 /// @param TParam Function template parameters.
502 createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
503 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
504 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
505 unsigned Flags = 0, bool isOptimized = false,
506 Function *Fn = nullptr, MDNode *TParam = nullptr,
507 MDNode *Decl = nullptr);
509 /// createTempFunctionFwdDecl - Identical to createFunction,
510 /// except that the resulting DbgNode is meant to be RAUWed.
511 DISubprogram *createTempFunctionFwdDecl(
512 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
513 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
514 bool isDefinition, unsigned ScopeLine, unsigned Flags = 0,
515 bool isOptimized = false, Function *Fn = nullptr,
516 MDNode *TParam = nullptr, MDNode *Decl = nullptr);
518 /// FIXME: this is added for dragonegg. Once we update dragonegg
519 /// to call resolve function, this will be removed.
521 createFunction(DIScopeRef Scope, StringRef Name, StringRef LinkageName,
522 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
523 bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
524 unsigned Flags = 0, bool isOptimized = false,
525 Function *Fn = nullptr, MDNode *TParam = nullptr,
526 MDNode *Decl = nullptr);
528 /// createMethod - Create a new descriptor for the specified C++ method.
529 /// See comments in DISubprogram* for descriptions of these fields.
530 /// @param Scope Function scope.
531 /// @param Name Function name.
532 /// @param LinkageName Mangled function name.
533 /// @param File File where this variable is defined.
534 /// @param LineNo Line number.
535 /// @param Ty Function type.
536 /// @param isLocalToUnit True if this function is not externally visible..
537 /// @param isDefinition True if this is a function definition.
538 /// @param Virtuality Attributes describing virtualness. e.g. pure
539 /// virtual function.
540 /// @param VTableIndex Index no of this method in virtual table.
541 /// @param VTableHolder Type that holds vtable.
542 /// @param Flags e.g. is this function prototyped or not.
543 /// This flags are used to emit dwarf attributes.
544 /// @param isOptimized True if optimization is ON.
545 /// @param Fn llvm::Function pointer.
546 /// @param TParam Function template parameters.
548 createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
549 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
550 bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0,
551 unsigned VTableIndex = 0, DIType *VTableHolder = nullptr,
552 unsigned Flags = 0, bool isOptimized = false,
553 Function *Fn = nullptr, MDNode *TParam = nullptr);
555 /// createNameSpace - This creates new descriptor for a namespace
556 /// with the specified parent scope.
557 /// @param Scope Namespace scope
558 /// @param Name Name of this namespace
559 /// @param File Source file
560 /// @param LineNo Line number
561 DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
564 /// createModule - This creates new descriptor for a module
565 /// with the specified parent scope.
566 /// @param Scope Parent scope
567 /// @param Name Name of this module
568 /// @param ConfigurationMacros
569 /// A space-separated shell-quoted list of -D macro
570 /// definitions as they would appear on a command line.
571 /// @param IncludePath The path to the module map file.
572 /// @param ISysRoot The clang system root (value of -isysroot).
573 DIModule *createModule(DIScope *Scope, StringRef Name,
574 StringRef ConfigurationMacros,
575 StringRef IncludePath,
578 /// createLexicalBlockFile - This creates a descriptor for a lexical
579 /// block with a new file attached. This merely extends the existing
580 /// lexical block as it crosses a file.
581 /// @param Scope Lexical block.
582 /// @param File Source file.
583 /// @param Discriminator DWARF path discriminator value.
584 DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
585 unsigned Discriminator = 0);
587 /// createLexicalBlock - This creates a descriptor for a lexical block
588 /// with the specified parent context.
589 /// @param Scope Parent lexical scope.
590 /// @param File Source file.
591 /// @param Line Line number.
592 /// @param Col Column number.
593 DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
594 unsigned Line, unsigned Col);
596 /// \brief Create a descriptor for an imported module.
597 /// @param Context The scope this module is imported into
598 /// @param NS The namespace being imported here
599 /// @param Line Line number
600 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
603 /// \brief Create a descriptor for an imported module.
604 /// @param Context The scope this module is imported into
605 /// @param NS An aliased namespace
606 /// @param Line Line number
607 DIImportedEntity *createImportedModule(DIScope *Context,
608 DIImportedEntity *NS, unsigned Line);
610 /// \brief Create a descriptor for an imported module.
611 /// @param Context The scope this module is imported into
612 /// @param M The module being imported here
613 /// @param Line Line number
614 DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
617 /// \brief Create a descriptor for an imported function.
618 /// @param Context The scope this module is imported into
619 /// @param Decl The declaration (or definition) of a function, type, or
621 /// @param Line Line number
622 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
624 StringRef Name = "");
626 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
627 /// @param Storage llvm::Value of the variable
628 /// @param VarInfo Variable's debug info descriptor.
629 /// @param Expr A complex location expression.
630 /// @param DL Debug info location.
631 /// @param InsertAtEnd Location for the new intrinsic.
632 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
633 DIExpression *Expr, const DILocation *DL,
634 BasicBlock *InsertAtEnd);
636 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
637 /// @param Storage llvm::Value of the variable
638 /// @param VarInfo Variable's debug info descriptor.
639 /// @param Expr A complex location expression.
640 /// @param DL Debug info location.
641 /// @param InsertBefore Location for the new intrinsic.
642 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
643 DIExpression *Expr, const DILocation *DL,
644 Instruction *InsertBefore);
646 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
647 /// @param Val llvm::Value of the variable
648 /// @param Offset Offset
649 /// @param VarInfo Variable's debug info descriptor.
650 /// @param Expr A complex location expression.
651 /// @param DL Debug info location.
652 /// @param InsertAtEnd Location for the new intrinsic.
653 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
654 DILocalVariable *VarInfo,
656 const DILocation *DL,
657 BasicBlock *InsertAtEnd);
659 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
660 /// @param Val llvm::Value of the variable
661 /// @param Offset Offset
662 /// @param VarInfo Variable's debug info descriptor.
663 /// @param Expr A complex location expression.
664 /// @param DL Debug info location.
665 /// @param InsertBefore Location for the new intrinsic.
666 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
667 DILocalVariable *VarInfo,
669 const DILocation *DL,
670 Instruction *InsertBefore);
672 /// \brief Replace the vtable holder in the given composite type.
674 /// If this creates a self reference, it may orphan some unresolved cycles
675 /// in the operands of \c T, so \a DIBuilder needs to track that.
676 void replaceVTableHolder(DICompositeType *&T,
677 DICompositeType *VTableHolder);
679 /// \brief Replace arrays on a composite type.
681 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
682 /// has a self-reference -- \a DIBuilder needs to track the array to
684 void replaceArrays(DICompositeType *&T, DINodeArray Elements,
685 DINodeArray TParems = DINodeArray());
687 /// \brief Replace a temporary node.
689 /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
692 /// If \c Replacement is the same as \c N.get(), instead call \a
693 /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
694 /// have a different address, so we return the final address.
695 template <class NodeTy>
696 NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
697 if (N.get() == Replacement)
698 return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
700 N->replaceAllUsesWith(Replacement);
704 } // end namespace llvm