clang 22.0.0git
CGDebugInfo.h
Go to the documentation of this file.
1//===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- 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 is the source-level debug info generator for llvm translation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
14#define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
15
16#include "CGBuilder.h"
17#include "SanitizerHandler.h"
18#include "clang/AST/DeclCXX.h"
19#include "clang/AST/Expr.h"
22#include "clang/AST/Type.h"
27#include "llvm/ADT/DenseMap.h"
28#include "llvm/ADT/DenseSet.h"
29#include "llvm/IR/DIBuilder.h"
30#include "llvm/IR/DebugInfo.h"
31#include "llvm/IR/ValueHandle.h"
32#include "llvm/Support/Allocator.h"
33#include <map>
34#include <optional>
35#include <string>
36
37namespace llvm {
38class MDNode;
39}
40
41namespace clang {
42class ClassTemplateSpecializationDecl;
43class GlobalDecl;
44class Module;
45class ModuleMap;
46class ObjCInterfaceDecl;
47class UsingDecl;
48class VarDecl;
49enum class DynamicInitKind : unsigned;
50
51namespace CodeGen {
52class CodeGenModule;
53class CodeGenFunction;
54class CGBlockInfo;
55
56/// This class gathers all debug information during compilation and is
57/// responsible for emitting to llvm globals or pass directly to the
58/// backend.
60 friend class ApplyDebugLocation;
62 friend class ApplyAtomGroup;
63
64 CodeGenModule &CGM;
65 const llvm::codegenoptions::DebugInfoKind DebugKind;
66 bool DebugTypeExtRefs;
67 llvm::DIBuilder DBuilder;
68 llvm::DICompileUnit *TheCU = nullptr;
69 ModuleMap *ClangModuleMap = nullptr;
70 ASTSourceDescriptor PCHDescriptor;
71 SourceLocation CurLoc;
72 llvm::MDNode *CurInlinedAt = nullptr;
73 llvm::DIType *VTablePtrType = nullptr;
74 llvm::DIType *ClassTy = nullptr;
75 llvm::DICompositeType *ObjTy = nullptr;
76 llvm::DIType *SelTy = nullptr;
77#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
78 llvm::DIType *SingletonId = nullptr;
79#include "clang/Basic/OpenCLImageTypes.def"
80 llvm::DIType *OCLSamplerDITy = nullptr;
81 llvm::DIType *OCLEventDITy = nullptr;
82 llvm::DIType *OCLClkEventDITy = nullptr;
83 llvm::DIType *OCLQueueDITy = nullptr;
84 llvm::DIType *OCLNDRangeDITy = nullptr;
85 llvm::DIType *OCLReserveIDDITy = nullptr;
86#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
87 llvm::DIType *Id##Ty = nullptr;
88#include "clang/Basic/OpenCLExtensionTypes.def"
89#define WASM_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
90#include "clang/Basic/WebAssemblyReferenceTypes.def"
91#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
92 llvm::DIType *SingletonId = nullptr;
93#include "clang/Basic/AMDGPUTypes.def"
94#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
95 llvm::DIType *SingletonId = nullptr;
96#include "clang/Basic/HLSLIntangibleTypes.def"
97
98 /// Cache of previously constructed Types.
99 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
100
101 /// Cache that maps VLA types to size expressions for that type,
102 /// represented by instantiated Metadata nodes.
103 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
104
105 /// Callbacks to use when printing names and types.
106 class PrintingCallbacks final : public clang::PrintingCallbacks {
107 const CGDebugInfo &Self;
108
109 public:
110 PrintingCallbacks(const CGDebugInfo &Self) : Self(Self) {}
111 std::string remapPath(StringRef Path) const override {
112 return Self.remapDIPath(Path);
113 }
114 };
115 PrintingCallbacks PrintCB = {*this};
116
117 struct ObjCInterfaceCacheEntry {
118 const ObjCInterfaceType *Type;
119 llvm::DIType *Decl;
120 llvm::DIFile *Unit;
121 ObjCInterfaceCacheEntry(const ObjCInterfaceType *Type, llvm::DIType *Decl,
122 llvm::DIFile *Unit)
123 : Type(Type), Decl(Decl), Unit(Unit) {}
124 };
125
126 /// Cache of previously constructed interfaces which may change.
128
129 /// Cache of forward declarations for methods belonging to the interface.
130 /// The extra bit on the DISubprogram specifies whether a method is
131 /// "objc_direct".
132 llvm::DenseMap<const ObjCInterfaceDecl *,
133 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
134 ObjCMethodCache;
135
136 /// Cache of references to clang modules and precompiled headers.
137 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
138
139 /// List of interfaces we want to keep even if orphaned.
140 std::vector<void *> RetainedTypes;
141
142 /// Cache of forward declared types to RAUW at the end of compilation.
143 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
144
145 /// Cache of replaceable forward declarations (functions and
146 /// variables) to RAUW at the end of compilation.
147 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
148 FwdDeclReplaceMap;
149
150 /// Keep track of our current nested lexical block.
151 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
152 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
153 /// Keep track of LexicalBlockStack counter at the beginning of a
154 /// function. This is used to pop unbalanced regions at the end of a
155 /// function.
156 std::vector<unsigned> FnBeginRegionCount;
157
158 /// This is a storage for names that are constructed on demand. For
159 /// example, C++ destructors, C++ operators etc..
160 llvm::BumpPtrAllocator DebugInfoNames;
161
162 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
163 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
164 /// Cache declarations relevant to DW_TAG_imported_declarations (C++
165 /// using declarations and global alias variables) that aren't covered
166 /// by other more specific caches.
167 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
168 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
169 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
170 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
171 NamespaceAliasCache;
172 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
173 StaticDataMemberCache;
174
175 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
176 using Param2DILocTy =
177 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
178
179 /// The key is coroutine real parameters, value is coroutine move parameters.
180 ParamDecl2StmtTy CoroutineParameterMappings;
181 /// The key is coroutine real parameters, value is DIVariable in LLVM IR.
182 Param2DILocTy ParamDbgMappings;
183
184 /// Key Instructions bookkeeping.
185 /// Source atoms are identified by a {AtomGroup, InlinedAt} pair, meaning
186 /// AtomGroup numbers can be repeated across different functions.
187 struct {
188 uint64_t NextAtom = 1;
189 uint64_t HighestEmittedAtom = 0;
190 uint64_t CurrentAtom = 0;
191 } KeyInstructionsInfo;
192
193private:
194 /// Helper functions for getOrCreateType.
195 /// @{
196 /// Currently the checksum of an interface includes the number of
197 /// ivars and property accessors.
198 llvm::DIType *CreateType(const BuiltinType *Ty);
199 llvm::DIType *CreateType(const ComplexType *Ty);
200 llvm::DIType *CreateType(const BitIntType *Ty);
201 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
202 llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty,
203 llvm::DIFile *Fg);
204 llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg);
205 llvm::DIType *CreateType(const TemplateSpecializationType *Ty,
206 llvm::DIFile *Fg);
207 llvm::DIType *CreateType(const ObjCObjectPointerType *Ty, llvm::DIFile *F);
208 llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F);
209 llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F);
210 llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F);
211 llvm::DIType *CreateType(const HLSLAttributedResourceType *Ty,
212 llvm::DIFile *F);
213 llvm::DIType *CreateType(const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
214 /// Get structure or union type.
215 llvm::DIType *CreateType(const RecordType *Tyg);
216
217 /// Create definition for the specified 'Ty'.
218 ///
219 /// \returns A pair of 'llvm::DIType's. The first is the definition
220 /// of the 'Ty'. The second is the type specified by the preferred_name
221 /// attribute on 'Ty', which can be a nullptr if no such attribute
222 /// exists.
223 std::pair<llvm::DIType *, llvm::DIType *>
224 CreateTypeDefinition(const RecordType *Ty);
225 llvm::DICompositeType *CreateLimitedType(const RecordType *Ty);
226 void CollectContainingType(const CXXRecordDecl *RD,
227 llvm::DICompositeType *CT);
228 /// Get Objective-C interface type.
229 llvm::DIType *CreateType(const ObjCInterfaceType *Ty, llvm::DIFile *F);
230 llvm::DIType *CreateTypeDefinition(const ObjCInterfaceType *Ty,
231 llvm::DIFile *F);
232 /// Get Objective-C object type.
233 llvm::DIType *CreateType(const ObjCObjectType *Ty, llvm::DIFile *F);
234 llvm::DIType *CreateType(const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
235
236 llvm::DIType *CreateType(const VectorType *Ty, llvm::DIFile *F);
237 llvm::DIType *CreateType(const ConstantMatrixType *Ty, llvm::DIFile *F);
238 llvm::DIType *CreateType(const ArrayType *Ty, llvm::DIFile *F);
239 llvm::DIType *CreateType(const LValueReferenceType *Ty, llvm::DIFile *F);
240 llvm::DIType *CreateType(const RValueReferenceType *Ty, llvm::DIFile *Unit);
241 llvm::DIType *CreateType(const MemberPointerType *Ty, llvm::DIFile *F);
242 llvm::DIType *CreateType(const AtomicType *Ty, llvm::DIFile *F);
243 llvm::DIType *CreateType(const PipeType *Ty, llvm::DIFile *F);
244 /// Get enumeration type.
245 llvm::DIType *CreateEnumType(const EnumType *Ty);
246 llvm::DIType *CreateTypeDefinition(const EnumType *Ty);
247 /// Look up the completed type for a self pointer in the TypeCache and
248 /// create a copy of it with the ObjectPointer and Artificial flags
249 /// set. If the type is not cached, a new one is created. This should
250 /// never happen though, since creating a type for the implicit self
251 /// argument implies that we already parsed the interface definition
252 /// and the ivar declarations in the implementation.
253 llvm::DIType *CreateSelfType(const QualType &QualTy, llvm::DIType *Ty);
254 /// @}
255
256 /// Get the type from the cache or return null type if it doesn't
257 /// exist.
258 llvm::DIType *getTypeOrNull(const QualType);
259 /// Return the debug type for a C++ method.
260 /// \arg CXXMethodDecl is of FunctionType. This function type is
261 /// not updated to include implicit \c this pointer. Use this routine
262 /// to get a method type which includes \c this pointer.
263 llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
264 llvm::DIFile *F);
265
266 llvm::DISubroutineType *
267 getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
268 llvm::DIFile *F, QualType FNType);
269
270 llvm::DISubroutineType *
271 getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
272 llvm::DIFile *Unit, bool SkipFirst = false);
273 llvm::DISubroutineType *
274 getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
275 /// \return debug info descriptor for vtable.
276 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
277
278 /// \return namespace descriptor for the given namespace decl.
279 llvm::DINamespace *getOrCreateNamespace(const NamespaceDecl *N);
280 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty,
281 QualType PointeeTy, llvm::DIFile *F);
282 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&Cache);
283
284 /// A helper function to create a subprogram for a single member
285 /// function GlobalDecl.
286 llvm::DISubprogram *CreateCXXMemberFunction(const CXXMethodDecl *Method,
287 llvm::DIFile *F,
288 llvm::DIType *RecordTy);
289
290 /// A helper function to collect debug info for C++ member
291 /// functions. This is used while creating debug info entry for a
292 /// Record.
293 void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::DIFile *F,
295 llvm::DIType *T);
296
297 /// A helper function to collect debug info for C++ base
298 /// classes. This is used while creating debug info entry for a
299 /// Record.
300 void CollectCXXBases(const CXXRecordDecl *Decl, llvm::DIFile *F,
302 llvm::DIType *RecordTy);
303
304 /// Helper function for CollectCXXBases.
305 /// Adds debug info entries for types in Bases that are not in SeenTypes.
306 void CollectCXXBasesAux(
307 const CXXRecordDecl *RD, llvm::DIFile *Unit,
308 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
310 llvm::DenseSet<CanonicalDeclPtr<const CXXRecordDecl>> &SeenTypes,
311 llvm::DINode::DIFlags StartingFlags);
312
313 /// Helper function that returns the llvm::DIType that the
314 /// PreferredNameAttr attribute on \ref RD refers to. If no such
315 /// attribute exists, returns nullptr.
316 llvm::DIType *GetPreferredNameType(const CXXRecordDecl *RD,
317 llvm::DIFile *Unit);
318
319 struct TemplateArgs {
320 const TemplateParameterList *TList;
322 };
323 /// A helper function to collect template parameters.
324 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
325 llvm::DIFile *Unit);
326 /// A helper function to collect debug info for function template
327 /// parameters.
328 llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD,
329 llvm::DIFile *Unit);
330
331 /// A helper function to collect debug info for function template
332 /// parameters.
333 llvm::DINodeArray CollectVarTemplateParams(const VarDecl *VD,
334 llvm::DIFile *Unit);
335
336 std::optional<TemplateArgs> GetTemplateArgs(const VarDecl *) const;
337 std::optional<TemplateArgs> GetTemplateArgs(const RecordDecl *) const;
338 std::optional<TemplateArgs> GetTemplateArgs(const FunctionDecl *) const;
339
340 /// A helper function to collect debug info for template
341 /// parameters.
342 llvm::DINodeArray CollectCXXTemplateParams(const RecordDecl *TS,
343 llvm::DIFile *F);
344
345 /// A helper function to collect debug info for btf_decl_tag annotations.
346 llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
347
348 llvm::DIType *createFieldType(StringRef name, QualType type,
350 uint64_t offsetInBits, uint32_t AlignInBits,
351 llvm::DIFile *tunit, llvm::DIScope *scope,
352 const RecordDecl *RD = nullptr,
353 llvm::DINodeArray Annotations = nullptr);
354
355 llvm::DIType *createFieldType(StringRef name, QualType type,
357 uint64_t offsetInBits, llvm::DIFile *tunit,
358 llvm::DIScope *scope,
359 const RecordDecl *RD = nullptr) {
360 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
361 RD);
362 }
363
364 /// Create new bit field member.
365 llvm::DIDerivedType *createBitFieldType(const FieldDecl *BitFieldDecl,
366 llvm::DIScope *RecordTy,
367 const RecordDecl *RD);
368
369 /// Create an anonnymous zero-size separator for bit-field-decl if needed on
370 /// the target.
371 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
372 const FieldDecl *BitFieldDecl, const llvm::DIDerivedType *BitFieldDI,
373 llvm::ArrayRef<llvm::Metadata *> PreviousFieldsDI, const RecordDecl *RD);
374
375 /// A cache that maps names of artificial inlined functions to subprograms.
376 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
377
378 /// A function that returns the subprogram corresponding to the artificial
379 /// inlined function for traps.
380 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
381 llvm::DIFile *FileScope);
382
383 /// Helpers for collecting fields of a record.
384 /// @{
385 void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
386 SmallVectorImpl<llvm::Metadata *> &E,
387 llvm::DIType *RecordTy);
388 llvm::DIDerivedType *CreateRecordStaticField(const VarDecl *Var,
389 llvm::DIType *RecordTy,
390 const RecordDecl *RD);
391 void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,
392 llvm::DIFile *F,
393 SmallVectorImpl<llvm::Metadata *> &E,
394 llvm::DIType *RecordTy, const RecordDecl *RD);
395 void CollectRecordNestedType(const TypeDecl *RD,
396 SmallVectorImpl<llvm::Metadata *> &E);
397 void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
398 SmallVectorImpl<llvm::Metadata *> &E,
399 llvm::DICompositeType *RecordTy);
400
401 /// If the C++ class has vtable info then insert appropriate debug
402 /// info entry in EltTys vector.
403 void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile *F,
404 SmallVectorImpl<llvm::Metadata *> &EltTys);
405 /// @}
406
407 /// Create a new lexical block node and push it on the stack.
408 void CreateLexicalBlock(SourceLocation Loc);
409
410 /// If target-specific LLVM \p AddressSpace directly maps to target-specific
411 /// DWARF address space, appends extended dereferencing mechanism to complex
412 /// expression \p Expr. Otherwise, does nothing.
413 ///
414 /// Extended dereferencing mechanism is has the following format:
415 /// DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef
416 void AppendAddressSpaceXDeref(unsigned AddressSpace,
417 SmallVectorImpl<uint64_t> &Expr) const;
418
419 /// A helper function to collect debug info for the default elements of a
420 /// block.
421 ///
422 /// \returns The next available field offset after the default elements.
423 uint64_t collectDefaultElementTypesForBlockPointer(
424 const BlockPointerType *Ty, llvm::DIFile *Unit,
425 llvm::DIDerivedType *DescTy, unsigned LineNo,
426 SmallVectorImpl<llvm::Metadata *> &EltTys);
427
428 /// A helper function to collect debug info for the default fields of a
429 /// block.
430 void collectDefaultFieldsForBlockLiteralDeclare(
431 const CGBlockInfo &Block, const ASTContext &Context, SourceLocation Loc,
432 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
433 SmallVectorImpl<llvm::Metadata *> &Fields);
434
435public:
436 CGDebugInfo(CodeGenModule &CGM);
437 ~CGDebugInfo();
438
439 void finalize();
440
441 /// Remap a given path with the current debug prefix map
442 std::string remapDIPath(StringRef) const;
443
444 /// Register VLA size expression debug node with the qualified type.
445 void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr) {
446 SizeExprCache[Ty] = SizeExpr;
447 }
448
449 /// Module debugging: Support for building PCMs.
450 /// @{
451 /// Set the main CU's DwoId field to \p Signature.
452 void setDwoId(uint64_t Signature);
453
454 /// When generating debug information for a clang module or
455 /// precompiled header, this module map will be used to determine
456 /// the module of origin of each Decl.
457 void setModuleMap(ModuleMap &MMap) { ClangModuleMap = &MMap; }
458
459 /// When generating debug information for a clang module or
460 /// precompiled header, this module map will be used to determine
461 /// the module of origin of each Decl.
462 void setPCHDescriptor(ASTSourceDescriptor PCH) { PCHDescriptor = PCH; }
463 /// @}
464
465 /// Update the current source location. If \arg loc is invalid it is
466 /// ignored.
468
469 /// Return the current source location. This does not necessarily correspond
470 /// to the IRBuilder's current DebugLoc.
471 SourceLocation getLocation() const { return CurLoc; }
472
473 /// Update the current inline scope. All subsequent calls to \p EmitLocation
474 /// will create a location with this inlinedAt field.
475 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
476
477 /// \return the current inline scope.
478 llvm::MDNode *getInlinedAt() const { return CurInlinedAt; }
479
480 // Converts a SourceLocation to a DebugLoc
481 llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc);
482
483 /// Emit metadata to indicate a change in line/column information in
484 /// the source file. If the location is invalid, the previous
485 /// location will be reused.
487
490
491 /// Emit a call to llvm.dbg.function.start to indicate
492 /// start of a new function.
493 /// \param Loc The location of the function header.
494 /// \param ScopeLoc The location of the function body.
496 SourceLocation ScopeLoc, QualType FnType,
497 llvm::Function *Fn, bool CurFnIsThunk);
498
499 /// Start a new scope for an inlined function.
501 /// End an inlined function scope.
502 void EmitInlineFunctionEnd(CGBuilderTy &Builder);
503
504 /// Emit debug info for a function declaration.
505 /// \p Fn is set only when a declaration for a debug call site gets created.
507 QualType FnType, llvm::Function *Fn = nullptr);
508
509 /// Emit debug info for an extern function being called.
510 /// This is needed for call site debug info.
511 void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
512 QualType CalleeType,
513 const FunctionDecl *CalleeDecl);
514
515 /// Constructs the debug code for exiting a function.
516 void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
517
518 /// Emit metadata to indicate the beginning of a new lexical block
519 /// and push the block onto the stack.
521
522 /// Emit metadata to indicate the end of a new lexical block and pop
523 /// the current block.
525
526 /// Emit call to \c llvm.dbg.declare for an automatic variable
527 /// declaration.
528 /// Returns a pointer to the DILocalVariable associated with the
529 /// llvm.dbg.declare, or nullptr otherwise.
530 llvm::DILocalVariable *
531 EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
532 CGBuilderTy &Builder,
533 const bool UsePointerValue = false);
534
535 /// Emit call to \c llvm.dbg.label for an label.
536 void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
537
538 /// Emit call to \c llvm.dbg.declare for an imported variable
539 /// declaration in a block.
541 const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder,
542 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint = nullptr);
543
544 /// Emit call to \c llvm.dbg.declare for an argument variable
545 /// declaration.
546 llvm::DILocalVariable *
547 EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo,
548 CGBuilderTy &Builder, bool UsePointerValue = false);
549
550 /// Emit call to \c llvm.dbg.declare for the block-literal argument
551 /// to a block invocation function.
553 StringRef Name, unsigned ArgNo,
554 llvm::AllocaInst *LocalAddr,
555 CGBuilderTy &Builder);
556
557 /// Emit information about a global variable.
558 void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
559
560 /// Emit a constant global variable's debug info.
561 void EmitGlobalVariable(const ValueDecl *VD, const APValue &Init);
562
563 /// Emit information about an external variable.
564 void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
565
566 /// Emit a pseudo variable and debug info for an intermediate value if it does
567 /// not correspond to a variable in the source code, so that a profiler can
568 /// track more accurate usage of certain instructions of interest.
569 void EmitPseudoVariable(CGBuilderTy &Builder, llvm::Instruction *Value,
570 QualType Ty);
571
572 /// Emit information about global variable alias.
573 void EmitGlobalAlias(const llvm::GlobalValue *GV, const GlobalDecl Decl);
574
575 /// Emit C++ using directive.
577
578 /// Emit the type explicitly casted to.
580
581 /// Emit the type even if it might not be used.
583
584 /// Emit a shadow decl brought in by a using or using-enum
585 void EmitUsingShadowDecl(const UsingShadowDecl &USD);
586
587 /// Emit C++ using declaration.
588 void EmitUsingDecl(const UsingDecl &UD);
589
590 /// Emit C++ using-enum declaration.
591 void EmitUsingEnumDecl(const UsingEnumDecl &UD);
592
593 /// Emit an @import declaration.
594 void EmitImportDecl(const ImportDecl &ID);
595
596 /// DebugInfo isn't attached to string literals by default. While certain
597 /// aspects of debuginfo aren't useful for string literals (like a name), it's
598 /// nice to be able to symbolize the line and column information. This is
599 /// especially useful for sanitizers, as it allows symbolization of
600 /// heap-buffer-overflows on constant strings.
601 void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
602 const StringLiteral *S);
603
604 /// Emit C++ namespace alias.
605 llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
606
607 /// Emit record type's standalone debug info.
608 llvm::DIType *getOrCreateRecordType(QualType Ty, SourceLocation L);
609
610 /// Emit an Objective-C interface type standalone debug info.
612
613 /// Emit standalone debug info for a type.
615
616 /// Add heapallocsite metadata for MSAllocator calls.
617 void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy,
619
620 void completeType(const EnumDecl *ED);
621 void completeType(const RecordDecl *RD);
622 void completeRequiredType(const RecordDecl *RD);
623 void completeClassData(const RecordDecl *RD);
624 void completeClass(const RecordDecl *RD);
625
628
629 /// Create debug info for a macro defined by a #define directive or a macro
630 /// undefined by a #undef directive.
631 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *Parent, unsigned MType,
632 SourceLocation LineLoc, StringRef Name,
633 StringRef Value);
634
635 /// Create debug info for a file referenced by an #include directive.
636 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
637 SourceLocation LineLoc,
638 SourceLocation FileLoc);
639
640 Param2DILocTy &getParamDbgMappings() { return ParamDbgMappings; }
641 ParamDecl2StmtTy &getCoroutineParameterMappings() {
642 return CoroutineParameterMappings;
643 }
644
645 /// Create a debug location from `TrapLocation` that adds an artificial inline
646 /// frame where the frame name is
647 ///
648 /// * `<Prefix>:<Category>:<FailureMsg>`
649 ///
650 /// `<Prefix>` is "__clang_trap_msg".
651 ///
652 /// This is used to store failure reasons for traps.
653 llvm::DILocation *CreateTrapFailureMessageFor(llvm::DebugLoc TrapLocation,
654 StringRef Category,
655 StringRef FailureMsg);
656 /// Create a debug location from `Location` that adds an artificial inline
657 /// frame where the frame name is FuncName
658 ///
659 /// This is used to indiciate instructions that come from compiler
660 /// instrumentation.
661 llvm::DILocation *CreateSyntheticInlineAt(llvm::DebugLoc Location,
662 StringRef FuncName);
663
664 /// Reset internal state.
665 void completeFunction();
666
667 /// Add \p KeyInstruction and an optional \p Backup instruction to the
668 /// current atom group, created using ApplyAtomGroup.
669 void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
670 llvm::Value *Backup);
671
672 /// Add \p KeyInstruction and an optional \p Backup instruction to the atom
673 /// group \p Atom.
674 void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
675 llvm::Value *Backup, uint64_t Atom);
676
677 /// Emit symbol for debugger that holds the pointer to the vtable.
678 void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD);
679
680private:
681 /// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
682 /// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
683 /// has no DebugLoc, and chooses the atom group in which the instruction
684 /// has the highest precedence if it's already in one.
685 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
686 uint8_t Rank);
687
688 /// Emit call to llvm.dbg.declare for a variable declaration.
689 /// Returns a pointer to the DILocalVariable associated with the
690 /// llvm.dbg.declare, or nullptr otherwise.
691 llvm::DILocalVariable *EmitDeclare(const VarDecl *decl, llvm::Value *AI,
692 std::optional<unsigned> ArgNo,
693 CGBuilderTy &Builder,
694 const bool UsePointerValue = false);
695
696 /// Emit call to llvm.dbg.declare for a binding declaration.
697 /// Returns a pointer to the DILocalVariable associated with the
698 /// llvm.dbg.declare, or nullptr otherwise.
699 llvm::DILocalVariable *EmitDeclare(const BindingDecl *decl, llvm::Value *AI,
700 std::optional<unsigned> ArgNo,
701 CGBuilderTy &Builder,
702 const bool UsePointerValue = false);
703
704 struct BlockByRefType {
705 /// The wrapper struct used inside the __block_literal struct.
706 llvm::DIType *BlockByRefWrapper;
707 /// The type as it appears in the source code.
708 llvm::DIType *WrappedType;
709 };
710
711 bool HasReconstitutableArgs(ArrayRef<TemplateArgument> Args) const;
712 std::string GetName(const Decl *, bool Qualified = false) const;
713
714 /// Build up structure info for the byref. See \a BuildByRefType.
715 BlockByRefType EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
716 uint64_t *OffSet);
717
718 /// Get context info for the DeclContext of \p Decl.
719 llvm::DIScope *getDeclContextDescriptor(const Decl *D);
720 /// Get context info for a given DeclContext \p Decl.
721 llvm::DIScope *getContextDescriptor(const Decl *Context,
722 llvm::DIScope *Default);
723
724 llvm::DIScope *getCurrentContextDescriptor(const Decl *Decl);
725
726 /// Create a forward decl for a RecordType in a given context.
727 llvm::DICompositeType *getOrCreateRecordFwdDecl(const RecordType *,
728 llvm::DIScope *);
729
730 /// Return current directory name.
731 StringRef getCurrentDirname();
732
733 /// Create new compile unit.
734 void CreateCompileUnit();
735
736 /// Compute the file checksum debug info for input file ID.
737 std::optional<llvm::DIFile::ChecksumKind>
738 computeChecksum(FileID FID, SmallString<64> &Checksum) const;
739
740 /// Get the source of the given file ID.
741 std::optional<StringRef> getSource(const SourceManager &SM, FileID FID);
742
743 /// Convenience function to get the file debug info descriptor for the input
744 /// location.
745 llvm::DIFile *getOrCreateFile(SourceLocation Loc);
746
747 /// Create a file debug info descriptor for a source file.
748 llvm::DIFile *
749 createFile(StringRef FileName,
750 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
751 std::optional<StringRef> Source);
752
753 /// Get the type from the cache or create a new type if necessary.
754 llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
755
756 /// Get a reference to a clang module. If \p CreateSkeletonCU is true,
757 /// this also creates a split dwarf skeleton compile unit.
758 llvm::DIModule *getOrCreateModuleRef(ASTSourceDescriptor Mod,
759 bool CreateSkeletonCU);
760
761 /// DebugTypeExtRefs: If \p D originated in a clang module, return it.
762 llvm::DIModule *getParentModuleOrNull(const Decl *D);
763
764 /// Get the type from the cache or create a new partial type if
765 /// necessary.
766 llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty);
767
768 /// Create type metadata for a source language type.
769 llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg);
770
771 /// Create new member and increase Offset by FType's size.
772 llvm::DIType *CreateMemberType(llvm::DIFile *Unit, QualType FType,
773 StringRef Name, uint64_t *Offset);
774
775 /// Retrieve the DIDescriptor, if any, for the canonical form of this
776 /// declaration.
777 llvm::DINode *getDeclarationOrDefinition(const Decl *D);
778
779 /// \return debug info descriptor to describe method
780 /// declaration for the given method definition.
781 llvm::DISubprogram *getFunctionDeclaration(const Decl *D);
782
783 /// \return debug info descriptor to the describe method declaration
784 /// for the given method definition.
785 /// \param FnType For Objective-C methods, their type.
786 /// \param LineNo The declaration's line number.
787 /// \param Flags The DIFlags for the method declaration.
788 /// \param SPFlags The subprogram-spcific flags for the method declaration.
789 llvm::DISubprogram *
790 getObjCMethodDeclaration(const Decl *D, llvm::DISubroutineType *FnType,
791 unsigned LineNo, llvm::DINode::DIFlags Flags,
792 llvm::DISubprogram::DISPFlags SPFlags);
793
794 /// \return debug info descriptor to describe in-class static data
795 /// member declaration for the given out-of-class definition. If D
796 /// is an out-of-class definition of a static data member of a
797 /// class, find its corresponding in-class declaration.
798 llvm::DIDerivedType *
799 getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
800
801 /// Helper that either creates a forward declaration or a stub.
802 llvm::DISubprogram *getFunctionFwdDeclOrStub(GlobalDecl GD, bool Stub);
803
804 /// Create a subprogram describing the forward declaration
805 /// represented in the given FunctionDecl wrapped in a GlobalDecl.
806 llvm::DISubprogram *getFunctionForwardDeclaration(GlobalDecl GD);
807
808 /// Create a DISubprogram describing the function
809 /// represented in the given FunctionDecl wrapped in a GlobalDecl.
810 llvm::DISubprogram *getFunctionStub(GlobalDecl GD);
811
812 /// Create a global variable describing the forward declaration
813 /// represented in the given VarDecl.
814 llvm::DIGlobalVariable *
815 getGlobalVariableForwardDeclaration(const VarDecl *VD);
816
817 /// Return a global variable that represents one of the collection of global
818 /// variables created for an anonmyous union.
819 ///
820 /// Recursively collect all of the member fields of a global
821 /// anonymous decl and create static variables for them. The first
822 /// time this is called it needs to be on a union and then from
823 /// there we can have additional unnamed fields.
824 llvm::DIGlobalVariableExpression *
825 CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile *Unit,
826 unsigned LineNo, StringRef LinkageName,
827 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
828
829
830 /// Return flags which enable debug info emission for call sites, provided
831 /// that it is supported and enabled.
832 llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
833
834 /// Get the printing policy for producing names for debug info.
835 PrintingPolicy getPrintingPolicy() const;
836
837 /// Get function name for the given FunctionDecl. If the name is
838 /// constructed on demand (e.g., C++ destructor) then the name is
839 /// stored on the side.
840 StringRef getFunctionName(const FunctionDecl *FD);
841
842 /// Returns the unmangled name of an Objective-C method.
843 /// This is the display name for the debugging info.
844 StringRef getObjCMethodName(const ObjCMethodDecl *FD);
845
846 /// Return selector name. This is used for debugging
847 /// info.
848 StringRef getSelectorName(Selector S);
849
850 /// Get class name including template argument list.
851 StringRef getClassName(const RecordDecl *RD);
852
853 /// Get the vtable name for the given class.
854 StringRef getVTableName(const CXXRecordDecl *Decl);
855
856 /// Get the name to use in the debug info for a dynamic initializer or atexit
857 /// stub function.
858 StringRef getDynamicInitializerName(const VarDecl *VD,
859 DynamicInitKind StubKind,
860 llvm::Function *InitFn);
861
862 /// Get line number for the location. If location is invalid
863 /// then use current location.
864 unsigned getLineNumber(SourceLocation Loc);
865
866 /// Get column number for the location. If location is
867 /// invalid then use current location.
868 /// \param Force Assume DebugColumnInfo option is true.
869 unsigned getColumnNumber(SourceLocation Loc, bool Force = false);
870
871 /// Collect various properties of a FunctionDecl.
872 /// \param GD A GlobalDecl whose getDecl() must return a FunctionDecl.
873 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
874 StringRef &Name, StringRef &LinkageName,
875 llvm::DIScope *&FDContext,
876 llvm::DINodeArray &TParamsArray,
877 llvm::DINode::DIFlags &Flags);
878
879 /// Collect various properties of a VarDecl.
880 void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
881 unsigned &LineNo, QualType &T, StringRef &Name,
882 StringRef &LinkageName,
883 llvm::MDTuple *&TemplateParameters,
884 llvm::DIScope *&VDContext);
885
886 /// Create a DIExpression representing the constant corresponding
887 /// to the specified 'Val'. Returns nullptr on failure.
888 llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD,
889 const APValue &Val);
890
891 /// Allocate a copy of \p A using the DebugInfoNames allocator
892 /// and return a reference to it. If multiple arguments are given the strings
893 /// are concatenated.
894 StringRef internString(StringRef A, StringRef B = StringRef()) {
895 char *Data = DebugInfoNames.Allocate<char>(A.size() + B.size());
896 if (!A.empty())
897 std::memcpy(Data, A.data(), A.size());
898 if (!B.empty())
899 std::memcpy(Data + A.size(), B.data(), B.size());
900 return StringRef(Data, A.size() + B.size());
901 }
902};
903
904/// A scoped helper to set the current debug location to the specified
905/// location or preferred location of the specified Expr.
907private:
908 void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false);
909 ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty,
910 SourceLocation TemporaryLocation);
911
912 llvm::DebugLoc OriginalLocation;
913 CodeGenFunction *CGF;
914
915public:
916 /// Set the location to the (valid) TemporaryLocation.
917 ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation);
919 ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
921 Other.CGF = nullptr;
922 }
923
924 // Define copy assignment operator.
926 if (this != &Other) {
927 CGF = Other.CGF;
928 Other.CGF = nullptr;
929 }
930 return *this;
931 }
932
934
935 /// Apply TemporaryLocation if it is valid. Otherwise switch
936 /// to an artificial debug location that has a valid scope, but no
937 /// line information.
938 ///
939 /// Artificial locations are useful when emitting compiler-generated
940 /// helper functions that have no source location associated with
941 /// them. The DWARF specification allows the compiler to use the
942 /// special line number 0 to indicate code that can not be
943 /// attributed to any source location. Note that passing an empty
944 /// SourceLocation to CGDebugInfo::setLocation() will result in the
945 /// last valid location being reused.
947 return ApplyDebugLocation(CGF, false, SourceLocation());
948 }
949 /// Apply TemporaryLocation if it is valid. Otherwise switch
950 /// to an artificial debug location that has a valid scope, but no
951 /// line information.
952 static ApplyDebugLocation
954 SourceLocation TemporaryLocation) {
955 return ApplyDebugLocation(CGF, false, TemporaryLocation);
956 }
957
958 /// Set the IRBuilder to not attach debug locations. Note that
959 /// passing an empty SourceLocation to \a CGDebugInfo::setLocation()
960 /// will result in the last valid location being reused. Note that
961 /// all instructions that do not have a location at the beginning of
962 /// a function are counted towards to function prologue.
964 return ApplyDebugLocation(CGF, true, SourceLocation());
965 }
966};
967
968/// A scoped helper to set the current debug location to an inlined location.
970 SourceLocation SavedLocation;
971 CodeGenFunction *CGF;
972
973public:
974 /// Set up the CodeGenFunction's DebugInfo to produce inline locations for the
975 /// function \p InlinedFn. The current debug location becomes the inlined call
976 /// site of the inlined function.
978 /// Restore everything back to the original state.
982};
983
985 CodeGenFunction *CGF;
986 ApplyDebugLocation Apply;
987
988public:
991 SanitizerHandler Handler);
995};
996
997} // namespace CodeGen
998} // namespace clang
999
1000#endif // LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
NodeId Parent
Definition: ASTDiff.cpp:191
MatchType Type
Defines the clang::ASTSourceDescriptor class, which abstracts clang modules and precompiled header fi...
static char ID
Definition: Arena.cpp:183
const Decl * D
IndirectLocalPath & Path
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
int Category
Definition: Format.cpp:3180
#define SM(sm)
Definition: OffloadArch.cpp:16
SanitizerHandler
SourceLocation Loc
Definition: SemaObjC.cpp:754
Defines the clang::SourceLocation class and associated facilities.
Allows QualTypes to be sorted and hence used in maps and sets.
C Language Family Type Representation.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: TypeBase.h:3738
A binding in a decomposition declaration.
Definition: DeclCXX.h:4179
A fixed int type of a specified bitwidth.
Definition: TypeBase.h:8195
Pointer to a block type.
Definition: TypeBase.h:3558
This class is used for builtin types like 'int'.
Definition: TypeBase.h:3182
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2129
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
llvm::iterator_range< base_class_const_iterator > base_class_const_range
Definition: DeclCXX.h:606
A wrapper class around a pointer that always points to its canonical declaration.
Definition: Redeclarable.h:346
Represents a class template specialization, which refers to a class template with a given set of temp...
A scoped helper to set the current source atom group for CGDebugInfo::addInstToCurrentSourceAtom.
A scoped helper to set the current debug location to the specified location or preferred location of ...
Definition: CGDebugInfo.h:906
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
Definition: CGDebugInfo.h:946
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
Definition: CGDebugInfo.h:953
ApplyDebugLocation(ApplyDebugLocation &&Other)
Definition: CGDebugInfo.h:920
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
Definition: CGDebugInfo.h:963
ApplyDebugLocation & operator=(ApplyDebugLocation &&Other)
Definition: CGDebugInfo.h:925
A scoped helper to set the current debug location to an inlined location.
Definition: CGDebugInfo.h:969
ApplyInlineDebugLocation & operator=(ApplyInlineDebugLocation &)=delete
ApplyInlineDebugLocation(const ApplyInlineDebugLocation &)=delete
~ApplyInlineDebugLocation()
Restore everything back to the original state.
CGBlockInfo - Information to generate a block literal.
Definition: CGBlocks.h:157
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:59
llvm::MDNode * getInlinedAt() const
Definition: CGDebugInfo.h:478
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
Add KeyInstruction and an optional Backup instruction to the current atom group, created using ApplyA...
llvm::DIType * getOrCreateStandaloneType(QualType Ty, SourceLocation Loc)
Emit standalone debug info for a type.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate a change in line/column information in the source file.
void completeFunction()
Reset internal state.
void EmitGlobalAlias(const llvm::GlobalValue *GV, const GlobalDecl Decl)
Emit information about global variable alias.
void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder)
Emit call to llvm.dbg.label for an label.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
void setInlinedAt(llvm::MDNode *InlinedAt)
Update the current inline scope.
Definition: CGDebugInfo.h:475
void completeUnusedClass(const CXXRecordDecl &D)
SourceLocation getLocation() const
Return the current source location.
Definition: CGDebugInfo.h:471
llvm::DILocation * CreateSyntheticInlineAt(llvm::DebugLoc Location, StringRef FuncName)
Create a debug location from Location that adds an artificial inline frame where the frame name is Fu...
void EmitUsingShadowDecl(const UsingShadowDecl &USD)
Emit a shadow decl brought in by a using or using-enum.
void EmitUsingEnumDecl(const UsingEnumDecl &UD)
Emit C++ using-enum declaration.
void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn)
Constructs the debug code for exiting a function.
void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke, QualType CalleeType, const FunctionDecl *CalleeDecl)
Emit debug info for an extern function being called.
void EmitUsingDecl(const UsingDecl &UD)
Emit C++ using declaration.
llvm::DIMacroFile * CreateTempMacroFile(llvm::DIMacroFile *Parent, SourceLocation LineLoc, SourceLocation FileLoc)
Create debug info for a file referenced by an #include directive.
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD)
void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about an external variable.
Param2DILocTy & getParamDbgMappings()
Definition: CGDebugInfo.h:640
void emitFunctionStart(GlobalDecl GD, SourceLocation Loc, SourceLocation ScopeLoc, QualType FnType, llvm::Function *Fn, bool CurFnIsThunk)
Emit a call to llvm.dbg.function.start to indicate start of a new function.
llvm::DILocalVariable * EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder, bool UsePointerValue=false)
Emit call to llvm.dbg.declare for an argument variable declaration.
void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD)
Emit symbol for debugger that holds the pointer to the vtable.
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the end of a new lexical block and pop the current block.
void EmitUsingDirective(const UsingDirectiveDecl &UD)
Emit C++ using directive.
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom)
Add KeyInstruction and an optional Backup instruction to the atom group Atom.
void completeRequiredType(const RecordDecl *RD)
void EmitAndRetainType(QualType Ty)
Emit the type even if it might not be used.
void EmitInlineFunctionEnd(CGBuilderTy &Builder)
End an inlined function scope.
ParamDecl2StmtTy & getCoroutineParameterMappings()
Definition: CGDebugInfo.h:641
void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType, llvm::Function *Fn=nullptr)
Emit debug info for a function declaration.
void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV, const StringLiteral *S)
DebugInfo isn't attached to string literals by default.
llvm::DILocalVariable * EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder, const bool UsePointerValue=false)
Emit call to llvm.dbg.declare for an automatic variable declaration.
void completeClassData(const RecordDecl *RD)
void EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD)
Start a new scope for an inlined function.
void setModuleMap(ModuleMap &MMap)
When generating debug information for a clang module or precompiled header, this module map will be u...
Definition: CGDebugInfo.h:457
void EmitImportDecl(const ImportDecl &ID)
Emit an @import declaration.
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, StringRef Name, unsigned ArgNo, llvm::AllocaInst *LocalAddr, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for the block-literal argument to a block invocation function.
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc)
void completeClass(const RecordDecl *RD)
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the beginning of a new lexical block and push the block onto the stack.
friend class SaveAndRestoreLocation
Definition: CGDebugInfo.h:61
void setLocation(SourceLocation Loc)
Update the current source location.
llvm::DIMacro * CreateMacro(llvm::DIMacroFile *Parent, unsigned MType, SourceLocation LineLoc, StringRef Name, StringRef Value)
Create debug info for a macro defined by a #define directive or a macro undefined by a #undef directi...
llvm::DILocation * CreateTrapFailureMessageFor(llvm::DebugLoc TrapLocation, StringRef Category, StringRef FailureMsg)
Create a debug location from TrapLocation that adds an artificial inline frame where the frame name i...
llvm::DIType * getOrCreateRecordType(QualType Ty, SourceLocation L)
Emit record type's standalone debug info.
void EmitPseudoVariable(CGBuilderTy &Builder, llvm::Instruction *Value, QualType Ty)
Emit a pseudo variable and debug info for an intermediate value if it does not correspond to a variab...
std::string remapDIPath(StringRef) const
Remap a given path with the current debug prefix map.
void EmitExplicitCastType(QualType Ty)
Emit the type explicitly casted to.
void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy, SourceLocation Loc)
Add heapallocsite metadata for MSAllocator calls.
void setDwoId(uint64_t Signature)
Module debugging: Support for building PCMs.
QualType getFunctionType(const FunctionDecl *FD, QualType RetTy, const SmallVectorImpl< const VarDecl * > &Args)
llvm::DIType * getOrCreateInterfaceType(QualType Ty, SourceLocation Loc)
Emit an Objective-C interface type standalone debug info.
void setPCHDescriptor(ASTSourceDescriptor PCH)
When generating debug information for a clang module or precompiled header, this module map will be u...
Definition: CGDebugInfo.h:462
void completeType(const EnumDecl *ED)
void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr)
Register VLA size expression debug node with the qualified type.
Definition: CGDebugInfo.h:445
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint=nullptr)
Emit call to llvm.dbg.declare for an imported variable declaration in a block.
llvm::DIImportedEntity * EmitNamespaceAlias(const NamespaceAliasDecl &NA)
Emit C++ namespace alias.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
SanitizerDebugLocation & operator=(SanitizerDebugLocation &)=delete
SanitizerDebugLocation(const SanitizerDebugLocation &)=delete
Complex values, per C99 6.2.5p11.
Definition: TypeBase.h:3293
Represents a concrete matrix type with constant number of rows and columns.
Definition: TypeBase.h:4389
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents an enum.
Definition: Decl.h:4004
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: TypeBase.h:6522
This represents one expression.
Definition: Expr.h:112
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
Definition: Decl.h:1999
Represents a prototype with parameter type info, e.g.
Definition: TypeBase.h:5282
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: TypeBase.h:4478
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:57
Represents an arbitrary, user-specified SPIR-V type instruction.
Definition: TypeBase.h:6860
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:5015
An lvalue reference type, per C++11 [dcl.ref].
Definition: TypeBase.h:3633
Represents the declaration of a label.
Definition: Decl.h:523
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: TypeBase.h:3669
Represents a C++ namespace alias.
Definition: DeclCXX.h:3195
Represent a C++ namespace.
Definition: Decl.h:591
Interfaces are the core concept in Objective-C for object oriented design.
Definition: TypeBase.h:7905
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: TypeBase.h:7961
Represents a class type in Objective C.
Definition: TypeBase.h:7707
Represents a type parameter type in Objective C.
Definition: TypeBase.h:7633
PipeType - OpenCL20.
Definition: TypeBase.h:8161
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: TypeBase.h:3346
Callbacks to use to customize the behavior of the pretty-printer.
Definition: PrettyPrinter.h:32
A (possibly-)qualified type.
Definition: TypeBase.h:937
An rvalue reference type, per C++11 [dcl.ref].
Definition: TypeBase.h:3651
Represents a struct/union/class.
Definition: Decl.h:4309
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: TypeBase.h:6502
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1801
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:74
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: TypeBase.h:7290
The type-property cache.
Definition: Type.cpp:4791
The base class of the type hierarchy.
Definition: TypeBase.h:1833
Represents a C++ using-declaration.
Definition: DeclCXX.h:3585
Represents C++ using-directive.
Definition: DeclCXX.h:3090
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3786
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3393
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
Represents a variable declaration or definition.
Definition: Decl.h:925
Represents a GCC generic vector type.
Definition: TypeBase.h:4191
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
The JSON file list parser is used to communicate input to InstallAPI.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:123
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
DynamicInitKind
Definition: GlobalDecl.h:33
const FunctionProtoType * T
@ PCH
Disable validation for a precompiled header and the modules it depends on.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57