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