| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 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" |
| 19 | #include "clang/AST/ExternalASTSource.h" |
| 20 | #include "clang/AST/Type.h" |
| 21 | #include "clang/AST/TypeOrdering.h" |
| 22 | #include "clang/Basic/CodeGenOptions.h" |
| 23 | #include "clang/Basic/SourceLocation.h" |
| 24 | #include "llvm/ADT/DenseMap.h" |
| 25 | #include "llvm/ADT/DenseSet.h" |
| 26 | #include "llvm/ADT/Optional.h" |
| 27 | #include "llvm/IR/DIBuilder.h" |
| 28 | #include "llvm/IR/DebugInfo.h" |
| 29 | #include "llvm/IR/ValueHandle.h" |
| 30 | #include "llvm/Support/Allocator.h" |
| 31 | |
| 32 | namespace llvm { |
| 33 | class MDNode; |
| 34 | } |
| 35 | |
| 36 | namespace clang { |
| 37 | class ClassTemplateSpecializationDecl; |
| 38 | class GlobalDecl; |
| 39 | class ModuleMap; |
| 40 | class ObjCInterfaceDecl; |
| 41 | class ObjCIvarDecl; |
| 42 | class UsingDecl; |
| 43 | class VarDecl; |
| 44 | |
| 45 | namespace CodeGen { |
| 46 | class CodeGenModule; |
| 47 | class CodeGenFunction; |
| 48 | class CGBlockInfo; |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | class CGDebugInfo { |
| 54 | friend class ApplyDebugLocation; |
| 55 | friend class SaveAndRestoreLocation; |
| 56 | CodeGenModule &CGM; |
| 57 | const codegenoptions::DebugInfoKind DebugKind; |
| 58 | bool DebugTypeExtRefs; |
| 59 | llvm::DIBuilder DBuilder; |
| 60 | llvm::DICompileUnit *TheCU = nullptr; |
| 61 | ModuleMap *ClangModuleMap = nullptr; |
| 62 | ExternalASTSource::ASTSourceDescriptor PCHDescriptor; |
| 63 | SourceLocation CurLoc; |
| 64 | llvm::MDNode *CurInlinedAt = nullptr; |
| 65 | llvm::DIType *VTablePtrType = nullptr; |
| 66 | llvm::DIType *ClassTy = nullptr; |
| 67 | llvm::DICompositeType *ObjTy = nullptr; |
| 68 | llvm::DIType *SelTy = nullptr; |
| 69 | #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ |
| 70 | llvm::DIType *SingletonId = nullptr; |
| 71 | #include "clang/Basic/OpenCLImageTypes.def" |
| 72 | llvm::DIType *OCLSamplerDITy = nullptr; |
| 73 | llvm::DIType *OCLEventDITy = nullptr; |
| 74 | llvm::DIType *OCLClkEventDITy = nullptr; |
| 75 | llvm::DIType *OCLQueueDITy = nullptr; |
| 76 | llvm::DIType *OCLNDRangeDITy = nullptr; |
| 77 | llvm::DIType *OCLReserveIDDITy = nullptr; |
| 78 | #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ |
| 79 | llvm::DIType *Id##Ty = nullptr; |
| 80 | #include "clang/Basic/OpenCLExtensionTypes.def" |
| 81 | |
| 82 | |
| 83 | llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache; |
| 84 | |
| 85 | llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap; |
| 86 | |
| 87 | |
| 88 | |
| 89 | llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache; |
| 90 | |
| 91 | struct ObjCInterfaceCacheEntry { |
| 92 | const ObjCInterfaceType *Type; |
| 93 | llvm::DIType *Decl; |
| 94 | llvm::DIFile *Unit; |
| 95 | ObjCInterfaceCacheEntry(const ObjCInterfaceType *Type, llvm::DIType *Decl, |
| 96 | llvm::DIFile *Unit) |
| 97 | : Type(Type), Decl(Decl), Unit(Unit) {} |
| 98 | }; |
| 99 | |
| 100 | |
| 101 | llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache; |
| 102 | |
| 103 | |
| 104 | llvm::DenseMap<const ObjCInterfaceDecl *, std::vector<llvm::DISubprogram *>> |
| 105 | ObjCMethodCache; |
| 106 | |
| 107 | |
| 108 | llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache; |
| 109 | |
| 110 | |
| 111 | std::vector<void *> RetainedTypes; |
| 112 | |
| 113 | |
| 114 | std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap; |
| 115 | |
| 116 | |
| 117 | |
| 118 | std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>> |
| 119 | FwdDeclReplaceMap; |
| 120 | |
| 121 | |
| 122 | std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack; |
| 123 | llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap; |
| 124 | |
| 125 | |
| 126 | |
| 127 | std::vector<unsigned> FnBeginRegionCount; |
| 128 | |
| 129 | |
| 130 | |
| 131 | llvm::BumpPtrAllocator DebugInfoNames; |
| 132 | StringRef CWDName; |
| 133 | |
| 134 | llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache; |
| 135 | llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache; |
| 136 | |
| 137 | |
| 138 | llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache; |
| 139 | llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache; |
| 140 | llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef> |
| 141 | NamespaceAliasCache; |
| 142 | llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>> |
| 143 | StaticDataMemberCache; |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | llvm::DIType *CreateType(const BuiltinType *Ty); |
| 150 | llvm::DIType *CreateType(const ComplexType *Ty); |
| 151 | llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); |
| 152 | llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg); |
| 153 | llvm::DIType *CreateType(const TemplateSpecializationType *Ty, |
| 154 | llvm::DIFile *Fg); |
| 155 | llvm::DIType *CreateType(const ObjCObjectPointerType *Ty, llvm::DIFile *F); |
| 156 | llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F); |
| 157 | llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F); |
| 158 | llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F); |
| 159 | |
| 160 | llvm::DIType *CreateType(const RecordType *Tyg); |
| 161 | llvm::DIType *CreateTypeDefinition(const RecordType *Ty); |
| 162 | llvm::DICompositeType *CreateLimitedType(const RecordType *Ty); |
| 163 | void CollectContainingType(const CXXRecordDecl *RD, |
| 164 | llvm::DICompositeType *CT); |
| 165 | |
| 166 | llvm::DIType *CreateType(const ObjCInterfaceType *Ty, llvm::DIFile *F); |
| 167 | llvm::DIType *CreateTypeDefinition(const ObjCInterfaceType *Ty, |
| 168 | llvm::DIFile *F); |
| 169 | |
| 170 | llvm::DIType *CreateType(const ObjCObjectType *Ty, llvm::DIFile *F); |
| 171 | llvm::DIType *CreateType(const ObjCTypeParamType *Ty, llvm::DIFile *Unit); |
| 172 | |
| 173 | llvm::DIType *CreateType(const VectorType *Ty, llvm::DIFile *F); |
| 174 | llvm::DIType *CreateType(const ArrayType *Ty, llvm::DIFile *F); |
| 175 | llvm::DIType *CreateType(const LValueReferenceType *Ty, llvm::DIFile *F); |
| 176 | llvm::DIType *CreateType(const RValueReferenceType *Ty, llvm::DIFile *Unit); |
| 177 | llvm::DIType *CreateType(const MemberPointerType *Ty, llvm::DIFile *F); |
| 178 | llvm::DIType *CreateType(const AtomicType *Ty, llvm::DIFile *F); |
| 179 | llvm::DIType *CreateType(const PipeType *Ty, llvm::DIFile *F); |
| 180 | |
| 181 | llvm::DIType *CreateEnumType(const EnumType *Ty); |
| 182 | llvm::DIType *CreateTypeDefinition(const EnumType *Ty); |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | llvm::DIType *CreateSelfType(const QualType &QualTy, llvm::DIType *Ty); |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | llvm::DIType *getTypeOrNull(const QualType); |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method, |
| 200 | llvm::DIFile *F); |
| 201 | llvm::DISubroutineType * |
| 202 | getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func, |
| 203 | llvm::DIFile *Unit); |
| 204 | llvm::DISubroutineType * |
| 205 | getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F); |
| 206 | |
| 207 | llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F); |
| 208 | |
| 209 | |
| 210 | llvm::DINamespace *getOrCreateNamespace(const NamespaceDecl *N); |
| 211 | llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty, |
| 212 | QualType PointeeTy, llvm::DIFile *F); |
| 213 | llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&Cache); |
| 214 | |
| 215 | |
| 216 | |
| 217 | llvm::DISubprogram *CreateCXXMemberFunction(const CXXMethodDecl *Method, |
| 218 | llvm::DIFile *F, |
| 219 | llvm::DIType *RecordTy); |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::DIFile *F, |
| 225 | SmallVectorImpl<llvm::Metadata *> &E, |
| 226 | llvm::DIType *T); |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | void CollectCXXBases(const CXXRecordDecl *Decl, llvm::DIFile *F, |
| 232 | SmallVectorImpl<llvm::Metadata *> &EltTys, |
| 233 | llvm::DIType *RecordTy); |
| 234 | |
| 235 | |
| 236 | |
| 237 | void CollectCXXBasesAux( |
| 238 | const CXXRecordDecl *RD, llvm::DIFile *Unit, |
| 239 | SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy, |
| 240 | const CXXRecordDecl::base_class_const_range &Bases, |
| 241 | llvm::DenseSet<CanonicalDeclPtr<const CXXRecordDecl>> &SeenTypes, |
| 242 | llvm::DINode::DIFlags StartingFlags); |
| 243 | |
| 244 | |
| 245 | llvm::DINodeArray CollectTemplateParams(const TemplateParameterList *TPList, |
| 246 | ArrayRef<TemplateArgument> TAList, |
| 247 | llvm::DIFile *Unit); |
| 248 | |
| 249 | |
| 250 | llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD, |
| 251 | llvm::DIFile *Unit); |
| 252 | |
| 253 | |
| 254 | |
| 255 | llvm::DINodeArray CollectVarTemplateParams(const VarDecl *VD, |
| 256 | llvm::DIFile *Unit); |
| 257 | |
| 258 | |
| 259 | |
| 260 | llvm::DINodeArray |
| 261 | CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS, |
| 262 | llvm::DIFile *F); |
| 263 | |
| 264 | llvm::DIType *createFieldType(StringRef name, QualType type, |
| 265 | SourceLocation loc, AccessSpecifier AS, |
| 266 | uint64_t offsetInBits, uint32_t AlignInBits, |
| 267 | llvm::DIFile *tunit, llvm::DIScope *scope, |
| 268 | const RecordDecl *RD = nullptr); |
| 269 | |
| 270 | llvm::DIType *createFieldType(StringRef name, QualType type, |
| 271 | SourceLocation loc, AccessSpecifier AS, |
| 272 | uint64_t offsetInBits, llvm::DIFile *tunit, |
| 273 | llvm::DIScope *scope, |
| 274 | const RecordDecl *RD = nullptr) { |
| 275 | return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope, |
| 276 | RD); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl, |
| 281 | llvm::DIScope *RecordTy, |
| 282 | const RecordDecl *RD); |
| 283 | |
| 284 | |
| 285 | |
| 286 | void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, |
| 287 | SmallVectorImpl<llvm::Metadata *> &E, |
| 288 | llvm::DIType *RecordTy); |
| 289 | llvm::DIDerivedType *CreateRecordStaticField(const VarDecl *Var, |
| 290 | llvm::DIType *RecordTy, |
| 291 | const RecordDecl *RD); |
| 292 | void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits, |
| 293 | llvm::DIFile *F, |
| 294 | SmallVectorImpl<llvm::Metadata *> &E, |
| 295 | llvm::DIType *RecordTy, const RecordDecl *RD); |
| 296 | void CollectRecordNestedType(const TypeDecl *RD, |
| 297 | SmallVectorImpl<llvm::Metadata *> &E); |
| 298 | void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F, |
| 299 | SmallVectorImpl<llvm::Metadata *> &E, |
| 300 | llvm::DICompositeType *RecordTy); |
| 301 | |
| 302 | |
| 303 | |
| 304 | void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile *F, |
| 305 | SmallVectorImpl<llvm::Metadata *> &EltTys, |
| 306 | llvm::DICompositeType *RecordTy); |
| 307 | |
| 308 | |
| 309 | |
| 310 | void CreateLexicalBlock(SourceLocation Loc); |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | void AppendAddressSpaceXDeref(unsigned AddressSpace, |
| 319 | SmallVectorImpl<int64_t> &Expr) const; |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | uint64_t collectDefaultElementTypesForBlockPointer( |
| 326 | const BlockPointerType *Ty, llvm::DIFile *Unit, |
| 327 | llvm::DIDerivedType *DescTy, unsigned LineNo, |
| 328 | SmallVectorImpl<llvm::Metadata *> &EltTys); |
| 329 | |
| 330 | |
| 331 | |
| 332 | void collectDefaultFieldsForBlockLiteralDeclare( |
| 333 | const CGBlockInfo &Block, const ASTContext &Context, SourceLocation Loc, |
| 334 | const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit, |
| 335 | SmallVectorImpl<llvm::Metadata *> &Fields); |
| 336 | |
| 337 | public: |
| 338 | CGDebugInfo(CodeGenModule &CGM); |
| 339 | ~CGDebugInfo(); |
| 340 | |
| 341 | void finalize(); |
| 342 | |
| 343 | |
| 344 | std::string remapDIPath(StringRef) const; |
| 345 | |
| 346 | |
| 347 | void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr) { |
| 348 | SizeExprCache[Ty] = SizeExpr; |
| 349 | } |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | void setDwoId(uint64_t Signature); |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | void setModuleMap(ModuleMap &MMap) { ClangModuleMap = &MMap; } |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | void setPCHDescriptor(ExternalASTSource::ASTSourceDescriptor PCH) { |
| 365 | PCHDescriptor = PCH; |
| 366 | } |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | void setLocation(SourceLocation Loc); |
| 372 | |
| 373 | |
| 374 | |
| 375 | SourceLocation getLocation() const { return CurLoc; } |
| 376 | |
| 377 | |
| 378 | |
| 379 | void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; } |
| 380 | |
| 381 | |
| 382 | llvm::MDNode *getInlinedAt() const { return CurInlinedAt; } |
| 383 | |
| 384 | |
| 385 | llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc); |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc); |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | void EmitFunctionStart(GlobalDecl GD, SourceLocation Loc, |
| 397 | SourceLocation ScopeLoc, QualType FnType, |
| 398 | llvm::Function *Fn, bool CurFnIsThunk, |
| 399 | CGBuilderTy &Builder); |
| 400 | |
| 401 | |
| 402 | void EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD); |
| 403 | |
| 404 | void EmitInlineFunctionEnd(CGBuilderTy &Builder); |
| 405 | |
| 406 | |
| 407 | void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType); |
| 408 | |
| 409 | |
| 410 | void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn); |
| 411 | |
| 412 | |
| 413 | |
| 414 | void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc); |
| 415 | |
| 416 | |
| 417 | |
| 418 | void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc); |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | llvm::DILocalVariable *EmitDeclareOfAutoVariable(const VarDecl *Decl, |
| 425 | llvm::Value *AI, |
| 426 | CGBuilderTy &Builder); |
| 427 | |
| 428 | |
| 429 | void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder); |
| 430 | |
| 431 | |
| 432 | |
| 433 | void EmitDeclareOfBlockDeclRefVariable( |
| 434 | const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, |
| 435 | const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint = nullptr); |
| 436 | |
| 437 | |
| 438 | |
| 439 | void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, |
| 440 | unsigned ArgNo, CGBuilderTy &Builder); |
| 441 | |
| 442 | |
| 443 | |
| 444 | void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, |
| 445 | StringRef Name, unsigned ArgNo, |
| 446 | llvm::AllocaInst *LocalAddr, |
| 447 | CGBuilderTy &Builder); |
| 448 | |
| 449 | |
| 450 | void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl); |
| 451 | |
| 452 | |
| 453 | void EmitGlobalVariable(const ValueDecl *VD, const APValue &Init); |
| 454 | |
| 455 | |
| 456 | void EmitUsingDirective(const UsingDirectiveDecl &UD); |
| 457 | |
| 458 | |
| 459 | void EmitExplicitCastType(QualType Ty); |
| 460 | |
| 461 | |
| 462 | void EmitUsingDecl(const UsingDecl &UD); |
| 463 | |
| 464 | |
| 465 | void EmitImportDecl(const ImportDecl &ID); |
| 466 | |
| 467 | |
| 468 | llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA); |
| 469 | |
| 470 | |
| 471 | llvm::DIType *getOrCreateRecordType(QualType Ty, SourceLocation L); |
| 472 | |
| 473 | |
| 474 | llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc); |
| 475 | |
| 476 | |
| 477 | llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc); |
| 478 | |
| 479 | void completeType(const EnumDecl *ED); |
| 480 | void completeType(const RecordDecl *RD); |
| 481 | void completeRequiredType(const RecordDecl *RD); |
| 482 | void completeClassData(const RecordDecl *RD); |
| 483 | void completeClass(const RecordDecl *RD); |
| 484 | |
| 485 | void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD); |
| 486 | void completeUnusedClass(const CXXRecordDecl &D); |
| 487 | |
| 488 | |
| 489 | |
| 490 | llvm::DIMacro *CreateMacro(llvm::DIMacroFile *Parent, unsigned MType, |
| 491 | SourceLocation LineLoc, StringRef Name, |
| 492 | StringRef Value); |
| 493 | |
| 494 | |
| 495 | llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent, |
| 496 | SourceLocation LineLoc, |
| 497 | SourceLocation FileLoc); |
| 498 | |
| 499 | private: |
| 500 | |
| 501 | |
| 502 | |
| 503 | llvm::DILocalVariable *EmitDeclare(const VarDecl *decl, llvm::Value *AI, |
| 504 | llvm::Optional<unsigned> ArgNo, |
| 505 | CGBuilderTy &Builder); |
| 506 | |
| 507 | struct BlockByRefType { |
| 508 | |
| 509 | llvm::DIType *BlockByRefWrapper; |
| 510 | |
| 511 | llvm::DIType *WrappedType; |
| 512 | }; |
| 513 | |
| 514 | |
| 515 | BlockByRefType EmitTypeForVarWithBlocksAttr(const VarDecl *VD, |
| 516 | uint64_t *OffSet); |
| 517 | |
| 518 | |
| 519 | llvm::DIScope *getDeclContextDescriptor(const Decl *D); |
| 520 | |
| 521 | llvm::DIScope *getContextDescriptor(const Decl *Context, |
| 522 | llvm::DIScope *Default); |
| 523 | |
| 524 | llvm::DIScope *getCurrentContextDescriptor(const Decl *Decl); |
| 525 | |
| 526 | |
| 527 | llvm::DICompositeType *getOrCreateRecordFwdDecl(const RecordType *, |
| 528 | llvm::DIScope *); |
| 529 | |
| 530 | |
| 531 | StringRef getCurrentDirname(); |
| 532 | |
| 533 | |
| 534 | void CreateCompileUnit(); |
| 535 | |
| 536 | |
| 537 | Optional<llvm::DIFile::ChecksumKind> |
| 538 | computeChecksum(FileID FID, SmallString<32> &Checksum) const; |
| 539 | |
| 540 | |
| 541 | Optional<StringRef> getSource(const SourceManager &SM, FileID FID); |
| 542 | |
| 543 | |
| 544 | |
| 545 | llvm::DIFile *getOrCreateFile(SourceLocation Loc); |
| 546 | |
| 547 | |
| 548 | llvm::DIFile * |
| 549 | createFile(StringRef FileName, |
| 550 | Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo, |
| 551 | Optional<StringRef> Source); |
| 552 | |
| 553 | |
| 554 | llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg); |
| 555 | |
| 556 | |
| 557 | |
| 558 | llvm::DIModule * |
| 559 | getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod, |
| 560 | bool CreateSkeletonCU); |
| 561 | |
| 562 | |
| 563 | llvm::DIModule *getParentModuleOrNull(const Decl *D); |
| 564 | |
| 565 | |
| 566 | |
| 567 | llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty, |
| 568 | llvm::DIFile *F); |
| 569 | |
| 570 | |
| 571 | llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg); |
| 572 | |
| 573 | |
| 574 | llvm::DIType *CreateMemberType(llvm::DIFile *Unit, QualType FType, |
| 575 | StringRef Name, uint64_t *Offset); |
| 576 | |
| 577 | |
| 578 | |
| 579 | llvm::DINode *getDeclarationOrDefinition(const Decl *D); |
| 580 | |
| 581 | |
| 582 | |
| 583 | llvm::DISubprogram *getFunctionDeclaration(const Decl *D); |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | llvm::DIDerivedType * |
| 590 | getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D); |
| 591 | |
| 592 | |
| 593 | llvm::DISubprogram *getFunctionFwdDeclOrStub(GlobalDecl GD, bool Stub); |
| 594 | |
| 595 | |
| 596 | |
| 597 | llvm::DISubprogram *getFunctionForwardDeclaration(GlobalDecl GD); |
| 598 | |
| 599 | |
| 600 | |
| 601 | llvm::DISubprogram *getFunctionStub(GlobalDecl GD); |
| 602 | |
| 603 | |
| 604 | |
| 605 | llvm::DIGlobalVariable * |
| 606 | getGlobalVariableForwardDeclaration(const VarDecl *VD); |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | llvm::DIGlobalVariableExpression * |
| 616 | CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile *Unit, |
| 617 | unsigned LineNo, StringRef LinkageName, |
| 618 | llvm::GlobalVariable *Var, llvm::DIScope *DContext); |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | llvm::DINode::DIFlags getCallSiteRelatedAttrs() const; |
| 624 | |
| 625 | |
| 626 | PrintingPolicy getPrintingPolicy() const; |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | StringRef getFunctionName(const FunctionDecl *FD); |
| 632 | |
| 633 | |
| 634 | |
| 635 | StringRef getObjCMethodName(const ObjCMethodDecl *FD); |
| 636 | |
| 637 | |
| 638 | |
| 639 | StringRef getSelectorName(Selector S); |
| 640 | |
| 641 | |
| 642 | StringRef getClassName(const RecordDecl *RD); |
| 643 | |
| 644 | |
| 645 | StringRef getVTableName(const CXXRecordDecl *Decl); |
| 646 | |
| 647 | |
| 648 | |
| 649 | unsigned getLineNumber(SourceLocation Loc); |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | unsigned getColumnNumber(SourceLocation Loc, bool Force = false); |
| 655 | |
| 656 | |
| 657 | |
| 658 | void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit, |
| 659 | StringRef &Name, StringRef &LinkageName, |
| 660 | llvm::DIScope *&FDContext, |
| 661 | llvm::DINodeArray &TParamsArray, |
| 662 | llvm::DINode::DIFlags &Flags); |
| 663 | |
| 664 | |
| 665 | void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit, |
| 666 | unsigned &LineNo, QualType &T, StringRef &Name, |
| 667 | StringRef &LinkageName, |
| 668 | llvm::MDTuple *&TemplateParameters, |
| 669 | llvm::DIScope *&VDContext); |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | StringRef internString(StringRef A, StringRef B = StringRef()) { |
| 675 | char *Data = DebugInfoNames.Allocate<char>(A.size() + B.size()); |
| 676 | if (!A.empty()) |
| 677 | std::memcpy(Data, A.data(), A.size()); |
| 678 | if (!B.empty()) |
| 679 | std::memcpy(Data + A.size(), B.data(), B.size()); |
| 680 | return StringRef(Data, A.size() + B.size()); |
| 681 | } |
| 682 | }; |
| 683 | |
| 684 | |
| 685 | |
| 686 | class ApplyDebugLocation { |
| 687 | private: |
| 688 | void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false); |
| 689 | ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty, |
| 690 | SourceLocation TemporaryLocation); |
| 691 | |
| 692 | llvm::DebugLoc OriginalLocation; |
| 693 | CodeGenFunction *CGF; |
| 694 | |
| 695 | public: |
| 696 | |
| 697 | ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation); |
| 698 | ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E); |
| 699 | ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc); |
| 700 | ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) { |
| 701 | Other.CGF = nullptr; |
| 702 | } |
| 703 | |
| 704 | ~ApplyDebugLocation(); |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF) { |
| 718 | return ApplyDebugLocation(CGF, false, SourceLocation()); |
| 719 | } |
| 720 | |
| 721 | |
| 722 | |
| 723 | static ApplyDebugLocation |
| 724 | CreateDefaultArtificial(CodeGenFunction &CGF, |
| 725 | SourceLocation TemporaryLocation) { |
| 726 | return ApplyDebugLocation(CGF, false, TemporaryLocation); |
| 727 | } |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF) { |
| 735 | return ApplyDebugLocation(CGF, true, SourceLocation()); |
| 736 | } |
| 737 | }; |
| 738 | |
| 739 | |
| 740 | class ApplyInlineDebugLocation { |
| 741 | SourceLocation SavedLocation; |
| 742 | CodeGenFunction *CGF; |
| 743 | |
| 744 | public: |
| 745 | |
| 746 | |
| 747 | |
| 748 | ApplyInlineDebugLocation(CodeGenFunction &CGF, GlobalDecl InlinedFn); |
| 749 | |
| 750 | ~ApplyInlineDebugLocation(); |
| 751 | }; |
| 752 | |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | #endif |
| 757 | |