Lines Matching refs:llvm

30 #include "llvm/ADT/SmallVector.h"
31 #include "llvm/ADT/StringExtras.h"
32 #include "llvm/IR/Constants.h"
33 #include "llvm/IR/DataLayout.h"
34 #include "llvm/IR/DerivedTypes.h"
35 #include "llvm/IR/Instructions.h"
36 #include "llvm/IR/Intrinsics.h"
37 #include "llvm/IR/Module.h"
38 #include "llvm/Support/Dwarf.h"
39 #include "llvm/Support/FileSystem.h"
40 #include "llvm/Support/Path.h"
72 Builder.SetCurrentDebugLocation(llvm::DebugLoc());
83 Builder.SetCurrentDebugLocation(llvm::DebugLoc());
93 llvm::DIDescriptor Scope(DI->LexicalBlockStack.back());
94 Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));
115 llvm::DIScope Scope(LexicalBlockStack.back());
122 llvm::DILexicalBlockFile LBF = llvm::DILexicalBlockFile(Scope);
123 llvm::DIDescriptor D
126 llvm::MDNode *N = D;
130 llvm::DIDescriptor D
132 llvm::MDNode *N = D;
139 llvm::DIScope CGDebugInfo::getContextDescriptor(const Decl *Context) {
143 llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator
146 llvm::Value *V = I->second;
147 return llvm::DIScope(dyn_cast_or_null<llvm::MDNode>(V));
174 llvm::raw_svector_ostream OS(NS);
193 llvm::raw_svector_ostream OS(MethodName);
235 llvm::raw_svector_ostream OS(Name);
245 llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
259 llvm::DenseMap<const char *, llvm::WeakVH>::iterator it =
264 if (llvm::Value *V = it->second)
265 return llvm::DIFile(cast<llvm::MDNode>(V));
268 llvm::DIFile F = DBuilder.createFile(PLoc.getFilename(), getCurrentDirname());
275 llvm::DIFile CGDebugInfo::getOrCreateMainFile() {
310 llvm::sys::fs::current_path(CWD);
338 llvm::SmallString<1024> MainFileDirSS(MainFileDir);
339 llvm::sys::path::append(MainFileDirSS, MainFileName);
351 llvm::dwarf::SourceLanguage LangTag;
355 LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
357 LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
359 LangTag = llvm::dwarf::DW_LANG_ObjC;
361 LangTag = llvm::dwarf::DW_LANG_C99;
363 LangTag = llvm::dwarf::DW_LANG_C89;
379 ? llvm::DIBuilder::LineTablesOnly
380 : llvm::DIBuilder::FullDebug,
386 llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) {
387 llvm::dwarf::TypeKind Encoding;
399 return llvm::DIType();
402 ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
416 ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
422 llvm::DIType ISATy = DBuilder.createPointerType(ClassTy, Size);
426 0, 0, 0, 0, llvm::DIType(), llvm::DIArray());
434 SelTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
462 llvm::dwarf::DW_ATE_unsigned);
468 case BuiltinType::Char_U: Encoding = llvm::dwarf::DW_ATE_unsigned_char; break;
470 case BuiltinType::SChar: Encoding = llvm::dwarf::DW_ATE_signed_char; break;
472 case BuiltinType::Char32: Encoding = llvm::dwarf::DW_ATE_UTF; break;
478 case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break;
484 case BuiltinType::LongLong: Encoding = llvm::dwarf::DW_ATE_signed; break;
485 case BuiltinType::Bool: Encoding = llvm::dwarf::DW_ATE_boolean; break;
489 case BuiltinType::Double: Encoding = llvm::dwarf::DW_ATE_float; break;
504 llvm::DIType DbgTy =
509 llvm::DIType CGDebugInfo::CreateType(const ComplexType *Ty) {
511 llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
513 Encoding = llvm::dwarf::DW_ATE_lo_user;
517 llvm::DIType DbgTy =
525 llvm::DIType CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile Unit) {
536 llvm::dwarf::Tag Tag;
538 Tag = llvm::dwarf::DW_TAG_const_type;
541 Tag = llvm::dwarf::DW_TAG_volatile_type;
544 Tag = llvm::dwarf::DW_TAG_restrict_type;
551 llvm::DIType FromTy = getOrCreateType(Qc.apply(CGM.getContext(), T), Unit);
555 llvm::DIType DbgTy = DBuilder.createQualifiedType(Tag, FromTy);
560 llvm::DIType CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
561 llvm::DIFile Unit) {
569 llvm::DIType DbgTy =
570 CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
575 llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty,
576 llvm::DIFile Unit) {
577 return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
585 llvm::DICompileUnit TheCU) {
590 if (TheCU.getLanguage() != llvm::dwarf::DW_LANG_C_plus_plus ||
599 llvm::raw_svector_ostream Out(FullName);
606 llvm::DICompositeType
608 llvm::DIDescriptor Ctx) {
610 if (llvm::DIType T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
611 return llvm::DICompositeType(T);
612 llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
616 llvm::dwarf::Tag Tag;
618 Tag = llvm::dwarf::DW_TAG_structure_type;
620 Tag = llvm::dwarf::DW_TAG_union_type;
623 Tag = llvm::dwarf::DW_TAG_class_type;
628 llvm::DICompositeType RetTy = DBuilder.createReplaceableForwardDecl(
630 ReplaceMap.push_back(std::make_pair(Ty, static_cast<llvm::Value *>(RetTy)));
634 llvm::DIType CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
637 llvm::DIFile Unit) {
638 if (Tag == llvm::dwarf::DW_TAG_reference_type ||
639 Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
653 llvm::DIType CGDebugInfo::getOrCreateStructPtrType(StringRef Name,
654 llvm::DIType &Cache) {
657 Cache = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name,
664 llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty,
665 llvm::DIFile Unit) {
669 SmallVector<llvm::Value *, 8> EltTys;
670 llvm::DIType FieldTy;
674 llvm::DIArray Elements;
675 llvm::DIType EltTy, DescTy;
685 unsigned Flags = llvm::DIDescriptor::FlagAppleBlock;
690 Flags, llvm::DIType(), Elements);
720 Flags, llvm::DIType(), Elements);
726 llvm::DIType CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::DIFile Unit) {
728 llvm::DIType Src = getOrCreateType(Ty->getAliasedType(), Unit);
731 llvm::raw_svector_ostream OS(NS);
743 llvm::DIFile File = getOrCreateFile(Loc);
746 llvm::DIDescriptor Ctxt = getContextDescriptor(cast<Decl>(AliasDecl->getDeclContext()));
751 llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile Unit) {
754 llvm::DIType Src = getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit);
758 llvm::DIFile File = getOrCreateFile(Loc);
762 llvm::DIDescriptor TypedefContext =
769 llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
770 llvm::DIFile Unit) {
771 SmallVector<llvm::Value *, 16> EltTys;
787 llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
792 llvm::DIType CGDebugInfo::createFieldType(StringRef name,
798 llvm::DIFile tunit,
799 llvm::DIScope scope) {
800 llvm::DIType debugType = getOrCreateType(type, tunit);
803 llvm::DIFile file = getOrCreateFile(loc);
817 flags |= llvm::DIDescriptor::FlagPrivate;
819 flags |= llvm::DIDescriptor::FlagProtected;
828 SmallVectorImpl<llvm::Value *> &elements,
829 llvm::DIType RecordTy) {
841 llvm::DIFile VUnit = getOrCreateFile(C.getLocation());
848 llvm::DIType fieldType
860 llvm::DIFile VUnit = getOrCreateFile(f->getLocation());
862 llvm::DIType fieldType
872 llvm::DIDerivedType
874 llvm::DIType RecordTy) {
877 llvm::DIFile VUnit = getOrCreateFile(Var->getLocation());
878 llvm::DIType VTy = getOrCreateType(Var->getType(), VUnit);
882 llvm::Constant *C = nullptr;
887 C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
889 C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
896 Flags |= llvm::DIDescriptor::FlagPrivate;
898 Flags |= llvm::DIDescriptor::FlagProtected;
900 llvm::DIDerivedType GV = DBuilder.createStaticMemberType(
902 StaticDataMemberCache[Var->getCanonicalDecl()] = llvm::WeakVH(GV);
909 llvm::DIFile tunit,
910 SmallVectorImpl<llvm::Value *> &elements,
911 llvm::DIType RecordTy) {
925 llvm::DIType fieldType
936 llvm::DIFile tunit,
937 SmallVectorImpl<llvm::Value *> &elements,
938 llvm::DICompositeType RecordTy) {
954 llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
960 llvm::DIDerivedType(cast<llvm::MDNode>(MI->second)));
976 llvm::DICompositeType
978 llvm::DIFile Unit) {
981 return llvm::DICompositeType(getOrCreateType(QualType(Func, 0), Unit));
986 llvm::DICompositeType CGDebugInfo::getOrCreateInstanceMethodType(
987 QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit) {
989 llvm::DIArray Args = llvm::DICompositeType(
993 SmallVector<llvm::Value *, 16> Elts;
1007 llvm::DIType PointeeType = getOrCreateType(PointeeTy, Unit);
1008 llvm::DIType ThisPtrType =
1017 llvm::DIType ThisPtrType = getOrCreateType(ThisPtr, Unit);
1027 llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
1031 Flags |= llvm::DIDescriptor::FlagLValueReference;
1033 Flags |= llvm::DIDescriptor::FlagRValueReference;
1050 llvm::DISubprogram
1052 llvm::DIFile Unit,
1053 llvm::DIType RecordTy) {
1058 llvm::DICompositeType MethodTy = getOrCreateMethodType(Method, Unit);
1067 llvm::DIFile MethodDefUnit;
1075 llvm::DIType ContainingType;
1081 Virtuality = llvm::dwarf::DW_VIRTUALITY_pure_virtual;
1083 Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
1098 Flags |= llvm::DIDescriptor::FlagArtificial;
1101 Flags |= llvm::DIDescriptor::FlagPrivate;
1103 Flags |= llvm::DIDescriptor::FlagProtected;
1106 Flags |= llvm::DIDescriptor::FlagExplicit;
1110 Flags |= llvm::DIDescriptor::FlagExplicit;
1113 Flags |= llvm::DIDescriptor::FlagPrototyped;
1115 Flags |= llvm::DIDescriptor::FlagLValueReference;
1117 Flags |= llvm::DIDescriptor::FlagRValueReference;
1119 llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
1120 llvm::DISubprogram SP =
1129 SPCache[Method->getCanonicalDecl()] = llvm::WeakVH(SP);
1138 CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit,
1139 SmallVectorImpl<llvm::Value *> &EltTys,
1140 llvm::DIType RecordTy) {
1153 llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
1168 llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
1181 CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit,
1182 SmallVectorImpl<llvm::Value *> &EltTys,
1183 llvm::DIType RecordTy) {
1199 BFlags = llvm::DIDescriptor::FlagVirtual;
1207 BFlags |= llvm::DIDescriptor::FlagPrivate;
1209 BFlags |= llvm::DIDescriptor::FlagProtected;
1211 llvm::DIType DTy =
1220 llvm::DIArray CGDebugInfo::
1223 llvm::DIFile Unit) {
1224 SmallVector<llvm::Value *, 16> TemplateParams;
1232 llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit);
1233 llvm::DITemplateTypeParameter TTP =
1238 llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit);
1239 llvm::DITemplateValueParameter TVP =
1242 llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral()));
1253 llvm::DIType TTy = getOrCreateType(T, Unit);
1254 llvm::Value *V = nullptr;
1278 llvm::DITemplateValueParameter TVP =
1285 llvm::DIType TTy = getOrCreateType(T, Unit);
1286 llvm::Value *V = nullptr;
1299 V = llvm::ConstantInt::get(CGM.Int8Ty, 0);
1300 llvm::DITemplateValueParameter TVP =
1305 llvm::DITemplateValueParameter TVP =
1307 TheCU, Name, llvm::DIType(),
1313 llvm::DITemplateValueParameter TVP =
1315 TheCU, Name, llvm::DIType(),
1322 llvm::Value *V = CGM.EmitConstantExpr(E, T);
1324 llvm::DIType TTy = getOrCreateType(T, Unit);
1325 llvm::DITemplateValueParameter TVP =
1342 llvm::DIArray CGDebugInfo::
1343 CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit) {
1352 return llvm::DIArray();
1357 llvm::DIArray CGDebugInfo::
1359 llvm::DIFile Unit) {
1369 llvm::DIType CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile Unit) {
1376 llvm::Value *STy = getOrCreateType(Context.IntTy, Unit);
1377 llvm::DIArray SElements = DBuilder.getOrCreateArray(STy);
1378 llvm::DIType SubTy = DBuilder.createSubroutineType(Unit, SElements);
1380 llvm::DIType vtbl_ptr_type = DBuilder.createPointerType(SubTy, Size, 0,
1396 CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,
1397 SmallVectorImpl<llvm::Value *> &EltTys) {
1409 llvm::DIType VPTR
1412 llvm::DIDescriptor::FlagArtificial,
1418 llvm::DIType CGDebugInfo::getOrCreateRecordType(QualType RTy,
1421 llvm::DIType T = getOrCreateType(RTy, getOrCreateFile(Loc));
1427 llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D,
1430 llvm::DIType T = getOrCreateType(D, getOrCreateFile(Loc));
1442 !llvm::DIType(cast<llvm::MDNode>(static_cast<llvm::Value *>(I->second)))
1445 llvm::DIType Res = CreateTypeDefinition(Ty->castAs<EnumType>());
1465 llvm::DIType T = getTypeOrNull(Ty);
1477 !llvm::DIType(cast<llvm::MDNode>(static_cast<llvm::Value *>(I->second)))
1480 llvm::DIType Res = CreateTypeDefinition(Ty->castAs<RecordType>());
1529 llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) {
1531 llvm::DICompositeType T(getTypeOrNull(QualType(Ty, 0)));
1542 llvm::DIType CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
1546 llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
1555 llvm::DICompositeType FwdDecl(getOrCreateLimitedType(Ty, DefUnit));
1557 "The debug type of a RecordType should be a llvm::DICompositeType");
1567 RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);
1570 SmallVector<llvm::Value *, 16> EltTys;
1591 llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
1594 RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);
1599 llvm::DIType CGDebugInfo::CreateType(const ObjCObjectType *Ty,
1600 llvm::DIFile Unit) {
1631 llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
1632 llvm::DIFile Unit) {
1635 return llvm::DIType();
1638 llvm::DIFile DefUnit = getOrCreateFile(ID->getLocation());
1640 llvm::dwarf::SourceLanguage RuntimeLang = TheCU.getLanguage();
1646 llvm::DIType FwdDecl = DBuilder.createReplaceableForwardDecl(
1647 llvm::dwarf::DW_TAG_structure_type, ID->getName(), TheCU, DefUnit, Line,
1657 llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::DIFile Unit) {
1659 llvm::DIFile DefUnit = getOrCreateFile(ID->getLocation());
1669 Flags |= llvm::DIDescriptor::FlagObjcClassComplete;
1671 llvm::DICompositeType RealDecl =
1674 llvm::DIType(), llvm::DIArray(), RuntimeLang);
1680 LexicalBlockStack.push_back(static_cast<llvm::MDNode*>(RealDecl));
1681 RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl);
1684 SmallVector<llvm::Value *, 16> EltTys;
1688 llvm::DIType SClassTy =
1691 return llvm::DIType();
1693 llvm::DIType InhTag =
1701 llvm::DIFile PUnit = getOrCreateFile(Loc);
1705 llvm::MDNode *PropertyNode =
1721 llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
1723 return llvm::DIType();
1732 llvm::DIFile FieldDefUnit = getOrCreateFile(Field->getLocation());
1765 Flags = llvm::DIDescriptor::FlagProtected;
1767 Flags = llvm::DIDescriptor::FlagPrivate;
1769 llvm::MDNode *PropertyNode = nullptr;
1775 llvm::DIFile PUnit = getOrCreateFile(Loc);
1798 llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
1805 llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) {
1806 llvm::DIType ElementTy = getOrCreateType(Ty->getElementType(), Unit);
1813 llvm::Value *Subscript = DBuilder.getOrCreateSubrange(0, Count);
1814 llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
1822 llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
1823 llvm::DIFile Unit) {
1850 SmallVector<llvm::Value *, 8> Subscripts;
1869 llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts);
1871 llvm::DIType DbgTy =
1877 llvm::DIType CGDebugInfo::CreateType(const LValueReferenceType *Ty,
1878 llvm::DIFile Unit) {
1879 return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type,
1883 llvm::DIType CGDebugInfo::CreateType(const RValueReferenceType *Ty,
1884 llvm::DIFile Unit) {
1885 return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type,
1889 llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty,
1890 llvm::DIFile U) {
1891 llvm::DIType ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U);
1904 llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty,
1905 llvm::DIFile U) {
1912 llvm::DIType CGDebugInfo::CreateEnumType(const EnumType *Ty) {
1926 llvm::DIDescriptor EDContext;
1928 llvm::DIFile DefUnit = getOrCreateFile(ED->getLocation());
1931 llvm::DIType RetTy = DBuilder.createReplaceableForwardDecl(
1932 llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, Line,
1934 ReplaceMap.push_back(std::make_pair(Ty, static_cast<llvm::Value *>(RetTy)));
1941 llvm::DIType CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
1953 SmallVector<llvm::Value *, 16> Enumerators;
1962 llvm::DIArray EltArray = DBuilder.getOrCreateArray(Enumerators);
1964 llvm::DIFile DefUnit = getOrCreateFile(ED->getLocation());
1966 llvm::DIDescriptor EnumContext =
1968 llvm::DIType ClassTy = ED->isFixed() ?
1969 getOrCreateType(ED->getIntegerType(), DefUnit) : llvm::DIType();
1970 llvm::DIType DbgTy =
2034 llvm::DIType CGDebugInfo::getTypeOrNull(QualType Ty) {
2042 if (llvm::Value *V = it->second)
2043 return llvm::DIType(cast<llvm::MDNode>(V));
2046 return llvm::DIType();
2062 llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
2064 return llvm::DIType();
2069 if (llvm::DIType T = getTypeOrNull(Ty))
2073 llvm::DIType Res = CreateTypeNode(Ty, Unit);
2109 llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) {
2195 return llvm::DIType();
2200 llvm::DIType CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty,
2201 llvm::DIFile Unit) {
2204 llvm::DICompositeType T(getTypeOrNull(QTy));
2212 llvm::DICompositeType Res = CreateLimitedType(Ty);
2225 llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
2229 llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
2233 llvm::DIDescriptor RDContext =
2238 llvm::DICompositeType T(getTypeOrNull(CGM.getContext().getRecordType(RD)));
2250 llvm::DICompositeType RealDecl;
2256 Size, Align, 0, llvm::DIArray(), 0,
2260 // than C++ class type, but needs llvm metadata changes first.
2262 Size, Align, 0, 0, llvm::DIType(),
2263 llvm::DIArray(), llvm::DIType(),
2264 llvm::DIArray(), FullName);
2267 Size, Align, 0, llvm::DIType(),
2268 llvm::DIArray(), 0, llvm::DIType(),
2271 RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl);
2276 RealDecl.setTypeArray(llvm::DIArray(),
2282 llvm::DICompositeType RealDecl) {
2284 llvm::DICompositeType ContainingType;
2296 ContainingType = llvm::DICompositeType(
2306 llvm::DIType CGDebugInfo::CreateMemberType(llvm::DIFile Unit, QualType FType,
2309 llvm::DIType FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
2312 llvm::DIType Ty = DBuilder.createMemberType(Unit, Name, Unit, 0,
2319 llvm::DIScope CGDebugInfo::getDeclarationOrDefinition(const Decl *D) {
2334 llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator I =
2337 return llvm::DIScope();
2338 llvm::Value *V = I->second;
2339 return llvm::DIScope(dyn_cast_or_null<llvm::MDNode>(V));
2344 llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) {
2346 return llvm::DISubprogram();
2349 if (!FD) return llvm::DISubprogram();
2352 llvm::DIScope S = getContextDescriptor(cast<Decl>(D->getDeclContext()));
2354 llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
2359 llvm::DICompositeType T(S);
2360 llvm::DISubprogram SP =
2366 llvm::Value *V = MI->second;
2367 llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(V));
2373 llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
2376 llvm::Value *V = MI->second;
2377 llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(V));
2382 return llvm::DISubprogram();
2387 llvm::DICompositeType CGDebugInfo::getOrCreateFunctionType(const Decl *D,
2389 llvm::DIFile F) {
2392 // llvm::DISubprogram::Verify() would return false, and
2401 SmallVector<llvm::Value *, 16> Elts;
2414 llvm::DIType SelfTy = getOrCreateType(SelfDeclTy, F);
2417 llvm::DIType CmdTy = getOrCreateType(OMethod->getCmdDecl()->getType(), F);
2423 llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
2431 SmallVector<llvm::Value *, 16> EltTys;
2437 llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
2441 return llvm::DICompositeType(getOrCreateType(FnType, F));
2449 llvm::Function *Fn,
2461 llvm::DIFile Unit = getOrCreateFile(Loc);
2462 llvm::DIDescriptor FDContext(Unit);
2463 llvm::DIArray TParamsArray;
2465 // Use llvm function name.
2469 llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
2472 llvm::Value *V = FI->second;
2473 llvm::DIDescriptor SP(dyn_cast_or_null<llvm::MDNode>(V));
2474 if (SP.isSubprogram() && llvm::DISubprogram(SP).isDefinition()) {
2475 llvm::MDNode *SPN = SP;
2477 RegionMap[D] = llvm::WeakVH(SP);
2485 Flags |= llvm::DIDescriptor::FlagPrototyped;
2509 Flags |= llvm::DIDescriptor::FlagPrototyped;
2511 // Use llvm function name.
2513 Flags |= llvm::DIDescriptor::FlagPrototyped;
2519 Flags |= llvm::DIDescriptor::FlagArtificial;
2532 llvm::DISubprogram SP =
2540 DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP)));
2543 llvm::MDNode *SPN = SP;
2547 RegionMap[D] = llvm::WeakVH(SP);
2573 llvm::MDNode *Scope = LexicalBlockStack.back();
2574 Builder.SetCurrentDebugLocation(llvm::DebugLoc::get
2583 llvm::DIDescriptor D = DBuilder.createLexicalBlock(
2584 llvm::DIDescriptor(LexicalBlockStack.empty() ? nullptr
2588 llvm::MDNode *DN = D;
2603 Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(getLineNumber(Loc),
2634 llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
2637 SmallVector<llvm::Value *, 5> EltTys;
2642 llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
2683 llvm::APInt pad(32, NumPaddingBytes.getQuantity());
2691 llvm::DIType FieldTy = getOrCreateType(FType, Unit);
2702 llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
2704 unsigned Flags = llvm::DIDescriptor::FlagBlockByrefStruct;
2707 llvm::DIType(), Elements);
2711 void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag,
2712 llvm::Value *Storage,
2720 llvm::DIFile Unit;
2723 llvm::DIType Ty;
2744 Flags |= llvm::DIDescriptor::FlagArtificial;
2751 Flags |= llvm::DIDescriptor::FlagObjectPointer;
2752 if (llvm::Argument *Arg = dyn_cast<llvm::Argument>(Storage))
2755 Flags |= llvm::DIDescriptor::FlagIndirectVariable;
2757 llvm::MDNode *Scope = LexicalBlockStack.back();
2763 SmallVector<llvm::Value *, 9> addr;
2764 llvm::Type *Int64Ty = CGM.Int64Ty;
2765 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
2769 addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
2770 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpDeref));
2771 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
2774 addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
2777 llvm::DIVariable D =
2779 llvm::DIDescriptor(Scope),
2783 // Insert an llvm.dbg.declare into the current block.
2784 llvm::Instruction *Call =
2786 Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope));
2789 Flags |= llvm::DIDescriptor::FlagIndirectVariable;
2796 llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
2804 llvm::DIVariable D =
2805 DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope),
2810 // Insert an llvm.dbg.declare into the current block.
2811 llvm::Instruction *Call =
2813 Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope));
2820 llvm::DIVariable D =
2821 DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope),
2825 // Insert an llvm.dbg.declare into the current block.
2826 llvm::Instruction *Call =
2828 Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope));
2832 llvm::Value *Storage,
2835 EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, 0, Builder);
2844 llvm::DIType CGDebugInfo::CreateSelfType(const QualType &QualTy,
2845 llvm::DIType Ty) {
2846 llvm::DIType CachedTy = getTypeOrNull(QualTy);
2852 llvm::Value *Storage,
2864 llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
2865 llvm::DIType Ty;
2880 const llvm::DataLayout &target = CGM.getDataLayout();
2886 SmallVector<llvm::Value *, 9> addr;
2887 llvm::Type *Int64Ty = CGM.Int64Ty;
2888 if (isa<llvm::AllocaInst>(Storage))
2889 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpDeref));
2890 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
2891 addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
2893 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpDeref));
2894 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
2898 addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
2899 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpDeref));
2900 addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIBuilder::OpPlus));
2903 addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity()));
2907 llvm::DIVariable D =
2908 DBuilder.createComplexVariable(llvm::dwarf::DW_TAG_auto_variable,
2909 llvm::DIDescriptor(LexicalBlockStack.back()),
2912 // Insert an llvm.dbg.declare into the current block.
2913 llvm::Instruction *Call =
2915 Call->setDebugLoc(llvm::DebugLoc::get(Line, Column,
2919 /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
2921 void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
2925 EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, ArgNo, Builder);
2939 llvm::Value *Arg,
2940 llvm::Value *LocalAddr,
2948 llvm::DIFile tunit = getOrCreateFile(loc);
2955 const llvm::StructLayout *blockLayout =
2958 SmallVector<llvm::Value*, 16> fields;
3009 llvm::array_pod_sort(chunks.begin(), chunks.end());
3030 llvm::DIType fieldType;
3049 llvm::raw_svector_ostream(typeName)
3052 llvm::DIArray fieldsArray = DBuilder.getOrCreateArray(fields);
3054 llvm::DIType type =
3058 0, llvm::DIType(), fieldsArray);
3062 unsigned flags = llvm::DIDescriptor::FlagArtificial;
3063 llvm::MDNode *scope = LexicalBlockStack.back();
3066 llvm::DIVariable debugVar =
3067 DBuilder.createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
3068 llvm::DIDescriptor(scope),
3071 cast<llvm::Argument>(Arg)->getArgNo() + 1);
3074 // Insert an llvm.dbg.value into the current block.
3075 llvm::Instruction *DbgVal =
3078 DbgVal->setDebugLoc(llvm::DebugLoc::get(line, column, scope));
3081 // Insert an llvm.dbg.declare into the current block.
3082 llvm::Instruction *DbgDecl =
3084 DbgDecl->setDebugLoc(llvm::DebugLoc::get(line, column, scope));
3089 llvm::DIDerivedType
3092 return llvm::DIDerivedType();
3093 llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
3097 return llvm::DIDerivedType(cast<llvm::MDNode>(MI->second));
3102 llvm::DICompositeType Ctxt(
3104 llvm::DIDerivedType T = CreateRecordStaticField(D, Ctxt);
3111 llvm::DIGlobalVariable
3112 CGDebugInfo::CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit,
3114 llvm::GlobalVariable *Var,
3115 llvm::DIDescriptor DContext) {
3116 llvm::DIGlobalVariable GV;
3119 llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
3134 llvm::DIDerivedType());
3140 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
3144 llvm::DIFile Unit = getOrCreateFile(D->getLocation());
3153 llvm::APInt ConstVal(32, 1);
3168 llvm::DIDescriptor DContext =
3173 llvm::DIGlobalVariable GV;
3188 DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(GV)));
3193 llvm::Constant *Init) {
3196 llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
3198 llvm::DIType Ty = getOrCreateType(VD->getType(), Unit);
3205 if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type)
3211 auto pair = DeclCache.insert(std::make_pair(VD, llvm::WeakVH()));
3214 llvm::DIDescriptor DContext =
3216 llvm::DIGlobalVariable GV = DBuilder.createStaticVariable(
3220 pair.first->second = llvm::WeakVH(GV);
3223 llvm::DIScope CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
3225 return llvm::DIScope(LexicalBlockStack.back());
3246 if (llvm::DIScope Target =
3253 llvm::DIImportedEntity
3256 return llvm::DIImportedEntity(nullptr);
3257 llvm::WeakVH &VH = NamespaceAliasCache[&NA];
3259 return llvm::DIImportedEntity(cast<llvm::MDNode>(VH));
3260 llvm::DIImportedEntity R(nullptr);
3279 llvm::DINameSpace
3282 llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH>::iterator I =
3285 return llvm::DINameSpace(cast<llvm::MDNode>(I->second));
3288 llvm::DIFile FileD = getOrCreateFile(NSDecl->getLocation());
3289 llvm::DIDescriptor Context =
3291 llvm::DINameSpace NS =
3293 NameSpaceCache[NSDecl] = llvm::WeakVH(NS);
3310 llvm::DIType Ty(cast<llvm::MDNode>(p.second));
3317 llvm::DIType RepTy(cast<llvm::MDNode>(it->second));
3325 DBuilder.retainType(llvm::DIType(cast<llvm::MDNode>(TypeCache[*RI])));