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