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