LLVM 17.0.0git
DIBuilder.h
Go to the documentation of this file.
1//===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines a DIBuilder that is useful for creating debugging
10// information entries in LLVM IR form.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_DIBUILDER_H
15#define LLVM_IR_DIBUILDER_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/MapVector.h"
20#include "llvm/ADT/SetVector.h"
22#include "llvm/ADT/StringRef.h"
27#include <algorithm>
28#include <cstdint>
29#include <optional>
30
31namespace llvm {
32
33 class BasicBlock;
34 class Constant;
35 class Function;
36 class Instruction;
37 class LLVMContext;
38 class Module;
39 class Value;
40 class DbgAssignIntrinsic;
41
42 class DIBuilder {
43 Module &M;
44 LLVMContext &VMContext;
45
46 DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
47 Function *DeclareFn; ///< llvm.dbg.declare
48 Function *ValueFn; ///< llvm.dbg.value
49 Function *LabelFn; ///< llvm.dbg.label
50 Function *AssignFn; ///< llvm.dbg.assign
51
53 /// Track the RetainTypes, since they can be updated later on.
55 SmallVector<Metadata *, 4> AllSubprograms;
57 SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
58 /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of
59 /// Metadata all of type DIMacroNode.
60 /// DIMacroNode's with nullptr parent are DICompileUnit direct children.
62
63 /// Track nodes that may be unresolved.
65 bool AllowUnresolvedNodes;
66
67 /// Each subprogram's preserved local variables.
68 ///
69 /// Do not use a std::vector. Some versions of libc++ apparently copy
70 /// instead of move on grow operations, and TrackingMDRef is expensive to
71 /// copy.
73
74 /// Each subprogram's preserved labels.
76
77 /// Create a temporary.
78 ///
79 /// Create an \a temporary node and track it in \a UnresolvedNodes.
80 void trackIfUnresolved(MDNode *N);
81
82 /// Internal helper for insertDeclare.
83 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
84 DIExpression *Expr, const DILocation *DL,
85 BasicBlock *InsertBB, Instruction *InsertBefore);
86
87 /// Internal helper for insertLabel.
88 Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
89 BasicBlock *InsertBB, Instruction *InsertBefore);
90
91 /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
92 Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
93 DILocalVariable *VarInfo,
94 DIExpression *Expr, const DILocation *DL,
95 BasicBlock *InsertBB,
96 Instruction *InsertBefore);
97
98 /// Internal helper for insertDbgValueIntrinsic.
100 insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo,
101 DIExpression *Expr, const DILocation *DL,
102 BasicBlock *InsertBB, Instruction *InsertBefore);
103
104 public:
105 /// Construct a builder for a module.
106 ///
107 /// If \c AllowUnresolved, collect unresolved nodes attached to the module
108 /// in order to resolve cycles during \a finalize().
109 ///
110 /// If \p CU is given a value other than nullptr, then set \p CUNode to CU.
111 explicit DIBuilder(Module &M, bool AllowUnresolved = true,
112 DICompileUnit *CU = nullptr);
113 DIBuilder(const DIBuilder &) = delete;
114 DIBuilder &operator=(const DIBuilder &) = delete;
115
116 /// Construct any deferred debug info descriptors.
117 void finalize();
118
119 /// Finalize a specific subprogram - no new variables may be added to this
120 /// subprogram afterwards.
122
123 /// A CompileUnit provides an anchor for all debugging
124 /// information generated during this instance of compilation.
125 /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
126 /// \param File File info.
127 /// \param Producer Identify the producer of debugging information
128 /// and code. Usually this is a compiler
129 /// version string.
130 /// \param isOptimized A boolean flag which indicates whether optimization
131 /// is enabled or not.
132 /// \param Flags This string lists command line options. This
133 /// string is directly embedded in debug info
134 /// output which may be used by a tool
135 /// analyzing generated debugging information.
136 /// \param RV This indicates runtime version for languages like
137 /// Objective-C.
138 /// \param SplitName The name of the file that we'll split debug info
139 /// out into.
140 /// \param Kind The kind of debug information to generate.
141 /// \param DWOId The DWOId if this is a split skeleton compile unit.
142 /// \param SplitDebugInlining Whether to emit inline debug info.
143 /// \param DebugInfoForProfiling Whether to emit extra debug info for
144 /// profile collection.
145 /// \param NameTableKind Whether to emit .debug_gnu_pubnames,
146 /// .debug_pubnames, or no pubnames at all.
147 /// \param SysRoot The clang system root (value of -isysroot).
148 /// \param SDK The SDK name. On Darwin, this is the last component
149 /// of the sysroot.
151 createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
152 bool isOptimized, StringRef Flags, unsigned RV,
153 StringRef SplitName = StringRef(),
156 uint64_t DWOId = 0, bool SplitDebugInlining = true,
157 bool DebugInfoForProfiling = false,
160 bool RangesBaseAddress = false, StringRef SysRoot = {},
161 StringRef SDK = {});
162
163 /// Create a file descriptor to hold debugging information for a file.
164 /// \param Filename File name.
165 /// \param Directory Directory.
166 /// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.)
167 /// and value.
168 /// \param Source Optional source text.
169 DIFile *createFile(
170 StringRef Filename, StringRef Directory,
171 std::optional<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt,
172 std::optional<StringRef> Source = std::nullopt);
173
174 /// Create debugging information entry for a macro.
175 /// \param Parent Macro parent (could be nullptr).
176 /// \param Line Source line number where the macro is defined.
177 /// \param MacroType DW_MACINFO_define or DW_MACINFO_undef.
178 /// \param Name Macro name.
179 /// \param Value Macro value.
180 DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType,
181 StringRef Name, StringRef Value = StringRef());
182
183 /// Create debugging information temporary entry for a macro file.
184 /// List of macro node direct children will be calculated by DIBuilder,
185 /// using the \p Parent relationship.
186 /// \param Parent Macro file parent (could be nullptr).
187 /// \param Line Source line number where the macro file is included.
188 /// \param File File descriptor containing the name of the macro file.
189 DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line,
190 DIFile *File);
191
192 /// Create a single enumerator value.
193 DIEnumerator *createEnumerator(StringRef Name, const APSInt &Value);
194 DIEnumerator *createEnumerator(StringRef Name, uint64_t Val,
195 bool IsUnsigned = false);
196
197 /// Create a DWARF unspecified type.
198 DIBasicType *createUnspecifiedType(StringRef Name);
199
200 /// Create C++11 nullptr type.
201 DIBasicType *createNullPtrType();
202
203 /// Create debugging information entry for a basic
204 /// type.
205 /// \param Name Type name.
206 /// \param SizeInBits Size of the type.
207 /// \param Encoding DWARF encoding code, e.g., dwarf::DW_ATE_float.
208 /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity.
209 DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
210 unsigned Encoding,
211 DINode::DIFlags Flags = DINode::FlagZero);
212
213 /// Create debugging information entry for a string
214 /// type.
215 /// \param Name Type name.
216 /// \param SizeInBits Size of the type.
217 DIStringType *createStringType(StringRef Name, uint64_t SizeInBits);
218
219 /// Create debugging information entry for Fortran
220 /// assumed length string type.
221 /// \param Name Type name.
222 /// \param StringLength String length expressed as DIVariable *.
223 /// \param StrLocationExp Optional memory location of the string.
224 DIStringType *createStringType(StringRef Name, DIVariable *StringLength,
225 DIExpression *StrLocationExp = nullptr);
226
227 /// Create debugging information entry for Fortran
228 /// assumed length string type.
229 /// \param Name Type name.
230 /// \param StringLengthExp String length expressed in DIExpression form.
231 /// \param StrLocationExp Optional memory location of the string.
232 DIStringType *createStringType(StringRef Name,
233 DIExpression *StringLengthExp,
234 DIExpression *StrLocationExp = nullptr);
235
236 /// Create debugging information entry for a qualified
237 /// type, e.g. 'const int'.
238 /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
239 /// \param FromTy Base Type.
240 DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
241
242 /// Create debugging information entry for a pointer.
243 /// \param PointeeTy Type pointed by this pointer.
244 /// \param SizeInBits Size.
245 /// \param AlignInBits Alignment. (optional)
246 /// \param DWARFAddressSpace DWARF address space. (optional)
247 /// \param Name Pointer type name. (optional)
248 /// \param Annotations Member annotations.
249 DIDerivedType *
250 createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
251 uint32_t AlignInBits = 0,
252 std::optional<unsigned> DWARFAddressSpace = std::nullopt,
253 StringRef Name = "", DINodeArray Annotations = nullptr);
254
255 /// Create debugging information entry for a pointer to member.
256 /// \param PointeeTy Type pointed to by this pointer.
257 /// \param SizeInBits Size.
258 /// \param AlignInBits Alignment. (optional)
259 /// \param Class Type for which this pointer points to members of.
260 DIDerivedType *
261 createMemberPointerType(DIType *PointeeTy, DIType *Class,
262 uint64_t SizeInBits, uint32_t AlignInBits = 0,
263 DINode::DIFlags Flags = DINode::FlagZero);
264
265 /// Create debugging information entry for a c++
266 /// style reference or rvalue reference type.
267 DIDerivedType *createReferenceType(
268 unsigned Tag, DIType *RTy, uint64_t SizeInBits = 0,
269 uint32_t AlignInBits = 0,
270 std::optional<unsigned> DWARFAddressSpace = std::nullopt);
271
272 /// Create debugging information entry for a typedef.
273 /// \param Ty Original type.
274 /// \param Name Typedef name.
275 /// \param File File where this type is defined.
276 /// \param LineNo Line number.
277 /// \param Context The surrounding context for the typedef.
278 /// \param AlignInBits Alignment. (optional)
279 /// \param Flags Flags to describe inheritance attribute, e.g. private
280 /// \param Annotations Annotations. (optional)
281 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
282 unsigned LineNo, DIScope *Context,
283 uint32_t AlignInBits = 0,
284 DINode::DIFlags Flags = DINode::FlagZero,
285 DINodeArray Annotations = nullptr);
286
287 /// Create debugging information entry for a 'friend'.
288 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
289
290 /// Create debugging information entry to establish
291 /// inheritance relationship between two types.
292 /// \param Ty Original type.
293 /// \param BaseTy Base type. Ty is inherits from base.
294 /// \param BaseOffset Base offset.
295 /// \param VBPtrOffset Virtual base pointer offset.
296 /// \param Flags Flags to describe inheritance attribute,
297 /// e.g. private
298 DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
299 uint64_t BaseOffset, uint32_t VBPtrOffset,
301
302 /// Create debugging information entry for a member.
303 /// \param Scope Member scope.
304 /// \param Name Member name.
305 /// \param File File where this member is defined.
306 /// \param LineNo Line number.
307 /// \param SizeInBits Member size.
308 /// \param AlignInBits Member alignment.
309 /// \param OffsetInBits Member offset.
310 /// \param Flags Flags to encode member attribute, e.g. private
311 /// \param Ty Parent type.
312 /// \param Annotations Member annotations.
313 DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
314 DIFile *File, unsigned LineNo,
315 uint64_t SizeInBits, uint32_t AlignInBits,
316 uint64_t OffsetInBits,
317 DINode::DIFlags Flags, DIType *Ty,
318 DINodeArray Annotations = nullptr);
319
320 /// Create debugging information entry for a variant. A variant
321 /// normally should be a member of a variant part.
322 /// \param Scope Member scope.
323 /// \param Name Member name.
324 /// \param File File where this member is defined.
325 /// \param LineNo Line number.
326 /// \param SizeInBits Member size.
327 /// \param AlignInBits Member alignment.
328 /// \param OffsetInBits Member offset.
329 /// \param Flags Flags to encode member attribute, e.g. private
330 /// \param Discriminant The discriminant for this branch; null for
331 /// the default branch
332 /// \param Ty Parent type.
333 DIDerivedType *createVariantMemberType(DIScope *Scope, StringRef Name,
334 DIFile *File, unsigned LineNo,
335 uint64_t SizeInBits,
336 uint32_t AlignInBits,
337 uint64_t OffsetInBits,
338 Constant *Discriminant,
339 DINode::DIFlags Flags, DIType *Ty);
340
341 /// Create debugging information entry for a bit field member.
342 /// \param Scope Member scope.
343 /// \param Name Member name.
344 /// \param File File where this member is defined.
345 /// \param LineNo Line number.
346 /// \param SizeInBits Member size.
347 /// \param OffsetInBits Member offset.
348 /// \param StorageOffsetInBits Member storage offset.
349 /// \param Flags Flags to encode member attribute.
350 /// \param Ty Parent type.
351 /// \param Annotations Member annotations.
352 DIDerivedType *createBitFieldMemberType(DIScope *Scope, StringRef Name,
353 DIFile *File, unsigned LineNo,
354 uint64_t SizeInBits,
355 uint64_t OffsetInBits,
356 uint64_t StorageOffsetInBits,
357 DINode::DIFlags Flags, DIType *Ty,
358 DINodeArray Annotations = nullptr);
359
360 /// Create debugging information entry for a
361 /// C++ static data member.
362 /// \param Scope Member scope.
363 /// \param Name Member name.
364 /// \param File File where this member is declared.
365 /// \param LineNo Line number.
366 /// \param Ty Type of the static member.
367 /// \param Flags Flags to encode member attribute, e.g. private.
368 /// \param Val Const initializer of the member.
369 /// \param AlignInBits Member alignment.
370 DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
371 DIFile *File, unsigned LineNo,
372 DIType *Ty, DINode::DIFlags Flags,
373 Constant *Val,
374 uint32_t AlignInBits = 0);
375
376 /// Create debugging information entry for Objective-C
377 /// instance variable.
378 /// \param Name Member name.
379 /// \param File File where this member is defined.
380 /// \param LineNo Line number.
381 /// \param SizeInBits Member size.
382 /// \param AlignInBits Member alignment.
383 /// \param OffsetInBits Member offset.
384 /// \param Flags Flags to encode member attribute, e.g. private
385 /// \param Ty Parent type.
386 /// \param PropertyNode Property associated with this ivar.
387 DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
388 uint64_t SizeInBits, uint32_t AlignInBits,
389 uint64_t OffsetInBits, DINode::DIFlags Flags,
390 DIType *Ty, MDNode *PropertyNode);
391
392 /// Create debugging information entry for Objective-C
393 /// property.
394 /// \param Name Property name.
395 /// \param File File where this property is defined.
396 /// \param LineNumber Line number.
397 /// \param GetterName Name of the Objective C property getter selector.
398 /// \param SetterName Name of the Objective C property setter selector.
399 /// \param PropertyAttributes Objective C property attributes.
400 /// \param Ty Type.
401 DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
402 unsigned LineNumber,
403 StringRef GetterName,
404 StringRef SetterName,
405 unsigned PropertyAttributes, DIType *Ty);
406
407 /// Create debugging information entry for a class.
408 /// \param Scope Scope in which this class is defined.
409 /// \param Name class name.
410 /// \param File File where this member is defined.
411 /// \param LineNumber Line number.
412 /// \param SizeInBits Member size.
413 /// \param AlignInBits Member alignment.
414 /// \param OffsetInBits Member offset.
415 /// \param Flags Flags to encode member attribute, e.g. private
416 /// \param Elements class members.
417 /// \param VTableHolder Debug info of the base class that contains vtable
418 /// for this type. This is used in
419 /// DW_AT_containing_type. See DWARF documentation
420 /// for more info.
421 /// \param TemplateParms Template type parameters.
422 /// \param UniqueIdentifier A unique identifier for the class.
423 DICompositeType *createClassType(
424 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
425 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
426 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
427 DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
428 StringRef UniqueIdentifier = "");
429
430 /// Create debugging information entry for a struct.
431 /// \param Scope Scope in which this struct is defined.
432 /// \param Name Struct name.
433 /// \param File File where this member is defined.
434 /// \param LineNumber Line number.
435 /// \param SizeInBits Member size.
436 /// \param AlignInBits Member alignment.
437 /// \param Flags Flags to encode member attribute, e.g. private
438 /// \param Elements Struct elements.
439 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
440 /// \param UniqueIdentifier A unique identifier for the struct.
441 DICompositeType *createStructType(
442 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
443 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
444 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
445 DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
446
447 /// Create debugging information entry for an union.
448 /// \param Scope Scope in which this union is defined.
449 /// \param Name Union name.
450 /// \param File File where this member is defined.
451 /// \param LineNumber Line number.
452 /// \param SizeInBits Member size.
453 /// \param AlignInBits Member alignment.
454 /// \param Flags Flags to encode member attribute, e.g. private
455 /// \param Elements Union elements.
456 /// \param RunTimeLang Optional parameter, Objective-C runtime version.
457 /// \param UniqueIdentifier A unique identifier for the union.
458 DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
459 DIFile *File, unsigned LineNumber,
460 uint64_t SizeInBits, uint32_t AlignInBits,
462 DINodeArray Elements,
463 unsigned RunTimeLang = 0,
464 StringRef UniqueIdentifier = "");
465
466 /// Create debugging information entry for a variant part. A
467 /// variant part normally has a discriminator (though this is not
468 /// required) and a number of variant children.
469 /// \param Scope Scope in which this union is defined.
470 /// \param Name Union name.
471 /// \param File File where this member is defined.
472 /// \param LineNumber Line number.
473 /// \param SizeInBits Member size.
474 /// \param AlignInBits Member alignment.
475 /// \param Flags Flags to encode member attribute, e.g. private
476 /// \param Discriminator Discriminant member
477 /// \param Elements Variant elements.
478 /// \param UniqueIdentifier A unique identifier for the union.
479 DICompositeType *createVariantPart(DIScope *Scope, StringRef Name,
480 DIFile *File, unsigned LineNumber,
481 uint64_t SizeInBits, uint32_t AlignInBits,
483 DIDerivedType *Discriminator,
484 DINodeArray Elements,
485 StringRef UniqueIdentifier = "");
486
487 /// Create debugging information for template
488 /// type parameter.
489 /// \param Scope Scope in which this type is defined.
490 /// \param Name Type parameter name.
491 /// \param Ty Parameter type.
492 /// \param IsDefault Parameter is default or not
493 DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope,
494 StringRef Name,
495 DIType *Ty,
496 bool IsDefault);
497
498 /// Create debugging information for template
499 /// value parameter.
500 /// \param Scope Scope in which this type is defined.
501 /// \param Name Value parameter name.
502 /// \param Ty Parameter type.
503 /// \param IsDefault Parameter is default or not
504 /// \param Val Constant parameter value.
505 DITemplateValueParameter *
506 createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty,
507 bool IsDefault, Constant *Val);
508
509 /// Create debugging information for a template template parameter.
510 /// \param Scope Scope in which this type is defined.
511 /// \param Name Value parameter name.
512 /// \param Ty Parameter type.
513 /// \param Val The fully qualified name of the template.
514 /// \param IsDefault Parameter is default or not.
515 DITemplateValueParameter *
516 createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty,
517 StringRef Val, bool IsDefault = false);
518
519 /// Create debugging information for a template parameter pack.
520 /// \param Scope Scope in which this type is defined.
521 /// \param Name Value parameter name.
522 /// \param Ty Parameter type.
523 /// \param Val An array of types in the pack.
524 DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
525 StringRef Name,
526 DIType *Ty,
527 DINodeArray Val);
528
529 /// Create debugging information entry for an array.
530 /// \param Size Array size.
531 /// \param AlignInBits Alignment.
532 /// \param Ty Element type.
533 /// \param Subscripts Subscripts.
534 /// \param DataLocation The location of the raw data of a descriptor-based
535 /// Fortran array, either a DIExpression* or
536 /// a DIVariable*.
537 /// \param Associated The associated attribute of a descriptor-based
538 /// Fortran array, either a DIExpression* or
539 /// a DIVariable*.
540 /// \param Allocated The allocated attribute of a descriptor-based
541 /// Fortran array, either a DIExpression* or
542 /// a DIVariable*.
543 /// \param Rank The rank attribute of a descriptor-based
544 /// Fortran array, either a DIExpression* or
545 /// a DIVariable*.
546 DICompositeType *createArrayType(
547 uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
548 PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr,
549 PointerUnion<DIExpression *, DIVariable *> Associated = nullptr,
550 PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
551 PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
552
553 /// Create debugging information entry for a vector type.
554 /// \param Size Array size.
555 /// \param AlignInBits Alignment.
556 /// \param Ty Element type.
557 /// \param Subscripts Subscripts.
558 DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits,
559 DIType *Ty, DINodeArray Subscripts);
560
561 /// Create debugging information entry for an
562 /// enumeration.
563 /// \param Scope Scope in which this enumeration is defined.
564 /// \param Name Union name.
565 /// \param File File where this member is defined.
566 /// \param LineNumber Line number.
567 /// \param SizeInBits Member size.
568 /// \param AlignInBits Member alignment.
569 /// \param Elements Enumeration elements.
570 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
571 /// \param UniqueIdentifier A unique identifier for the enum.
572 /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum class'.
573 DICompositeType *createEnumerationType(
574 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
575 uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
576 DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped = false);
577
578 /// Create debugging information entry for a set.
579 /// \param Scope Scope in which this set is defined.
580 /// \param Name Set name.
581 /// \param File File where this set is defined.
582 /// \param LineNo Line number.
583 /// \param SizeInBits Set size.
584 /// \param AlignInBits Set alignment.
585 /// \param Ty Base type of the set.
586 DIDerivedType *createSetType(DIScope *Scope, StringRef Name, DIFile *File,
587 unsigned LineNo, uint64_t SizeInBits,
588 uint32_t AlignInBits, DIType *Ty);
589
590 /// Create subroutine type.
591 /// \param ParameterTypes An array of subroutine parameter types. This
592 /// includes return type at 0th index.
593 /// \param Flags E.g.: LValueReference.
594 /// These flags are used to emit dwarf attributes.
595 /// \param CC Calling convention, e.g. dwarf::DW_CC_normal
596 DISubroutineType *
597 createSubroutineType(DITypeRefArray ParameterTypes,
598 DINode::DIFlags Flags = DINode::FlagZero,
599 unsigned CC = 0);
600
601 /// Create a distinct clone of \p SP with FlagArtificial set.
602 static DISubprogram *createArtificialSubprogram(DISubprogram *SP);
603
604 /// Create a uniqued clone of \p Ty with FlagArtificial set.
605 static DIType *createArtificialType(DIType *Ty);
606
607 /// Create a uniqued clone of \p Ty with FlagObjectPointer and
608 /// FlagArtificial set.
609 static DIType *createObjectPointerType(DIType *Ty);
610
611 /// Create a permanent forward-declared type.
612 DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
613 DIScope *Scope, DIFile *F, unsigned Line,
614 unsigned RuntimeLang = 0,
615 uint64_t SizeInBits = 0,
616 uint32_t AlignInBits = 0,
617 StringRef UniqueIdentifier = "");
618
619 /// Create a temporary forward-declared type.
620 DICompositeType *createReplaceableCompositeType(
621 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
622 unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
623 uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
624 StringRef UniqueIdentifier = "", DINodeArray Annotations = nullptr);
625
626 /// Retain DIScope* in a module even if it is not referenced
627 /// through debug info anchors.
628 void retainType(DIScope *T);
629
630 /// Create unspecified parameter type
631 /// for a subroutine type.
632 DIBasicType *createUnspecifiedParameter();
633
634 /// Get a DINodeArray, create one if required.
635 DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
636
637 /// Get a DIMacroNodeArray, create one if required.
638 DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements);
639
640 /// Get a DITypeRefArray, create one if required.
641 DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
642
643 /// Create a descriptor for a value range. This
644 /// implicitly uniques the values returned.
645 DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
646 DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode);
647 DISubrange *getOrCreateSubrange(Metadata *Count, Metadata *LowerBound,
648 Metadata *UpperBound, Metadata *Stride);
649
650 DIGenericSubrange *
655
656 /// Create a new descriptor for the specified variable.
657 /// \param Context Variable scope.
658 /// \param Name Name of the variable.
659 /// \param LinkageName Mangled name of the variable.
660 /// \param File File where this variable is defined.
661 /// \param LineNo Line number.
662 /// \param Ty Variable Type.
663 /// \param IsLocalToUnit Boolean flag indicate whether this variable is
664 /// externally visible or not.
665 /// \param Expr The location of the global relative to the attached
666 /// GlobalVariable.
667 /// \param Decl Reference to the corresponding declaration.
668 /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
669 /// specified)
670 DIGlobalVariableExpression *createGlobalVariableExpression(
671 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
672 unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true,
673 DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
674 MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0,
675 DINodeArray Annotations = nullptr);
676
677 /// Identical to createGlobalVariable
678 /// except that the resulting DbgNode is temporary and meant to be RAUWed.
679 DIGlobalVariable *createTempGlobalVariableFwdDecl(
680 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
681 unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr,
682 MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0);
683
684 /// Create a new descriptor for an auto variable. This is a local variable
685 /// that is not a subprogram parameter.
686 ///
687 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
688 /// leads to a \a DISubprogram.
689 ///
690 /// If \c AlwaysPreserve, this variable will be referenced from its
691 /// containing subprogram, and will survive some optimizations.
692 DILocalVariable *
693 createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
694 unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
695 DINode::DIFlags Flags = DINode::FlagZero,
696 uint32_t AlignInBits = 0);
697
698 /// Create a new descriptor for an label.
699 ///
700 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
701 /// leads to a \a DISubprogram.
702 DILabel *
703 createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
704 bool AlwaysPreserve = false);
705
706 /// Create a new descriptor for a parameter variable.
707 ///
708 /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
709 /// leads to a \a DISubprogram.
710 ///
711 /// \c ArgNo is the index (starting from \c 1) of this variable in the
712 /// subprogram parameters. \c ArgNo should not conflict with other
713 /// parameters of the same subprogram.
714 ///
715 /// If \c AlwaysPreserve, this variable will be referenced from its
716 /// containing subprogram, and will survive some optimizations.
717 DILocalVariable *
718 createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
719 DIFile *File, unsigned LineNo, DIType *Ty,
720 bool AlwaysPreserve = false,
721 DINode::DIFlags Flags = DINode::FlagZero,
722 DINodeArray Annotations = nullptr);
723
724 /// Create a new descriptor for the specified
725 /// variable which has a complex address expression for its address.
726 /// \param Addr An array of complex address operations.
727 DIExpression *createExpression(ArrayRef<uint64_t> Addr = std::nullopt);
728
729 /// Create an expression for a variable that does not have an address, but
730 /// does have a constant value.
732 return DIExpression::get(
733 VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
734 }
735
736 /// Create a new descriptor for the specified subprogram.
737 /// See comments in DISubprogram* for descriptions of these fields.
738 /// \param Scope Function scope.
739 /// \param Name Function name.
740 /// \param LinkageName Mangled function name.
741 /// \param File File where this variable is defined.
742 /// \param LineNo Line number.
743 /// \param Ty Function type.
744 /// \param ScopeLine Set to the beginning of the scope this starts
745 /// \param Flags e.g. is this function prototyped or not.
746 /// These flags are used to emit dwarf attributes.
747 /// \param SPFlags Additional flags specific to subprograms.
748 /// \param TParams Function template parameters.
749 /// \param ThrownTypes Exception types this function may throw.
750 /// \param Annotations Attribute Annotations.
751 /// \param TargetFuncName The name of the target function if this is
752 /// a trampoline.
755 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
756 unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero,
757 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
758 DITemplateParameterArray TParams = nullptr,
759 DISubprogram *Decl = nullptr,
760 DITypeArray ThrownTypes = nullptr,
761 DINodeArray Annotations = nullptr,
762 StringRef TargetFuncName = "");
763
764 /// Identical to createFunction,
765 /// except that the resulting DbgNode is meant to be RAUWed.
768 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
769 DINode::DIFlags Flags = DINode::FlagZero,
770 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
771 DITemplateParameterArray TParams = nullptr,
772 DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
773
774 /// Create a new descriptor for the specified C++ method.
775 /// See comments in \a DISubprogram* for descriptions of these fields.
776 /// \param Scope Function scope.
777 /// \param Name Function name.
778 /// \param LinkageName Mangled function name.
779 /// \param File File where this variable is defined.
780 /// \param LineNo Line number.
781 /// \param Ty Function type.
782 /// \param VTableIndex Index no of this method in virtual table, or -1u if
783 /// unrepresentable.
784 /// \param ThisAdjustment
785 /// MS ABI-specific adjustment of 'this' that occurs
786 /// in the prologue.
787 /// \param VTableHolder Type that holds vtable.
788 /// \param Flags e.g. is this function prototyped or not.
789 /// This flags are used to emit dwarf attributes.
790 /// \param SPFlags Additional flags specific to subprograms.
791 /// \param TParams Function template parameters.
792 /// \param ThrownTypes Exception types this function may throw.
795 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
796 unsigned VTableIndex = 0, int ThisAdjustment = 0,
797 DIType *VTableHolder = nullptr,
798 DINode::DIFlags Flags = DINode::FlagZero,
799 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
800 DITemplateParameterArray TParams = nullptr,
801 DITypeArray ThrownTypes = nullptr);
802
803 /// Create common block entry for a Fortran common block.
804 /// \param Scope Scope of this common block.
805 /// \param decl Global variable declaration.
806 /// \param Name The name of this common block.
807 /// \param File The file this common block is defined.
808 /// \param LineNo Line number.
810 StringRef Name, DIFile *File,
811 unsigned LineNo);
812
813 /// This creates new descriptor for a namespace with the specified
814 /// parent scope.
815 /// \param Scope Namespace scope
816 /// \param Name Name of this namespace
817 /// \param ExportSymbols True for C++ inline namespaces.
819 bool ExportSymbols);
820
821 /// This creates new descriptor for a module with the specified
822 /// parent scope.
823 /// \param Scope Parent scope
824 /// \param Name Name of this module
825 /// \param ConfigurationMacros
826 /// A space-separated shell-quoted list of -D macro
827 /// definitions as they would appear on a command line.
828 /// \param IncludePath The path to the module map file.
829 /// \param APINotesFile The path to an API notes file for this module.
830 /// \param File Source file of the module.
831 /// Used for Fortran modules.
832 /// \param LineNo Source line number of the module.
833 /// Used for Fortran modules.
834 /// \param IsDecl This is a module declaration; default to false;
835 /// when set to true, only Scope and Name are required
836 /// as this entry is just a hint for the debugger to find
837 /// the corresponding definition in the global scope.
839 StringRef ConfigurationMacros, StringRef IncludePath,
840 StringRef APINotesFile = {}, DIFile *File = nullptr,
841 unsigned LineNo = 0, bool IsDecl = false);
842
843 /// This creates a descriptor for a lexical block with a new file
844 /// attached. This merely extends the existing
845 /// lexical block as it crosses a file.
846 /// \param Scope Lexical block.
847 /// \param File Source file.
848 /// \param Discriminator DWARF path discriminator value.
849 DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
850 unsigned Discriminator = 0);
851
852 /// This creates a descriptor for a lexical block with the
853 /// specified parent context.
854 /// \param Scope Parent lexical scope.
855 /// \param File Source file.
856 /// \param Line Line number.
857 /// \param Col Column number.
858 DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
859 unsigned Line, unsigned Col);
860
861 /// Create a descriptor for an imported module.
862 /// \param Context The scope this module is imported into
863 /// \param NS The namespace being imported here.
864 /// \param File File where the declaration is located.
865 /// \param Line Line number of the declaration.
866 /// \param Elements Renamed elements.
867 DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
868 DIFile *File, unsigned Line,
869 DINodeArray Elements = nullptr);
870
871 /// Create a descriptor for an imported module.
872 /// \param Context The scope this module is imported into.
873 /// \param NS An aliased namespace.
874 /// \param File File where the declaration is located.
875 /// \param Line Line number of the declaration.
876 /// \param Elements Renamed elements.
877 DIImportedEntity *createImportedModule(DIScope *Context,
878 DIImportedEntity *NS, DIFile *File,
879 unsigned Line,
880 DINodeArray Elements = nullptr);
881
882 /// Create a descriptor for an imported module.
883 /// \param Context The scope this module is imported into.
884 /// \param M The module being imported here
885 /// \param File File where the declaration is located.
886 /// \param Line Line number of the declaration.
887 /// \param Elements Renamed elements.
888 DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
889 DIFile *File, unsigned Line,
890 DINodeArray Elements = nullptr);
891
892 /// Create a descriptor for an imported function.
893 /// \param Context The scope this module is imported into.
894 /// \param Decl The declaration (or definition) of a function, type, or
895 /// variable.
896 /// \param File File where the declaration is located.
897 /// \param Line Line number of the declaration.
898 /// \param Elements Renamed elements.
899 DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
900 DIFile *File, unsigned Line,
901 StringRef Name = "",
902 DINodeArray Elements = nullptr);
903
904 /// Insert a new llvm.dbg.declare intrinsic call.
905 /// \param Storage llvm::Value of the variable
906 /// \param VarInfo Variable's debug info descriptor.
907 /// \param Expr A complex location expression.
908 /// \param DL Debug info location.
909 /// \param InsertAtEnd Location for the new intrinsic.
910 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
911 DIExpression *Expr, const DILocation *DL,
912 BasicBlock *InsertAtEnd);
913
914 /// Insert a new llvm.dbg.assign intrinsic call.
915 /// \param LinkedInstr Instruction with a DIAssignID to link with the new
916 /// intrinsic. The intrinsic will be inserted after
917 /// this instruction.
918 /// \param Val The value component of this dbg.assign.
919 /// \param SrcVar Variable's debug info descriptor.
920 /// \param ValExpr A complex location expression to modify \p Val.
921 /// \param Addr The address component (store destination).
922 /// \param AddrExpr A complex location expression to modify \p Addr.
923 /// NOTE: \p ValExpr carries the FragInfo for the
924 /// variable.
925 /// \param DL Debug info location, usually: (line: 0,
926 /// column: 0, scope: var-decl-scope). See
927 /// getDebugValueLoc.
928 DbgAssignIntrinsic *insertDbgAssign(Instruction *LinkedInstr, Value *Val,
929 DILocalVariable *SrcVar,
930 DIExpression *ValExpr, Value *Addr,
931 DIExpression *AddrExpr,
932 const DILocation *DL);
933
934 /// Insert a new llvm.dbg.declare intrinsic call.
935 /// \param Storage llvm::Value of the variable
936 /// \param VarInfo Variable's debug info descriptor.
937 /// \param Expr A complex location expression.
938 /// \param DL Debug info location.
939 /// \param InsertBefore Location for the new intrinsic.
940 Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
941 DIExpression *Expr, const DILocation *DL,
942 Instruction *InsertBefore);
943
944 /// Insert a new llvm.dbg.label intrinsic call.
945 /// \param LabelInfo Label's debug info descriptor.
946 /// \param DL Debug info location.
947 /// \param InsertBefore Location for the new intrinsic.
948 Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
949 Instruction *InsertBefore);
950
951 /// Insert a new llvm.dbg.label intrinsic call.
952 /// \param LabelInfo Label's debug info descriptor.
953 /// \param DL Debug info location.
954 /// \param InsertAtEnd Location for the new intrinsic.
955 Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
956 BasicBlock *InsertAtEnd);
957
958 /// Insert a new llvm.dbg.value intrinsic call.
959 /// \param Val llvm::Value of the variable
960 /// \param VarInfo Variable's debug info descriptor.
961 /// \param Expr A complex location expression.
962 /// \param DL Debug info location.
963 /// \param InsertAtEnd Location for the new intrinsic.
964 Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
965 DILocalVariable *VarInfo,
966 DIExpression *Expr,
967 const DILocation *DL,
968 BasicBlock *InsertAtEnd);
969
970 /// Insert a new llvm.dbg.value intrinsic call.
971 /// \param Val llvm::Value of the variable
972 /// \param VarInfo Variable's debug info descriptor.
973 /// \param Expr A complex location expression.
974 /// \param DL Debug info location.
975 /// \param InsertBefore Location for the new intrinsic.
976 Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
977 DILocalVariable *VarInfo,
978 DIExpression *Expr,
979 const DILocation *DL,
980 Instruction *InsertBefore);
981
982 /// Replace the vtable holder in the given type.
983 ///
984 /// If this creates a self reference, it may orphan some unresolved cycles
985 /// in the operands of \c T, so \a DIBuilder needs to track that.
986 void replaceVTableHolder(DICompositeType *&T,
987 DIType *VTableHolder);
988
989 /// Replace arrays on a composite type.
990 ///
991 /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
992 /// has a self-reference -- \a DIBuilder needs to track the array to
993 /// resolve cycles.
994 void replaceArrays(DICompositeType *&T, DINodeArray Elements,
995 DINodeArray TParams = DINodeArray());
996
997 /// Replace a temporary node.
998 ///
999 /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
1000 /// Replacement.
1001 ///
1002 /// If \c Replacement is the same as \c N.get(), instead call \a
1003 /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
1004 /// have a different address, so we return the final address.
1005 template <class NodeTy>
1006 NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
1007 if (N.get() == Replacement)
1008 return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
1009
1010 N->replaceAllUsesWith(Replacement);
1011 return Replacement;
1012 }
1013 };
1014
1015 // Create wrappers for C Binding types (see CBindingWrapping.h).
1017
1018} // end namespace llvm
1019
1020#endif // LLVM_IR_DIBUILDER_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
uint64_t Addr
std::string Name
uint64_t Size
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
@ Flags
Definition: TextStubV5.cpp:93
Annotations lets you mark points and ranges inside source code, for tests:
Definition: Annotations.h:53
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:642
DIGlobalVariable * createTempGlobalVariableFwdDecl(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl=nullptr, MDTuple *TemplateParams=nullptr, uint32_t AlignInBits=0)
Identical to createGlobalVariable except that the resulting DbgNode is temporary and meant to be RAUW...
Definition: DIBuilder.cpp:754
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val, bool IsDefault=false)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:471
DIDerivedType * createBitFieldMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations=nullptr)
Create debugging information entry for a bit field member.
Definition: DIBuilder.cpp:401
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition: DIBuilder.h:1006
DIDerivedType * createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagZero, DINodeArray Annotations=nullptr)
Create debugging information entry for a typedef.
Definition: DIBuilder.cpp:345
DIBuilder & operator=(const DIBuilder &)=delete
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:74
DbgAssignIntrinsic * insertDbgAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *SrcVar, DIExpression *ValExpr, Value *Addr, DIExpression *AddrExpr, const DILocation *DL)
Insert a new llvm.dbg.assign intrinsic call.
Definition: DIBuilder.cpp:961
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
Definition: DIBuilder.cpp:543
DIMacro * createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, StringRef Name, StringRef Value=StringRef())
Create debugging information entry for a macro.
Definition: DIBuilder.cpp:232
DIDerivedType * createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, uint32_t VBPtrOffset, DINode::DIFlags Flags)
Create debugging information entry to establish inheritance relationship between two types.
Definition: DIBuilder.cpp:363
DIDerivedType * createVariantMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty)
Create debugging information entry for a variant.
Definition: DIBuilder.cpp:391
DILexicalBlockFile * createLexicalBlockFile(DIScope *Scope, DIFile *File, unsigned Discriminator=0)
This creates a descriptor for a lexical block with a new file attached.
Definition: DIBuilder.cpp:930
DIDerivedType * createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, DINode::DIFlags Flags, Constant *Val, uint32_t AlignInBits=0)
Create debugging information entry for a C++ static data member.
Definition: DIBuilder.cpp:416
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards.
Definition: DIBuilder.cpp:54
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:308
DICompileUnit * createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName=StringRef(), DICompileUnit::DebugEmissionKind Kind=DICompileUnit::DebugEmissionKind::FullDebug, uint64_t DWOId=0, bool SplitDebugInlining=true, bool DebugInfoForProfiling=false, DICompileUnit::DebugNameTableKind NameTableKind=DICompileUnit::DebugNameTableKind::Default, bool RangesBaseAddress=false, StringRef SysRoot={}, StringRef SDK={})
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DIBuilder.cpp:146
DISubprogram * createTempFunctionFwdDecl(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr)
Identical to createFunction, except that the resulting DbgNode is meant to be RAUWed.
Definition: DIBuilder.cpp:864
DIDerivedType * createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty, MDNode *PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition: DIBuilder.cpp:428
static DIType * createArtificialType(DIType *Ty)
Create a uniqued clone of Ty with FlagArtificial set.
Definition: DIBuilder.cpp:619
DICompositeType * createStructType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang=0, DIType *VTableHolder=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a struct.
Definition: DIBuilder.cpp:504
DICompositeType * createVectorType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:598
static DIType * createObjectPointerType(DIType *Ty)
Create a uniqued clone of Ty with FlagObjectPointer and FlagArtificial set.
Definition: DIBuilder.cpp:626
DILabel * createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, bool AlwaysPreserve=false)
Create a new descriptor for an label.
Definition: DIBuilder.cpp:814
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, bool ExportSymbols)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:909
DIStringType * createStringType(StringRef Name, uint64_t SizeInBits)
Create debugging information entry for a string type.
Definition: DIBuilder.cpp:286
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr, DINodeArray Annotations=nullptr, StringRef TargetFuncName="")
Create a new descriptor for the specified subprogram.
Definition: DIBuilder.cpp:843
DILexicalBlock * createLexicalBlock(DIScope *Scope, DIFile *File, unsigned Line, unsigned Col)
This creates a descriptor for a lexical block with the specified parent context.
Definition: DIBuilder.cpp:936
DICompositeType * createUnionType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DINodeArray Elements, unsigned RunTimeLang=0, StringRef UniqueIdentifier="")
Create debugging information entry for an union.
Definition: DIBuilder.cpp:517
DIMacroNodeArray getOrCreateMacroArray(ArrayRef< Metadata * > Elements)
Get a DIMacroNodeArray, create one if required.
Definition: DIBuilder.cpp:680
DIDerivedType * createSetType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, DIType *Ty)
Create debugging information entry for a set.
Definition: DIBuilder.cpp:563
void replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder)
Replace the vtable holder in the given type.
Definition: DIBuilder.cpp:1117
DIExpression * createConstantValueExpression(uint64_t Val)
Create an expression for a variable that does not have an address, but does have a constant value.
Definition: DIBuilder.h:731
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:274
DICommonBlock * createCommonBlock(DIScope *Scope, DIGlobalVariable *decl, StringRef Name, DIFile *File, unsigned LineNo)
Create common block entry for a Fortran common block.
Definition: DIBuilder.cpp:902
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
Definition: DIBuilder.cpp:356
void retainType(DIScope *T)
Retain DIScope* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:634
DIBuilder(const DIBuilder &)=delete
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits=0, std::optional< unsigned > DWARFAddressSpace=std::nullopt, StringRef Name="", DINodeArray Annotations=nullptr)
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:314
DIExpression * createExpression(ArrayRef< uint64_t > Addr=std::nullopt)
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition: DIBuilder.cpp:832
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:480
DIGlobalVariableExpression * createGlobalVariableExpression(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined=true, DIExpression *Expr=nullptr, MDNode *Decl=nullptr, MDTuple *TemplateParams=nullptr, uint32_t AlignInBits=0, DINodeArray Annotations=nullptr)
Create a new descriptor for the specified variable.
Definition: DIBuilder.cpp:735
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, StringRef UniqueIdentifier="", bool IsScoped=false)
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:549
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:695
DIDerivedType * createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits=0, uint32_t AlignInBits=0, std::optional< unsigned > DWARFAddressSpace=std::nullopt)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DIBuilder.cpp:336
DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned VTableIndex=0, int ThisAdjustment=0, DIType *VTableHolder=nullptr, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified C++ method.
Definition: DIBuilder.cpp:879
DIMacroFile * createTempMacroFile(DIMacroFile *Parent, unsigned Line, DIFile *File)
Create debugging information temporary entry for a macro file.
Definition: DIBuilder.cpp:244
DICompositeType * createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, PointerUnion< DIExpression *, DIVariable * > DataLocation=nullptr, PointerUnion< DIExpression *, DIVariable * > Associated=nullptr, PointerUnion< DIExpression *, DIVariable * > Allocated=nullptr, PointerUnion< DIExpression *, DIVariable * > Rank=nullptr)
Create debugging information entry for an array.
Definition: DIBuilder.cpp:576
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding, DINode::DIFlags Flags=DINode::FlagZero)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:278
DIDerivedType * createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagZero)
Create debugging information entry for a pointer to member.
Definition: DIBuilder.cpp:325
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:684
DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:675
DIEnumerator * createEnumerator(StringRef Name, const APSInt &Value)
Create a single enumerator value.
Definition: DIBuilder.cpp:264
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:447
DICompositeType * createReplaceableCompositeType(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagFwdDecl, StringRef UniqueIdentifier="", DINodeArray Annotations=nullptr)
Create a temporary forward-declared type.
Definition: DIBuilder.cpp:659
DICompositeType * createVariantPart(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIDerivedType *Discriminator, DINodeArray Elements, StringRef UniqueIdentifier="")
Create debugging information entry for a variant part.
Definition: DIBuilder.cpp:530
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, unsigned Line, DINodeArray Elements=nullptr)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:189
DIDerivedType * createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations=nullptr)
Create debugging information entry for a member.
Definition: DIBuilder.cpp:375
DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, DIFile *File, unsigned Line, StringRef Name="", DINodeArray Elements=nullptr)
Create a descriptor for an imported function.
Definition: DIBuilder.cpp:216
DILocalVariable * createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero, uint32_t AlignInBits=0)
Create a new descriptor for an auto variable.
Definition: DIBuilder.cpp:794
static DISubprogram * createArtificialSubprogram(DISubprogram *SP)
Create a distinct clone of SP with FlagArtificial set.
Definition: DIBuilder.cpp:608
DIGenericSubrange * getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count, DIGenericSubrange::BoundType LowerBound, DIGenericSubrange::BoundType UpperBound, DIGenericSubrange::BoundType Stride)
Definition: DIBuilder.cpp:714
DICompositeType * createClassType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder=nullptr, MDNode *TemplateParms=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a class.
Definition: DIBuilder.cpp:487
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:269
DIObjCProperty * createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber, StringRef GetterName, StringRef SetterName, unsigned PropertyAttributes, DIType *Ty)
Create debugging information entry for Objective-C property.
Definition: DIBuilder.cpp:439
DICompositeType * createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint32_t AlignInBits=0, StringRef UniqueIdentifier="")
Create a permanent forward-declared type.
Definition: DIBuilder.cpp:645
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:462
DILocalVariable * createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero, DINodeArray Annotations=nullptr)
Create a new descriptor for a parameter variable.
Definition: DIBuilder.cpp:804
DIFile * createFile(StringRef Filename, StringRef Directory, std::optional< DIFile::ChecksumInfo< StringRef > > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt)
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:226
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParams=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:1136
DIModule * createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile={}, DIFile *File=nullptr, unsigned LineNo=0, bool IsDecl=false)
This creates new descriptor for a module with the specified parent scope.
Definition: DIBuilder.cpp:921
DWARF expression.
PointerUnion< DIVariable *, DIExpression * > BoundType
Debug location.
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
DIFlags
Debug info flags.
Base class for scope-like contexts.
Subprogram description.
DISPFlags
Debug info subprogram flags.
Type array for a subprogram.
Base class for types.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Metadata node.
Definition: Metadata.h:943
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1399
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition: Metadata.h:1167
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
struct LLVMOpaqueDIBuilder * LLVMDIBuilderRef
Represents an LLVM debug info builder.
Definition: Types.h:117
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N