32 #include "llvm/ADT/SmallVector.h"
33 #include "llvm/ADT/StringExtras.h"
34 #include "llvm/IR/Constants.h"
35 #include "llvm/IR/DataLayout.h"
36 #include "llvm/IR/DerivedTypes.h"
37 #include "llvm/IR/Instructions.h"
38 #include "llvm/IR/Intrinsics.h"
39 #include "llvm/IR/Module.h"
40 #include "llvm/Support/Dwarf.h"
41 #include "llvm/Support/FileSystem.h"
42 #include "llvm/Support/Path.h"
43 using namespace clang;
44 using namespace clang::CodeGen;
47 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
48 DBuilder(CGM.getModule()) {
53 assert(LexicalBlockStack.empty() &&
54 "Region stack mismatch, stack not empty!");
60 init(TemporaryLocation);
67 init(TemporaryLocation, DefaultToEmpty);
71 bool DefaultToEmpty) {
73 OriginalLocation = CGF.
Builder.getCurrentDebugLocation();
76 CGF.
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
79 assert(!DI->LexicalBlockStack.empty());
80 CGF.
Builder.SetCurrentDebugLocation(
81 llvm::DebugLoc::get(0, 0, DI->LexicalBlockStack.back()));
84 DI->EmitLocation(CGF.
Builder, TemporaryLocation);
96 OriginalLocation = CGF.
Builder.getCurrentDebugLocation();
98 CGF.
Builder.SetCurrentDebugLocation(std::move(Loc));
106 CGF.
Builder.SetCurrentDebugLocation(std::move(OriginalLocation));
119 if (LexicalBlockStack.empty())
123 auto *
Scope = cast<llvm::DIScope>(LexicalBlockStack.back());
126 if (PCLoc.isInvalid() ||
Scope->getFilename() == PCLoc.getFilename())
129 if (
auto *LBF = dyn_cast<llvm::DILexicalBlockFile>(
Scope)) {
130 LexicalBlockStack.pop_back();
131 LexicalBlockStack.emplace_back(DBuilder.createLexicalBlockFile(
132 LBF->getScope(), getOrCreateFile(CurLoc)));
133 }
else if (isa<llvm::DILexicalBlock>(
Scope) ||
134 isa<llvm::DISubprogram>(
Scope)) {
135 LexicalBlockStack.pop_back();
136 LexicalBlockStack.emplace_back(
137 DBuilder.createLexicalBlockFile(
Scope, getOrCreateFile(CurLoc)));
141 llvm::DIScope *CGDebugInfo::getContextDescriptor(
const Decl *
Context) {
145 auto I = RegionMap.find(Context);
146 if (I != RegionMap.end()) {
147 llvm::Metadata *V = I->second;
148 return dyn_cast_or_null<llvm::DIScope>(V);
152 if (
const NamespaceDecl *NSDecl = dyn_cast<NamespaceDecl>(Context))
153 return getOrCreateNameSpace(NSDecl);
155 if (
const RecordDecl *RDecl = dyn_cast<RecordDecl>(Context))
156 if (!RDecl->isDependentType())
158 getOrCreateMainFile());
162 StringRef CGDebugInfo::getFunctionName(
const FunctionDecl *FD) {
163 assert(FD &&
"Invalid FunctionDecl!");
172 llvm::raw_svector_ostream OS(NS);
179 unsigned NumArgs = TArgs->
size();
186 return internString(OS.str());
189 StringRef CGDebugInfo::getObjCMethodName(
const ObjCMethodDecl *OMD) {
190 SmallString<256> MethodName;
191 llvm::raw_svector_ostream OS(MethodName);
195 dyn_cast<const ObjCImplementationDecl>(DC)) {
196 OS << OID->getName();
198 dyn_cast<const ObjCInterfaceDecl>(DC)) {
199 OS << OID->getName();
201 dyn_cast<const ObjCCategoryImplDecl>(DC)) {
202 OS << ((
const NamedDecl *)OCD)->getIdentifier()->getNameStart() <<
'('
203 << OCD->getIdentifier()->getNameStart() <<
')';
204 }
else if (isa<ObjCProtocolDecl>(DC)) {
208 cast<ObjCObjectPointerType>(SelfDecl->getType())->getPointeeType();
214 return internString(OS.str());
217 StringRef CGDebugInfo::getSelectorName(
Selector S) {
221 StringRef CGDebugInfo::getClassName(
const RecordDecl *RD) {
224 if (!isa<ClassTemplateSpecializationDecl>(RD))
227 SmallString<128> Name;
229 llvm::raw_svector_ostream OS(Name);
235 return internString(Name);
241 return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
248 return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
252 auto it = DIFileCache.find(fname);
254 if (it != DIFileCache.end()) {
256 if (llvm::Metadata *V = it->second)
257 return cast<llvm::DIFile>(V);
261 DBuilder.createFile(PLoc.
getFilename(), getCurrentDirname());
263 DIFileCache[fname].reset(F);
267 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
268 return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
279 unsigned CGDebugInfo::getColumnNumber(
SourceLocation Loc,
bool Force) {
292 StringRef CGDebugInfo::getCurrentDirname() {
296 if (!CWDName.empty())
298 SmallString<256> CWD;
299 llvm::sys::fs::current_path(CWD);
300 return CWDName = internString(CWD);
303 void CGDebugInfo::CreateCompileUnit() {
315 if (MainFileName.empty())
316 MainFileName =
"<stdin>";
322 std::string MainFileDir;
324 MainFileDir = MainFile->getDir()->getName();
325 if (MainFileDir !=
".") {
327 llvm::sys::path::append(MainFileDirSS, MainFileName);
328 MainFileName = MainFileDirSS.str();
333 StringRef Filename = internString(MainFileName);
337 StringRef SplitDwarfFilename = internString(SplitDwarfFile);
339 llvm::dwarf::SourceLanguage LangTag;
343 LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
345 LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
346 }
else if (LO.ObjC1) {
347 LangTag = llvm::dwarf::DW_LANG_ObjC;
349 LangTag = llvm::dwarf::DW_LANG_C99;
351 LangTag = llvm::dwarf::DW_LANG_C89;
357 unsigned RuntimeVers = 0;
363 TheCU = DBuilder.createCompileUnit(
364 LangTag, Filename, getCurrentDirname(), Producer, LO.Optimize,
367 ? llvm::DIBuilder::LineTablesOnly
368 : llvm::DIBuilder::FullDebug,
373 llvm::DIType *CGDebugInfo::CreateType(
const BuiltinType *BT) {
377 #define BUILTIN_TYPE(Id, SingletonId)
378 #define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
379 #include "clang/AST/BuiltinTypes.def"
380 case BuiltinType::Dependent:
381 llvm_unreachable(
"Unexpected builtin type");
382 case BuiltinType::NullPtr:
383 return DBuilder.createNullPtrType();
384 case BuiltinType::Void:
386 case BuiltinType::ObjCClass:
388 ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
390 getOrCreateMainFile(), 0);
392 case BuiltinType::ObjCId: {
402 ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
404 getOrCreateMainFile(), 0);
408 auto *ISATy = DBuilder.createPointerType(ClassTy, Size);
411 DBuilder.createStructType(TheCU,
"objc_object", getOrCreateMainFile(),
412 0, 0, 0, 0,
nullptr, llvm::DINodeArray());
414 DBuilder.replaceArrays(
416 DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
417 ObjTy,
"isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
420 case BuiltinType::ObjCSel: {
422 SelTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
423 "objc_selector", TheCU,
424 getOrCreateMainFile(), 0);
428 case BuiltinType::OCLImage1d:
429 return getOrCreateStructPtrType(
"opencl_image1d_t", OCLImage1dDITy);
430 case BuiltinType::OCLImage1dArray:
431 return getOrCreateStructPtrType(
"opencl_image1d_array_t",
432 OCLImage1dArrayDITy);
433 case BuiltinType::OCLImage1dBuffer:
434 return getOrCreateStructPtrType(
"opencl_image1d_buffer_t",
435 OCLImage1dBufferDITy);
436 case BuiltinType::OCLImage2d:
437 return getOrCreateStructPtrType(
"opencl_image2d_t", OCLImage2dDITy);
438 case BuiltinType::OCLImage2dArray:
439 return getOrCreateStructPtrType(
"opencl_image2d_array_t",
440 OCLImage2dArrayDITy);
441 case BuiltinType::OCLImage3d:
442 return getOrCreateStructPtrType(
"opencl_image3d_t", OCLImage3dDITy);
443 case BuiltinType::OCLSampler:
444 return DBuilder.createBasicType(
447 case BuiltinType::OCLEvent:
448 return getOrCreateStructPtrType(
"opencl_event_t", OCLEventDITy);
450 case BuiltinType::UChar:
451 case BuiltinType::Char_U:
452 Encoding = llvm::dwarf::DW_ATE_unsigned_char;
454 case BuiltinType::Char_S:
455 case BuiltinType::SChar:
456 Encoding = llvm::dwarf::DW_ATE_signed_char;
458 case BuiltinType::Char16:
459 case BuiltinType::Char32:
460 Encoding = llvm::dwarf::DW_ATE_UTF;
462 case BuiltinType::UShort:
463 case BuiltinType::UInt:
464 case BuiltinType::UInt128:
465 case BuiltinType::ULong:
466 case BuiltinType::WChar_U:
467 case BuiltinType::ULongLong:
468 Encoding = llvm::dwarf::DW_ATE_unsigned;
470 case BuiltinType::Short:
471 case BuiltinType::Int:
472 case BuiltinType::Int128:
473 case BuiltinType::Long:
474 case BuiltinType::WChar_S:
475 case BuiltinType::LongLong:
476 Encoding = llvm::dwarf::DW_ATE_signed;
478 case BuiltinType::Bool:
479 Encoding = llvm::dwarf::DW_ATE_boolean;
481 case BuiltinType::Half:
482 case BuiltinType::Float:
483 case BuiltinType::LongDouble:
484 case BuiltinType::Double:
485 Encoding = llvm::dwarf::DW_ATE_float;
490 case BuiltinType::Long:
493 case BuiltinType::LongLong:
494 BTName =
"long long int";
496 case BuiltinType::ULong:
497 BTName =
"long unsigned int";
499 case BuiltinType::ULongLong:
500 BTName =
"long long unsigned int";
509 return DBuilder.createBasicType(BTName, Size, Align, Encoding);
512 llvm::DIType *CGDebugInfo::CreateType(
const ComplexType *Ty) {
514 llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
516 Encoding = llvm::dwarf::DW_ATE_lo_user;
520 return DBuilder.createBasicType(
"complex", Size, Align, Encoding);
523 llvm::DIType *CGDebugInfo::CreateQualifiedType(
QualType Ty,
524 llvm::DIFile *Unit) {
535 llvm::dwarf::Tag Tag;
537 Tag = llvm::dwarf::DW_TAG_const_type;
540 Tag = llvm::dwarf::DW_TAG_volatile_type;
543 Tag = llvm::dwarf::DW_TAG_restrict_type;
546 assert(Qc.
empty() &&
"Unknown type qualifier for debug info");
547 return getOrCreateType(
QualType(T, 0), Unit);
554 return DBuilder.createQualifiedType(Tag, FromTy);
558 llvm::DIFile *Unit) {
566 return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
570 llvm::DIType *CGDebugInfo::CreateType(
const PointerType *Ty,
571 llvm::DIFile *Unit) {
572 return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
578 switch (TheCU->getSourceLanguage()) {
579 case llvm::dwarf::DW_LANG_C_plus_plus:
581 case llvm::dwarf::DW_LANG_ObjC_plus_plus:
582 return isa<CXXRecordDecl>(TD) || isa<EnumDecl>(TD);
592 llvm::DICompileUnit *TheCU) {
593 SmallString<256> FullName;
605 llvm::raw_svector_ostream Out(FullName);
613 llvm::dwarf::Tag Tag;
615 Tag = llvm::dwarf::DW_TAG_structure_type;
617 Tag = llvm::dwarf::DW_TAG_union_type;
622 Tag = llvm::dwarf::DW_TAG_class_type;
627 llvm::DICompositeType *
628 CGDebugInfo::getOrCreateRecordFwdDecl(
const RecordType *Ty,
629 llvm::DIScope *Ctx) {
632 return cast<llvm::DICompositeType>(T);
633 llvm::DIFile *DefUnit = getOrCreateFile(RD->
getLocation());
635 StringRef RDName = getClassName(RD);
648 llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
650 llvm::DINode::FlagFwdDecl, FullName);
651 ReplaceMap.emplace_back(
652 std::piecewise_construct, std::make_tuple(Ty),
653 std::make_tuple(static_cast<llvm::Metadata *>(RetTy)));
657 llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
660 llvm::DIFile *Unit) {
661 if (Tag == llvm::dwarf::DW_TAG_reference_type ||
662 Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
663 return DBuilder.createReferenceType(Tag, getOrCreateType(PointeeTy, Unit));
672 return DBuilder.createPointerType(getOrCreateType(PointeeTy, Unit), Size,
676 llvm::DIType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name,
677 llvm::DIType *&
Cache) {
680 Cache = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name,
681 TheCU, getOrCreateMainFile(), 0);
683 Cache = DBuilder.createPointerType(Cache, Size);
688 llvm::DIFile *Unit) {
691 uint64_t FieldSize, FieldOffset;
693 llvm::DINodeArray Elements;
697 EltTys.push_back(CreateMemberType(Unit, FType,
"reserved", &FieldOffset));
698 EltTys.push_back(CreateMemberType(Unit, FType,
"Size", &FieldOffset));
700 Elements = DBuilder.getOrCreateArray(EltTys);
703 unsigned Flags = llvm::DINode::FlagAppleBlock;
707 DBuilder.createStructType(Unit,
"__block_descriptor",
nullptr, LineNo,
708 FieldOffset, 0, Flags,
nullptr, Elements);
713 auto *DescTy = DBuilder.createPointerType(EltTy, Size);
717 EltTys.push_back(CreateMemberType(Unit, FType,
"__isa", &FieldOffset));
719 EltTys.push_back(CreateMemberType(Unit, FType,
"__flags", &FieldOffset));
720 EltTys.push_back(CreateMemberType(Unit, FType,
"__reserved", &FieldOffset));
722 EltTys.push_back(CreateMemberType(Unit, FType,
"__FuncPtr", &FieldOffset));
727 EltTys.push_back(DBuilder.createMemberType(Unit,
"__descriptor",
nullptr, LineNo,
728 FieldSize, FieldAlign, FieldOffset,
731 FieldOffset += FieldSize;
732 Elements = DBuilder.getOrCreateArray(EltTys);
739 DBuilder.createStructType(Unit,
"",
nullptr, LineNo,
740 FieldOffset, 0, Flags,
nullptr, Elements);
742 return DBuilder.createPointerType(EltTy, Size);
746 llvm::DIFile *Unit) {
751 llvm::raw_svector_ostream OS(NS);
763 return DBuilder.createTypedef(
764 Src, internString(OS.str()), getOrCreateFile(Loc), getLineNumber(Loc),
765 getContextDescriptor(cast<Decl>(AliasDecl->getDeclContext())));
768 llvm::DIType *CGDebugInfo::CreateType(
const TypedefType *Ty,
769 llvm::DIFile *Unit) {
775 return DBuilder.createTypedef(
777 Ty->
getDecl()->
getName(), getOrCreateFile(Loc), getLineNumber(Loc),
781 llvm::DIType *CGDebugInfo::CreateType(
const FunctionType *Ty,
782 llvm::DIFile *Unit) {
786 EltTys.push_back(getOrCreateType(Ty->
getReturnType(), Unit));
790 if (isa<FunctionNoProtoType>(Ty))
791 EltTys.push_back(DBuilder.createUnspecifiedParameter());
793 for (
unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)
794 EltTys.push_back(getOrCreateType(FPT->getParamType(i), Unit));
795 if (FPT->isVariadic())
796 EltTys.push_back(DBuilder.createUnspecifiedParameter());
799 llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
800 return DBuilder.createSubroutineType(Unit, EltTypeArray);
813 if (Access == Default)
818 return llvm::DINode::FlagPrivate;
820 return llvm::DINode::FlagProtected;
822 return llvm::DINode::FlagPublic;
826 llvm_unreachable(
"unexpected access enumerator");
829 llvm::DIType *CGDebugInfo::createFieldType(
830 StringRef name,
QualType type, uint64_t sizeInBitsOverride,
832 llvm::DIFile *tunit, llvm::DIScope *scope,
const RecordDecl *RD) {
833 llvm::DIType *debugType = getOrCreateType(type, tunit);
836 llvm::DIFile *file = getOrCreateFile(loc);
837 unsigned line = getLineNumber(loc);
839 uint64_t SizeInBits = 0;
840 unsigned AlignInBits = 0;
843 SizeInBits = TI.
Width;
844 AlignInBits = TI.
Align;
846 if (sizeInBitsOverride)
847 SizeInBits = sizeInBitsOverride;
851 return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
852 AlignInBits, offsetInBits, flags, debugType);
855 void CGDebugInfo::CollectRecordLambdaFields(
857 llvm::DIType *RecordTy) {
863 unsigned fieldno = 0;
866 I != E; ++I, ++Field, ++fieldno) {
870 llvm::DIFile *VUnit = getOrCreateFile(C.
getLocation());
871 StringRef VName = V->
getName();
872 uint64_t SizeInBitsOverride = 0;
873 if (Field->isBitField()) {
874 SizeInBitsOverride = Field->getBitWidthValue(CGM.
getContext());
875 assert(SizeInBitsOverride &&
"found named 0-width bitfield");
877 llvm::DIType *fieldType = createFieldType(
878 VName, Field->getType(), SizeInBitsOverride, C.
getLocation(),
879 Field->getAccess(), layout.
getFieldOffset(fieldno), VUnit, RecordTy,
881 elements.push_back(fieldType);
888 llvm::DIFile *VUnit = getOrCreateFile(f->
getLocation());
890 llvm::DIType *fieldType = createFieldType(
894 elements.push_back(fieldType);
899 llvm::DIDerivedType *
900 CGDebugInfo::CreateRecordStaticField(
const VarDecl *Var, llvm::DIType *RecordTy,
905 llvm::DIFile *VUnit = getOrCreateFile(Var->
getLocation());
906 llvm::DIType *VTy = getOrCreateType(Var->
getType(), VUnit);
908 unsigned LineNumber = getLineNumber(Var->
getLocation());
909 StringRef VName = Var->
getName();
910 llvm::Constant *C =
nullptr;
922 llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
923 RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
928 void CGDebugInfo::CollectRecordNormalField(
929 const FieldDecl *field, uint64_t OffsetInBits, llvm::DIFile *tunit,
932 StringRef name = field->
getName();
939 uint64_t SizeInBitsOverride = 0;
942 assert(SizeInBitsOverride &&
"found named 0-width bitfield");
945 llvm::DIType *fieldType =
946 createFieldType(name, type, SizeInBitsOverride, field->
getLocation(),
947 field->
getAccess(), OffsetInBits, tunit, RecordTy, RD);
949 elements.push_back(fieldType);
952 void CGDebugInfo::CollectRecordFields(
953 const RecordDecl *record, llvm::DIFile *tunit,
955 llvm::DICompositeType *RecordTy) {
959 CollectRecordLambdaFields(CXXDecl, elements, RecordTy);
964 unsigned fieldNo = 0;
968 for (
const auto *I : record->
decls())
969 if (
const auto *V = dyn_cast<VarDecl>(I)) {
972 if (MI != StaticDataMemberCache.end()) {
974 "Static data member declaration should still exist");
975 elements.push_back(cast<llvm::DIDerivedTypeBase>(MI->second));
977 auto Field = CreateRecordStaticField(V, RecordTy, record);
978 elements.push_back(Field);
980 }
else if (
const auto *field = dyn_cast<FieldDecl>(I)) {
981 CollectRecordNormalField(field, layout.
getFieldOffset(fieldNo), tunit,
982 elements, RecordTy, record);
990 llvm::DISubroutineType *
991 CGDebugInfo::getOrCreateMethodType(
const CXXMethodDecl *Method,
992 llvm::DIFile *Unit) {
995 return cast_or_null<llvm::DISubroutineType>(
996 getOrCreateType(
QualType(Func, 0), Unit));
1001 llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
1004 llvm::DITypeRefArray Args(
1005 cast<llvm::DISubroutineType>(getOrCreateType(
QualType(Func, 0), Unit))
1007 assert(Args.size() &&
"Invalid number of arguments!");
1012 Elts.push_back(Args[0]);
1016 if (isa<ClassTemplateSpecializationDecl>(RD)) {
1018 const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
1023 llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit);
1024 llvm::DIType *ThisPtrType =
1025 DBuilder.createPointerType(PointeeType, Size, Align);
1030 ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
1031 Elts.push_back(ThisPtrType);
1033 llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
1035 ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
1036 Elts.push_back(ThisPtrType);
1040 for (
unsigned i = 1, e = Args.size(); i != e; ++i)
1041 Elts.push_back(Args[i]);
1043 llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
1047 Flags |= llvm::DINode::FlagLValueReference;
1049 Flags |= llvm::DINode::FlagRValueReference;
1051 return DBuilder.createSubroutineType(Unit, EltTypeArray, Flags);
1064 llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
1065 const CXXMethodDecl *Method, llvm::DIFile *Unit, llvm::DIType *RecordTy) {
1067 isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method);
1069 StringRef MethodName = getFunctionName(Method);
1070 llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit);
1074 StringRef MethodLinkageName;
1079 llvm::DIFile *MethodDefUnit =
nullptr;
1080 unsigned MethodLine = 0;
1082 MethodDefUnit = getOrCreateFile(Method->
getLocation());
1083 MethodLine = getLineNumber(Method->
getLocation());
1087 llvm::DIType *ContainingType =
nullptr;
1088 unsigned Virtuality = 0;
1089 unsigned VIndex = 0;
1093 Virtuality = llvm::dwarf::DW_VIRTUALITY_pure_virtual;
1095 Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
1102 if (!isa<CXXDestructorDecl>(Method) &&
1105 ContainingType = RecordTy;
1110 Flags |= llvm::DINode::FlagArtificial;
1113 if (CXXC->isExplicit())
1114 Flags |= llvm::DINode::FlagExplicit;
1116 dyn_cast<CXXConversionDecl>(Method)) {
1117 if (CXXC->isExplicit())
1118 Flags |= llvm::DINode::FlagExplicit;
1121 Flags |= llvm::DINode::FlagPrototyped;
1123 Flags |= llvm::DINode::FlagLValueReference;
1125 Flags |= llvm::DINode::FlagRValueReference;
1127 llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
1128 llvm::DISubprogram *SP = DBuilder.createMethod(
1129 RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
1131 false, Virtuality, VIndex, ContainingType, Flags,
1132 CGM.
getLangOpts().Optimize,
nullptr, TParamsArray.get());
1139 void CGDebugInfo::CollectCXXMemberFunctions(
1146 for (
const auto *I : RD->
decls()) {
1171 EltTys.push_back(MI == SPCache.end()
1172 ? CreateCXXMemberFunction(Method, Unit, RecordTy)
1173 : static_cast<llvm::Metadata *>(MI->second));
1177 void CGDebugInfo::CollectCXXBases(
const CXXRecordDecl *RD, llvm::DIFile *Unit,
1179 llvm::DIType *RecordTy) {
1181 for (
const auto &BI : RD->
bases()) {
1182 unsigned BFlags = 0;
1183 uint64_t BaseOffset;
1186 cast<CXXRecordDecl>(BI.getType()->getAs<
RecordType>()->getDecl());
1188 if (BI.isVirtual()) {
1201 BFlags = llvm::DINode::FlagVirtual;
1208 llvm::DIType *DTy = DBuilder.createInheritance(
1209 RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags);
1210 EltTys.push_back(DTy);
1217 llvm::DIFile *Unit) {
1219 for (
unsigned i = 0, e = TAList.size(); i != e; ++i) {
1226 llvm::DIType *TTy = getOrCreateType(TA.
getAsType(), Unit);
1227 TemplateParams.push_back(
1228 DBuilder.createTemplateTypeParameter(TheCU, Name, TTy));
1232 TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1239 llvm::DIType *TTy = getOrCreateType(T, Unit);
1240 llvm::Constant *V =
nullptr;
1244 if (
const auto *VD = dyn_cast<VarDecl>(D))
1248 else if ((MD = dyn_cast<CXXMethodDecl>(D)) && MD->
isInstance())
1250 else if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1254 else if (
const auto *MPT = dyn_cast<MemberPointerType>(T.
getTypePtr())) {
1263 TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1265 cast_or_null<llvm::Constant>(V->stripPointerCasts())));
1269 llvm::DIType *TTy = getOrCreateType(T, Unit);
1270 llvm::Constant *V =
nullptr;
1280 if (MPT->isMemberDataPointer())
1283 V = llvm::ConstantInt::get(CGM.
Int8Ty, 0);
1284 TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1285 TheCU, Name, TTy, cast<llvm::Constant>(V)));
1288 TemplateParams.push_back(DBuilder.createTemplateTemplateParameter(
1289 TheCU, Name,
nullptr,
1293 TemplateParams.push_back(DBuilder.createTemplateParameterPack(
1294 TheCU, Name,
nullptr,
1303 assert(V &&
"Expression in template argument isn't constant");
1304 llvm::DIType *TTy = getOrCreateType(T, Unit);
1305 TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1306 TheCU, Name, TTy, cast<llvm::Constant>(V->stripPointerCasts())));
1312 "These argument types shouldn't exist in concrete types");
1315 return DBuilder.getOrCreateArray(TemplateParams);
1319 CGDebugInfo::CollectFunctionTemplateParams(
const FunctionDecl *FD,
1320 llvm::DIFile *Unit) {
1326 return CollectTemplateParams(
1329 return llvm::DINodeArray();
1332 llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(
1339 return CollectTemplateParams(TPList, TAList.
asArray(), Unit);
1342 llvm::DIType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile *Unit) {
1344 return VTablePtrType;
1349 llvm::Metadata *STy = getOrCreateType(Context.
IntTy, Unit);
1350 llvm::DITypeRefArray SElements = DBuilder.getOrCreateTypeArray(STy);
1351 llvm::DIType *SubTy = DBuilder.createSubroutineType(Unit, SElements);
1353 llvm::DIType *vtbl_ptr_type =
1354 DBuilder.createPointerType(SubTy, Size, 0,
"__vtbl_ptr_type");
1355 VTablePtrType = DBuilder.createPointerType(vtbl_ptr_type, Size);
1356 return VTablePtrType;
1359 StringRef CGDebugInfo::getVTableName(
const CXXRecordDecl *RD) {
1364 void CGDebugInfo::CollectVTableInfo(
const CXXRecordDecl *RD, llvm::DIFile *Unit,
1377 llvm::DIType *VPTR = DBuilder.createMemberType(
1378 Unit, getVTableName(RD), Unit, 0, Size, 0, 0,
1379 llvm::DINode::FlagArtificial, getOrCreateVTablePtrType(Unit));
1380 EltTys.push_back(VPTR);
1386 llvm::DIType *T = getOrCreateType(RTy, getOrCreateFile(Loc));
1393 llvm::DIType *T = getOrCreateType(D, getOrCreateFile(Loc));
1403 auto I = TypeCache.find(TyPtr);
1404 if (I == TypeCache.end() || !cast<llvm::DIType>(I->second)->isForwardDecl())
1406 llvm::DIType *Res = CreateTypeDefinition(Ty->
castAs<
EnumType>());
1407 assert(!Res->isForwardDecl());
1408 TypeCache[TyPtr].reset(Res);
1421 if (
const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD))
1426 llvm::DIType *T = getTypeOrNull(Ty);
1427 if (T && T->isForwardDecl())
1436 auto I = TypeCache.find(TyPtr);
1437 if (I != TypeCache.end() && !cast<llvm::DIType>(I->second)->isForwardDecl())
1440 assert(!Res->isForwardDecl());
1441 TypeCache[TyPtr].reset(Res);
1446 for (; I !=
End; ++I)
1447 if (
FunctionDecl *Tmpl = I->getInstantiatedFromMemberFunction())
1448 if (!Tmpl->isImplicit() && Tmpl->isThisDeclarationADefinition() &&
1449 !I->getMemberSpecializationInfo()->isExplicitSpecialization())
1460 if (!LangOpts.CPlusPlus)
1476 dyn_cast<ClassTemplateSpecializationDecl>(RD))
1477 Spec = SD->getSpecializationKind();
1487 llvm::DIType *CGDebugInfo::CreateType(
const RecordType *Ty) {
1489 llvm::DIType *T = cast_or_null<llvm::DIType>(getTypeOrNull(
QualType(Ty, 0)));
1492 T = getOrCreateRecordFwdDecl(
1497 return CreateTypeDefinition(Ty);
1500 llvm::DIType *CGDebugInfo::CreateTypeDefinition(
const RecordType *Ty) {
1504 llvm::DIFile *DefUnit = getOrCreateFile(RD->
getLocation());
1514 cast<llvm::DICompositeType>(getOrCreateLimitedType(Ty, DefUnit));
1517 if (!D || !D->isCompleteDefinition())
1520 if (
const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD))
1521 CollectContainingType(CXXDecl, FwdDecl);
1524 LexicalBlockStack.emplace_back(&*FwdDecl);
1525 RegionMap[Ty->
getDecl()].reset(FwdDecl);
1537 CollectCXXBases(CXXDecl, DefUnit, EltTys, FwdDecl);
1538 CollectVTableInfo(CXXDecl, DefUnit, EltTys);
1542 CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
1544 CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
1546 LexicalBlockStack.pop_back();
1547 RegionMap.erase(Ty->
getDecl());
1549 llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
1550 DBuilder.replaceArrays(FwdDecl, Elements);
1552 if (FwdDecl->isTemporary())
1554 llvm::MDNode::replaceWithPermanent(llvm::TempDICompositeType(FwdDecl));
1556 RegionMap[Ty->
getDecl()].reset(FwdDecl);
1561 llvm::DIFile *Unit) {
1591 llvm::DIFile *Unit) {
1597 llvm::DIFile *DefUnit = getOrCreateFile(ID->
getLocation());
1600 static_cast<llvm::dwarf::SourceLanguage
>(TheCU->getSourceLanguage());
1606 llvm::DIType *FwdDecl = DBuilder.createReplaceableCompositeType(
1607 llvm::dwarf::DW_TAG_structure_type, ID->
getName(), TheCU, DefUnit,
Line,
1609 ObjCInterfaceCache.push_back(ObjCInterfaceCacheEntry(Ty, FwdDecl, Unit));
1613 return CreateTypeDefinition(Ty, Unit);
1618 auto it = ModuleRefCache.find(Mod.
Signature);
1619 if (it != ModuleRefCache.end())
1623 SmallString<128> ConfigMacros;
1625 llvm::raw_svector_ostream OS(ConfigMacros);
1629 for (
auto &M : PPOpts.Macros) {
1632 const std::string &Macro = M.first;
1633 bool Undef = M.second;
1634 OS <<
"\"-" << (Undef ?
'U' :
'D');
1635 for (
char c : Macro)
1637 case '\\' : OS <<
"\\\\";
break;
1638 case '"' : OS <<
"\\\"";
break;
1644 llvm::DIBuilder DIB(CGM.getModule());
1645 auto *CU = DIB.createCompileUnit(
1646 TheCU->getSourceLanguage(), internString(Mod.
ModuleName),
1647 internString(Mod.
Path), TheCU->getProducer(),
true, StringRef(), 0,
1649 llvm::DIModule *ModuleRef =
1650 DIB.createModule(CU, Mod.
ModuleName, ConfigMacros, internString(Mod.
Path),
1651 internString(CGM.getHeaderSearchOpts().Sysroot));
1653 ModuleRefCache.insert(std::make_pair(Mod.
Signature, ModuleRef));
1658 llvm::DIFile *Unit) {
1660 llvm::DIFile *DefUnit = getOrCreateFile(ID->
getLocation());
1662 unsigned RuntimeLang = TheCU->getSourceLanguage();
1665 uint64_t Size = CGM.getContext().getTypeSize(Ty);
1666 uint64_t Align = CGM.getContext().getTypeAlign(Ty);
1670 Flags |= llvm::DINode::FlagObjcClassComplete;
1672 llvm::DICompositeType *RealDecl = DBuilder.createStructType(
1673 Unit, ID->
getName(), DefUnit,
Line, Size, Align, Flags,
nullptr,
1674 llvm::DINodeArray(), RuntimeLang);
1677 TypeCache[QTy.getAsOpaquePtr()].reset(RealDecl);
1680 LexicalBlockStack.emplace_back(RealDecl);
1681 RegionMap[Ty->
getDecl()].reset(RealDecl);
1688 llvm::DIType *SClassTy =
1689 getOrCreateType(CGM.getContext().getObjCInterfaceType(SClass), Unit);
1693 llvm::DIType *InhTag = DBuilder.createInheritance(RealDecl, SClassTy, 0, 0);
1694 EltTys.push_back(InhTag);
1700 llvm::DIFile *PUnit = getOrCreateFile(Loc);
1701 unsigned PLine = getLineNumber(Loc);
1704 llvm::MDNode *PropertyNode = DBuilder.createObjCProperty(
1705 PD->getName(), PUnit, PLine,
1707 : getSelectorName(PD->getGetterName()),
1709 : getSelectorName(PD->getSetterName()),
1710 PD->getPropertyAttributes(), getOrCreateType(PD->getType(), PUnit));
1711 EltTys.push_back(PropertyNode);
1714 const ASTRecordLayout &RL = CGM.getContext().getASTObjCInterfaceLayout(ID);
1715 unsigned FieldNo = 0;
1718 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
1722 StringRef FieldName = Field->getName();
1725 if (FieldName.empty())
1729 llvm::DIFile *FieldDefUnit = getOrCreateFile(Field->getLocation());
1730 unsigned FieldLine = getLineNumber(Field->getLocation());
1732 uint64_t FieldSize = 0;
1733 unsigned FieldAlign = 0;
1735 if (!FType->isIncompleteArrayType()) {
1738 FieldSize = Field->isBitField()
1739 ? Field->getBitWidthValue(CGM.getContext())
1740 : CGM.getContext().getTypeSize(FType);
1741 FieldAlign = CGM.getContext().getTypeAlign(FType);
1744 uint64_t FieldOffset;
1745 if (CGM.getLangOpts().ObjCRuntime.isNonFragile()) {
1749 if (Field->isBitField()) {
1751 CGM.getObjCRuntime().ComputeBitfieldBitOffset(CGM, ID, Field);
1752 FieldOffset %= CGM.getContext().getCharWidth();
1762 Flags = llvm::DINode::FlagProtected;
1764 Flags = llvm::DINode::FlagPrivate;
1766 Flags = llvm::DINode::FlagPublic;
1768 llvm::MDNode *PropertyNode =
nullptr;
1771 ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) {
1774 llvm::DIFile *PUnit = getOrCreateFile(Loc);
1775 unsigned PLine = getLineNumber(Loc);
1778 PropertyNode = DBuilder.createObjCProperty(
1779 PD->getName(), PUnit, PLine,
1781 PD->getGetterName()),
1783 PD->getSetterName()),
1784 PD->getPropertyAttributes(),
1785 getOrCreateType(PD->getType(), PUnit));
1789 FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit, FieldLine,
1790 FieldSize, FieldAlign, FieldOffset, Flags,
1791 FieldTy, PropertyNode);
1792 EltTys.push_back(FieldTy);
1795 llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
1796 DBuilder.replaceArrays(RealDecl, Elements);
1798 LexicalBlockStack.pop_back();
1802 llvm::DIType *CGDebugInfo::CreateType(
const VectorType *Ty,
1803 llvm::DIFile *Unit) {
1804 llvm::DIType *ElementTy = getOrCreateType(Ty->
getElementType(), Unit);
1811 llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(0, Count);
1812 llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
1814 uint64_t Size = CGM.getContext().getTypeSize(Ty);
1815 uint64_t Align = CGM.getContext().getTypeAlign(Ty);
1817 return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray);
1820 llvm::DIType *CGDebugInfo::CreateType(
const ArrayType *Ty, llvm::DIFile *Unit) {
1828 CGM.getContext().getTypeAlign(CGM.getContext().getBaseElementType(VAT));
1840 Size = CGM.getContext().getTypeSize(Ty);
1841 Align = CGM.getContext().getTypeAlign(Ty);
1849 while ((Ty = dyn_cast<ArrayType>(EltTy))) {
1859 Count = CAT->getSize().getZExtValue();
1862 Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));
1866 llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts);
1868 return DBuilder.createArrayType(Size, Align, getOrCreateType(EltTy, Unit),
1873 llvm::DIFile *Unit) {
1874 return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, Ty,
1879 llvm::DIFile *Unit) {
1880 return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
1886 uint64_t Size = CGM.getCXXABI().isTypeInfoCalculable(
QualType(Ty, 0))
1887 ? CGM.getContext().getTypeSize(Ty)
1891 return DBuilder.createMemberPointerType(
1896 return DBuilder.createMemberPointerType(
1897 getOrCreateInstanceMethodType(CGM.getContext().getPointerType(
QualType(
1903 llvm::DIType *CGDebugInfo::CreateType(
const AtomicType *Ty, llvm::DIFile *U) {
1909 llvm::DIType *CGDebugInfo::CreateEnumType(
const EnumType *Ty) {
1923 llvm::DIScope *EDContext =
1925 llvm::DIFile *DefUnit = getOrCreateFile(ED->
getLocation());
1927 StringRef EDName = ED->
getName();
1928 llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
1929 llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, Line,
1930 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
1931 ReplaceMap.emplace_back(
1932 std::piecewise_construct, std::make_tuple(Ty),
1933 std::make_tuple(static_cast<llvm::Metadata *>(RetTy)));
1937 return CreateTypeDefinition(Ty);
1940 llvm::DIType *CGDebugInfo::CreateTypeDefinition(
const EnumType *Ty) {
1955 Enumerators.push_back(DBuilder.createEnumerator(
1956 Enum->getName(), Enum->getInitVal().getSExtValue()));
1960 llvm::DINodeArray EltArray = DBuilder.getOrCreateArray(Enumerators);
1962 llvm::DIFile *DefUnit = getOrCreateFile(ED->
getLocation());
1964 llvm::DIScope *EnumContext =
1966 llvm::DIType *ClassTy =
1968 return DBuilder.createEnumerationType(EnumContext, ED->
getName(), DefUnit,
1969 Line, Size, Align, EltArray, ClassTy,
1980 Quals += InnerQuals;
1985 case Type::TemplateSpecialization: {
1986 const auto *Spec = cast<TemplateSpecializationType>(T);
1987 if (Spec->isTypeAlias())
1989 T = Spec->desugar();
1992 case Type::TypeOfExpr:
1993 T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType();
1998 case Type::Decltype:
2001 case Type::UnaryTransform:
2004 case Type::Attributed:
2005 T = cast<AttributedType>(T)->getEquivalentType();
2007 case Type::Elaborated:
2008 T = cast<ElaboratedType>(T)->getNamedType();
2011 T = cast<ParenType>(T)->getInnerType();
2013 case Type::SubstTemplateTypeParm:
2014 T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
2017 QualType DT = cast<AutoType>(T)->getDeducedType();
2018 assert(!DT.
isNull() &&
"Undeduced types shouldn't reach here.");
2023 assert(T != LastT &&
"Type unwrapping failed to unwrap!");
2028 llvm::DIType *CGDebugInfo::getTypeOrNull(
QualType Ty) {
2034 if (it != TypeCache.end()) {
2036 if (llvm::Metadata *V = it->second)
2037 return cast<llvm::DIType>(V);
2043 void CGDebugInfo::completeTemplateDefinition(
2048 completeClassData(&SD);
2051 RetainedTypes.push_back(CGM.getContext().getRecordType(&SD).getAsOpaquePtr());
2054 llvm::DIType *CGDebugInfo::getOrCreateType(
QualType Ty, llvm::DIFile *Unit) {
2061 if (
auto *T = getTypeOrNull(Ty))
2065 llvm::DIType *Res = CreateTypeNode(Ty, Unit);
2069 TypeCache[TyPtr].reset(Res);
2088 case Type::ObjCObjectPointer:
2089 return getObjCInterfaceDecl(
2090 cast<ObjCObjectPointerType>(Ty)->getPointeeType());
2091 case Type::ObjCInterface:
2092 return cast<ObjCInterfaceType>(Ty)->getDecl();
2098 llvm::DIType *CGDebugInfo::CreateTypeNode(
QualType Ty, llvm::DIFile *Unit) {
2101 return CreateQualifiedType(Ty, Unit);
2105 #define TYPE(Class, Base)
2106 #define ABSTRACT_TYPE(Class, Base)
2107 #define NON_CANONICAL_TYPE(Class, Base)
2108 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
2109 #include "clang/AST/TypeNodes.def"
2110 llvm_unreachable(
"Dependent types cannot show up in debug information");
2112 case Type::ExtVector:
2114 return CreateType(cast<VectorType>(Ty), Unit);
2115 case Type::ObjCObjectPointer:
2116 return CreateType(cast<ObjCObjectPointerType>(Ty), Unit);
2117 case Type::ObjCObject:
2118 return CreateType(cast<ObjCObjectType>(Ty), Unit);
2119 case Type::ObjCInterface:
2120 return CreateType(cast<ObjCInterfaceType>(Ty), Unit);
2122 return CreateType(cast<BuiltinType>(Ty));
2124 return CreateType(cast<ComplexType>(Ty));
2126 return CreateType(cast<PointerType>(Ty), Unit);
2127 case Type::Adjusted:
2131 cast<PointerType>(cast<AdjustedType>(Ty)->getAdjustedType()), Unit);
2132 case Type::BlockPointer:
2133 return CreateType(cast<BlockPointerType>(Ty), Unit);
2135 return CreateType(cast<TypedefType>(Ty), Unit);
2137 return CreateType(cast<RecordType>(Ty));
2139 return CreateEnumType(cast<EnumType>(Ty));
2140 case Type::FunctionProto:
2141 case Type::FunctionNoProto:
2142 return CreateType(cast<FunctionType>(Ty), Unit);
2143 case Type::ConstantArray:
2144 case Type::VariableArray:
2145 case Type::IncompleteArray:
2146 return CreateType(cast<ArrayType>(Ty), Unit);
2148 case Type::LValueReference:
2149 return CreateType(cast<LValueReferenceType>(Ty), Unit);
2150 case Type::RValueReference:
2151 return CreateType(cast<RValueReferenceType>(Ty), Unit);
2153 case Type::MemberPointer:
2154 return CreateType(cast<MemberPointerType>(Ty), Unit);
2157 return CreateType(cast<AtomicType>(Ty), Unit);
2159 case Type::TemplateSpecialization:
2160 return CreateType(cast<TemplateSpecializationType>(Ty), Unit);
2163 case Type::Attributed:
2164 case Type::Elaborated:
2166 case Type::SubstTemplateTypeParm:
2167 case Type::TypeOfExpr:
2169 case Type::Decltype:
2170 case Type::UnaryTransform:
2171 case Type::PackExpansion:
2175 llvm_unreachable(
"type should have been unwrapped!");
2178 llvm::DIType *CGDebugInfo::getOrCreateLimitedType(
const RecordType *Ty,
2179 llvm::DIFile *Unit) {
2182 auto *T = cast_or_null<llvm::DICompositeTypeBase>(getTypeOrNull(QTy));
2187 if (T && !T->isForwardDecl())
2191 llvm::DICompositeType *Res = CreateLimitedType(Ty);
2196 DBuilder.replaceArrays(Res, T ? T->getElements() : llvm::DINodeArray());
2199 TypeCache[QTy.getAsOpaquePtr()].reset(Res);
2204 llvm::DICompositeType *CGDebugInfo::CreateLimitedType(
const RecordType *Ty) {
2208 llvm::DIFile *DefUnit = getOrCreateFile(RD->
getLocation());
2210 StringRef RDName = getClassName(RD);
2212 llvm::DIScope *RDContext =
2217 auto *T = cast_or_null<llvm::DICompositeType>(
2218 getTypeOrNull(CGM.getContext().getRecordType(RD)));
2226 return getOrCreateRecordFwdDecl(Ty, RDContext);
2228 uint64_t Size = CGM.getContext().getTypeSize(Ty);
2229 uint64_t Align = CGM.getContext().getTypeAlign(Ty);
2233 llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
2234 getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align, 0,
2237 RegionMap[Ty->
getDecl()].reset(RealDecl);
2241 dyn_cast<ClassTemplateSpecializationDecl>(RD))
2242 DBuilder.replaceArrays(RealDecl, llvm::DINodeArray(),
2243 CollectCXXTemplateParams(TSpecial, DefUnit));
2247 void CGDebugInfo::CollectContainingType(
const CXXRecordDecl *RD,
2248 llvm::DICompositeType *RealDecl) {
2250 llvm::DICompositeType *ContainingType =
nullptr;
2255 const ASTRecordLayout &BRL = CGM.getContext().getASTRecordLayout(PBase);
2262 ContainingType = cast<llvm::DICompositeType>(
2263 getOrCreateType(
QualType(PBase->getTypeForDecl(), 0),
2266 ContainingType = RealDecl;
2268 DBuilder.replaceVTableHolder(RealDecl, ContainingType);
2271 llvm::DIType *CGDebugInfo::CreateMemberType(llvm::DIFile *Unit,
QualType FType,
2272 StringRef Name, uint64_t *
Offset) {
2273 llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
2274 uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
2275 unsigned FieldAlign = CGM.getContext().getTypeAlign(FType);
2276 llvm::DIType *Ty = DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize,
2277 FieldAlign, *Offset, 0, FieldTy);
2278 *Offset += FieldSize;
2282 void CGDebugInfo::collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
2284 StringRef &LinkageName,
2285 llvm::DIScope *&FDContext,
2286 llvm::DINodeArray &TParamsArray,
2292 LinkageName = CGM.getMangledName(GD);
2293 Flags |= llvm::DINode::FlagPrototyped;
2298 if (LinkageName == Name ||
2299 (!CGM.getCodeGenOpts().EmitGcovArcs &&
2300 !CGM.getCodeGenOpts().EmitGcovNotes &&
2302 LinkageName = StringRef();
2307 FDContext = getOrCreateNameSpace(NSDecl);
2310 FDContext = getContextDescriptor(cast<Decl>(RDecl));
2312 TParamsArray = CollectFunctionTemplateParams(FD, Unit);
2316 void CGDebugInfo::collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
2318 StringRef &Name, StringRef &LinkageName,
2319 llvm::DIScope *&VDContext) {
2326 if (T->isIncompleteArrayType()) {
2328 llvm::APInt ConstVal(32, 1);
2329 QualType ET = CGM.getContext().getAsArrayType(T)->getElementType();
2331 T = CGM.getContext().getConstantArrayType(ET, ConstVal,
2338 LinkageName = CGM.getMangledName(VD);
2339 if (LinkageName == Name)
2340 LinkageName = StringRef();
2357 DC = CGM.getContext().getTranslationUnitDecl();
2358 VDContext = getContextDescriptor(dyn_cast<Decl>(DC));
2361 llvm::DISubprogram *
2362 CGDebugInfo::getFunctionForwardDeclaration(
const FunctionDecl *FD) {
2363 llvm::DINodeArray TParamsArray;
2364 StringRef Name, LinkageName;
2367 llvm::DIFile *Unit = getOrCreateFile(Loc);
2368 llvm::DIScope *DContext = Unit;
2369 unsigned Line = getLineNumber(Loc);
2371 collectFunctionDeclProps(FD, Unit, Name, LinkageName, DContext,
2372 TParamsArray, Flags);
2376 ArgTypes.push_back(Parm->getType());
2378 CGM.getContext().getFunctionType(FD->
getReturnType(), ArgTypes,
2380 llvm::DISubprogram *SP = DBuilder.createTempFunctionFwdDecl(
2381 DContext, Name, LinkageName, Unit, Line,
2383 false , 0, Flags, CGM.getLangOpts().Optimize,
nullptr,
2384 TParamsArray.get(), getFunctionDeclaration(FD));
2386 FwdDeclReplaceMap.emplace_back(std::piecewise_construct,
2387 std::make_tuple(CanonDecl),
2388 std::make_tuple(SP));
2392 llvm::DIGlobalVariable *
2393 CGDebugInfo::getGlobalVariableForwardDeclaration(
const VarDecl *VD) {
2395 StringRef Name, LinkageName;
2397 llvm::DIFile *Unit = getOrCreateFile(Loc);
2398 llvm::DIScope *DContext = Unit;
2399 unsigned Line = getLineNumber(Loc);
2401 collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, DContext);
2402 auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
2403 DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
2405 FwdDeclReplaceMap.emplace_back(
2406 std::piecewise_construct,
2408 std::make_tuple(static_cast<llvm::Metadata *>(GV)));
2412 llvm::DINode *CGDebugInfo::getDeclarationOrDefinition(
const Decl *D) {
2417 if (
const TypeDecl *TD = dyn_cast<TypeDecl>(D))
2418 return getOrCreateType(CGM.getContext().getTypeDeclType(TD),
2419 getOrCreateFile(TD->getLocation()));
2422 if (I != DeclCache.end())
2423 return dyn_cast_or_null<llvm::DINode>(I->second);
2427 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
2428 return getFunctionForwardDeclaration(FD);
2429 else if (
const auto *VD = dyn_cast<VarDecl>(D))
2430 return getGlobalVariableForwardDeclaration(VD);
2435 llvm::DISubprogram *CGDebugInfo::getFunctionDeclaration(
const Decl *D) {
2447 if (MI == SPCache.end()) {
2450 return CreateCXXMemberFunction(MD, getOrCreateFile(MD->
getLocation()),
2451 cast<llvm::DICompositeType>(S));
2454 if (MI != SPCache.end()) {
2455 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
2456 if (SP && !SP->isDefinition())
2460 for (
auto NextFD : FD->
redecls()) {
2461 auto MI = SPCache.find(NextFD->getCanonicalDecl());
2462 if (MI != SPCache.end()) {
2463 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
2464 if (SP && !SP->isDefinition())
2473 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(
const Decl *D,
2479 return DBuilder.createSubroutineType(F,
2480 DBuilder.getOrCreateTypeArray(None));
2482 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
2483 return getOrCreateMethodType(Method, F);
2484 if (
const ObjCMethodDecl *OMethod = dyn_cast<ObjCMethodDecl>(D)) {
2489 QualType ResultTy = OMethod->getReturnType();
2492 if (ResultTy == CGM.getContext().getObjCInstanceType())
2493 ResultTy = CGM.getContext().getPointerType(
2494 QualType(OMethod->getClassInterface()->getTypeForDecl(), 0));
2496 Elts.push_back(getOrCreateType(ResultTy, F));
2498 QualType SelfDeclTy = OMethod->getSelfDecl()->getType();
2499 Elts.push_back(CreateSelfType(SelfDeclTy, getOrCreateType(SelfDeclTy, F)));
2501 Elts.push_back(DBuilder.createArtificialType(
2502 getOrCreateType(OMethod->getCmdDecl()->getType(), F)));
2504 for (
const auto *PI : OMethod->params())
2505 Elts.push_back(getOrCreateType(PI->getType(), F));
2507 if (OMethod->isVariadic())
2508 Elts.push_back(DBuilder.createUnspecifiedParameter());
2510 llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
2511 return DBuilder.createSubroutineType(F, EltTypeArray);
2516 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
2521 for (
unsigned i = 0, e = FPT->
getNumParams(); i != e; ++i)
2522 EltTys.push_back(getOrCreateType(FPT->
getParamType(i), F));
2523 EltTys.push_back(DBuilder.createUnspecifiedParameter());
2524 llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
2525 return DBuilder.createSubroutineType(F, EltTypeArray);
2528 return cast<llvm::DISubroutineType>(getOrCreateType(FnType, F));
2536 StringRef LinkageName;
2538 FnBeginRegionCount.push_back(LexicalBlockStack.size());
2541 bool HasDecl = (D !=
nullptr);
2544 llvm::DIFile *Unit = getOrCreateFile(Loc);
2545 llvm::DIScope *FDContext = Unit;
2546 llvm::DINodeArray TParamsArray;
2549 LinkageName = Fn->getName();
2550 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2553 if (FI != SPCache.end()) {
2554 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
2555 if (SP && SP->isDefinition()) {
2556 LexicalBlockStack.emplace_back(SP);
2557 RegionMap[D].reset(SP);
2561 collectFunctionDeclProps(GD, Unit, Name, LinkageName, FDContext,
2562 TParamsArray, Flags);
2563 }
else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)) {
2564 Name = getObjCMethodName(OMD);
2565 Flags |= llvm::DINode::FlagPrototyped;
2568 Name = Fn->getName();
2569 Flags |= llvm::DINode::FlagPrototyped;
2571 if (!Name.empty() && Name[0] ==
'\01')
2572 Name = Name.substr(1);
2575 Flags |= llvm::DINode::FlagArtificial;
2580 unsigned LineNo = getLineNumber(Loc);
2581 unsigned ScopeLine = getLineNumber(ScopeLoc);
2588 llvm::DISubprogram *SP = DBuilder.createFunction(
2589 FDContext, Name, LinkageName, Unit, LineNo,
2590 getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),
2591 true , ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn,
2592 TParamsArray.get(), getFunctionDeclaration(D));
2596 if (HasDecl && isa<FunctionDecl>(D))
2600 LexicalBlockStack.emplace_back(SP);
2603 RegionMap[D].reset(SP);
2610 if (CurLoc.isInvalid() || CurLoc.isMacroID())
2613 llvm::MDNode *
Scope = LexicalBlockStack.back();
2614 Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
2615 getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope));
2619 llvm::MDNode *Back =
nullptr;
2620 if (!LexicalBlockStack.empty())
2621 Back = LexicalBlockStack.back().get();
2622 LexicalBlockStack.emplace_back(DBuilder.createLexicalBlock(
2623 cast<llvm::DIScope>(Back), getOrCreateFile(CurLoc), getLineNumber(CurLoc),
2624 getColumnNumber(CurLoc)));
2633 Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
2634 getLineNumber(Loc), getColumnNumber(Loc), LexicalBlockStack.back()));
2640 CreateLexicalBlock(Loc);
2645 assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
2653 LexicalBlockStack.pop_back();
2657 assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
2658 unsigned RCount = FnBeginRegionCount.back();
2659 assert(RCount <= LexicalBlockStack.size() &&
"Region stack mismatch");
2662 while (LexicalBlockStack.size() != RCount) {
2665 LexicalBlockStack.pop_back();
2667 FnBeginRegionCount.pop_back();
2670 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
2671 uint64_t *XOffset) {
2675 uint64_t FieldSize, FieldOffset;
2676 unsigned FieldAlign;
2678 llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
2682 FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
2683 EltTys.push_back(CreateMemberType(Unit, FType,
"__isa", &FieldOffset));
2684 EltTys.push_back(CreateMemberType(Unit, FType,
"__forwarding", &FieldOffset));
2685 FType = CGM.getContext().IntTy;
2686 EltTys.push_back(CreateMemberType(Unit, FType,
"__flags", &FieldOffset));
2687 EltTys.push_back(CreateMemberType(Unit, FType,
"__size", &FieldOffset));
2689 bool HasCopyAndDispose = CGM.getContext().BlockRequiresCopying(Type, VD);
2690 if (HasCopyAndDispose) {
2691 FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
2693 CreateMemberType(Unit, FType,
"__copy_helper", &FieldOffset));
2695 CreateMemberType(Unit, FType,
"__destroy_helper", &FieldOffset));
2697 bool HasByrefExtendedLayout;
2699 if (CGM.getContext().getByrefLifetime(Type, Lifetime,
2700 HasByrefExtendedLayout) &&
2701 HasByrefExtendedLayout) {
2702 FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
2704 CreateMemberType(Unit, FType,
"__byref_variable_layout", &FieldOffset));
2707 CharUnits Align = CGM.getContext().getDeclAlign(VD);
2708 if (Align > CGM.getContext().toCharUnitsFromBits(
2709 CGM.getTarget().getPointerAlign(0))) {
2711 CGM.getContext().toCharUnitsFromBits(FieldOffset);
2714 CharUnits NumPaddingBytes = AlignedOffsetInBytes - FieldOffsetInBytes;
2717 llvm::APInt pad(32, NumPaddingBytes.
getQuantity());
2718 FType = CGM.getContext().getConstantArrayType(CGM.getContext().CharTy,
2720 EltTys.push_back(CreateMemberType(Unit, FType,
"", &FieldOffset));
2725 llvm::DIType *FieldTy = getOrCreateType(FType, Unit);
2726 FieldSize = CGM.getContext().getTypeSize(FType);
2727 FieldAlign = CGM.getContext().toBits(Align);
2729 *XOffset = FieldOffset;
2730 FieldTy = DBuilder.createMemberType(Unit, VD->
getName(), Unit, 0, FieldSize,
2731 FieldAlign, FieldOffset, 0, FieldTy);
2732 EltTys.push_back(FieldTy);
2733 FieldOffset += FieldSize;
2735 llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
2737 unsigned Flags = llvm::DINode::FlagBlockByrefStruct;
2739 return DBuilder.createStructType(Unit,
"", Unit, 0, FieldOffset, 0, Flags,
2743 void CGDebugInfo::EmitDeclare(
const VarDecl *VD, llvm::dwarf::Tag Tag,
2747 assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
2752 llvm::DIFile *Unit =
nullptr;
2756 uint64_t XOffset = 0;
2757 if (VD->
hasAttr<BlocksAttr>())
2758 Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset);
2760 Ty = getOrCreateType(VD->
getType(), Unit);
2777 Flags |= llvm::DINode::FlagArtificial;
2783 if (isa<ImplicitParamDecl>(VD) && ArgNo == 1)
2784 Flags |= llvm::DINode::FlagObjectPointer;
2785 if (llvm::Argument *Arg = dyn_cast<llvm::Argument>(Storage))
2786 if (Arg->getType()->isPointerTy() && !Arg->hasByValAttr() &&
2788 Expr.push_back(llvm::dwarf::DW_OP_deref);
2790 auto *
Scope = cast<llvm::DIScope>(LexicalBlockStack.back());
2792 StringRef Name = VD->
getName();
2793 if (!Name.empty()) {
2794 if (VD->
hasAttr<BlocksAttr>()) {
2796 Expr.push_back(llvm::dwarf::DW_OP_plus);
2798 offset = CGM.getContext().toCharUnitsFromBits(
2799 CGM.getTarget().getPointerWidth(0));
2801 Expr.push_back(llvm::dwarf::DW_OP_deref);
2802 Expr.push_back(llvm::dwarf::DW_OP_plus);
2804 offset = CGM.getContext().toCharUnitsFromBits(XOffset);
2808 auto *D = DBuilder.createLocalVariable(Tag,
Scope, VD->
getName(), Unit,
2812 DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
2813 llvm::DebugLoc::get(Line, Column,
Scope),
2814 Builder.GetInsertBlock());
2816 }
else if (isa<VariableArrayType>(VD->
getType()))
2817 Expr.push_back(llvm::dwarf::DW_OP_deref);
2821 const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
2830 for (
const auto *Field : RD->
fields()) {
2831 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
2832 StringRef FieldName = Field->
getName();
2835 if (FieldName.empty() && !isa<RecordType>(Field->getType()))
2839 auto *D = DBuilder.createLocalVariable(
2840 Tag,
Scope, FieldName, Unit, Line, FieldTy,
2841 CGM.getLangOpts().Optimize, Flags | llvm::DINode::FlagArtificial,
2845 DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
2846 llvm::DebugLoc::get(Line, Column,
Scope),
2847 Builder.GetInsertBlock());
2854 DBuilder.createLocalVariable(Tag,
Scope, Name, Unit, Line, Ty,
2855 CGM.getLangOpts().Optimize, Flags, ArgNo);
2858 DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
2859 llvm::DebugLoc::get(Line, Column,
Scope),
2860 Builder.GetInsertBlock());
2863 void CGDebugInfo::EmitDeclareOfAutoVariable(
const VarDecl *VD,
2867 EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, 0, Builder);
2870 llvm::DIType *CGDebugInfo::CreateSelfType(
const QualType &QualTy,
2872 llvm::DIType *CachedTy = getTypeOrNull(QualTy);
2875 return DBuilder.createObjectPointerType(Ty);
2878 void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
2880 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint) {
2882 assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
2884 if (Builder.GetInsertBlock() ==
nullptr)
2887 bool isByRef = VD->
hasAttr<BlocksAttr>();
2889 uint64_t XOffset = 0;
2890 llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
2893 Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset);
2895 Ty = getOrCreateType(VD->
getType(), Unit);
2899 if (isa<ImplicitParamDecl>(VD) && VD->
getName() ==
"self")
2900 Ty = CreateSelfType(VD->
getType(), Ty);
2904 unsigned Column = getColumnNumber(VD->
getLocation());
2906 const llvm::DataLayout &target = CGM.getDataLayout();
2913 if (isa<llvm::AllocaInst>(Storage))
2914 addr.push_back(llvm::dwarf::DW_OP_deref);
2915 addr.push_back(llvm::dwarf::DW_OP_plus);
2918 addr.push_back(llvm::dwarf::DW_OP_deref);
2919 addr.push_back(llvm::dwarf::DW_OP_plus);
2922 CGM.getContext().toCharUnitsFromBits(target.getPointerSizeInBits(0));
2924 addr.push_back(llvm::dwarf::DW_OP_deref);
2925 addr.push_back(llvm::dwarf::DW_OP_plus);
2927 offset = CGM.getContext().toCharUnitsFromBits(XOffset);
2932 auto *D = DBuilder.createLocalVariable(
2933 llvm::dwarf::DW_TAG_auto_variable,
2934 cast<llvm::DILocalScope>(LexicalBlockStack.back()), VD->
getName(), Unit,
2938 auto DL = llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back());
2940 DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), DL,
2943 DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), DL,
2944 Builder.GetInsertBlock());
2951 EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, ArgNo, Builder);
2955 struct BlockLayoutChunk {
2956 uint64_t OffsetInBits;
2959 bool operator<(
const BlockLayoutChunk &l,
const BlockLayoutChunk &r) {
2960 return l.OffsetInBits < r.OffsetInBits;
2964 void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(
const CGBlockInfo &block,
2975 llvm::DIFile *tunit = getOrCreateFile(loc);
2976 unsigned line = getLineNumber(loc);
2977 unsigned column = getColumnNumber(loc);
2982 const llvm::StructLayout *blockLayout =
2987 blockLayout->getElementOffsetInBits(0),
2989 fields.push_back(createFieldType(
"__flags", C.
IntTy, 0, loc,
AS_public,
2990 blockLayout->getElementOffsetInBits(1),
2992 fields.push_back(createFieldType(
"__reserved", C.
IntTy, 0, loc,
AS_public,
2993 blockLayout->getElementOffsetInBits(2),
2996 auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar());
2997 fields.push_back(createFieldType(
"__FuncPtr", FnPtrType, 0, loc,
AS_public,
2998 blockLayout->getElementOffsetInBits(3),
3000 fields.push_back(createFieldType(
3004 0, loc,
AS_public, blockLayout->getElementOffsetInBits(4), tunit, tunit));
3012 BlockLayoutChunk chunk;
3013 chunk.OffsetInBits =
3014 blockLayout->getElementOffsetInBits(block.
CXXThisIndex);
3015 chunk.Capture =
nullptr;
3016 chunks.push_back(chunk);
3020 for (
const auto &capture : blockDecl->
captures()) {
3021 const VarDecl *variable = capture.getVariable();
3028 BlockLayoutChunk chunk;
3029 chunk.OffsetInBits =
3030 blockLayout->getElementOffsetInBits(captureInfo.
getIndex());
3031 chunk.Capture = &capture;
3032 chunks.push_back(chunk);
3036 llvm::array_pod_sort(chunks.begin(), chunks.end());
3041 uint64_t offsetInBits = i->OffsetInBits;
3050 fields.push_back(createFieldType(
"this", type, 0, loc,
AS_public,
3051 offsetInBits, tunit, tunit));
3056 StringRef name = variable->
getName();
3058 llvm::DIType *fieldType;
3064 fieldType = EmitTypeForVarWithBlocksAttr(variable, &xoffset);
3065 fieldType = DBuilder.createPointerType(fieldType, PtrInfo.
Width);
3067 DBuilder.createMemberType(tunit, name, tunit, line, PtrInfo.
Width,
3068 PtrInfo.
Align, offsetInBits, 0, fieldType);
3071 offsetInBits, tunit, tunit);
3073 fields.push_back(fieldType);
3077 llvm::raw_svector_ostream(typeName) <<
"__block_literal_"
3078 << CGM.getUniqueBlockCount();
3080 llvm::DINodeArray fieldsArray = DBuilder.getOrCreateArray(fields);
3082 llvm::DIType *type = DBuilder.createStructType(
3083 tunit, typeName.str(), tunit, line,
3084 CGM.getContext().toBits(block.
BlockSize),
3085 CGM.getContext().toBits(block.
BlockAlign), 0,
nullptr, fieldsArray);
3086 type = DBuilder.createPointerType(type, CGM.PointerWidthInBits);
3089 unsigned flags = llvm::DINode::FlagArtificial;
3090 auto *scope = cast<llvm::DILocalScope>(LexicalBlockStack.back());
3093 auto *debugVar = DBuilder.createLocalVariable(
3094 llvm::dwarf::DW_TAG_arg_variable, scope, Arg->getName(), tunit, line,
3095 type, CGM.getLangOpts().Optimize, flags, ArgNo);
3099 DBuilder.insertDbgValueIntrinsic(
3100 LocalAddr, 0, debugVar, DBuilder.createExpression(),
3101 llvm::DebugLoc::get(line, column, scope), Builder.GetInsertBlock());
3105 DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
3106 llvm::DebugLoc::get(line, column, scope),
3107 Builder.GetInsertBlock());
3110 llvm::DIDerivedType *
3111 CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D) {
3116 if (MI != StaticDataMemberCache.end()) {
3117 assert(MI->second &&
"Static data member declaration should still exist");
3118 return cast<llvm::DIDerivedType>(MI->second);
3125 cast<llvm::DICompositeType>(getContextDescriptor(cast<Decl>(DC)));
3126 return CreateRecordStaticField(D, Ctxt, cast<RecordDecl>(DC));
3129 llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
3130 const RecordDecl *RD, llvm::DIFile *Unit,
unsigned LineNo,
3131 StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
3132 llvm::DIGlobalVariable *GV =
nullptr;
3134 for (
const auto *Field : RD->
fields()) {
3135 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
3136 StringRef FieldName = Field->getName();
3139 if (FieldName.empty()) {
3142 GV = CollectAnonRecordDecls(RT->
getDecl(), Unit, LineNo, LinkageName,
3147 GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
3149 Var->hasInternalLinkage(), Var,
nullptr);
3154 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
3158 llvm::DIFile *Unit =
nullptr;
3159 llvm::DIScope *DContext =
nullptr;
3161 StringRef DeclName, LinkageName;
3163 collectVarDeclProps(D, Unit, LineNo, T, DeclName, LinkageName, DContext);
3167 llvm::DIGlobalVariable *GV =
nullptr;
3173 const RecordDecl *RD = cast<RecordType>(T)->getDecl();
3175 "unnamed non-anonymous struct or union?");
3176 GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);
3178 GV = DBuilder.createGlobalVariable(
3179 DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
3180 Var->hasInternalLinkage(), Var,
3181 getOrCreateStaticDataMemberDeclarationOrNull(D));
3187 llvm::Constant *Init) {
3190 llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
3191 StringRef Name = VD->
getName();
3192 llvm::DIType *Ty = getOrCreateType(VD->
getType(), Unit);
3194 const EnumDecl *ED = cast<EnumDecl>(ECD->getDeclContext());
3195 assert(isa<EnumType>(ED->
getTypeForDecl()) &&
"Enum without EnumType?");
3201 if (Ty->getTag() == llvm::dwarf::DW_TAG_enumeration_type)
3207 auto *VarD = cast<VarDecl>(VD);
3208 if (VarD->isStaticDataMember()) {
3209 auto *RD = cast<RecordDecl>(VarD->getDeclContext());
3210 getContextDescriptor(RD);
3212 RetainedTypes.push_back(
3213 CGM.getContext().getRecordType(RD).getAsOpaquePtr());
3217 llvm::DIScope *DContext =
3220 auto &GV = DeclCache[VD];
3223 GV.reset(DBuilder.createGlobalVariable(
3224 DContext, Name, StringRef(), Unit, getLineNumber(VD->
getLocation()), Ty,
3225 true, Init, getOrCreateStaticDataMemberDeclarationOrNull(VarD)));
3228 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(
const Decl *D) {
3229 if (!LexicalBlockStack.empty())
3230 return LexicalBlockStack.back();
3231 return getContextDescriptor(D);
3237 DBuilder.createImportedModule(
3247 "We shouldn't be codegening an invalid UsingDecl containing no decls");
3251 if (llvm::DINode *Target =
3252 getDeclarationOrDefinition(USD.getUnderlyingDecl()))
3253 DBuilder.createImportedDeclaration(
3254 getCurrentContextDescriptor(cast<Decl>(USD.getDeclContext())), Target,
3255 getLineNumber(USD.getLocation()));
3259 auto *Reader = CGM.getContext().getExternalSource();
3261 DBuilder.createImportedDeclaration(
3263 getOrCreateModuleRef(Info),
3267 llvm::DIImportedEntity *
3271 auto &VH = NamespaceAliasCache[&NA];
3273 return cast<llvm::DIImportedEntity>(VH);
3274 llvm::DIImportedEntity *R;
3278 R = DBuilder.createImportedDeclaration(
3280 EmitNamespaceAlias(*Underlying), getLineNumber(NA.
getLocation()),
3283 R = DBuilder.createImportedDeclaration(
3292 CGDebugInfo::getOrCreateNameSpace(
const NamespaceDecl *NSDecl) {
3294 auto I = NameSpaceCache.find(NSDecl);
3295 if (I != NameSpaceCache.end())
3296 return cast<llvm::DINamespace>(I->second);
3298 unsigned LineNo = getLineNumber(NSDecl->
getLocation());
3299 llvm::DIFile *FileD = getOrCreateFile(NSDecl->
getLocation());
3300 llvm::DIScope *Context =
3302 llvm::DINamespace *NS =
3303 DBuilder.createNameSpace(Context, NSDecl->
getName(), FileD, LineNo);
3304 NameSpaceCache[NSDecl].reset(NS);
3308 void CGDebugInfo::finalize() {
3311 for (
size_t i = 0; i != ObjCInterfaceCache.size(); ++i) {
3312 ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i];
3313 llvm::DIType *Ty = E.Type->getDecl()->getDefinition()
3314 ? CreateTypeDefinition(E.Type, E.Unit)
3316 DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
3319 for (
auto p : ReplaceMap) {
3321 auto *Ty = cast<llvm::DIType>(
p.second);
3322 assert(Ty->isForwardDecl());
3324 auto it = TypeCache.find(
p.first);
3325 assert(it != TypeCache.end());
3328 DBuilder.replaceTemporary(llvm::TempDIType(Ty),
3329 cast<llvm::DIType>(it->second));
3332 for (
const auto &
p : FwdDeclReplaceMap) {
3334 llvm::TempMDNode FwdDecl(cast<llvm::MDNode>(
p.second));
3335 llvm::Metadata *Repl;
3337 auto it = DeclCache.find(
p.first);
3341 if (it == DeclCache.end())
3346 DBuilder.replaceTemporary(std::move(FwdDecl), cast<llvm::MDNode>(Repl));
3351 for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),
3352 RE = RetainedTypes.end(); RI != RE; ++RI)
3353 DBuilder.retainType(cast<llvm::DIType>(TypeCache[*RI]));
3355 DBuilder.finalize();
3362 if (
auto *DieTy = getOrCreateType(Ty, getOrCreateMainFile()))
3364 DBuilder.retainType(DieTy);
unsigned getNumElements() const
ArrayRef< ParmVarDecl * > parameters() const
Defines the clang::ASTContext interface.
bool isObjCOneArgSelector() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
ObjCInterfaceDecl * getDecl() const
getDecl - Get the declaration of this interface.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool SuppressNNS=false) const
Print the template name.
static bool hasDefaultSetterName(const ObjCPropertyDecl *PD, const ObjCMethodDecl *Setter)
StringRef getName() const
Smart pointer class that efficiently represents Objective-C method names.
std::string DwarfDebugFlags
void EmitLocation(raw_ostream &o, const SourceManager &SM, SourceLocation L, const FIDMap &FM, unsigned indent)
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
static unsigned getAccessFlag(AccessSpecifier Access, const RecordDecl *RD)
unsigned getColumn() const
Return the presumed column number of this location.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isBitField() const
Determines whether this field is a bitfield.
Defines the clang::FileManager interface and associated types.
llvm::LLVMContext & getLLVMContext()
IdentifierInfo * getIdentifier() const
std::string getClangFullVersion()
Retrieves a string representing the complete clang version, which includes the clang version number...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
llvm::DIType * getOrCreateRecordType(QualType Ty, SourceLocation L)
Emit record type's standalone debug info.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Defines the SourceManager interface.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isRecordType() const
QualType getUnderlyingType() const
capture_const_iterator captures_begin() const
Defines the C++ template declaration subclasses.
method_iterator method_begin() const
Method begin iterator. Iterates in the order the methods were declared.
static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C)
TypePropertyCache< Private > Cache
bool hasDefinition() const
static bool hasDefaultGetterName(const ObjCPropertyDecl *PD, const ObjCMethodDecl *Getter)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
QualType getPointeeType() const
QualType getRecordType(const RecordDecl *Decl) const
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
bool isPrimaryBaseVirtual() const
NamedDecl * getParam(unsigned Idx)
const PreprocessorOptions & getPreprocessorOpts() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
RefQualifierKind RefQualifier
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Describes the capture of a variable or of this, or of a C++1y init-capture.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
void * getAsOpaquePtr() const
void removeObjCLifetime()
bool capturesCXXThis() const
Represents an empty template argument, e.g., one that has not been deduced.
ExtProtoInfo - Extra information about a function prototype.
AccessSpecifier getAccess() const
field_iterator field_begin() const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr)
NamespaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this namespace.
std::string SplitDwarfFile
Stores a list of template parameters for a TemplateDecl and its derived classes.
bool isMemberDataPointerType() const
Describes how types, statements, expressions, and declarations should be printed. ...
ParmVarDecl - Represents a parameter to a function.
unsigned getNumArgs() const
Retrieve the number of template arguments.
static llvm::dwarf::Tag getTagForRecord(const RecordDecl *RD)
unsigned getNumParams() const
Represents a class template specialization, which refers to a class template with a given set of temp...
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
CGDebugInfo * getDebugInfo()
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static bool isFunctionLocalClass(const CXXRecordDecl *RD)
QualType getReturnType() const
bool isCompleteDefinition() const
Don't generate debug info.
QualType getBlockDescriptorType() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const CXXRecordDecl * getPointeeCXXRecordDecl() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
void completeClassData(const RecordDecl *RD)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const Decl * getDecl() const
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
const Capture & getCapture(const VarDecl *var) const
Represents a C++ using-declaration.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
static SmallString< 64 > constructSetterName(StringRef Name)
Return the default setter name for the given identifier.
An lvalue ref-qualifier was provided (&).
QualType getBaseType() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
QualType getReturnType() const
const CXXRecordDecl * getParent() const
shadow_iterator shadow_begin() const
field_range fields() const
RecordDecl * getDecl() const
static bool hasCXXMangling(const TagDecl *TD, llvm::DICompileUnit *TheCU)
std::string getNameAsString() const
bool isVariadic() const
Whether this function is variadic.
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
llvm::DIType * getOrCreateInterfaceType(QualType Ty, SourceLocation Loc)
Emit an Objective-C interface type standalone debug info.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
uint64_t getFieldOffset(unsigned FieldNo) const
TypeClass getTypeClass() const
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
DeclContext * getLexicalDeclContext()
unsigned getLine() const
Return the presumed line number of this location.
Represents an ObjC class declaration.
uint64_t getMethodVTableIndex(GlobalDecl GD)
Locate a virtual function in the vtable.
QualType getAliasedType() const
CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, const CXXRecordDecl *VBase)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool NeedsCopyDispose
True if the block needs a custom copy or dispose function.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
EnumDecl * getDecl() const
QualType getValueType() const
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
QualType getParamType(unsigned i) const
CGBlockInfo - Information to generate a block literal.
const TargetInfo & getTarget() const
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
ID
Defines the set of possible language-specific address spaces.
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
QualType getPointeeType() const
unsigned getIndex() const
QualType getBlockDescriptorExtendedType() const
StringRef getName() const
Return the actual identifier string.
CGCXXABI & getCXXABI() const
VarDecl * getVariable() const
The variable being captured.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Defines version macros and version-related utility functions for Clang.
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
DeclContext * getDeclContext()
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
ASTContext & getContext() const
SourceLocation getLocation() const
Retrieve the source location of the capture.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
MicrosoftVTableContext & getMicrosoftVTableContext()
ImplicitParamDecl * getSelfDecl() const
QualType getDesugaredType(const ASTContext &Context) const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine()) const
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)
Create a member pointer for the given method.
bool isObjCQualifiedIdType() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Represents an unpacked "presumed" location which can be presented to the user.
bool isExternallyVisible() const
DeclarationName getDeclName() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
QualType getElementType() const
Represents a C++ conversion function within a class.
bool isComplexIntegerType() const
RecordDecl * getDefinition() const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderTy
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const clang::PrintingPolicy & getPrintingPolicy() const
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
unsigned getVBTableIndex(const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the index of VBase in the vbtable of Derived. VBase must be a morally virtual base of Derived...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
virtual void mangleCXXRTTIName(QualType T, raw_ostream &)=0
const char * getFilename() const
Return the presumed filename of this location.
llvm::Constant * EmitConstantExpr(const Expr *E, QualType DestType, CodeGenFunction *CGF=nullptr)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
enumerator_range enumerators() const
const Type * getTypePtr() const
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getBitWidthValue(const ASTContext &Ctx) const
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
llvm::StructType * StructureType
void completeRequiredType(const RecordDecl *RD)
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
static QualType getUnderlyingType(const SubRegion *R)
Cached information about one file (either on disk or in the virtual file system). ...
void printName(raw_ostream &os) const
Represents a static or instance method of a struct/union/class.
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
const CodeGenOptions & getCodeGenOpts() const
const LangOptions & getLangOpts() const
Represents one property declaration in an Objective-C interface.
std::string getAsString() const
Derive the full selector name (e.g. "foo:bar:") and return it as an std::string.
TypedefNameDecl * getDecl() const
MangleContext & getMangleContext()
Gets the mangle context.
FileID getMainFileID() const
Returns the FileID of the main source file.
bool operator<(DeclarationName LHS, DeclarationName RHS)
method_iterator method_end() const
Method past-the-end iterator.
ItaniumVTableContext & getItaniumVTableContext()
unsigned CXXThisIndex
The field index of 'this' within the block, if there is one.
An rvalue ref-qualifier was provided (&&).
virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)
Create a null member pointer of the given type.
static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I, CXXRecordDecl::method_iterator End)
static std::string getFunctionName(const Decl *D)
bool isDynamicClass() const
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceLocation getExprLoc() const LLVM_READONLY
QualType getPointeeType() const
ObjCIvarDecl * getNextIvar()
bool isAnonymousStructOrUnion() const
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Selector getObjCSelector() const
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
A qualifier set is used to build a set of qualifiers.
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=0, bool ForVTable=false, bool DontDefer=false)
prop_range properties() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static __inline__ uint32_t volatile uint32_t * p
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
QualType getEnumType(const EnumDecl *Decl) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const Type * strip(QualType type)
Decl * getNonClosureContext()
CGDebugInfo(CodeGenModule &CGM)
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
Selector getSelector() const
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
bool isLambda() const
Determine whether this class describes a lambda function object.
QualType getPointeeType() const
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
SourceLocation getCaretLocation() const
unsigned getTypeQuals() const
CanQualType UnsignedLongTy
QualType getIntegralType() const
Retrieve the type of the integral value.
void completeType(const EnumDecl *ED)
QualType getIntegerType() const
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
StringRef getMangledName(GlobalDecl GD)
The template argument is a type.
ObjCImplementationDecl * getImplementation() const
bool isStaticDataMember() const
Determines whether this is a static data member.
bool isObjCZeroArgSelector() const
QualType getPointeeType() const
SourceManager & getSourceManager()
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
std::string getQualifiedNameAsString() const
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
const Type * getClass() const
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
const BlockDecl * getBlockDecl() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
QualType getParamTypeForDecl() const
capture_const_iterator captures_end() const
ObjCInterfaceDecl * getSuperClass() const
void setLocation(SourceLocation Loc)
TagDecl * getDecl() const
bool isIncompleteArrayType() const
unsigned getTargetAddressSpace(QualType T) const
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getElementType() const
bool capturesThis() const
Determine whether this capture handles the C++ this pointer.
static void PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
const BlockExpr * getBlockExpr() const
SourceLocation getLocation() const
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ObjCIvarDecl * all_declared_ivar_begin()
static SmallString< 256 > getUniqueTagTypeName(const TagType *Ty, CodeGenModule &CGM, llvm::DICompileUnit *TheCU)
StringRef getName(const PrintingPolicy &Policy) const
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
EnumDecl * getDefinition() const
Represents a C++ namespace alias.
Represents C++ using-directive.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind, const RecordDecl *RD, const LangOptions &LangOpts)
CharUnits RoundUpToAlignment(const CharUnits &Align) const
void removeAddressSpace()
This class handles loading and caching of source files into memory.
Holds everything needed to generate debug info for an imported module or precompiled header file...
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool capturesVariable() const
Determine whether this capture handles a variable.
bool isPointerType() const
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.