clang 23.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 {
43class GlobalDecl;
44class Module;
45class ModuleMap;
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.
127 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
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 *CreateType(const OverflowBehaviorType *Ty, llvm::DIFile *U);
202 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
203 llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty,
204 llvm::DIFile *Fg);
205 llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg);
206 llvm::DIType *CreateType(const TemplateSpecializationType *Ty,
207 llvm::DIFile *Fg);
208 llvm::DIType *CreateType(const ObjCObjectPointerType *Ty, llvm::DIFile *F);
209 llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F);
210 llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F);
211 llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F);
212 llvm::DIType *CreateType(const HLSLAttributedResourceType *Ty,
213 llvm::DIFile *F);
214 llvm::DIType *CreateType(const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
215 /// Get structure or union type.
216 llvm::DIType *CreateType(const RecordType *Tyg);
217
218 /// Create definition for the specified 'Ty'.
219 ///
220 /// \returns A pair of 'llvm::DIType's. The first is the definition
221 /// of the 'Ty'. The second is the type specified by the preferred_name
222 /// attribute on 'Ty', which can be a nullptr if no such attribute
223 /// exists.
224 std::pair<llvm::DIType *, llvm::DIType *>
225 CreateTypeDefinition(const RecordType *Ty);
226 llvm::DICompositeType *CreateLimitedType(const RecordType *Ty);
227 void CollectContainingType(const CXXRecordDecl *RD,
228 llvm::DICompositeType *CT);
229 /// Get Objective-C interface type.
230 llvm::DIType *CreateType(const ObjCInterfaceType *Ty, llvm::DIFile *F);
231 llvm::DIType *CreateTypeDefinition(const ObjCInterfaceType *Ty,
232 llvm::DIFile *F);
233 /// Get Objective-C object type.
234 llvm::DIType *CreateType(const ObjCObjectType *Ty, llvm::DIFile *F);
235 llvm::DIType *CreateType(const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
236
237 llvm::DIType *CreateType(const VectorType *Ty, llvm::DIFile *F);
238 llvm::DIType *CreateType(const ConstantMatrixType *Ty, llvm::DIFile *F);
239 llvm::DIType *CreateType(const ArrayType *Ty, llvm::DIFile *F);
240 llvm::DIType *CreateType(const LValueReferenceType *Ty, llvm::DIFile *F);
241 llvm::DIType *CreateType(const RValueReferenceType *Ty, llvm::DIFile *Unit);
242 llvm::DIType *CreateType(const MemberPointerType *Ty, llvm::DIFile *F);
243 llvm::DIType *CreateType(const AtomicType *Ty, llvm::DIFile *F);
244 llvm::DIType *CreateType(const PipeType *Ty, llvm::DIFile *F);
245 /// Get enumeration type.
246 llvm::DIType *CreateEnumType(const EnumType *Ty);
247 llvm::DIType *CreateTypeDefinition(const EnumType *Ty);
248 /// Look up the completed type for a self pointer in the TypeCache and
249 /// create a copy of it with the ObjectPointer and Artificial flags
250 /// set. If the type is not cached, a new one is created. This should
251 /// never happen though, since creating a type for the implicit self
252 /// argument implies that we already parsed the interface definition
253 /// and the ivar declarations in the implementation.
254 llvm::DIType *CreateSelfType(const QualType &QualTy, llvm::DIType *Ty);
255 /// @}
256
257 /// Get the type from the cache or return null type if it doesn't
258 /// exist.
259 llvm::DIType *getTypeOrNull(const QualType);
260 /// Return the debug type for a C++ method.
261 /// \arg CXXMethodDecl is of FunctionType. This function type is
262 /// not updated to include implicit \c this pointer. Use this routine
263 /// to get a method type which includes \c this pointer.
264 llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
265 llvm::DIFile *F);
266
267 llvm::DISubroutineType *
268 getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
269 llvm::DIFile *F, QualType FNType);
270
271 llvm::DISubroutineType *
272 getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
273 llvm::DIFile *Unit, bool SkipFirst = false);
274 llvm::DISubroutineType *
275 getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
276 /// \return debug info descriptor for vtable.
277 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
278
279 /// \return namespace descriptor for the given namespace decl.
280 llvm::DINamespace *getOrCreateNamespace(const NamespaceDecl *N);
281 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty,
282 QualType PointeeTy, llvm::DIFile *F);
283 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&Cache);
284
285 /// A helper function to create a subprogram for a single member
286 /// function GlobalDecl.
287 llvm::DISubprogram *CreateCXXMemberFunction(const CXXMethodDecl *Method,
288 llvm::DIFile *F,
289 llvm::DIType *RecordTy);
290
291 /// A helper function to collect debug info for C++ member
292 /// functions. This is used while creating debug info entry for a
293 /// Record.
294 void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::DIFile *F,
296 llvm::DIType *T);
297
298 /// A helper function to collect debug info for C++ base
299 /// classes. This is used while creating debug info entry for a
300 /// Record.
301 void CollectCXXBases(const CXXRecordDecl *Decl, llvm::DIFile *F,
303 llvm::DIType *RecordTy);
304
305 /// Helper function for CollectCXXBases.
306 /// Adds debug info entries for types in Bases that are not in SeenTypes.
307 void CollectCXXBasesAux(
308 const CXXRecordDecl *RD, llvm::DIFile *Unit,
309 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
311 llvm::DenseSet<CanonicalDeclPtr<const CXXRecordDecl>> &SeenTypes,
312 llvm::DINode::DIFlags StartingFlags);
313
314 /// Helper function that returns the llvm::DIType that the
315 /// PreferredNameAttr attribute on \ref RD refers to. If no such
316 /// attribute exists, returns nullptr.
317 llvm::DIType *GetPreferredNameType(const CXXRecordDecl *RD,
318 llvm::DIFile *Unit);
319
320 struct TemplateArgs {
321 const TemplateParameterList *TList;
323 };
324 /// A helper function to collect template parameters.
325 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
326 llvm::DIFile *Unit);
327 /// A helper function to collect debug info for function template
328 /// parameters.
329 llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD,
330 llvm::DIFile *Unit);
331
332 /// A helper function to collect debug info for function template
333 /// parameters.
334 llvm::DINodeArray CollectVarTemplateParams(const VarDecl *VD,
335 llvm::DIFile *Unit);
336
337 std::optional<TemplateArgs> GetTemplateArgs(const VarDecl *) const;
338 std::optional<TemplateArgs> GetTemplateArgs(const RecordDecl *) const;
339 std::optional<TemplateArgs> GetTemplateArgs(const FunctionDecl *) const;
340
341 /// A helper function to collect debug info for template
342 /// parameters.
343 llvm::DINodeArray CollectCXXTemplateParams(const RecordDecl *TS,
344 llvm::DIFile *F);
345
346 /// A helper function to collect debug info for btf_decl_tag annotations.
347 llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
348
349 llvm::DIType *createFieldType(StringRef name, QualType type,
351 uint64_t offsetInBits, uint32_t AlignInBits,
352 llvm::DIFile *tunit, llvm::DIScope *scope,
353 const RecordDecl *RD = nullptr,
354 llvm::DINodeArray Annotations = nullptr);
355
356 llvm::DIType *createFieldType(StringRef name, QualType type,
358 uint64_t offsetInBits, llvm::DIFile *tunit,
359 llvm::DIScope *scope,
360 const RecordDecl *RD = nullptr) {
361 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
362 RD);
363 }
364
365 /// Create new bit field member.
366 llvm::DIDerivedType *createBitFieldType(const FieldDecl *BitFieldDecl,
367 llvm::DIScope *RecordTy,
368 const RecordDecl *RD);
369
370 /// Create an anonnymous zero-size separator for bit-field-decl if needed on
371 /// the target.
372 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
373 const FieldDecl *BitFieldDecl, const llvm::DIDerivedType *BitFieldDI,
374 llvm::ArrayRef<llvm::Metadata *> PreviousFieldsDI, const RecordDecl *RD);
375
376 /// A cache that maps names of artificial inlined functions to subprograms.
377 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
378
379 /// A function that returns the subprogram corresponding to the artificial
380 /// inlined function for traps.
381 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
382 llvm::DIFile *FileScope);
383
384 /// Helpers for collecting fields of a record.
385 /// @{
386 void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
387 SmallVectorImpl<llvm::Metadata *> &E,
388 llvm::DIType *RecordTy);
389 llvm::DIDerivedType *CreateRecordStaticField(const VarDecl *Var,
390 llvm::DIType *RecordTy,
391 const RecordDecl *RD);
392 void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,
393 llvm::DIFile *F,
394 SmallVectorImpl<llvm::Metadata *> &E,
395 llvm::DIType *RecordTy, const RecordDecl *RD);
396 void CollectRecordNestedType(const TypeDecl *RD,
397 SmallVectorImpl<llvm::Metadata *> &E);
398 void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
399 SmallVectorImpl<llvm::Metadata *> &E,
400 llvm::DICompositeType *RecordTy);
401 llvm::StringRef GetLambdaCaptureName(const LambdaCapture &Capture);
402
403 /// If the C++ class has vtable info then insert appropriate debug
404 /// info entry in EltTys vector.
405 void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile *F,
406 SmallVectorImpl<llvm::Metadata *> &EltTys);
407 /// @}
408
409 /// Create a new lexical block node and push it on the stack.
410 void CreateLexicalBlock(SourceLocation Loc);
411
412 /// If target-specific LLVM \p AddressSpace directly maps to target-specific
413 /// DWARF address space, appends extended dereferencing mechanism to complex
414 /// expression \p Expr. Otherwise, does nothing.
415 ///
416 /// Extended dereferencing mechanism is has the following format:
417 /// DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef
418 void AppendAddressSpaceXDeref(unsigned AddressSpace,
419 SmallVectorImpl<uint64_t> &Expr) const;
420
421 /// A helper function to collect debug info for the default elements of a
422 /// block.
423 ///
424 /// \returns The next available field offset after the default elements.
425 uint64_t collectDefaultElementTypesForBlockPointer(
426 const BlockPointerType *Ty, llvm::DIFile *Unit,
427 llvm::DIDerivedType *DescTy, unsigned LineNo,
428 SmallVectorImpl<llvm::Metadata *> &EltTys);
429
430 /// A helper function to collect debug info for the default fields of a
431 /// block.
432 void collectDefaultFieldsForBlockLiteralDeclare(
433 const CGBlockInfo &Block, const ASTContext &Context, SourceLocation Loc,
434 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
435 SmallVectorImpl<llvm::Metadata *> &Fields);
436
437public:
438 CGDebugInfo(CodeGenModule &CGM);
439 ~CGDebugInfo();
440
441 void finalize();
442
443 /// Remap a given path with the current debug prefix map
444 std::string remapDIPath(StringRef) const;
445
446 /// Register VLA size expression debug node with the qualified type.
447 void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr) {
448 SizeExprCache[Ty] = SizeExpr;
449 }
450
451 /// Module debugging: Support for building PCMs.
452 /// @{
453 /// Set the main CU's DwoId field to \p Signature.
454 void setDwoId(uint64_t Signature);
455
456 /// When generating debug information for a clang module or
457 /// precompiled header, this module map will be used to determine
458 /// the module of origin of each Decl.
459 void setModuleMap(ModuleMap &MMap) { ClangModuleMap = &MMap; }
460
461 /// When generating debug information for a clang module or
462 /// precompiled header, this module map will be used to determine
463 /// the module of origin of each Decl.
464 void setPCHDescriptor(ASTSourceDescriptor PCH) { PCHDescriptor = PCH; }
465 /// @}
466
467 /// Update the current source location. If \arg loc is invalid it is
468 /// ignored.
469 void setLocation(SourceLocation Loc);
470
471 /// Return the current source location. This does not necessarily correspond
472 /// to the IRBuilder's current DebugLoc.
473 SourceLocation getLocation() const { return CurLoc; }
474
475 /// Update the current inline scope. All subsequent calls to \p EmitLocation
476 /// will create a location with this inlinedAt field.
477 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
478
479 /// \return the current inline scope.
480 llvm::MDNode *getInlinedAt() const { return CurInlinedAt; }
481
482 // Converts a SourceLocation to a DebugLoc
483 llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc);
484
485 /// Emit metadata to indicate a change in line/column information in
486 /// the source file. If the location is invalid, the previous
487 /// location will be reused.
488 void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc);
489
492
493 /// Emit a call to llvm.dbg.function.start to indicate
494 /// start of a new function.
495 /// \param Loc The location of the function header.
496 /// \param ScopeLoc The location of the function body.
498 SourceLocation ScopeLoc, QualType FnType,
499 llvm::Function *Fn, bool CurFnIsThunk);
500
501 /// Start a new scope for an inlined function.
503 /// End an inlined function scope.
504 void EmitInlineFunctionEnd(CGBuilderTy &Builder);
505
506 /// Emit debug info for a function declaration.
507 /// \p Fn is set only when a declaration for a debug call site gets created.
509 QualType FnType, llvm::Function *Fn = nullptr);
510
511 /// Emit debug info for an extern function being called.
512 /// This is needed for call site debug info.
513 void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
514 QualType CalleeType,
515 GlobalDecl CalleeGlobalDecl);
516
517 /// Constructs the debug code for exiting a function.
518 void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
519
520 /// Emit metadata to indicate the beginning of a new lexical block
521 /// and push the block onto the stack.
523
524 /// Emit metadata to indicate the end of a new lexical block and pop
525 /// the current block.
527
528 /// Emit call to \c llvm.dbg.declare for an automatic variable
529 /// declaration.
530 /// Returns a pointer to the DILocalVariable associated with the
531 /// llvm.dbg.declare, or nullptr otherwise.
532 llvm::DILocalVariable *
533 EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
534 CGBuilderTy &Builder,
535 const bool UsePointerValue = false);
536
537 /// Emit call to \c llvm.dbg.label for an label.
538 void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
539
540 /// Emit call to \c llvm.dbg.declare for an imported variable
541 /// declaration in a block.
543 const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder,
544 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint = nullptr);
545
546 /// Emit call to \c llvm.dbg.declare for an argument variable
547 /// declaration.
548 llvm::DILocalVariable *
549 EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo,
550 CGBuilderTy &Builder, bool UsePointerValue = false);
551
552 /// Emit call to \c llvm.dbg.declare for the block-literal argument
553 /// to a block invocation function.
555 StringRef Name, unsigned ArgNo,
556 llvm::AllocaInst *LocalAddr,
557 CGBuilderTy &Builder);
558
559 /// Emit information about a global variable.
560 void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
561
562 /// Emit a constant global variable's debug info.
563 void EmitGlobalVariable(const ValueDecl *VD, const APValue &Init);
564
565 /// Emit information about an external variable.
566 void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
567
568 /// Emit a pseudo variable and debug info for an intermediate value if it does
569 /// not correspond to a variable in the source code, so that a profiler can
570 /// track more accurate usage of certain instructions of interest.
571 void EmitPseudoVariable(CGBuilderTy &Builder, llvm::Instruction *Value,
572 QualType Ty);
573
574 /// Emit information about global variable alias.
575 void EmitGlobalAlias(const llvm::GlobalValue *GV, const GlobalDecl Decl);
576
577 /// Emit C++ using directive.
579
580 /// Emit the type explicitly casted to.
582
583 /// Emit the type even if it might not be used.
585
586 /// Emit a shadow decl brought in by a using or using-enum
587 void EmitUsingShadowDecl(const UsingShadowDecl &USD);
588
589 /// Emit C++ using declaration.
590 void EmitUsingDecl(const UsingDecl &UD);
591
592 /// Emit C++ using-enum declaration.
593 void EmitUsingEnumDecl(const UsingEnumDecl &UD);
594
595 /// Emit an @import declaration.
596 void EmitImportDecl(const ImportDecl &ID);
597
598 /// DebugInfo isn't attached to string literals by default. While certain
599 /// aspects of debuginfo aren't useful for string literals (like a name), it's
600 /// nice to be able to symbolize the line and column information. This is
601 /// especially useful for sanitizers, as it allows symbolization of
602 /// heap-buffer-overflows on constant strings.
603 void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
604 const StringLiteral *S);
605
606 /// Emit C++ namespace alias.
607 llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
608
609 /// Emit record type's standalone debug info.
610 llvm::DIType *getOrCreateRecordType(QualType Ty, SourceLocation L);
611
612 /// Emit an Objective-C interface type standalone debug info.
613 llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
614
615 /// Emit standalone debug info for a type.
617
618 /// Add heapallocsite metadata for MSAllocator calls.
619 void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy,
620 SourceLocation Loc);
621
622 void completeType(const EnumDecl *ED);
623 void completeType(const RecordDecl *RD);
624 void completeRequiredType(const RecordDecl *RD);
625 void completeClassData(const RecordDecl *RD);
626 void completeClass(const RecordDecl *RD);
627
629 void completeUnusedClass(const CXXRecordDecl &D);
630
631 /// Create debug info for a macro defined by a #define directive or a macro
632 /// undefined by a #undef directive.
633 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *Parent, unsigned MType,
634 SourceLocation LineLoc, StringRef Name,
635 StringRef Value);
636
637 /// Create debug info for a file referenced by an #include directive.
638 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
639 SourceLocation LineLoc,
640 SourceLocation FileLoc);
641
642 Param2DILocTy &getParamDbgMappings() { return ParamDbgMappings; }
643 ParamDecl2StmtTy &getCoroutineParameterMappings() {
644 return CoroutineParameterMappings;
645 }
646
647 /// Create a debug location from `TrapLocation` that adds an artificial inline
648 /// frame where the frame name is
649 ///
650 /// * `<Prefix>:<Category>:<FailureMsg>`
651 ///
652 /// `<Prefix>` is "__clang_trap_msg".
653 ///
654 /// This is used to store failure reasons for traps.
655 llvm::DILocation *CreateTrapFailureMessageFor(llvm::DebugLoc TrapLocation,
656 StringRef Category,
657 StringRef FailureMsg);
658 /// Create a debug location from `Location` that adds an artificial inline
659 /// frame where the frame name is FuncName
660 ///
661 /// This is used to indiciate instructions that come from compiler
662 /// instrumentation.
663 llvm::DILocation *CreateSyntheticInlineAt(llvm::DebugLoc Location,
664 StringRef FuncName);
665
666 /// Reset internal state.
667 void completeFunction();
668
669 /// Add \p KeyInstruction and an optional \p Backup instruction to the
670 /// current atom group, created using ApplyAtomGroup.
671 void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
672 llvm::Value *Backup);
673
674 /// Add \p KeyInstruction and an optional \p Backup instruction to the atom
675 /// group \p Atom.
676 void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
677 llvm::Value *Backup, uint64_t Atom);
678
679 /// Emit symbol for debugger that holds the pointer to the vtable.
680 void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD);
681
682 /// Return flags which enable debug info emission for call sites, provided
683 /// that it is supported and enabled.
684 llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
685
686private:
687 /// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
688 /// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
689 /// has no DebugLoc, and chooses the atom group in which the instruction
690 /// has the highest precedence if it's already in one.
691 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
692 uint8_t Rank);
693
694 /// Emit call to llvm.dbg.declare for a variable declaration.
695 /// Returns a pointer to the DILocalVariable associated with the
696 /// llvm.dbg.declare, or nullptr otherwise.
697 llvm::DILocalVariable *EmitDeclare(const VarDecl *decl, llvm::Value *AI,
698 std::optional<unsigned> ArgNo,
699 CGBuilderTy &Builder,
700 const bool UsePointerValue = false);
701
702 /// Emit call to llvm.dbg.declare for a binding declaration.
703 /// Returns a pointer to the DILocalVariable associated with the
704 /// llvm.dbg.declare, or nullptr otherwise.
705 llvm::DILocalVariable *EmitDeclare(const BindingDecl *decl, llvm::Value *AI,
706 std::optional<unsigned> ArgNo,
707 CGBuilderTy &Builder,
708 const bool UsePointerValue = false);
709
710 struct BlockByRefType {
711 /// The wrapper struct used inside the __block_literal struct.
712 llvm::DIType *BlockByRefWrapper;
713 /// The type as it appears in the source code.
714 llvm::DIType *WrappedType;
715 };
716
717 bool HasReconstitutableArgs(ArrayRef<TemplateArgument> Args) const;
718 std::string GetName(const Decl *, bool Qualified = false,
719 bool *NameIsSimplified = nullptr) const;
720
721 /// Build up structure info for the byref. See \a BuildByRefType.
722 BlockByRefType EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
723 uint64_t *OffSet);
724
725 /// Get context info for the DeclContext of \p Decl.
726 llvm::DIScope *getDeclContextDescriptor(const Decl *D);
727 /// Get context info for a given DeclContext \p Decl.
728 llvm::DIScope *getContextDescriptor(const Decl *Context,
729 llvm::DIScope *Default);
730
731 llvm::DIScope *getCurrentContextDescriptor(const Decl *Decl);
732
733 /// Create a forward decl for a RecordType in a given context.
734 llvm::DICompositeType *getOrCreateRecordFwdDecl(const RecordType *,
735 llvm::DIScope *);
736
737 /// Return current directory name.
738 StringRef getCurrentDirname();
739
740 /// Create new compile unit.
741 void CreateCompileUnit();
742
743 /// Compute the file checksum debug info for input file ID.
744 std::optional<llvm::DIFile::ChecksumKind>
745 computeChecksum(FileID FID, SmallString<64> &Checksum) const;
746
747 /// Get the source of the given file ID.
748 std::optional<StringRef> getSource(const SourceManager &SM, FileID FID);
749
750 /// Convenience function to get the file debug info descriptor for the input
751 /// location.
752 llvm::DIFile *getOrCreateFile(SourceLocation Loc);
753
754 /// Create a file debug info descriptor for a source file.
755 llvm::DIFile *
756 createFile(StringRef FileName,
757 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
758 std::optional<StringRef> Source);
759
760 /// Get the type from the cache or create a new type if necessary.
761 llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
762
763 /// Get a reference to a clang module. If \p CreateSkeletonCU is true,
764 /// this also creates a split dwarf skeleton compile unit.
765 llvm::DIModule *getOrCreateModuleRef(ASTSourceDescriptor Mod,
766 bool CreateSkeletonCU);
767
768 /// DebugTypeExtRefs: If \p D originated in a clang module, return it.
769 llvm::DIModule *getParentModuleOrNull(const Decl *D);
770
771 /// Get the type from the cache or create a new partial type if
772 /// necessary.
773 llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty);
774
775 /// Create type metadata for a source language type.
776 llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg);
777
778 /// Create new member and increase Offset by FType's size.
779 llvm::DIType *CreateMemberType(llvm::DIFile *Unit, QualType FType,
780 StringRef Name, uint64_t *Offset);
781
782 /// Retrieve the DIDescriptor, if any, for the canonical form of this
783 /// declaration.
784 llvm::DINode *getDeclarationOrDefinition(const Decl *D);
785
786 /// \return debug info descriptor to describe method
787 /// declaration for the given method definition.
788 llvm::DISubprogram *getFunctionDeclaration(const Decl *D);
789
790 /// \return debug info descriptor to the describe method declaration
791 /// for the given method definition.
792 /// \param FnType For Objective-C methods, their type.
793 /// \param LineNo The declaration's line number.
794 /// \param Flags The DIFlags for the method declaration.
795 /// \param SPFlags The subprogram-spcific flags for the method declaration.
796 llvm::DISubprogram *
797 getObjCMethodDeclaration(const Decl *D, llvm::DISubroutineType *FnType,
798 unsigned LineNo, llvm::DINode::DIFlags Flags,
799 llvm::DISubprogram::DISPFlags SPFlags);
800
801 /// \return debug info descriptor to describe in-class static data
802 /// member declaration for the given out-of-class definition. If D
803 /// is an out-of-class definition of a static data member of a
804 /// class, find its corresponding in-class declaration.
805 llvm::DIDerivedType *
806 getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
807
808 /// Helper that either creates a forward declaration or a stub.
809 llvm::DISubprogram *getFunctionFwdDeclOrStub(GlobalDecl GD, bool Stub);
810
811 /// Create a subprogram describing the forward declaration
812 /// represented in the given FunctionDecl wrapped in a GlobalDecl.
813 llvm::DISubprogram *getFunctionForwardDeclaration(GlobalDecl GD);
814
815 /// Create a DISubprogram describing the function
816 /// represented in the given FunctionDecl wrapped in a GlobalDecl.
817 llvm::DISubprogram *getFunctionStub(GlobalDecl GD);
818
819 /// Create a global variable describing the forward declaration
820 /// represented in the given VarDecl.
821 llvm::DIGlobalVariable *
822 getGlobalVariableForwardDeclaration(const VarDecl *VD);
823
824 /// Return a global variable that represents one of the collection of global
825 /// variables created for an anonmyous union.
826 ///
827 /// Recursively collect all of the member fields of a global
828 /// anonymous decl and create static variables for them. The first
829 /// time this is called it needs to be on a union and then from
830 /// there we can have additional unnamed fields.
831 llvm::DIGlobalVariableExpression *
832 CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile *Unit,
833 unsigned LineNo, StringRef LinkageName,
834 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
835
836 /// Get the printing policy for producing names for debug info.
837 PrintingPolicy getPrintingPolicy() const;
838
839 /// Get function name for the given FunctionDecl. If the name is
840 /// constructed on demand (e.g., C++ destructor) then the name is
841 /// stored on the side.
842 StringRef getFunctionName(const FunctionDecl *FD,
843 bool *NameIsSimplified = nullptr);
844
845 /// Returns the unmangled name of an Objective-C method.
846 /// This is the display name for the debugging info.
847 StringRef getObjCMethodName(const ObjCMethodDecl *FD);
848
849 /// Return selector name. This is used for debugging
850 /// info.
851 StringRef getSelectorName(Selector S);
852
853 /// Get class name including template argument list.
854 StringRef getClassName(const RecordDecl *RD,
855 bool *NameIsSimplified = nullptr);
856
857 /// Get the vtable name for the given class.
858 StringRef getVTableName(const CXXRecordDecl *Decl);
859
860 /// Get the name to use in the debug info for a dynamic initializer or atexit
861 /// stub function.
862 StringRef getDynamicInitializerName(const VarDecl *VD,
863 DynamicInitKind StubKind,
864 llvm::Function *InitFn);
865
866 /// Get line number for the location. If location is invalid
867 /// then use current location.
868 unsigned getLineNumber(SourceLocation Loc);
869
870 /// Get column number for the location. If location is
871 /// invalid then use current location.
872 /// \param Force Assume DebugColumnInfo option is true.
873 unsigned getColumnNumber(SourceLocation Loc, bool Force = false);
874
875 /// Collect various properties of a FunctionDecl.
876 /// \param GD A GlobalDecl whose getDecl() must return a FunctionDecl.
877 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
878 StringRef &Name, StringRef &LinkageName,
879 llvm::DIScope *&FDContext,
880 llvm::DINodeArray &TParamsArray,
881 llvm::DINode::DIFlags &Flags);
882
883 /// Collect various properties of a VarDecl.
884 void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
885 unsigned &LineNo, QualType &T, StringRef &Name,
886 StringRef &LinkageName,
887 llvm::MDTuple *&TemplateParameters,
888 llvm::DIScope *&VDContext);
889
890 /// Create a DIExpression representing the constant corresponding
891 /// to the specified 'Val'. Returns nullptr on failure.
892 llvm::DIExpression *createConstantValueExpression(const clang::ValueDecl *VD,
893 const APValue &Val);
894
895 /// Allocate a copy of \p A using the DebugInfoNames allocator
896 /// and return a reference to it. If multiple arguments are given the strings
897 /// are concatenated.
898 StringRef internString(StringRef A, StringRef B = StringRef()) {
899 char *Data = DebugInfoNames.Allocate<char>(A.size() + B.size());
900 if (!A.empty())
901 std::memcpy(Data, A.data(), A.size());
902 if (!B.empty())
903 std::memcpy(Data + A.size(), B.data(), B.size());
904 return StringRef(Data, A.size() + B.size());
905 }
906
907 /// If one exists, returns the linkage name of the specified \
908 /// (non-null) \c Method. Returns empty string otherwise.
909 llvm::StringRef GetMethodLinkageName(const CXXMethodDecl *Method) const;
910};
911
912/// A scoped helper to set the current debug location to the specified
913/// location or preferred location of the specified Expr.
914class ApplyDebugLocation {
915private:
916 void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false);
917 ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty,
918 SourceLocation TemporaryLocation);
919
920 llvm::DebugLoc OriginalLocation;
921 CodeGenFunction *CGF;
922
923public:
924 /// Set the location to the (valid) TemporaryLocation.
925 ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation);
926 ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E);
927 ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
928 ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) {
929 Other.CGF = nullptr;
930 }
931
932 // Define copy assignment operator.
933 ApplyDebugLocation &operator=(ApplyDebugLocation &&Other) {
934 if (this != &Other) {
935 CGF = Other.CGF;
936 Other.CGF = nullptr;
937 }
938 return *this;
939 }
940
942
943 /// Apply TemporaryLocation if it is valid. Otherwise switch
944 /// to an artificial debug location that has a valid scope, but no
945 /// line information.
946 ///
947 /// Artificial locations are useful when emitting compiler-generated
948 /// helper functions that have no source location associated with
949 /// them. The DWARF specification allows the compiler to use the
950 /// special line number 0 to indicate code that can not be
951 /// attributed to any source location. Note that passing an empty
952 /// SourceLocation to CGDebugInfo::setLocation() will result in the
953 /// last valid location being reused.
954 static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF) {
955 return ApplyDebugLocation(CGF, false, SourceLocation());
956 }
957 /// Apply TemporaryLocation if it is valid. Otherwise switch
958 /// to an artificial debug location that has a valid scope, but no
959 /// line information.
960 static ApplyDebugLocation
962 SourceLocation TemporaryLocation) {
963 return ApplyDebugLocation(CGF, false, TemporaryLocation);
964 }
965
966 /// Set the IRBuilder to not attach debug locations. Note that
967 /// passing an empty SourceLocation to \a CGDebugInfo::setLocation()
968 /// will result in the last valid location being reused. Note that
969 /// all instructions that do not have a location at the beginning of
970 /// a function are counted towards to function prologue.
971 static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF) {
972 return ApplyDebugLocation(CGF, true, SourceLocation());
973 }
974};
975
976/// A scoped helper to set the current debug location to an inlined location.
978 SourceLocation SavedLocation;
979 CodeGenFunction *CGF;
980
981public:
982 /// Set up the CodeGenFunction's DebugInfo to produce inline locations for the
983 /// function \p InlinedFn. The current debug location becomes the inlined call
984 /// site of the inlined function.
986 /// Restore everything back to the original state.
990};
991
1004
1005} // namespace CodeGen
1006} // namespace clang
1007
1008#endif // LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
Defines the clang::ASTSourceDescriptor class, which abstracts clang modules and precompiled header fi...
static llvm::SmallVector< TemplateArgument > GetTemplateArgs(const TemplateDecl *TD, const TemplateSpecializationType *Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
#define SM(sm)
static std::string getFunctionName(const CallEvent &Call)
SanitizerHandler
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:226
Represents a member of a struct/union/class.
Definition Decl.h:3160
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:3730
A binding in a decomposition declaration.
Definition DeclCXX.h:4187
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8201
Pointer to a block type.
Definition TypeBase.h:3550
This class is used for builtin types like 'int'.
Definition TypeBase.h:3172
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2135
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
llvm::iterator_range< base_class_const_iterator > base_class_const_range
Definition DeclCXX.h:605
A wrapper class around a pointer that always points to its canonical declaration.
Represents a class template specialization, which refers to a class template with a given set of temp...
A scoped helper to set the current debug location to the specified location or preferred location of ...
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
ApplyDebugLocation(ApplyDebugLocation &&Other)
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
ApplyDebugLocation & operator=(ApplyDebugLocation &&Other)
ApplyInlineDebugLocation & operator=(ApplyInlineDebugLocation &)=delete
ApplyInlineDebugLocation(CodeGenFunction &CGF, GlobalDecl InlinedFn)
Set up the CodeGenFunction's DebugInfo to produce inline locations for the function InlinedFn.
ApplyInlineDebugLocation(const ApplyInlineDebugLocation &)=delete
~ApplyInlineDebugLocation()
Restore everything back to the original state.
CGBlockInfo - Information to generate a block literal.
Definition CGBlocks.h:157
llvm::MDNode * getInlinedAt() const
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.
void completeUnusedClass(const CXXRecordDecl &D)
SourceLocation getLocation() const
Return the current source location.
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 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()
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const
Return flags which enable debug info emission for call sites, provided that it is supported and enabl...
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)
friend class ApplyDebugLocation
Definition CGDebugInfo.h:60
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()
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 EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke, QualType CalleeType, GlobalDecl CalleeGlobalDecl)
Emit debug info for an extern function being called.
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...
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)
CGDebugInfo(CodeGenModule &CGM)
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 directive...
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...
void completeType(const EnumDecl *ED)
void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr)
Register VLA size expression debug node with the qualified type.
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(CodeGenFunction *CGF, ArrayRef< SanitizerKind::SanitizerOrdinal > Ordinals, SanitizerHandler Handler)
SanitizerDebugLocation & operator=(SanitizerDebugLocation &)=delete
SanitizerDebugLocation(const SanitizerDebugLocation &)=delete
Complex values, per C99 6.2.5p11.
Definition TypeBase.h:3283
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4395
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Represents an enum.
Definition Decl.h:4010
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:2000
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5276
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4472
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5052
An lvalue reference type, per C++11 [dcl.ref].
Definition TypeBase.h:3625
Represents the declaration of a label.
Definition Decl.h:524
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3661
Describes a module or submodule.
Definition Module.h:144
Represents a C++ namespace alias.
Definition DeclCXX.h:3203
Represent a C++ namespace.
Definition Decl.h:592
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Definition TypeBase.h:7911
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:7967
PipeType - OpenCL20.
Definition TypeBase.h:8167
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3336
Callbacks to use to customize the behavior of the pretty-printer.
A (possibly-)qualified type.
Definition TypeBase.h:937
An rvalue reference type, per C++11 [dcl.ref].
Definition TypeBase.h:3643
Represents a struct/union/class.
Definition Decl.h:4324
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:1802
Stores a list of template parameters for a TemplateDecl and its derived classes.
Represents a C++ using-declaration.
Definition DeclCXX.h:3593
Represents C++ using-directive.
Definition DeclCXX.h:3098
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3794
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3401
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:926
Represents a GCC generic vector type.
Definition TypeBase.h:4183
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:123
DynamicInitKind
Definition GlobalDecl.h:33
@ PCH
Disable validation for a precompiled header and the modules it depends on.
@ Other
Other implicit parameter.
Definition Decl.h:1746
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
Describes how types, statements, expressions, and declarations should be printed.