;
61 if(TI.isAlignRequired())
89llvm::dyn_cast_or_null<DeclRefExpr>(
Init->IgnoreUnlessSpelledInSource());
93 returnllvm::dyn_cast_or_null<DecompositionDecl>(RefExpr->getDecl());
111: CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
112DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
113DBuilder(CGM.getModule()) {
118assert(LexicalBlockStack.empty() &&
119 "Region stack mismatch, stack not empty!");
125init(TemporaryLocation);
132init(TemporaryLocation, DefaultToEmpty);
136 boolDefaultToEmpty) {
143OriginalLocation = CGF->
Builder.getCurrentDebugLocation();
145 if(OriginalLocation && !DI->CGM.getExpressionLocationsEnabled())
148 if(TemporaryLocation.
isValid()) {
149DI->EmitLocation(CGF->
Builder, TemporaryLocation);
153 if(DefaultToEmpty) {
154CGF->
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
159assert(!DI->LexicalBlockStack.empty());
160CGF->
Builder.SetCurrentDebugLocation(
161llvm::DILocation::get(DI->LexicalBlockStack.back()->getContext(), 0, 0,
162DI->LexicalBlockStack.back(), DI->getInlinedAt()));
173this->CGF =
nullptr;
176OriginalLocation = CGF.
Builder.getCurrentDebugLocation();
178CGF.
Builder.SetCurrentDebugLocation(std::move(
Loc));
185CGF->
Builder.SetCurrentDebugLocation(std::move(OriginalLocation));
192this->CGF =
nullptr;
196SavedLocation = DI.getLocation();
197assert((DI.getInlinedAt() ==
198CGF.
Builder.getCurrentDebugLocation()->getInlinedAt()) &&
199 "CGDebugInfo and IRBuilder are out of sync");
201DI.EmitInlineFunctionStart(CGF.
Builder, InlinedFn);
209DI.EmitLocation(CGF->
Builder, SavedLocation);
222 if(LexicalBlockStack.empty())
226 auto*
Scope= cast<llvm::DIScope>(LexicalBlockStack.back());
228 if(PCLoc.
isInvalid() ||
Scope->getFile() == getOrCreateFile(CurLoc))
231 if(
auto*LBF = dyn_cast<llvm::DILexicalBlockFile>(
Scope)) {
232LexicalBlockStack.pop_back();
233LexicalBlockStack.emplace_back(DBuilder.createLexicalBlockFile(
234LBF->getScope(), getOrCreateFile(CurLoc)));
235}
else if(isa<llvm::DILexicalBlock>(
Scope) ||
236isa<llvm::DISubprogram>(
Scope)) {
237LexicalBlockStack.pop_back();
238LexicalBlockStack.emplace_back(
239DBuilder.createLexicalBlockFile(
Scope, getOrCreateFile(CurLoc)));
243llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(
const Decl*
D) {
244llvm::DIScope *Mod = getParentModuleOrNull(
D);
249llvm::DIScope *CGDebugInfo::getContextDescriptor(
const Decl*Context,
254 autoI = RegionMap.find(Context);
255 if(I != RegionMap.end()) {
256llvm::Metadata *
V= I->second;
257 returndyn_cast_or_null<llvm::DIScope>(
V);
261 if(
const auto*NSDecl = dyn_cast<NamespaceDecl>(Context))
262 returngetOrCreateNamespace(NSDecl);
264 if(
const auto*RDecl = dyn_cast<RecordDecl>(Context))
265 if(!RDecl->isDependentType())
300StringRef CGDebugInfo::getFunctionName(
const FunctionDecl*FD) {
301 returninternString(GetName(FD));
304StringRef CGDebugInfo::getObjCMethodName(
const ObjCMethodDecl*OMD) {
306llvm::raw_svector_ostream OS(MethodName);
309 if(
const auto*OID = dyn_cast<ObjCImplementationDecl>(DC)) {
310OS << OID->getName();
311}
else if(
const auto*OID = dyn_cast<ObjCInterfaceDecl>(DC)) {
312OS << OID->getName();
313}
else if(
const auto*OC = dyn_cast<ObjCCategoryDecl>(DC)) {
314 if(OC->IsClassExtension()) {
315OS << OC->getClassInterface()->getName();
317OS << OC->getIdentifier()->getNameStart() <<
'(' 318<< OC->getIdentifier()->getNameStart() <<
')';
320}
else if(
const auto*OCD = dyn_cast<ObjCCategoryImplDecl>(DC)) {
321OS << OCD->getClassInterface()->getName() <<
'('<< OCD->getName() <<
')';
325 returninternString(OS.str());
328StringRef CGDebugInfo::getSelectorName(
SelectorS) {
329 returninternString(S.getAsString());
332StringRef CGDebugInfo::getClassName(
const RecordDecl*RD) {
333 if(isa<ClassTemplateSpecializationDecl>(RD)) {
335 returninternString(GetName(RD));
341 returnII->getName();
349 "Typedef should not be in another decl context!");
350assert(
D->getDeclName().getAsIdentifierInfo() &&
351 "Typedef was not named!");
352 return D->getDeclName().getAsIdentifierInfo()->getName();
362Name = DD->getName();
367Name = TND->getName();
370 if(
const CXXRecordDecl*CXXRD = dyn_cast<CXXRecordDecl>(RD))
371 if(CXXRD->isLambda())
379 returninternString(UnnamedType);
387std::optional<llvm::DIFile::ChecksumKind>
396std::optional<llvm::MemoryBufferRef> MemBuffer =
SM.getBufferOrNone(FID);
400 auto Data= llvm::arrayRefFromStringRef(MemBuffer->getBuffer());
403llvm::toHex(llvm::MD5::hash(
Data),
true, Checksum);
404 returnllvm::DIFile::CSK_MD5;
406llvm::toHex(llvm::SHA1::hash(
Data),
true, Checksum);
407 returnllvm::DIFile::CSK_SHA1;
409llvm::toHex(llvm::SHA256::hash(
Data),
true, Checksum);
410 returnllvm::DIFile::CSK_SHA256;
412llvm_unreachable(
"Unhandled DebugSrcHashKind enum");
415std::optional<StringRef> CGDebugInfo::getSource(
const SourceManager&
SM,
420 boolSourceInvalid =
false;
421StringRef Source =
SM.getBufferData(FID, &SourceInvalid);
433std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
439 FileName= TheCU->getFile()->getFilename();
440CSInfo = TheCU->getFile()->getChecksum();
446 FileName= TheCU->getFile()->getFilename();
454 autoIt = DIFileCache.find(
FileName.data());
455 if(It != DIFileCache.end()) {
457 if(llvm::Metadata *
V= It->second)
458 returncast<llvm::DIFile>(
V);
464std::optional<llvm::DIFile::ChecksumKind> CSKind =
465computeChecksum(FID, Checksum);
467CSInfo.emplace(*CSKind, Checksum);
469 returncreateFile(
FileName, CSInfo, getSource(
SM,
SM.getFileID(
Loc)));
472llvm::DIFile *CGDebugInfo::createFile(
474std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
475std::optional<StringRef> Source) {
479std::string CurDir =
remapDIPath(getCurrentDirname());
482 if(llvm::sys::path::is_absolute(RemappedFile)) {
485 autoFileIt = llvm::sys::path::begin(RemappedFile);
486 autoFileE = llvm::sys::path::end(RemappedFile);
487 autoCurDirIt = llvm::sys::path::begin(CurDir);
488 autoCurDirE = llvm::sys::path::end(CurDir);
489 for(; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
490llvm::sys::path::append(DirBuf, *CurDirIt);
491 if(llvm::sys::path::root_path(DirBuf) == DirBuf) {
497 for(; FileIt != FileE; ++FileIt)
498llvm::sys::path::append(FileBuf, *FileIt);
503 if(!llvm::sys::path::is_absolute(
FileName))
507llvm::DIFile *F = DBuilder.createFile(
File, Dir, CSInfo, Source);
508DIFileCache[
FileName.data()].reset(F);
515 if(llvm::sys::path::replace_path_prefix(
P, From, To))
517 return P.str().str();
524 return SM.getPresumedLoc(
Loc).getLine();
540StringRef CGDebugInfo::getCurrentDirname() {
544 if(!CWDName.empty())
546llvm::ErrorOr<std::string> CWD =
550 returnCWDName = internString(*CWD);
553voidCGDebugInfo::CreateCompileUnit() {
555std::optional<llvm::DIFile::ChecksumKind> CSKind;
556std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
569std::string MainFileName = CGO.MainFileName;
570 if(MainFileName.empty())
571MainFileName =
"<stdin>";
577std::string MainFileDir;
579 SM.getFileEntryRefForID(
SM.getMainFileID())) {
580MainFileDir = std::string(MainFile->getDir().getName());
581 if(!llvm::sys::path::is_absolute(MainFileName)) {
583llvm::sys::path::Style Style =
586? llvm::sys::path::Style::windows_backslash
587: llvm::sys::path::Style::posix)
588: llvm::sys::path::Style::native;
589llvm::sys::path::append(MainFileDirSS, Style, MainFileName);
590MainFileName = std::string(
591llvm::sys::path::remove_leading_dotslash(MainFileDirSS, Style));
598 if(MainFile->getName() == MainFileName &&
600MainFile->getName().rsplit(
'.').second)
602MainFileName = CGM.
getModule().getName().str();
604CSKind = computeChecksum(
SM.getMainFileID(), Checksum);
608llvm::dwarf::SourceLanguage LangTag;
611LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
612 else if(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
613LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
614 else if(LO.CPlusPlus14)
615LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
616 else if(LO.CPlusPlus11)
617LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
619LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
620}
else if(LO.ObjC) {
621LangTag = llvm::dwarf::DW_LANG_ObjC;
622}
else if(LO.OpenCL && (!CGM.
getCodeGenOpts().DebugStrictDwarf ||
624LangTag = llvm::dwarf::DW_LANG_OpenCL;
625}
else if(LO.C11 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) {
626LangTag = llvm::dwarf::DW_LANG_C11;
628LangTag = llvm::dwarf::DW_LANG_C99;
630LangTag = llvm::dwarf::DW_LANG_C89;
636 unsignedRuntimeVers = 0;
640llvm::DICompileUnit::DebugEmissionKind EmissionKind;
642 casellvm::codegenoptions::NoDebugInfo:
643 casellvm::codegenoptions::LocTrackingOnly:
644EmissionKind = llvm::DICompileUnit::NoDebug;
646 casellvm::codegenoptions::DebugLineTablesOnly:
647EmissionKind = llvm::DICompileUnit::LineTablesOnly;
649 casellvm::codegenoptions::DebugDirectivesOnly:
650EmissionKind = llvm::DICompileUnit::DebugDirectivesOnly;
652 casellvm::codegenoptions::DebugInfoConstructor:
653 casellvm::codegenoptions::LimitedDebugInfo:
654 casellvm::codegenoptions::FullDebugInfo:
655 casellvm::codegenoptions::UnusedTypeInfo:
656EmissionKind = llvm::DICompileUnit::FullDebug;
667CSInfo.emplace(*CSKind, Checksum);
668llvm::DIFile *CUFile = DBuilder.createFile(
670getSource(
SM,
SM.getMainFileID()));
672StringRef Sysroot, SDK;
673 if(CGM.
getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
675 autoB = llvm::sys::path::rbegin(Sysroot);
676 auto E= llvm::sys::path::rend(Sysroot);
678std::find_if(B,
E, [](
autoSDK) {
returnSDK.ends_with(
".sdk"); });
683llvm::DICompileUnit::DebugNameTableKind NameTableKind =
684 static_cast<llvm::DICompileUnit::DebugNameTableKind
>(
685CGOpts.DebugNameTable);
687NameTableKind = llvm::DICompileUnit::DebugNameTableKind::None;
689NameTableKind = llvm::DICompileUnit::DebugNameTableKind::Apple;
692TheCU = DBuilder.createCompileUnit(
693LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer :
"",
694LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
695CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.SplitDwarfFile, EmissionKind,
696DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
697NameTableKind, CGOpts.DebugRangesBaseAddress,
remapDIPath(Sysroot), SDK);
700llvm::DIType *CGDebugInfo::CreateType(
const BuiltinType*BT) {
704#define BUILTIN_TYPE(Id, SingletonId) 705#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id: 706#include "clang/AST/BuiltinTypes.def" 707 caseBuiltinType::Dependent:
708llvm_unreachable(
"Unexpected builtin type");
709 caseBuiltinType::NullPtr:
710 returnDBuilder.createNullPtrType();
711 caseBuiltinType::Void:
713 caseBuiltinType::ObjCClass:
716DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
717 "objc_class", TheCU, TheCU->getFile(), 0);
719 caseBuiltinType::ObjCId: {
730DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
731 "objc_class", TheCU, TheCU->getFile(), 0);
735 auto*ISATy = DBuilder.createPointerType(ClassTy, Size);
737ObjTy = DBuilder.createStructType(TheCU,
"objc_object", TheCU->getFile(), 0,
7380, 0, llvm::DINode::FlagZero,
nullptr,
739llvm::DINodeArray());
741DBuilder.replaceArrays(
742ObjTy, DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
743ObjTy,
"isa", TheCU->getFile(), 0, Size, 0, 0,
744llvm::DINode::FlagZero, ISATy)));
747 caseBuiltinType::ObjCSel: {
749SelTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
750 "objc_selector", TheCU,
751TheCU->getFile(), 0);
755#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 756 case BuiltinType::Id: \ 757 return getOrCreateStructPtrType("opencl_"#ImgType "_" #Suffix "_t", \
759#include "clang/Basic/OpenCLImageTypes.def" 760 caseBuiltinType::OCLSampler:
761 returngetOrCreateStructPtrType(
"opencl_sampler_t", OCLSamplerDITy);
762 caseBuiltinType::OCLEvent:
763 returngetOrCreateStructPtrType(
"opencl_event_t", OCLEventDITy);
764 caseBuiltinType::OCLClkEvent:
765 returngetOrCreateStructPtrType(
"opencl_clk_event_t", OCLClkEventDITy);
766 caseBuiltinType::OCLQueue:
767 returngetOrCreateStructPtrType(
"opencl_queue_t", OCLQueueDITy);
768 caseBuiltinType::OCLReserveID:
769 returngetOrCreateStructPtrType(
"opencl_reserve_id_t", OCLReserveIDDITy);
770#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 771 case BuiltinType::Id: \ 772 return getOrCreateStructPtrType("opencl_"#ExtType, Id##Ty);
773#include "clang/Basic/OpenCLExtensionTypes.def" 774#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \ 775 case BuiltinType::Id: \ 776 return getOrCreateStructPtrType(#Name, SingletonId); 777#include "clang/Basic/HLSLIntangibleTypes.def" 779#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: 780#include "clang/Basic/AArch64SVEACLETypes.def" 782 if(BT->
getKind() == BuiltinType::MFloat8) {
783 Encoding= llvm::dwarf::DW_ATE_unsigned_char;
787 returnDBuilder.createBasicType(BTName, Size, Encoding);
791BT->
getKind() == BuiltinType::SveCount
795: CGM.getContext().getBuiltinVectorTypeInfo(BT);
802 "Unsupported number of vectors for svcount_t");
806 unsignedNumElems = Info.
EC.getKnownMinValue() * Info.
NumVectors;
812llvm::Metadata *LowerBound, *UpperBound;
813LowerBound = llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
815 if(Info.
EC.isScalable()) {
816 unsignedNumElemsPerVG = NumElems / 2;
818{llvm::dwarf::DW_OP_constu, NumElemsPerVG, llvm::dwarf::DW_OP_bregx,
81946, 0, llvm::dwarf::DW_OP_mul,
820llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
821UpperBound = DBuilder.createExpression(
Expr);
823UpperBound = llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
826llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(
827 nullptr, LowerBound, UpperBound,
nullptr);
828llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
829llvm::DIType *ElemTy =
830getOrCreateType(Info.
ElementType, TheCU->getFile());
832 returnDBuilder.createVectorType(
0, Align, ElemTy,
837#define PPC_VECTOR_TYPE(Name, Id, size) \ 838 case BuiltinType::Id: 839#include "clang/Basic/PPCTypes.def" 840 returnCreateType(cast<const BuiltinType>(CGM.
getContext().
IntTy));
842#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id: 843#include "clang/Basic/RISCVVTypes.def" 848 unsignedElementCount = Info.
EC.getKnownMinValue();
851 boolFractional =
false;
853 unsignedFixedSize = ElementCount * SEW;
857}
else if(FixedSize < 64) {
860LMUL = 64 / FixedSize;
862LMUL = FixedSize / 64;
870{llvm::dwarf::DW_OP_bregx,
873llvm::dwarf::DW_OP_constu,
875llvm::dwarf::DW_OP_div, llvm::dwarf::DW_OP_constu, LMUL});
877 Expr.push_back(llvm::dwarf::DW_OP_div);
879 Expr.push_back(llvm::dwarf::DW_OP_mul);
881 Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
884llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
886 auto*UpperBound = DBuilder.createExpression(
Expr);
887llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(
888 nullptr, LowerBound, UpperBound,
nullptr);
889llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
890llvm::DIType *ElemTy =
891getOrCreateType(Info.
ElementType, TheCU->getFile());
894 returnDBuilder.createVectorType(
0, Align, ElemTy,
898#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \ 899 case BuiltinType::Id: { \ 902 DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, \ 903 MangledName, TheCU, TheCU->getFile(), 0); \ 904 return SingletonId; \ 906#include "clang/Basic/WebAssemblyReferenceTypes.def" 907#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS) \ 908 case BuiltinType::Id: { \ 911 DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name, \ 912 TheCU, TheCU->getFile(), 0); \ 913 return SingletonId; \ 915#define AMDGPU_NAMED_BARRIER_TYPE(Name, Id, SingletonId, Width, Align, Scope) \ 916 case BuiltinType::Id: { \ 919 DBuilder.createBasicType(Name, Width, llvm::dwarf::DW_ATE_unsigned); \ 920 return SingletonId; \ 922#include "clang/Basic/AMDGPUTypes.def" 923 caseBuiltinType::UChar:
924 caseBuiltinType::Char_U:
925 Encoding= llvm::dwarf::DW_ATE_unsigned_char;
927 caseBuiltinType::Char_S:
928 caseBuiltinType::SChar:
929 Encoding= llvm::dwarf::DW_ATE_signed_char;
931 caseBuiltinType::Char8:
932 caseBuiltinType::Char16:
933 caseBuiltinType::Char32:
936 caseBuiltinType::UShort:
937 caseBuiltinType::UInt:
938 caseBuiltinType::UInt128:
939 caseBuiltinType::ULong:
940 caseBuiltinType::WChar_U:
941 caseBuiltinType::ULongLong:
942 Encoding= llvm::dwarf::DW_ATE_unsigned;
944 caseBuiltinType::Short:
945 caseBuiltinType::Int:
946 caseBuiltinType::Int128:
947 caseBuiltinType::Long:
948 caseBuiltinType::WChar_S:
949 caseBuiltinType::LongLong:
950 Encoding= llvm::dwarf::DW_ATE_signed;
952 caseBuiltinType::Bool:
953 Encoding= llvm::dwarf::DW_ATE_boolean;
955 caseBuiltinType::Half:
956 caseBuiltinType::Float:
957 caseBuiltinType::LongDouble:
958 caseBuiltinType::Float16:
959 caseBuiltinType::BFloat16:
960 caseBuiltinType::Float128:
961 caseBuiltinType::Double:
962 caseBuiltinType::Ibm128:
968 Encoding= llvm::dwarf::DW_ATE_float;
970 caseBuiltinType::ShortAccum:
971 caseBuiltinType::Accum:
972 caseBuiltinType::LongAccum:
973 caseBuiltinType::ShortFract:
974 caseBuiltinType::Fract:
975 caseBuiltinType::LongFract:
976 caseBuiltinType::SatShortFract:
977 caseBuiltinType::SatFract:
978 caseBuiltinType::SatLongFract:
979 caseBuiltinType::SatShortAccum:
980 caseBuiltinType::SatAccum:
981 caseBuiltinType::SatLongAccum:
982 Encoding= llvm::dwarf::DW_ATE_signed_fixed;
984 caseBuiltinType::UShortAccum:
985 caseBuiltinType::UAccum:
986 caseBuiltinType::ULongAccum:
987 caseBuiltinType::UShortFract:
988 caseBuiltinType::UFract:
989 caseBuiltinType::ULongFract:
990 caseBuiltinType::SatUShortAccum:
991 caseBuiltinType::SatUAccum:
992 caseBuiltinType::SatULongAccum:
993 caseBuiltinType::SatUShortFract:
994 caseBuiltinType::SatUFract:
995 caseBuiltinType::SatULongFract:
996 Encoding= llvm::dwarf::DW_ATE_unsigned_fixed;
1003 returnDBuilder.createBasicType(BTName, Size, Encoding);
1006llvm::DIType *CGDebugInfo::CreateType(
const BitIntType*Ty) {
1008StringRef Name = Ty->
isUnsigned() ?
"unsigned _BitInt":
"_BitInt";
1010? llvm::dwarf::DW_ATE_unsigned
1011: llvm::dwarf::DW_ATE_signed;
1017llvm::DIType *CGDebugInfo::CreateType(
const ComplexType*Ty) {
1019llvm::dwarf::TypeKind
Encoding= llvm::dwarf::DW_ATE_complex_float;
1021 Encoding= llvm::dwarf::DW_ATE_lo_user;
1024 returnDBuilder.createBasicType(
"complex", Size, Encoding);
1038 returnllvm::dwarf::DW_TAG_const_type;
1042 returnllvm::dwarf::DW_TAG_volatile_type;
1046 returnllvm::dwarf::DW_TAG_restrict_type;
1048 return(llvm::dwarf::Tag)0;
1051llvm::DIType *CGDebugInfo::CreateQualifiedType(
QualTypeTy,
1052llvm::DIFile *Unit) {
1062assert(Qc.
empty() &&
"Unknown type qualifier for debug info");
1063 returngetOrCreateType(
QualType(
T, 0), Unit);
1070 returnDBuilder.createQualifiedType(Tag, FromTy);
1074llvm::DIFile *Unit) {
1083assert(Q.
empty() &&
"Unknown type qualifier for debug info");
1094 returnDBuilder.createQualifiedType(Tag, FromTy);
1098llvm::DIFile *Unit) {
1106 returnCreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
1110llvm::DIType *CGDebugInfo::CreateType(
const PointerType*Ty,
1111llvm::DIFile *Unit) {
1112 returnCreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
1118 switch(TheCU->getSourceLanguage()) {
1119 casellvm::dwarf::DW_LANG_C_plus_plus:
1120 casellvm::dwarf::DW_LANG_C_plus_plus_11:
1121 casellvm::dwarf::DW_LANG_C_plus_plus_14:
1123 casellvm::dwarf::DW_LANG_ObjC_plus_plus:
1124 returnisa<CXXRecordDecl>(TD) || isa<EnumDecl>(TD);
1152llvm::DICompileUnit *TheCU) {
1170llvm::DICompileUnit *TheCU) {
1176 if(
const auto*RD = dyn_cast<CXXRecordDecl>(TD))
1178 if(RD->isDynamicClass() &&
1191llvm::dwarf::Tag Tag;
1193Tag = llvm::dwarf::DW_TAG_structure_type;
1195Tag = llvm::dwarf::DW_TAG_union_type;
1200Tag = llvm::dwarf::DW_TAG_class_type;
1205llvm::DICompositeType *
1206CGDebugInfo::getOrCreateRecordFwdDecl(
const RecordType*Ty,
1207llvm::DIScope *Ctx) {
1210 returncast<llvm::DICompositeType>(
T);
1211llvm::DIFile *DefUnit = getOrCreateFile(RD->
getLocation());
1212 const unsigned Line=
1214StringRef RDName = getClassName(RD);
1220 if(
D&&
D->isCompleteDefinition())
1223llvm::DINode::DIFlags Flags = llvm::DINode::FlagFwdDecl;
1228 if(
const CXXRecordDecl*CXXRD = dyn_cast<CXXRecordDecl>(RD))
1229 if(!CXXRD->hasDefinition() ||
1230(CXXRD->hasDefinition() && !CXXRD->isTrivial()))
1231Flags |= llvm::DINode::FlagNonTrivial;
1238llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
1242 if(
auto*TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD))
1243DBuilder.replaceArrays(RetTy, llvm::DINodeArray(),
1244CollectCXXTemplateParams(TSpecial, DefUnit));
1245ReplaceMap.emplace_back(
1246std::piecewise_construct, std::make_tuple(Ty),
1247std::make_tuple(
static_cast<llvm::Metadata *
>(RetTy)));
1251llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
1254llvm::DIFile *Unit) {
1259std::optional<unsigned> DWARFAddressSpace =
1265BTFAttrTy = dyn_cast<BTFTagAttributedType>(
Atomic->getValueType());
1267BTFAttrTy = dyn_cast<BTFTagAttributedType>(PointeeTy);
1270StringRef
Tag= BTFAttrTy->
getAttr()->getBTFTypeTag();
1271 if(!
Tag.empty()) {
1272llvm::Metadata *Ops[2] = {
1273llvm::MDString::get(CGM.
getLLVMContext(), StringRef(
"btf_type_tag")),
1275Annots.insert(Annots.begin(),
1278BTFAttrTy = dyn_cast<BTFTagAttributedType>(BTFAttrTy->
getWrappedType());
1281llvm::DINodeArray Annotations =
nullptr;
1282 if(Annots.size() > 0)
1283Annotations = DBuilder.getOrCreateArray(Annots);
1285 if(Tag == llvm::dwarf::DW_TAG_reference_type ||
1286Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
1287 returnDBuilder.createReferenceType(Tag, getOrCreateType(PointeeTy, Unit),
1288Size, Align, DWARFAddressSpace);
1290 returnDBuilder.createPointerType(getOrCreateType(PointeeTy, Unit), Size,
1291Align, DWARFAddressSpace, StringRef(),
1295llvm::DIType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name,
1296llvm::DIType *&
Cache) {
1299 Cache= DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name,
1300TheCU, TheCU->getFile(), 0);
1302 Cache= DBuilder.createPointerType(
Cache, Size);
1306uint64_tCGDebugInfo::collectDefaultElementTypesForBlockPointer(
1307 const BlockPointerType*Ty, llvm::DIFile *Unit, llvm::DIDerivedType *DescTy,
1320EltTys.push_back(CreateMemberType(Unit, FType,
"__size", &FieldOffset));
1321EltTys.push_back(CreateMemberType(Unit, FType,
"__align", &FieldOffset));
1324EltTys.push_back(CreateMemberType(Unit, FType,
"__isa", &FieldOffset));
1326EltTys.push_back(CreateMemberType(Unit, FType,
"__flags", &FieldOffset));
1327EltTys.push_back(CreateMemberType(Unit, FType,
"__reserved", &FieldOffset));
1329EltTys.push_back(CreateMemberType(Unit, FType,
"__FuncPtr", &FieldOffset));
1333EltTys.push_back(DBuilder.createMemberType(
1334Unit,
"__descriptor",
nullptr, LineNo, FieldSize, FieldAlign,
1335FieldOffset, llvm::DINode::FlagZero, DescTy));
1336FieldOffset += FieldSize;
1343llvm::DIFile *Unit) {
1347llvm::DINodeArray Elements;
1351EltTys.push_back(CreateMemberType(Unit, FType,
"reserved", &FieldOffset));
1352EltTys.push_back(CreateMemberType(Unit, FType,
"Size", &FieldOffset));
1354Elements = DBuilder.getOrCreateArray(EltTys);
1357llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
1360DBuilder.createStructType(Unit,
"__block_descriptor",
nullptr, 0,
1361FieldOffset, 0, Flags,
nullptr, Elements);
1366 auto*DescTy = DBuilder.createPointerType(EltTy, Size);
1368FieldOffset = collectDefaultElementTypesForBlockPointer(Ty, Unit, DescTy,
1371Elements = DBuilder.getOrCreateArray(EltTys);
1377EltTy = DBuilder.createStructType(Unit,
"",
nullptr, 0, FieldOffset, 0,
1378Flags,
nullptr, Elements);
1380 returnDBuilder.createPointerType(EltTy, Size);
1397 if(Param->isParameterPack()) {
1406 if(SubstArgs.empty()) {
1415SpecArgs.push_back(SubstArgs.front());
1416SubstArgs = SubstArgs.drop_front();
1422llvm::DIFile *Unit) {
1424llvm::DIType *Src = getOrCreateType(Ty->
getAliasedType(), Unit);
1427 if(isa<BuiltinTemplateDecl>(TD))
1430 const auto*
AliasDecl= cast<TypeAliasTemplateDecl>(TD)->getTemplatedDecl();
1431 if(
AliasDecl->hasAttr<NoDebugAttr>())
1435llvm::raw_svector_ostream OS(NS);
1437 autoPP = getPrintingPolicy();
1464 autoArgVector = ::GetTemplateArgs(TD, Ty);
1473llvm::raw_string_ostream OS(Name);
1476llvm::codegenoptions::DebugTemplateNamesKind::Simple ||
1477!HasReconstitutableArgs(Args.Args))
1480llvm::DIDerivedType *AliasTy = DBuilder.createTemplateAlias(
1481Src, Name, getOrCreateFile(
Loc), getLineNumber(
Loc),
1482getDeclContextDescriptor(
AliasDecl), CollectTemplateParams(Args, Unit));
1488 returnDBuilder.createTypedef(Src, OS.str(), getOrCreateFile(
Loc),
1489getLineNumber(
Loc),
1505 returnllvm::DINode::FlagZero;
1509 returnllvm::DINode::FlagPrivate;
1511 returnllvm::DINode::FlagProtected;
1513 returnllvm::DINode::FlagPublic;
1515 returnllvm::DINode::FlagZero;
1517llvm_unreachable(
"unexpected access enumerator");
1520llvm::DIType *CGDebugInfo::CreateType(
const TypedefType*Ty,
1521llvm::DIFile *Unit) {
1522llvm::DIType *Underlying =
1534llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->
getDecl());
1536llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1538 if(isa<RecordDecl>(DC))
1541 returnDBuilder.createTypedef(Underlying, Ty->
getDecl()->
getName(),
1542getOrCreateFile(
Loc), getLineNumber(
Loc),
1543getDeclContextDescriptor(Ty->
getDecl()), Align,
1544Flags, Annotations);
1554 returnllvm::dwarf::DW_CC_BORLAND_stdcall;
1556 returnllvm::dwarf::DW_CC_BORLAND_msfastcall;
1558 returnllvm::dwarf::DW_CC_BORLAND_thiscall;
1560 returnllvm::dwarf::DW_CC_LLVM_vectorcall;
1562 returnllvm::dwarf::DW_CC_BORLAND_pascal;
1564 returnllvm::dwarf::DW_CC_LLVM_Win64;
1566 returnllvm::dwarf::DW_CC_LLVM_X86_64SysV;
1570 returnllvm::dwarf::DW_CC_LLVM_AAPCS;
1572 returnllvm::dwarf::DW_CC_LLVM_AAPCS_VFP;
1574 returnllvm::dwarf::DW_CC_LLVM_IntelOclBicc;
1576 returnllvm::dwarf::DW_CC_LLVM_SpirFunction;
1579 returnllvm::dwarf::DW_CC_LLVM_OpenCLKernel;
1581 returnllvm::dwarf::DW_CC_LLVM_Swift;
1583 returnllvm::dwarf::DW_CC_LLVM_SwiftTail;
1585 returnllvm::dwarf::DW_CC_LLVM_PreserveMost;
1587 returnllvm::dwarf::DW_CC_LLVM_PreserveAll;
1589 returnllvm::dwarf::DW_CC_LLVM_X86RegCall;
1591 returnllvm::dwarf::DW_CC_LLVM_M68kRTD;
1593 returnllvm::dwarf::DW_CC_LLVM_PreserveNone;
1595 returnllvm::dwarf::DW_CC_LLVM_RISCVVectorCall;
1601llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1603Flags |= llvm::DINode::FlagLValueReference;
1605Flags |= llvm::DINode::FlagRValueReference;
1609llvm::DIType *CGDebugInfo::CreateType(
const FunctionType*Ty,
1610llvm::DIFile *Unit) {
1611 const auto*FPT = dyn_cast<FunctionProtoType>(Ty);
1613 if(llvm::DIType *QTy = CreateQualifiedType(FPT, Unit))
1622EltTys.push_back(getOrCreateType(Ty->
getReturnType(), Unit));
1624llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1628EltTys.push_back(DBuilder.createUnspecifiedParameter());
1631 for(
const QualType&ParamType : FPT->param_types())
1632EltTys.push_back(getOrCreateType(ParamType, Unit));
1633 if(FPT->isVariadic())
1634EltTys.push_back(DBuilder.createUnspecifiedParameter());
1637llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
1638llvm::DIType *F = DBuilder.createSubroutineType(
1643llvm::DIDerivedType *
1644CGDebugInfo::createBitFieldType(
const FieldDecl*BitFieldDecl,
1645llvm::DIScope *RecordTy,
const RecordDecl*RD) {
1646StringRef Name = BitFieldDecl->
getName();
1648 if(BitFieldDecl->
hasAttr<PreferredTypeAttr>())
1649Ty = BitFieldDecl->
getAttr<PreferredTypeAttr>()->getType();
1651llvm::DIFile *VUnit = getOrCreateFile(
Loc);
1652llvm::DIType *DebugType = getOrCreateType(Ty, VUnit);
1655llvm::DIFile *
File= getOrCreateFile(
Loc);
1656 unsigned Line= getLineNumber(
Loc);
1661assert(SizeInBits > 0 &&
"found named 0-width bitfield");
1670 uint64_tOffsetInBits = StorageOffsetInBits + Offset;
1672llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(BitFieldDecl);
1673 returnDBuilder.createBitFieldMemberType(
1674RecordTy, Name,
File,
Line, SizeInBits, OffsetInBits, StorageOffsetInBits,
1675Flags, DebugType, Annotations);
1678llvm::DIDerivedType *CGDebugInfo::createBitFieldSeparatorIfNeeded(
1679 const FieldDecl*BitFieldDecl,
constllvm::DIDerivedType *BitFieldDI,
1707 if(PreviousFieldsDI.empty())
1711 auto*PreviousMDEntry =
1712PreviousFieldsDI.empty() ? nullptr : PreviousFieldsDI.back();
1713 auto*PreviousMDField =
1714dyn_cast_or_null<llvm::DIDerivedType>(PreviousMDEntry);
1715 if(!PreviousMDField || !PreviousMDField->isBitField() ||
1716PreviousMDField->getSizeInBits() == 0)
1720std::advance(PreviousBitfield, BitFieldDecl->
getFieldIndex() - 1);
1722assert(PreviousBitfield->isBitField());
1724 if(!PreviousBitfield->isZeroLengthBitField())
1727 QualTypeTy = PreviousBitfield->getType();
1729llvm::DIFile *VUnit = getOrCreateFile(
Loc);
1730llvm::DIType *DebugType = getOrCreateType(Ty, VUnit);
1731llvm::DIScope *RecordTy = BitFieldDI->getScope();
1733llvm::DIFile *
File= getOrCreateFile(
Loc);
1734 unsigned Line= getLineNumber(
Loc);
1737cast<llvm::ConstantInt>(BitFieldDI->getStorageOffsetInBits())
1740llvm::DINode::DIFlags Flags =
1742llvm::DINodeArray Annotations =
1743CollectBTFDeclTagAnnotations(*PreviousBitfield);
1744 returnDBuilder.createBitFieldMemberType(
1745RecordTy,
"",
File,
Line, 0, StorageOffsetInBits, StorageOffsetInBits,
1746Flags, DebugType, Annotations);
1749llvm::DIType *CGDebugInfo::createFieldType(
1751uint64_t offsetInBits, uint32_t AlignInBits, llvm::DIFile *tunit,
1752llvm::DIScope *scope,
const RecordDecl*RD, llvm::DINodeArray Annotations) {
1753llvm::DIType *debugType = getOrCreateType(
type, tunit);
1756llvm::DIFile *file = getOrCreateFile(loc);
1757 const unsignedline = getLineNumber(loc.
isValid() ? loc : CurLoc);
1760 autoAlign = AlignInBits;
1761 if(!
type->isIncompleteArrayType()) {
1763SizeInBits = TI.
Width;
1769 returnDBuilder.createMemberType(scope, name, file, line, SizeInBits, Align,
1770offsetInBits, flags, debugType, Annotations);
1773llvm::DISubprogram *
1774CGDebugInfo::createInlinedTrapSubprogram(StringRef FuncName,
1775llvm::DIFile *FileScope) {
1779llvm::DISubprogram *&SP = InlinedTrapFuncMap[FuncName];
1782llvm::DISubroutineType *DIFnTy = DBuilder.createSubroutineType(
nullptr);
1783SP = DBuilder.createFunction(
1784FileScope,
FuncName,
StringRef(),
1785FileScope,
0,
DIFnTy,
1787llvm::DINode::FlagArtificial,
1788llvm::DISubprogram::SPFlagDefinition,
1789 nullptr,
nullptr,
nullptr);
1795voidCGDebugInfo::CollectRecordLambdaFields(
1797llvm::DIType *RecordTy) {
1803 unsignedfieldno = 0;
1806I !=
E; ++I, ++Field, ++fieldno) {
1808 if(
C.capturesVariable()) {
1810assert(!
Field->isBitField() &&
"lambdas don't have bitfield members!");
1812StringRef VName =
V->getName();
1813llvm::DIFile *VUnit = getOrCreateFile(
Loc);
1815llvm::DIType *FieldType = createFieldType(
1817layout.
getFieldOffset(fieldno), Align, VUnit, RecordTy, CXXDecl);
1818elements.push_back(FieldType);
1819}
else if(
C.capturesThis()) {
1825llvm::DIFile *VUnit = getOrCreateFile(f->
getLocation());
1827StringRef ThisName =
1829llvm::DIType *fieldType = createFieldType(
1833elements.push_back(fieldType);
1838llvm::DIDerivedType *
1839CGDebugInfo::CreateRecordStaticField(
const VarDecl*Var, llvm::DIType *RecordTy,
1844llvm::DIFile *VUnit = getOrCreateFile(Var->
getLocation());
1845llvm::DIType *VTy = getOrCreateType(Var->
getType(), VUnit);
1847 unsignedLineNumber = getLineNumber(Var->
getLocation());
1848StringRef VName = Var->
getName();
1852llvm::Constant *
C=
nullptr;
1856 if(
Value->isInt())
1858 if(
Value->isFloat())
1865? llvm::dwarf::DW_TAG_variable
1866: llvm::dwarf::DW_TAG_member;
1868llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
1869RecordTy, VName, VUnit, LineNumber, VTy, Flags,
C, Tag, Align);
1874voidCGDebugInfo::CollectRecordNormalField(
1875 const FieldDecl*field, uint64_t OffsetInBits, llvm::DIFile *tunit,
1882 if(
name.empty() && !
type->isRecordType())
1885llvm::DIType *FieldType;
1887llvm::DIDerivedType *BitFieldType;
1888FieldType = BitFieldType = createBitFieldType(field, RecordTy, RD);
1889 if(llvm::DIType *Separator =
1890createBitFieldSeparatorIfNeeded(field, BitFieldType, elements, RD))
1891elements.push_back(Separator);
1894llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(field);
1897OffsetInBits, Align, tunit, RecordTy, RD, Annotations);
1900elements.push_back(FieldType);
1903voidCGDebugInfo::CollectRecordNestedType(
1907 if(isa<InjectedClassNameType>(Ty))
1910 if(llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateFile(
Loc)))
1911elements.push_back(nestedType);
1914voidCGDebugInfo::CollectRecordFields(
1915 const RecordDecl*record, llvm::DIFile *tunit,
1917llvm::DICompositeType *RecordTy) {
1918 const auto*CXXDecl = dyn_cast<CXXRecordDecl>(record);
1920 if(CXXDecl && CXXDecl->
isLambda())
1921CollectRecordLambdaFields(CXXDecl, elements, RecordTy);
1926 unsignedfieldNo = 0;
1930 for(
const auto*I : record->
decls())
1931 if(
const auto*
V= dyn_cast<VarDecl>(I)) {
1932 if(
V->hasAttr<NoDebugAttr>())
1938isa<VarTemplateSpecializationDecl>(
V))
1941 if(isa<VarTemplatePartialSpecializationDecl>(
V))
1945 autoMI = StaticDataMemberCache.find(
V->getCanonicalDecl());
1946 if(MI != StaticDataMemberCache.end()) {
1947assert(MI->second &&
1948 "Static data member declaration should still exist");
1949elements.push_back(MI->second);
1951 auto Field= CreateRecordStaticField(
V, RecordTy, record);
1952elements.push_back(Field);
1954}
else if(
const auto*field = dyn_cast<FieldDecl>(I)) {
1955CollectRecordNormalField(field, layout.
getFieldOffset(fieldNo), tunit,
1956elements, RecordTy, record);
1963 if(
const auto*nestedType = dyn_cast<TypeDecl>(I)) {
1965 if(isa<RecordDecl>(I) &&
1966cast<RecordDecl>(I)->isAnonymousStructOrUnion())
1968 if(!nestedType->isImplicit() &&
1969nestedType->getDeclContext() == record)
1970CollectRecordNestedType(nestedType, elements);
1976llvm::DISubroutineType *
1977CGDebugInfo::getOrCreateMethodType(
const CXXMethodDecl*Method,
1978llvm::DIFile *Unit) {
1981 returncast_or_null<llvm::DISubroutineType>(
1988 returngetOrCreateInstanceMethodType(ThisType,
Func, Unit);
1991llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2007 const auto*OriginalFunc = cast<llvm::DISubroutineType>(
2009 Func->getReturnType(),
Func->getParamTypes(), EPI),
2011llvm::DITypeRefArray Args = OriginalFunc->getTypeArray();
2012assert(Args.size() &&
"Invalid number of arguments!");
2017Elts.push_back(Args[0]);
2019 const boolHasExplicitObjectParameter = ThisPtr.
isNull();
2023 if(!HasExplicitObjectParameter) {
2024llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
2027DBuilder.createObjectPointerType(ThisPtrType,
true);
2028Elts.push_back(ThisPtrType);
2032 for(
unsignedi = 1, e = Args.size(); i != e; ++i)
2033Elts.push_back(Args[i]);
2036 if(HasExplicitObjectParameter) {
2037assert(Elts.size() >= 2 && Args.size() >= 2 &&
2038 "Expected at least return type and object parameter.");
2039Elts[1] = DBuilder.createObjectPointerType(Args[1],
false);
2042llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
2044 returnDBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
2051 if(
const auto*NRD = dyn_cast<CXXRecordDecl>(RD->
getDeclContext()))
2058llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
2059 const CXXMethodDecl*Method, llvm::DIFile *Unit, llvm::DIType *RecordTy) {
2061isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method);
2063StringRef MethodName = getFunctionName(Method);
2064llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit);
2068StringRef MethodLinkageName;
2078llvm::DIFile *MethodDefUnit =
nullptr;
2079 unsignedMethodLine = 0;
2081MethodDefUnit = getOrCreateFile(Method->
getLocation());
2082MethodLine = getLineNumber(Method->
getLocation());
2086llvm::DIType *ContainingType =
nullptr;
2087 unsignedVIndex = 0;
2088llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
2089llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
2094SPFlags |= llvm::DISubprogram::SPFlagPureVirtual;
2096SPFlags |= llvm::DISubprogram::SPFlagVirtual;
2101 if(!isa<CXXDestructorDecl>(Method))
2106 const auto*DD = dyn_cast<CXXDestructorDecl>(Method);
2110VIndex = ML.
Index;
2118Flags |= llvm::DINode::FlagIntroducedVirtual;
2127ContainingType = RecordTy;
2131SPFlags |= llvm::DISubprogram::SPFlagDeleted;
2134Flags |= llvm::DINode::FlagNoReturn;
2137Flags |= llvm::DINode::FlagStaticMember;
2139Flags |= llvm::DINode::FlagArtificial;
2141 if(
const auto*CXXC = dyn_cast<CXXConstructorDecl>(Method)) {
2142 if(CXXC->isExplicit())
2143Flags |= llvm::DINode::FlagExplicit;
2144}
else if(
const auto*CXXC = dyn_cast<CXXConversionDecl>(Method)) {
2145 if(CXXC->isExplicit())
2146Flags |= llvm::DINode::FlagExplicit;
2149Flags |= llvm::DINode::FlagPrototyped;
2151Flags |= llvm::DINode::FlagLValueReference;
2153Flags |= llvm::DINode::FlagRValueReference;
2155SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
2157SPFlags |= llvm::DISubprogram::SPFlagOptimized;
2161 if(DebugKind == llvm::codegenoptions::DebugInfoConstructor)
2165llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
2166llvm::DISubprogram *SP = DBuilder.createMethod(
2167RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
2168MethodTy, VIndex,
ThisAdjustment, ContainingType, Flags, SPFlags,
2169TParamsArray.get());
2176voidCGDebugInfo::CollectCXXMemberFunctions(
2183 for(
const auto*I : RD->
decls()) {
2184 const auto*Method = dyn_cast<CXXMethodDecl>(I);
2208EltTys.push_back(MI == SPCache.end()
2209? CreateCXXMemberFunction(Method, Unit, RecordTy)
2210:
static_cast<llvm::Metadata *
>(MI->second));
2214voidCGDebugInfo::CollectCXXBases(
const CXXRecordDecl*RD, llvm::DIFile *Unit,
2216llvm::DIType *RecordTy) {
2217llvm::DenseSet<CanonicalDeclPtr<const CXXRecordDecl>> SeenTypes;
2218CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->
bases(), SeenTypes,
2219llvm::DINode::FlagZero);
2224CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->
vbases(), SeenTypes,
2225llvm::DINode::FlagIndirectVirtualBase);
2229voidCGDebugInfo::CollectCXXBasesAux(
2234llvm::DINode::DIFlags StartingFlags) {
2236 for(
const auto&BI : Bases) {
2239 if(!SeenTypes.insert(
Base).second)
2241 auto*BaseTy = getOrCreateType(BI.getType(), Unit);
2242llvm::DINode::DIFlags BFlags = StartingFlags;
2246 if(BI.isVirtual()) {
2263BFlags |= llvm::DINode::FlagVirtual;
2270llvm::DIType *DTy = DBuilder.createInheritance(RecordTy, BaseTy, BaseOffset,
2271VBPtrOffset, BFlags);
2272EltTys.push_back(DTy);
2277CGDebugInfo::CollectTemplateParams(std::optional<TemplateArgs> OArgs,
2278llvm::DIFile *Unit) {
2280 returnllvm::DINodeArray();
2281TemplateArgs &Args = *OArgs;
2283 for(
unsignedi = 0, e = Args.Args.size(); i != e; ++i) {
2288Name = Args.TList->getParam(i)->getName();
2292llvm::DIType *TTy = getOrCreateType(TA.
getAsType(), Unit);
2293TemplateParams.push_back(DBuilder.createTemplateTypeParameter(
2294TheCU, Name, TTy, defaultParameter));
2299TemplateParams.push_back(DBuilder.createTemplateValueParameter(
2300TheCU, Name, TTy, defaultParameter,
2306llvm::DIType *TTy = getOrCreateType(
T, Unit);
2307llvm::Constant *
V=
nullptr;
2311!
D->
hasAttr<CUDADeviceAttr>()) {
2314 if(
const auto*VD = dyn_cast<VarDecl>(
D))
2318 else if(
const auto*MD = dyn_cast<CXXMethodDecl>(
D);
2319MD && MD->isImplicitObjectMemberFunction())
2321 else if(
const auto*FD = dyn_cast<FunctionDecl>(
D))
2325 else if(
const auto*MPT =
2326dyn_cast<MemberPointerType>(
T.getTypePtr())) {
2334}
else if(
const auto*GD = dyn_cast<MSGuidDecl>(
D)) {
2336}
else if(
const auto*TPO = dyn_cast<TemplateParamObjectDecl>(
D)) {
2343assert(
V&&
"Failed to find template parameter pointer");
2344 V=
V->stripPointerCasts();
2346TemplateParams.push_back(DBuilder.createTemplateValueParameter(
2347TheCU, Name, TTy, defaultParameter, cast_or_null<llvm::Constant>(
V)));
2351llvm::DIType *TTy = getOrCreateType(
T, Unit);
2352llvm::Constant *
V=
nullptr;
2355 if(
const auto*MPT = dyn_cast<MemberPointerType>(
T.getTypePtr()))
2361 if(MPT->isMemberDataPointer())
2364 V= llvm::ConstantInt::get(CGM.
Int8Ty, 0);
2365TemplateParams.push_back(DBuilder.createTemplateValueParameter(
2366TheCU, Name, TTy, defaultParameter,
V));
2370llvm::DIType *TTy = getOrCreateType(
T, Unit);
2373TemplateParams.push_back(DBuilder.createTemplateValueParameter(
2374TheCU, Name, TTy, defaultParameter,
V));
2377std::string QualName;
2378llvm::raw_string_ostream OS(QualName);
2380OS, getPrintingPolicy());
2381TemplateParams.push_back(DBuilder.createTemplateTemplateParameter(
2382TheCU, Name,
nullptr, QualName, defaultParameter));
2386TemplateParams.push_back(DBuilder.createTemplateParameterPack(
2387TheCU, Name,
nullptr,
2388CollectTemplateParams({{
nullptr, TA.
getPackAsArray()}}, Unit)));
2396assert(
V&&
"Expression in template argument isn't constant");
2397llvm::DIType *TTy = getOrCreateType(
T, Unit);
2398TemplateParams.push_back(DBuilder.createTemplateValueParameter(
2399TheCU, Name, TTy, defaultParameter,
V->stripPointerCasts()));
2405 "These argument types shouldn't exist in concrete types");
2408 returnDBuilder.getOrCreateArray(TemplateParams);
2411std::optional<CGDebugInfo::TemplateArgs>
2412CGDebugInfo::GetTemplateArgs(
const FunctionDecl*FD)
const{
2420 returnstd::nullopt;
2422std::optional<CGDebugInfo::TemplateArgs>
2423CGDebugInfo::GetTemplateArgs(
const VarDecl*VD)
const{
2427 auto*TS = dyn_cast<VarTemplateSpecializationDecl>(VD);
2429 returnstd::nullopt;
2432 autoTA = TS->getTemplateArgs().asArray();
2433 return{{TList, TA}};
2435std::optional<CGDebugInfo::TemplateArgs>
2436CGDebugInfo::GetTemplateArgs(
const RecordDecl*RD)
const{
2437 if(
auto*TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
2442TSpecial->getSpecializedTemplate()->getTemplateParameters();
2444 return{{TPList, TAList.
asArray()}};
2446 returnstd::nullopt;
2450CGDebugInfo::CollectFunctionTemplateParams(
const FunctionDecl*FD,
2451llvm::DIFile *Unit) {
2452 returnCollectTemplateParams(GetTemplateArgs(FD), Unit);
2455llvm::DINodeArray CGDebugInfo::CollectVarTemplateParams(
const VarDecl*VL,
2456llvm::DIFile *Unit) {
2457 returnCollectTemplateParams(GetTemplateArgs(VL), Unit);
2460llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(
const RecordDecl*RD,
2461llvm::DIFile *Unit) {
2462 returnCollectTemplateParams(GetTemplateArgs(RD), Unit);
2465llvm::DINodeArray CGDebugInfo::CollectBTFDeclTagAnnotations(
const Decl*
D) {
2466 if(!
D->
hasAttr<BTFDeclTagAttr>())
2471llvm::Metadata *Ops[2] = {
2472llvm::MDString::get(CGM.
getLLVMContext(), StringRef(
"btf_decl_tag")),
2473llvm::MDString::get(CGM.
getLLVMContext(), I->getBTFDeclTag())};
2474Annotations.push_back(llvm::MDNode::get(CGM.
getLLVMContext(), Ops));
2476 returnDBuilder.getOrCreateArray(Annotations);
2479llvm::DIType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile *Unit) {
2481 returnVTablePtrType;
2486llvm::Metadata *STy = getOrCreateType(Context.
IntTy, Unit);
2487llvm::DITypeRefArray SElements = DBuilder.getOrCreateTypeArray(STy);
2488llvm::DIType *SubTy = DBuilder.createSubroutineType(SElements);
2491std::optional<unsigned> DWARFAddressSpace =
2494llvm::DIType *vtbl_ptr_type = DBuilder.createPointerType(
2495SubTy, Size, 0, DWARFAddressSpace,
"__vtbl_ptr_type");
2496VTablePtrType = DBuilder.createPointerType(vtbl_ptr_type, Size);
2497 returnVTablePtrType;
2500StringRef CGDebugInfo::getVTableName(
const CXXRecordDecl*RD) {
2505StringRef CGDebugInfo::getDynamicInitializerName(
const VarDecl*VD,
2507llvm::Function *InitFn) {
2512 returnInitFn->getName();
2522llvm::raw_svector_ostream OS(QualifiedGV);
2524std::tie(Quals, GVName) = OS.str().rsplit(
"::");
2526std::swap(Quals, GVName);
2530llvm::raw_svector_ostream OS(InitName);
2532OS << Quals <<
"::";
2537llvm_unreachable(
"not an initializer");
2539OS <<
"`dynamic initializer for '";
2542OS <<
"`dynamic atexit destructor for '";
2549 if(
const auto*VTpl = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
2551getPrintingPolicy());
2556 returninternString(OS.str());
2559voidCGDebugInfo::CollectVTableInfo(
const CXXRecordDecl*RD, llvm::DIFile *Unit,
2576llvm::DIType *VPtrTy =
nullptr;
2579 if(NeedVTableShape) {
2584 unsignedVSlotCount =
2586 unsignedVTableWidth = PtrWidth * VSlotCount;
2588std::optional<unsigned> DWARFAddressSpace =
2592llvm::DIType *VTableType = DBuilder.createPointerType(
2593 nullptr, VTableWidth, 0, DWARFAddressSpace,
"__vtbl_ptr_type");
2594EltTys.push_back(VTableType);
2597VPtrTy = DBuilder.createPointerType(VTableType, PtrWidth);
2605VPtrTy = getOrCreateVTablePtrType(Unit);
2608llvm::DIType *VPtrMember =
2609DBuilder.createMemberType(Unit, getVTableName(RD), Unit, 0, Size, 0, 0,
2610llvm::DINode::FlagArtificial, VPtrTy);
2611EltTys.push_back(VPtrMember);
2617llvm::DIType *
T= getOrCreateType(RTy, getOrCreateFile(
Loc));
2629assert(!
D.isNull() &&
"null type");
2630llvm::DIType *
T= getOrCreateType(
D, getOrCreateFile(
Loc));
2631assert(
T&&
"could not create debug info for type");
2633RetainedTypes.push_back(
D.getAsOpaquePtr());
2641llvm::codegenoptions::DebugLineTablesOnly)
2647node = getOrCreateType(AllocatedTy, getOrCreateFile(
Loc));
2649CI->setMetadata(
"heapallocsite", node);
2653 if(DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
2657 autoI = TypeCache.find(TyPtr);
2658 if(I == TypeCache.end() || !cast<llvm::DIType>(I->second)->isForwardDecl())
2660llvm::DIType *Res = CreateTypeDefinition(Ty->
castAs<
EnumType>());
2661assert(!Res->isForwardDecl());
2662TypeCache[TyPtr].reset(Res);
2666 if(DebugKind > llvm::codegenoptions::LimitedDebugInfo ||
2673 if(RD->
hasAttr<DLLImportAttr>())
2676 if(MD->hasAttr<DLLImportAttr>())
2689 if(
auto*CXXDecl = dyn_cast<CXXRecordDecl>(RD)) {
2699 if(
auto*TD = dyn_cast<ClassTemplateSpecializationDecl>(CXXDecl))
2700 Explicit= TD->isExplicitInstantiationOrSpecialization();
2714 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(RD))
2715 if(CXXRD->isDynamicClass() &&
2717llvm::GlobalValue::AvailableExternallyLinkage &&
2728 if(DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
2732 autoI = TypeCache.find(TyPtr);
2733 if(I != TypeCache.end() && !cast<llvm::DIType>(I->second)->isForwardDecl())
2740assert(!Res->isForwardDecl());
2741TypeCache[TyPtr].reset(Res);
2748 if(!Tmpl->isImplicit() && Tmpl->isThisDeclarationADefinition() &&
2749!MD->getMemberSpecializationInfo()->isExplicitSpecialization())
2772 if(Ctor->isCopyOrMoveConstructor())
2774 if(!Ctor->isDeleted())
2793 if(DebugKind == llvm::codegenoptions::DebugLineTablesOnly)
2796 if(DebugKind > llvm::codegenoptions::LimitedDebugInfo ||
2797RD->
hasAttr<StandaloneDebugAttr>())
2800 if(!LangOpts.CPlusPlus)
2806 const auto*CXXDecl = dyn_cast<CXXRecordDecl>(RD);
2822 if(
const auto*SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
2823Spec = SD->getSpecializationKind();
2832 if((DebugKind == llvm::codegenoptions::DebugInfoConstructor) &&
2844llvm::DIType *
T= getTypeOrNull(Ty);
2845 if(
T&&
T->isForwardDecl())
2849llvm::DIType *CGDebugInfo::CreateType(
const RecordType*Ty) {
2851llvm::DIType *
T= cast_or_null<llvm::DIType>(getTypeOrNull(
QualType(Ty, 0)));
2855 T= getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
2859 auto[Def, Pref] = CreateTypeDefinition(Ty);
2861 returnPref ? Pref : Def;
2864llvm::DIType *CGDebugInfo::GetPreferredNameType(
const CXXRecordDecl*RD,
2865llvm::DIFile *Unit) {
2869 auto const*PNA = RD->
getAttr<PreferredNameAttr>();
2873 returngetOrCreateType(PNA->getTypedefType(), Unit);
2876std::pair<llvm::DIType *, llvm::DIType *>
2877CGDebugInfo::CreateTypeDefinition(
const RecordType*Ty) {
2881llvm::DIFile *DefUnit = getOrCreateFile(RD->
getLocation());
2889llvm::DICompositeType *FwdDecl = getOrCreateLimitedType(Ty);
2892 if(!
D|| !
D->isCompleteDefinition())
2893 return{FwdDecl,
nullptr};
2895 if(
const auto*CXXDecl = dyn_cast<CXXRecordDecl>(RD))
2896CollectContainingType(CXXDecl, FwdDecl);
2899LexicalBlockStack.emplace_back(&*FwdDecl);
2900RegionMap[Ty->
getDecl()].reset(FwdDecl);
2910 const auto*CXXDecl = dyn_cast<CXXRecordDecl>(RD);
2912CollectCXXBases(CXXDecl, DefUnit, EltTys, FwdDecl);
2913CollectVTableInfo(CXXDecl, DefUnit, EltTys);
2917CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
2918 if(CXXDecl && !CGM.
getCodeGenOpts().DebugOmitUnreferencedMethods)
2919CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
2921LexicalBlockStack.pop_back();
2922RegionMap.erase(Ty->
getDecl());
2924llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
2925DBuilder.replaceArrays(FwdDecl, Elements);
2927 if(FwdDecl->isTemporary())
2929llvm::MDNode::replaceWithPermanent(llvm::TempDICompositeType(FwdDecl));
2931RegionMap[Ty->
getDecl()].reset(FwdDecl);
2933 if(CGM.
getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB)
2934 if(
auto*PrefDI = GetPreferredNameType(CXXDecl, DefUnit))
2935 return{FwdDecl, PrefDI};
2937 return{FwdDecl,
nullptr};
2941llvm::DIFile *Unit) {
2943 returngetOrCreateType(Ty->
getBaseType(), Unit);
2947llvm::DIFile *Unit) {
2952 returnDBuilder.createTypedef(
2955getDeclContextDescriptor(Ty->
getDecl()));
2983llvm::DIFile *Unit) {
2989 static_cast<llvm::dwarf::SourceLanguage
>(TheCU->getSourceLanguage());
2994 if(DebugTypeExtRefs &&
ID->isFromASTFile() &&
ID->getDefinition() &&
2995!
ID->getImplementation())
2996 returnDBuilder.createForwardDecl(
2997llvm::dwarf::DW_TAG_structure_type,
ID->getName(),
2998getDeclContextDescriptor(ID), Unit, 0, RuntimeLang);
3001llvm::DIFile *DefUnit = getOrCreateFile(
ID->getLocation());
3002 unsigned Line= getLineNumber(
ID->getLocation());
3008llvm::DIScope *Mod = getParentModuleOrNull(ID);
3009llvm::DIType *FwdDecl = DBuilder.createReplaceableCompositeType(
3010llvm::dwarf::DW_TAG_structure_type,
ID->getName(), Mod ? Mod : TheCU,
3011DefUnit,
Line, RuntimeLang);
3012ObjCInterfaceCache.push_back(ObjCInterfaceCacheEntry(Ty, FwdDecl, Unit));
3016 returnCreateTypeDefinition(Ty, Unit);
3020 boolCreateSkeletonCU) {
3025 autoModRef = ModuleCache.find(M);
3026 if(ModRef != ModuleCache.end())
3027 returncast<llvm::DIModule>(ModRef->second);
3032llvm::raw_svector_ostream OS(ConfigMacros);
3036 for(
auto&M : PPOpts.Macros) {
3039 conststd::string &
Macro= M.first;
3040 boolUndef = M.second;
3041OS <<
"\"-"<< (Undef ?
'U':
'D');
3042 for(
char c: Macro)
3057 boolIsRootModule = M ? !M->
Parent:
true;
3061 if(CreateSkeletonCU && IsRootModule && Mod.
getASTFile().empty() && M)
3063 "clang module without ASTFile must be specified by -fmodule-name");
3066 autoRemapPath = [
this](StringRef
Path) -> std::string {
3068StringRef Relative(Remapped);
3069StringRef CompDir = TheCU->getDirectory();
3070 if(Relative.consume_front(CompDir))
3071Relative.consume_front(llvm::sys::path::get_separator());
3073 returnRelative.str();
3076 if(CreateSkeletonCU && IsRootModule && !Mod.
getASTFile().empty()) {
3083Signature = ModSig.truncatedValue();
3089 if(!llvm::sys::path::is_absolute(Mod.
getASTFile())) {
3091PCM = getCurrentDirname();
3095llvm::sys::path::append(PCM, Mod.
getASTFile());
3096DIB.createCompileUnit(
3097TheCU->getSourceLanguage(),
3099DIB.createFile(Mod.
getModuleName(), TheCU->getDirectory()),
3100TheCU->getProducer(),
false, StringRef(), 0, RemapPath(PCM),
3101llvm::DICompileUnit::FullDebug, Signature);
3105llvm::DIModule *
Parent=
3106IsRootModule ? nullptr
3109std::string IncludePath = Mod.
getPath().str();
3110llvm::DIModule *DIMod =
3112RemapPath(IncludePath));
3113ModuleCache[M].reset(DIMod);
3118llvm::DIFile *Unit) {
3120llvm::DIFile *DefUnit = getOrCreateFile(
ID->getLocation());
3121 unsigned Line= getLineNumber(
ID->getLocation());
3122 unsignedRuntimeLang = TheCU->getSourceLanguage();
3128llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
3129 if(
ID->getImplementation())
3130Flags |= llvm::DINode::FlagObjcClassComplete;
3132llvm::DIScope *Mod = getParentModuleOrNull(ID);
3133llvm::DICompositeType *RealDecl = DBuilder.createStructType(
3134Mod ? Mod : Unit,
ID->getName(), DefUnit,
Line, Size, Align, Flags,
3135 nullptr, llvm::DINodeArray(), RuntimeLang);
3138TypeCache[QTy.getAsOpaquePtr()].reset(RealDecl);
3141LexicalBlockStack.emplace_back(RealDecl);
3142RegionMap[Ty->
getDecl()].reset(RealDecl);
3149llvm::DIType *SClassTy =
3154llvm::DIType *InhTag = DBuilder.createInheritance(RealDecl, SClassTy, 0, 0,
3155llvm::DINode::FlagZero);
3156EltTys.push_back(InhTag);
3162llvm::DIFile *PUnit = getOrCreateFile(
Loc);
3163 unsignedPLine = getLineNumber(
Loc);
3166llvm::MDNode *PropertyNode = DBuilder.createObjCProperty(
3167PD->getName(), PUnit, PLine,
3169: getSelectorName(PD->getGetterName()),
3171: getSelectorName(PD->getSetterName()),
3172PD->getPropertyAttributes(), getOrCreateType(PD->getType(), PUnit));
3173EltTys.push_back(PropertyNode);
3178 typedefstd::pair<char, const IdentifierInfo *> IsClassAndIdent;
3182llvm::DenseSet<IsClassAndIdent> PropertySet;
3185 returnstd::make_pair(PD->isClassProperty(), PD->getIdentifier());
3188 for(
auto*PD : ClassExt->properties()) {
3189PropertySet.insert(GetIsClassAndIdent(PD));
3192 for(
const auto*PD :
ID->properties()) {
3195 if(!PropertySet.insert(GetIsClassAndIdent(PD)).second)
3202 unsignedFieldNo = 0;
3203 for(
ObjCIvarDecl*Field =
ID->all_declared_ivar_begin(); Field;
3204Field =
Field->getNextIvar(), ++FieldNo) {
3205llvm::DIType *FieldTy = getOrCreateType(
Field->getType(), Unit);
3209StringRef FieldName =
Field->getName();
3212 if(FieldName.empty())
3216llvm::DIFile *FieldDefUnit = getOrCreateFile(
Field->getLocation());
3217 unsignedFieldLine = getLineNumber(
Field->getLocation());
3225FieldSize =
Field->isBitField() ?
Field->getBitWidthValue()
3235 if(
Field->isBitField()) {
3246llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
3248Flags = llvm::DINode::FlagProtected;
3250Flags = llvm::DINode::FlagPrivate;
3252Flags = llvm::DINode::FlagPublic;
3254 if(
Field->isBitField())
3255Flags |= llvm::DINode::FlagBitField;
3257llvm::MDNode *PropertyNode =
nullptr;
3260ImpD->FindPropertyImplIvarDecl(
Field->getIdentifier())) {
3263llvm::DIFile *PUnit = getOrCreateFile(
Loc);
3264 unsignedPLine = getLineNumber(
Loc);
3267PropertyNode = DBuilder.createObjCProperty(
3268PD->getName(), PUnit, PLine,
3271: getSelectorName(PD->getGetterName()),
3274: getSelectorName(PD->getSetterName()),
3275PD->getPropertyAttributes(),
3276getOrCreateType(PD->getType(), PUnit));
3280FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit, FieldLine,
3281FieldSize, FieldAlign, FieldOffset, Flags,
3282FieldTy, PropertyNode);
3283EltTys.push_back(FieldTy);
3286llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
3287DBuilder.replaceArrays(RealDecl, Elements);
3289LexicalBlockStack.pop_back();
3293llvm::DIType *CGDebugInfo::CreateType(
const VectorType*Ty,
3294llvm::DIFile *Unit) {
3312llvm::DIType *ElementTy = getOrCreateType(Ty->
getElementType(), Unit);
3315llvm::Metadata *Subscript;
3317 autoSizeExpr = SizeExprCache.find(QTy);
3318 if(SizeExpr != SizeExprCache.end())
3319Subscript = DBuilder.getOrCreateSubrange(
3320SizeExpr->getSecond()
,
nullptr,
3321 nullptr,
nullptr);
3324llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
3325llvm::Type::getInt64Ty(CGM.
getLLVMContext()), Count ? Count : -1));
3326Subscript = DBuilder.getOrCreateSubrange(
3327CountNode
,
nullptr,
nullptr,
3330llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
3335 returnDBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray);
3339llvm::DIFile *Unit) {
3343llvm::DIType *ElementTy = getOrCreateType(Ty->
getElementType(), Unit);
3349 auto*ColumnCountNode =
3350llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
3352 auto*RowCountNode =
3353llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
3355Subscripts.push_back(DBuilder.getOrCreateSubrange(
3356ColumnCountNode
,
nullptr,
nullptr,
3358Subscripts.push_back(DBuilder.getOrCreateSubrange(
3359RowCountNode
,
nullptr,
nullptr,
3361llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts);
3362 returnDBuilder.createArrayType(Size, Align, ElementTy, SubscriptArray);
3365llvm::DIType *CGDebugInfo::CreateType(
const ArrayType*Ty, llvm::DIFile *Unit) {
3370 if(
const auto*VAT = dyn_cast<VariableArrayType>(Ty)) {
3394 while((Ty = dyn_cast<ArrayType>(EltTy))) {
3403 if(
const auto*CAT = dyn_cast<ConstantArrayType>(Ty))
3404Count = CAT->getZExtSize();
3405 else if(
const auto*VAT = dyn_cast<VariableArrayType>(Ty)) {
3406 if(
Expr*Size = VAT->getSizeExpr()) {
3409Count =
Result.Val.getInt().getExtValue();
3413 autoSizeNode = SizeExprCache.find(EltTy);
3414 if(SizeNode != SizeExprCache.end())
3415Subscripts.push_back(DBuilder.getOrCreateSubrange(
3416SizeNode->getSecond()
,
nullptr,
3417 nullptr,
nullptr));
3420llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
3422Subscripts.push_back(DBuilder.getOrCreateSubrange(
3423CountNode
,
nullptr,
nullptr,
3429llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts);
3431 returnDBuilder.createArrayType(Size, Align, getOrCreateType(EltTy, Unit),
3436llvm::DIFile *Unit) {
3437 returnCreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, Ty,
3442llvm::DIFile *Unit) {
3443llvm::dwarf::Tag
Tag= llvm::dwarf::DW_TAG_rvalue_reference_type;
3447 Tag= llvm::dwarf::DW_TAG_reference_type;
3449 returnCreatePointerLikeType(Tag, Ty, Ty->
getPointeeType(), Unit);
3453llvm::DIFile *
U) {
3454llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
3464Flags |= llvm::DINode::FlagSingleInheritance;
3467Flags |= llvm::DINode::FlagMultipleInheritance;
3470Flags |= llvm::DINode::FlagVirtualInheritance;
3480 returnDBuilder.createMemberPointerType(
3486 returnDBuilder.createMemberPointerType(
3487getOrCreateInstanceMethodType(
3490ClassType,
Size,
0, Flags);
3493llvm::DIType *CGDebugInfo::CreateType(
const AtomicType*Ty, llvm::DIFile *
U) {
3495 returnDBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, FromTy);
3498llvm::DIType *CGDebugInfo::CreateType(
const PipeType*Ty, llvm::DIFile *
U) {
3503llvm::DIFile *
U) {
3507llvm::DIType *CGDebugInfo::CreateEnumType(
const EnumType*Ty) {
3519 boolisImportedFromModule =
3531llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
3532llvm::DIFile *DefUnit = getOrCreateFile(ED->
getLocation());
3533llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
3534llvm::dwarf::DW_TAG_enumeration_type,
"", TheCU, DefUnit, 0));
3537StringRef EDName = ED->
getName();
3538llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
3539llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit,
Line,
35400, Size, Align, llvm::DINode::FlagFwdDecl,
Identifier);
3542ReplaceMap.emplace_back(
3543std::piecewise_construct, std::make_tuple(Ty),
3544std::make_tuple(
static_cast<llvm::Metadata *
>(RetTy)));
3548 returnCreateTypeDefinition(Ty);
3551llvm::DIType *CGDebugInfo::CreateTypeDefinition(
const EnumType*Ty) {
3564assert(ED &&
"An enumeration definition is required");
3566Enumerators.push_back(
3567DBuilder.createEnumerator(
Enum->getName(),
Enum->getInitVal()));
3571llvm::DINodeArray EltArray = DBuilder.getOrCreateArray(Enumerators);
3573llvm::DIFile *DefUnit = getOrCreateFile(ED->
getLocation());
3575llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
3576llvm::DIType *ClassTy = getOrCreateType(ED->
getIntegerType(), DefUnit);
3577 returnDBuilder.createEnumerationType(
3578EnumContext, ED->
getName(), DefUnit,
Line, Size, Align, EltArray, ClassTy,
3584StringRef Name, StringRef
Value) {
3585 unsigned Line= LineLoc.
isInvalid() ? 0 : getLineNumber(LineLoc);
3592llvm::DIFile *FName = getOrCreateFile(FileLoc);
3593 unsigned Line= LineLoc.
isInvalid() ? 0 : getLineNumber(LineLoc);
3594 returnDBuilder.createTempMacroFile(
Parent,
Line, FName);
3598llvm::DebugLoc TrapLocation, StringRef
Category, StringRef FailureMsg) {
3606FuncName += FailureMsg;
3608llvm::DISubprogram *TrapSP =
3609createInlinedTrapSubprogram(FuncName, TrapLocation->getFile());
3611TrapSP,
TrapLocation);
3621Quals += InnerQuals;
3625 return C.getQualifiedType(
T.getTypePtr(), Quals);
3626 caseType::TemplateSpecialization: {
3627 const auto*Spec = cast<TemplateSpecializationType>(
T);
3628 if(Spec->isTypeAlias())
3629 return C.getQualifiedType(
T.getTypePtr(), Quals);
3633 caseType::TypeOfExpr:
3634 T= cast<TypeOfExprType>(
T)->getUnderlyingExpr()->getType();
3637 T= cast<TypeOfType>(
T)->getUnmodifiedType();
3639 caseType::Decltype:
3640 T= cast<DecltypeType>(
T)->getUnderlyingType();
3642 caseType::UnaryTransform:
3643 T= cast<UnaryTransformType>(
T)->getUnderlyingType();
3645 caseType::Attributed:
3646 T= cast<AttributedType>(
T)->getEquivalentType();
3648 caseType::BTFTagAttributed:
3649 T= cast<BTFTagAttributedType>(
T)->getWrappedType();
3651 caseType::CountAttributed:
3652 T= cast<CountAttributedType>(
T)->
desugar();
3654 caseType::Elaborated:
3655 T= cast<ElaboratedType>(
T)->getNamedType();
3658 T= cast<UsingType>(
T)->getUnderlyingType();
3661 T= cast<ParenType>(
T)->getInnerType();
3663 caseType::MacroQualified:
3664 T= cast<MacroQualifiedType>(
T)->getUnderlyingType();
3666 caseType::SubstTemplateTypeParm:
3667 T= cast<SubstTemplateTypeParmType>(
T)->getReplacementType();
3670 caseType::DeducedTemplateSpecialization: {
3671 QualTypeDT = cast<DeducedType>(
T)->getDeducedType();
3672assert(!DT.
isNull() &&
"Undeduced types shouldn't reach here.");
3676 caseType::PackIndexing: {
3677 T= cast<PackIndexingType>(
T)->getSelectedType();
3680 caseType::Adjusted:
3683 T= cast<AdjustedType>(
T)->getAdjustedType();
3687assert(
T!= LastT &&
"Type unwrapping failed to unwrap!");
3692llvm::DIType *CGDebugInfo::getTypeOrNull(
QualTypeTy) {
3695 if(It != TypeCache.end()) {
3697 if(llvm::Metadata *
V= It->second)
3698 returncast<llvm::DIType>(
V);
3710 if(DebugKind <= llvm::codegenoptions::DebugLineTablesOnly ||
3711 D.isDynamicClass())
3720llvm::DIType *CGDebugInfo::getOrCreateType(
QualTypeTy, llvm::DIFile *Unit) {
3724llvm::TimeTraceScope TimeScope(
"DebugType", [&]() {
3726llvm::raw_string_ostream OS(Name);
3727Ty.
print(OS, getPrintingPolicy());
3734 if(
auto*
T= getTypeOrNull(Ty))
3737llvm::DIType *Res = CreateTypeNode(Ty, Unit);
3738 void*TyPtr = Ty.getAsOpaquePtr();
3741TypeCache[TyPtr].reset(Res);
3746llvm::DIModule *CGDebugInfo::getParentModuleOrNull(
const Decl*
D) {
3748 if(isa<RecordDecl>(
D) && !cast<RecordDecl>(
D)->
getDefinition())
3754 autoInfo = Reader->getSourceDescriptor(Idx);
3756 returngetOrCreateModuleRef(*Info,
true);
3757}
else if(ClangModuleMap) {
3771 returngetOrCreateModuleRef(Info,
false);
3774 returngetOrCreateModuleRef(PCHDescriptor,
false);
3781llvm::DIType *CGDebugInfo::CreateTypeNode(
QualTypeTy, llvm::DIFile *Unit) {
3784 returnCreateQualifiedType(Ty, Unit);
3788#define TYPE(Class, Base) 3789#define ABSTRACT_TYPE(Class, Base) 3790#define NON_CANONICAL_TYPE(Class, Base) 3791#define DEPENDENT_TYPE(Class, Base) case Type::Class: 3792#include "clang/AST/TypeNodes.inc" 3793llvm_unreachable(
"Dependent types cannot show up in debug information");
3795 caseType::ExtVector:
3797 returnCreateType(cast<VectorType>(Ty), Unit);
3798 caseType::ConstantMatrix:
3799 returnCreateType(cast<ConstantMatrixType>(Ty), Unit);
3800 caseType::ObjCObjectPointer:
3801 returnCreateType(cast<ObjCObjectPointerType>(Ty), Unit);
3802 caseType::ObjCObject:
3803 returnCreateType(cast<ObjCObjectType>(Ty), Unit);
3804 caseType::ObjCTypeParam:
3805 returnCreateType(cast<ObjCTypeParamType>(Ty), Unit);
3806 caseType::ObjCInterface:
3807 returnCreateType(cast<ObjCInterfaceType>(Ty), Unit);
3809 returnCreateType(cast<BuiltinType>(Ty));
3811 returnCreateType(cast<ComplexType>(Ty));
3813 returnCreateType(cast<PointerType>(Ty), Unit);
3814 caseType::BlockPointer:
3815 returnCreateType(cast<BlockPointerType>(Ty), Unit);
3817 returnCreateType(cast<TypedefType>(Ty), Unit);
3819 returnCreateType(cast<RecordType>(Ty));
3821 returnCreateEnumType(cast<EnumType>(Ty));
3822 caseType::FunctionProto:
3823 caseType::FunctionNoProto:
3824 returnCreateType(cast<FunctionType>(Ty), Unit);
3825 caseType::ConstantArray:
3826 caseType::VariableArray:
3827 caseType::IncompleteArray:
3828 caseType::ArrayParameter:
3829 returnCreateType(cast<ArrayType>(Ty), Unit);
3831 caseType::LValueReference:
3832 returnCreateType(cast<LValueReferenceType>(Ty), Unit);
3833 caseType::RValueReference:
3834 returnCreateType(cast<RValueReferenceType>(Ty), Unit);
3836 caseType::MemberPointer:
3837 returnCreateType(cast<MemberPointerType>(Ty), Unit);
3840 returnCreateType(cast<AtomicType>(Ty), Unit);
3843 returnCreateType(cast<BitIntType>(Ty));
3845 returnCreateType(cast<PipeType>(Ty), Unit);
3847 caseType::TemplateSpecialization:
3848 returnCreateType(cast<TemplateSpecializationType>(Ty), Unit);
3849 caseType::HLSLAttributedResource:
3850 returnCreateType(cast<HLSLAttributedResourceType>(Ty), Unit);
3852 caseType::CountAttributed:
3854 caseType::Attributed:
3855 caseType::BTFTagAttributed:
3856 caseType::Adjusted:
3858 caseType::DeducedTemplateSpecialization:
3859 caseType::Elaborated:
3862 caseType::MacroQualified:
3863 caseType::SubstTemplateTypeParm:
3864 caseType::TypeOfExpr:
3866 caseType::Decltype:
3867 caseType::PackIndexing:
3868 caseType::UnaryTransform:
3872llvm_unreachable(
"type should have been unwrapped!");
3875llvm::DICompositeType *
3876CGDebugInfo::getOrCreateLimitedType(
const RecordType*Ty) {
3879 auto*
T= cast_or_null<llvm::DICompositeType>(getTypeOrNull(QTy));
3884 if(
T&& !
T->isForwardDecl())
3888llvm::DICompositeType *Res = CreateLimitedType(Ty);
3893DBuilder.replaceArrays(Res,
T?
T->getElements() : llvm::DINodeArray());
3896TypeCache[QTy.getAsOpaquePtr()].reset(Res);
3901llvm::DICompositeType *CGDebugInfo::CreateLimitedType(
const RecordType*Ty) {
3905StringRef RDName = getClassName(RD);
3907llvm::DIFile *DefUnit =
nullptr;
3910DefUnit = getOrCreateFile(
Loc);
3914llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
3918 auto*
T= cast_or_null<llvm::DICompositeType>(
3926 if(!
D|| !
D->isCompleteDefinition())
3927 returngetOrCreateRecordFwdDecl(Ty, RDContext);
3940 autoFlags = llvm::DINode::FlagZero;
3941 if(
autoCXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3943Flags |= llvm::DINode::FlagTypePassByReference;
3945Flags |= llvm::DINode::FlagTypePassByValue;
3948 if(!CXXRD->isTrivial())
3949Flags |= llvm::DINode::FlagNonTrivial;
3952 if(CXXRD->isAnonymousStructOrUnion())
3953Flags |= llvm::DINode::FlagExportSymbols;
3956dyn_cast<CXXRecordDecl>(CXXRD->getDeclContext()));
3959llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(
D);
3960llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
3966 switch(RealDecl->getTag()) {
3968llvm_unreachable(
"invalid composite type tag");
3970 casellvm::dwarf::DW_TAG_array_type:
3971 casellvm::dwarf::DW_TAG_enumeration_type:
3980 casellvm::dwarf::DW_TAG_structure_type:
3981 casellvm::dwarf::DW_TAG_union_type:
3982 casellvm::dwarf::DW_TAG_class_type:
3985llvm::MDNode::replaceWithDistinct(llvm::TempDICompositeType(RealDecl));
3989RegionMap[Ty->
getDecl()].reset(RealDecl);
3992 if(
const auto*TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD))
3993DBuilder.replaceArrays(RealDecl, llvm::DINodeArray(),
3994CollectCXXTemplateParams(TSpecial, DefUnit));
3998voidCGDebugInfo::CollectContainingType(
const CXXRecordDecl*RD,
3999llvm::DICompositeType *RealDecl) {
4001llvm::DIType *ContainingType =
nullptr;
4013ContainingType = getOrCreateType(
QualType(PBase->getTypeForDecl(), 0),
4016ContainingType = RealDecl;
4018DBuilder.replaceVTableHolder(RealDecl, ContainingType);
4021llvm::DIType *CGDebugInfo::CreateMemberType(llvm::DIFile *Unit,
QualTypeFType,
4022StringRef Name, uint64_t *Offset) {
4023llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
4027DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize, FieldAlign,
4028*Offset, llvm::DINode::FlagZero, FieldTy);
4029*Offset += FieldSize;
4033voidCGDebugInfo::collectFunctionDeclProps(
GlobalDeclGD, llvm::DIFile *Unit,
4035StringRef &LinkageName,
4036llvm::DIScope *&FDContext,
4037llvm::DINodeArray &TParamsArray,
4038llvm::DINode::DIFlags &Flags) {
4040Name = getFunctionName(FD);
4045Flags |= llvm::DINode::FlagPrototyped;
4049 if(LinkageName == Name ||
4054DebugKind <= llvm::codegenoptions::DebugLineTablesOnly))
4055LinkageName = StringRef();
4060(DebugKind == llvm::codegenoptions::DebugLineTablesOnly &&
4064FDContext = getOrCreateNamespace(NSDecl);
4067llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
4068FDContext = getContextDescriptor(RDecl, Mod ? Mod : TheCU);
4074Flags |= llvm::DINode::FlagNoReturn;
4076TParamsArray = CollectFunctionTemplateParams(FD, Unit);
4080voidCGDebugInfo::collectVarDeclProps(
const VarDecl*VD, llvm::DIFile *&Unit,
4082StringRef &Name, StringRef &LinkageName,
4083llvm::MDTuple *&TemplateParameters,
4084llvm::DIScope *&VDContext) {
4093llvm::APInt ConstVal(32, 1);
4104 if(LinkageName == Name)
4105LinkageName = StringRef();
4107 if(isa<VarTemplateSpecializationDecl>(VD)) {
4108llvm::DINodeArray parameterNodes = CollectVarTemplateParams(VD, &*Unit);
4109TemplateParameters = parameterNodes.get();
4111TemplateParameters =
nullptr;
4131llvm::DIScope *Mod = getParentModuleOrNull(VD);
4132VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);
4135llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(
GlobalDeclGD,
4137llvm::DINodeArray TParamsArray;
4138StringRef Name, LinkageName;
4139llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
4140llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
4142llvm::DIFile *Unit = getOrCreateFile(
Loc);
4143llvm::DIScope *DContext = Unit;
4144 unsigned Line= getLineNumber(
Loc);
4145collectFunctionDeclProps(GD, Unit, Name, LinkageName, DContext, TParamsArray,
4147 auto*FD = cast<FunctionDecl>(GD.
getDecl());
4152ArgTypes.push_back(Parm->getType());
4158SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
4160SPFlags |= llvm::DISubprogram::SPFlagOptimized;
4163Flags |= getCallSiteRelatedAttrs();
4164SPFlags |= llvm::DISubprogram::SPFlagDefinition;
4165 returnDBuilder.createFunction(
4166DContext, Name, LinkageName, Unit,
Line,
4167getOrCreateFunctionType(GD.
getDecl(), FnType, Unit), 0, Flags, SPFlags,
4168TParamsArray.get(), getFunctionDeclaration(FD));
4171llvm::DISubprogram *SP = DBuilder.createTempFunctionFwdDecl(
4172DContext, Name, LinkageName, Unit,
Line,
4173getOrCreateFunctionType(GD.
getDecl(), FnType, Unit), 0, Flags, SPFlags,
4174TParamsArray.get(), getFunctionDeclaration(FD));
4176FwdDeclReplaceMap.emplace_back(std::piecewise_construct,
4177std::make_tuple(CanonDecl),
4178std::make_tuple(SP));
4182llvm::DISubprogram *CGDebugInfo::getFunctionForwardDeclaration(
GlobalDeclGD) {
4183 returngetFunctionFwdDeclOrStub(GD,
false);
4186llvm::DISubprogram *CGDebugInfo::getFunctionStub(
GlobalDeclGD) {
4187 returngetFunctionFwdDeclOrStub(GD,
true);
4190llvm::DIGlobalVariable *
4191CGDebugInfo::getGlobalVariableForwardDeclaration(
const VarDecl*VD) {
4193StringRef Name, LinkageName;
4195llvm::DIFile *Unit = getOrCreateFile(
Loc);
4196llvm::DIScope *DContext = Unit;
4197 unsigned Line= getLineNumber(
Loc);
4198llvm::MDTuple *TemplateParameters =
nullptr;
4200collectVarDeclProps(VD, Unit,
Line,
T, Name, LinkageName, TemplateParameters,
4203 auto*GV = DBuilder.createTempGlobalVariableFwdDecl(
4204DContext, Name, LinkageName, Unit,
Line, getOrCreateType(
T, Unit),
4206FwdDeclReplaceMap.emplace_back(
4207std::piecewise_construct,
4209std::make_tuple(
static_cast<llvm::Metadata *
>(GV)));
4213llvm::DINode *CGDebugInfo::getDeclarationOrDefinition(
const Decl*
D) {
4218 if(
const auto*TD = dyn_cast<TypeDecl>(
D))
4223 if(I != DeclCache.end()) {
4225 if(
auto*GVE = dyn_cast_or_null<llvm::DIGlobalVariableExpression>(N))
4226 returnGVE->getVariable();
4227 returncast<llvm::DINode>(N);
4234 if(IE != ImportedDeclCache.end()) {
4235 autoN = IE->second;
4236 if(
auto*GVE = dyn_cast_or_null<llvm::DIImportedEntity>(N))
4237 returncast<llvm::DINode>(GVE);
4238 returndyn_cast_or_null<llvm::DINode>(N);
4243 if(
const auto*FD = dyn_cast<FunctionDecl>(
D))
4244 returngetFunctionForwardDeclaration(FD);
4245 else if(
const auto*VD = dyn_cast<VarDecl>(
D))
4246 returngetGlobalVariableForwardDeclaration(VD);
4251llvm::DISubprogram *CGDebugInfo::getFunctionDeclaration(
const Decl*
D) {
4252 if(!
D|| DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
4255 const auto*FD = dyn_cast<FunctionDecl>(
D);
4260 auto*S = getDeclContextDescriptor(
D);
4263 if(MI == SPCache.end()) {
4265 returnCreateCXXMemberFunction(MD, getOrCreateFile(MD->getLocation()),
4266cast<llvm::DICompositeType>(S));
4269 if(MI != SPCache.end()) {
4270 auto*SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
4271 if(SP && !SP->isDefinition())
4275 for(
auto*NextFD : FD->
redecls()) {
4276 autoMI = SPCache.find(NextFD->getCanonicalDecl());
4277 if(MI != SPCache.end()) {
4278 auto*SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
4279 if(SP && !SP->isDefinition())
4286llvm::DISubprogram *CGDebugInfo::getObjCMethodDeclaration(
4287 const Decl*
D, llvm::DISubroutineType *FnType,
unsignedLineNo,
4288llvm::DINode::DIFlags Flags, llvm::DISubprogram::DISPFlags SPFlags) {
4289 if(!
D|| DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
4292 const auto*OMD = dyn_cast<ObjCMethodDecl>(
D);
4300SPFlags |= llvm::DISubprogram::SPFlagObjCDirect;
4310 autoIt = TypeCache.find(QTy.getAsOpaquePtr());
4311 if(It == TypeCache.end())
4313 auto*InterfaceType = cast<llvm::DICompositeType>(It->second);
4314llvm::DISubprogram *FD = DBuilder.createFunction(
4315InterfaceType, getObjCMethodName(OMD), StringRef(),
4316InterfaceType->getFile(), LineNo, FnType, LineNo, Flags, SPFlags);
4317DBuilder.finalizeSubprogram(FD);
4324llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(
const Decl*
D,
4329 if(!
D|| (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly &&
4333 returnDBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray({}));
4335 if(
const auto*Method = dyn_cast<CXXMethodDecl>(
D))
4336 returngetOrCreateMethodType(Method, F);
4341 if(
const auto*OMethod = dyn_cast<ObjCMethodDecl>(
D)) {
4346 QualTypeResultTy = OMethod->getReturnType();
4351 QualType(OMethod->getClassInterface()->getTypeForDecl(), 0));
4353Elts.push_back(getOrCreateType(ResultTy, F));
4356 if(
auto*SelfDecl = OMethod->getSelfDecl())
4357SelfDeclTy = SelfDecl->getType();
4358 else if(
auto*FPT = dyn_cast<FunctionProtoType>(FnType))
4361 if(!SelfDeclTy.
isNull())
4363CreateSelfType(SelfDeclTy, getOrCreateType(SelfDeclTy, F)));
4365Elts.push_back(DBuilder.createArtificialType(
4368 for(
const auto*PI : OMethod->parameters())
4369Elts.push_back(getOrCreateType(PI->getType(), F));
4371 if(OMethod->isVariadic())
4372Elts.push_back(DBuilder.createUnspecifiedParameter());
4374llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
4375 returnDBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero,
4381 if(
const auto*FD = dyn_cast<FunctionDecl>(
D))
4382 if(FD->isVariadic()) {
4384EltTys.push_back(getOrCreateType(FD->getReturnType(), F));
4385 if(
const auto*FPT = dyn_cast<FunctionProtoType>(FnType))
4387EltTys.push_back(getOrCreateType(ParamType, F));
4388EltTys.push_back(DBuilder.createUnspecifiedParameter());
4389llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
4390 returnDBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero,
4394 returncast<llvm::DISubroutineType>(getOrCreateType(FnType, F));
4403CC = SrcFnTy->getCallConv();
4405 for(
const VarDecl*VD : Args)
4406ArgTypes.push_back(VD->
getType());
4413llvm::Function *Fn,
boolCurFuncIsThunk) {
4415StringRef LinkageName;
4417FnBeginRegionCount.push_back(LexicalBlockStack.size());
4420 boolHasDecl = (
D!=
nullptr);
4422llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
4423llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
4424llvm::DIFile *Unit = getOrCreateFile(
Loc);
4425llvm::DIScope *FDContext = Unit;
4426llvm::DINodeArray TParamsArray;
4429LinkageName = Fn->getName();
4430}
else if(
const auto*FD = dyn_cast<FunctionDecl>(
D)) {
4432 autoFI = SPCache.find(FD->getCanonicalDecl());
4433 if(FI != SPCache.end()) {
4434 auto*SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
4435 if(SP && SP->isDefinition()) {
4436LexicalBlockStack.emplace_back(SP);
4437RegionMap[
D].reset(SP);
4441collectFunctionDeclProps(GD, Unit, Name, LinkageName, FDContext,
4442TParamsArray, Flags);
4443}
else if(
const auto*OMD = dyn_cast<ObjCMethodDecl>(
D)) {
4444Name = getObjCMethodName(OMD);
4445Flags |= llvm::DINode::FlagPrototyped;
4446}
else if(isa<VarDecl>(
D) &&
4452Name = Fn->getName();
4454 if(isa<BlockDecl>(
D))
4457Flags |= llvm::DINode::FlagPrototyped;
4459 if(Name.starts_with(
"\01"))
4460Name = Name.substr(1);
4462assert((!
D|| !isa<VarDecl>(
D) ||
4464 "Unexpected DynamicInitKind !");
4467isa<VarDecl>(
D) || isa<CapturedDecl>(
D)) {
4468Flags |= llvm::DINode::FlagArtificial;
4474Flags |= llvm::DINode::FlagThunk;
4476 if(Fn->hasLocalLinkage())
4477SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
4479SPFlags |= llvm::DISubprogram::SPFlagOptimized;
4481llvm::DINode::DIFlags FlagsForDef = Flags | getCallSiteRelatedAttrs();
4482llvm::DISubprogram::DISPFlags SPFlagsForDef =
4483SPFlags | llvm::DISubprogram::SPFlagDefinition;
4485 const unsignedLineNo = getLineNumber(
Loc.
isValid() ?
Loc: CurLoc);
4486 unsignedScopeLine = getLineNumber(ScopeLoc);
4487llvm::DISubroutineType *DIFnType = getOrCreateFunctionType(
D, FnType, Unit);
4488llvm::DISubprogram *
Decl=
nullptr;
4489llvm::DINodeArray Annotations =
nullptr;
4491 Decl= isa<ObjCMethodDecl>(
D)
4492? getObjCMethodDeclaration(
D, DIFnType, LineNo, Flags, SPFlags)
4493: getFunctionDeclaration(
D);
4494Annotations = CollectBTFDeclTagAnnotations(
D);
4502llvm::DISubprogram *SP = DBuilder.createFunction(
4503FDContext, Name, LinkageName, Unit, LineNo, DIFnType, ScopeLine,
4504FlagsForDef, SPFlagsForDef, TParamsArray.get(),
Decl,
nullptr,
4506Fn->setSubprogram(SP);
4510 if(HasDecl && isa<FunctionDecl>(
D))
4514LexicalBlockStack.emplace_back(SP);
4517RegionMap[
D].reset(SP);
4521 QualTypeFnType, llvm::Function *Fn) {
4523StringRef LinkageName;
4529llvm::TimeTraceScope TimeScope(
"DebugFunction", [&]() {
4530 returnGetName(
D,
true);
4533llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
4534llvm::DIFile *Unit = getOrCreateFile(
Loc);
4535 boolIsDeclForCallSite = Fn ?
true:
false;
4536llvm::DIScope *FDContext =
4537IsDeclForCallSite ? Unit : getDeclContextDescriptor(
D);
4538llvm::DINodeArray TParamsArray;
4539 if(isa<FunctionDecl>(
D)) {
4541collectFunctionDeclProps(GD, Unit, Name, LinkageName, FDContext,
4542TParamsArray, Flags);
4543}
else if(
const auto*OMD = dyn_cast<ObjCMethodDecl>(
D)) {
4544Name = getObjCMethodName(OMD);
4545Flags |= llvm::DINode::FlagPrototyped;
4547llvm_unreachable(
"not a function or ObjC method");
4549 if(!Name.empty() && Name[0] ==
'\01')
4550Name = Name.substr(1);
4553Flags |= llvm::DINode::FlagArtificial;
4558 unsignedLineNo = getLineNumber(
Loc);
4559 unsignedScopeLine = 0;
4560llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
4562SPFlags |= llvm::DISubprogram::SPFlagOptimized;
4564llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(
D);
4565llvm::DISubroutineType *STy = getOrCreateFunctionType(
D, FnType, Unit);
4566llvm::DISubprogram *SP = DBuilder.createFunction(
4567FDContext, Name, LinkageName, Unit, LineNo, STy, ScopeLine, Flags,
4568SPFlags, TParamsArray.get(),
nullptr,
nullptr, Annotations);
4574 if(
auto*FD = dyn_cast<FunctionDecl>(
D)) {
4575llvm::DITypeRefArray ParamTypes = STy->getTypeArray();
4578llvm::DINodeArray ParamAnnotations = CollectBTFDeclTagAnnotations(PD);
4579DBuilder.createParameterVariable(
4580SP, PD->getName(), ArgNo, Unit, LineNo, ParamTypes[ArgNo],
true,
4581llvm::DINode::FlagZero, ParamAnnotations);
4587 if(IsDeclForCallSite)
4588Fn->setSubprogram(SP);
4590DBuilder.finalizeSubprogram(SP);
4598 auto*
Func= CallOrInvoke->getCalledFunction();
4601 if(
Func->getSubprogram())
4606 if(CalleeDecl->
hasAttr<NoDebugAttr>() ||
4607getCallSiteRelatedAttrs() == llvm::DINode::FlagZero)
4618 const auto*FD = cast<FunctionDecl>(GD.
getDecl());
4620 autoFI = SPCache.find(FD->getCanonicalDecl());
4621llvm::DISubprogram *SP =
nullptr;
4622 if(FI != SPCache.end())
4623SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
4624 if(!SP || !SP->isDefinition())
4625SP = getFunctionStub(GD);
4626FnBeginRegionCount.push_back(LexicalBlockStack.size());
4627LexicalBlockStack.emplace_back(SP);
4633assert(CurInlinedAt &&
"unbalanced inline scope stack");
4642 if(CurLoc.isInvalid() || CurLoc.isMacroID() || LexicalBlockStack.empty())
4645llvm::MDNode *
Scope= LexicalBlockStack.back();
4646Builder.SetCurrentDebugLocation(
4647llvm::DILocation::get(CGM.
getLLVMContext(), getLineNumber(CurLoc),
4648getColumnNumber(CurLoc),
Scope, CurInlinedAt));
4652llvm::MDNode *Back =
nullptr;
4653 if(!LexicalBlockStack.empty())
4654Back = LexicalBlockStack.back().get();
4655LexicalBlockStack.emplace_back(DBuilder.createLexicalBlock(
4656cast<llvm::DIScope>(Back), getOrCreateFile(CurLoc), getLineNumber(CurLoc),
4657getColumnNumber(CurLoc)));
4660voidCGDebugInfo::AppendAddressSpaceXDeref(
4662std::optional<unsigned> DWARFAddressSpace =
4664 if(!DWARFAddressSpace)
4667 Expr.push_back(llvm::dwarf::DW_OP_constu);
4668 Expr.push_back(*DWARFAddressSpace);
4669 Expr.push_back(llvm::dwarf::DW_OP_swap);
4670 Expr.push_back(llvm::dwarf::DW_OP_xderef);
4679Builder.SetCurrentDebugLocation(llvm::DILocation::get(
4681LexicalBlockStack.back(), CurInlinedAt));
4683 if(DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
4687CreateLexicalBlock(
Loc);
4692assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
4697 if(DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
4700LexicalBlockStack.pop_back();
4704assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
4705 unsignedRCount = FnBeginRegionCount.back();
4706assert(RCount <= LexicalBlockStack.size() &&
"Region stack mismatch");
4709 while(LexicalBlockStack.size() != RCount) {
4712LexicalBlockStack.pop_back();
4714FnBeginRegionCount.pop_back();
4716 if(Fn && Fn->getSubprogram())
4717DBuilder.finalizeSubprogram(Fn->getSubprogram());
4720CGDebugInfo::BlockByRefType
4721CGDebugInfo::EmitTypeForVarWithBlocksAttr(
const VarDecl*VD,
4722uint64_t *XOffset) {
4725uint64_t FieldSize, FieldOffset;
4726uint32_t FieldAlign;
4728llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
4733EltTys.push_back(CreateMemberType(Unit, FType,
"__isa", &FieldOffset));
4734EltTys.push_back(CreateMemberType(Unit, FType,
"__forwarding", &FieldOffset));
4736EltTys.push_back(CreateMemberType(Unit, FType,
"__flags", &FieldOffset));
4737EltTys.push_back(CreateMemberType(Unit, FType,
"__size", &FieldOffset));
4740 if(HasCopyAndDispose) {
4743CreateMemberType(Unit, FType,
"__copy_helper", &FieldOffset));
4745CreateMemberType(Unit, FType,
"__destroy_helper", &FieldOffset));
4747 boolHasByrefExtendedLayout;
4750HasByrefExtendedLayout) &&
4751HasByrefExtendedLayout) {
4754CreateMemberType(Unit, FType,
"__byref_variable_layout", &FieldOffset));
4763 CharUnitsNumPaddingBytes = AlignedOffsetInBytes - FieldOffsetInBytes;
4766llvm::APInt pad(32, NumPaddingBytes.
getQuantity());
4769EltTys.push_back(CreateMemberType(Unit, FType,
"", &FieldOffset));
4774llvm::DIType *WrappedTy = getOrCreateType(FType, Unit);
4778*XOffset = FieldOffset;
4779llvm::DIType *FieldTy = DBuilder.createMemberType(
4780Unit, VD->
getName(), Unit, 0, FieldSize, FieldAlign, FieldOffset,
4781llvm::DINode::FlagZero, WrappedTy);
4782EltTys.push_back(FieldTy);
4783FieldOffset += FieldSize;
4785llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
4786 return{DBuilder.createStructType(Unit,
"", Unit, 0, FieldOffset, 0,
4787llvm::DINode::FlagZero,
nullptr, Elements),
4791llvm::DILocalVariable *CGDebugInfo::EmitDeclare(
const VarDecl*VD,
4792llvm::Value *Storage,
4793std::optional<unsigned> ArgNo,
4795 const boolUsePointerValue) {
4797assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
4798 if(VD->
hasAttr<NoDebugAttr>())
4803llvm::DIFile *Unit =
nullptr;
4804 if(!VarIsArtificial)
4808 if(VD->
hasAttr<BlocksAttr>())
4809Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset).WrappedType;
4811Ty = getOrCreateType(VD->
getType(), Unit);
4821 if(!VarIsArtificial) {
4826llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
4827 if(VarIsArtificial)
4828Flags |= llvm::DINode::FlagArtificial;
4833AppendAddressSpaceXDeref(AddressSpace,
Expr);
4837 if(
const auto*IPD = dyn_cast<ImplicitParamDecl>(VD)) {
4840Flags |= llvm::DINode::FlagObjectPointer;
4841}
else if(
const auto*PVD = dyn_cast<ParmVarDecl>(VD)) {
4842 if(PVD->isExplicitObjectParameter())
4843Flags |= llvm::DINode::FlagObjectPointer;
4850 auto*
Scope= cast<llvm::DIScope>(LexicalBlockStack.back());
4851StringRef Name = VD->
getName();
4852 if(!Name.empty()) {
4858 Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
4863 Expr.push_back(llvm::dwarf::DW_OP_deref);
4864 Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
4869}
else if(
const auto*RT = dyn_cast<RecordType>(VD->
getType())) {
4881 for(
const auto*Field : RD->
fields()) {
4882llvm::DIType *FieldTy = getOrCreateType(
Field->getType(), Unit);
4883StringRef FieldName =
Field->getName();
4886 if(FieldName.empty() && !isa<RecordType>(
Field->getType()))
4891 auto*
D= DBuilder.createAutoVariable(
4893Flags | llvm::DINode::FlagArtificial, FieldAlign);
4896DBuilder.insertDeclare(Storage,
D, DBuilder.createExpression(
Expr),
4900Builder.GetInsertBlock());
4908 if(UsePointerValue) {
4909assert(!llvm::is_contained(
Expr, llvm::dwarf::DW_OP_deref) &&
4910 "Debug info already contains DW_OP_deref.");
4911 Expr.push_back(llvm::dwarf::DW_OP_deref);
4915llvm::DILocalVariable *
D=
nullptr;
4917llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD);
4918 D= DBuilder.createParameterVariable(
Scope, Name, *ArgNo, Unit,
Line, Ty,
4929 autoRemapCoroArgToLocalVar = [&]() -> llvm::DILocalVariable * {
4932 if(!isa<llvm::DISubprogram>(
Scope) || !
Scope->isDistinct())
4935 auto Iter= llvm::find_if(CoroutineParameterMappings, [&](
auto&Pair) {
4936 Stmt*StmtPtr =
const_cast<Stmt*
>(Pair.second);
4937 if(
DeclStmt*DeclStmtPtr = dyn_cast<DeclStmt>(StmtPtr)) {
4940 if(VD == dyn_cast_or_null<VarDecl>(
Decl))
4946 if(
Iter!= CoroutineParameterMappings.end()) {
4948 autoIter2 = llvm::find_if(ParamDbgMappings, [&](
auto&DbgPair) {
4949 returnDbgPair.first == PD && DbgPair.second->getScope() ==
Scope;
4951 if(Iter2 != ParamDbgMappings.end())
4952 return const_cast<llvm::DILocalVariable *
>(Iter2->second);
4958 D= RemapCoroArgToLocalVar();
4961 D= DBuilder.createAutoVariable(
Scope, Name, Unit,
Line, Ty,
4965DBuilder.insertDeclare(Storage,
D, DBuilder.createExpression(
Expr),
4968Builder.GetInsertBlock());
4973llvm::DILocalVariable *CGDebugInfo::EmitDeclare(
const BindingDecl*BD,
4974llvm::Value *Storage,
4975std::optional<unsigned> ArgNo,
4977 const boolUsePointerValue) {
4979assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
4980 if(BD->
hasAttr<NoDebugAttr>())
4987llvm::DIFile *Unit = getOrCreateFile(BD->
getLocation());
4988llvm::DIType *Ty = getOrCreateType(BD->
getType(), Unit);
4999AppendAddressSpaceXDeref(AddressSpace,
Expr);
5004 if(UsePointerValue) {
5005assert(!llvm::is_contained(
Expr, llvm::dwarf::DW_OP_deref) &&
5006 "Debug info already contains DW_OP_deref.");
5007 Expr.push_back(llvm::dwarf::DW_OP_deref);
5012StringRef Name = BD->
getName();
5013 auto*
Scope= cast<llvm::DIScope>(LexicalBlockStack.back());
5015llvm::DILocalVariable *
D= DBuilder.createAutoVariable(
5017llvm::DINode::FlagZero, Align);
5020 if(
const FieldDecl*FD = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
5021 const unsignedfieldIndex = FD->getFieldIndex();
5027 if(FD->isBitField()) {
5034 Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5040? llvm::dwarf::DW_OP_LLVM_extract_bits_sext
5041: llvm::dwarf::DW_OP_LLVM_extract_bits_zext);
5046 Expr.push_back(std::min((uint64_t)Info.
Size, TypeSize));
5047}
else if(fieldOffset != 0) {
5049 "Unexpected non-bitfield with non-byte-aligned offset");
5050 Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5056dyn_cast<ArraySubscriptExpr>(BD->
getBinding())) {
5057 if(
const IntegerLiteral*IL = dyn_cast<IntegerLiteral>(ASE->getIdx())) {
5058 const uint64_tvalue = IL->getValue().getZExtValue();
5062 Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5071DBuilder.insertDeclare(Storage,
D, DBuilder.createExpression(
Expr),
5074Builder.GetInsertBlock());
5079llvm::DILocalVariable *
5082 const boolUsePointerValue) {
5085 if(
auto*DD = dyn_cast<DecompositionDecl>(VD)) {
5087EmitDeclare(B, Storage, std::nullopt, Builder,
5094 returnEmitDeclare(VD, Storage, std::nullopt, Builder, UsePointerValue);
5099assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
5104 auto*
Scope= cast<llvm::DIScope>(LexicalBlockStack.back());
5105llvm::DIFile *Unit = getOrCreateFile(
D->
getLocation());
5111StringRef Name =
D->getName();
5118DBuilder.insertLabel(L,
5120 Scope, CurInlinedAt),
5121Builder.GetInsertBlock());
5124llvm::DIType *CGDebugInfo::CreateSelfType(
const QualType&QualTy,
5126llvm::DIType *CachedTy = getTypeOrNull(QualTy);
5129 returnDBuilder.createObjectPointerType(Ty,
true);
5134 const CGBlockInfo&blockInfo, llvm::Instruction *InsertPoint) {
5136assert(!LexicalBlockStack.empty() &&
"Region stack mismatch, stack empty!");
5138 if(Builder.GetInsertBlock() ==
nullptr)
5140 if(VD->
hasAttr<NoDebugAttr>())
5143 boolisByRef = VD->
hasAttr<BlocksAttr>();
5145uint64_t XOffset = 0;
5146llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
5149Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset).WrappedType;
5151Ty = getOrCreateType(VD->
getType(), Unit);
5155 if(
const auto*IPD = dyn_cast<ImplicitParamDecl>(VD))
5157Ty = CreateSelfType(VD->
getType(), Ty);
5160 const unsigned Line=
5171addr.push_back(llvm::dwarf::DW_OP_deref);
5172addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5175addr.push_back(llvm::dwarf::DW_OP_deref);
5176addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5181addr.push_back(llvm::dwarf::DW_OP_deref);
5182addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
5190 auto*
D= DBuilder.createAutoVariable(
5191cast<llvm::DILocalScope>(LexicalBlockStack.back()), VD->
getName(), Unit,
5192 Line, Ty,
false, llvm::DINode::FlagZero, Align);
5196LexicalBlockStack.back(), CurInlinedAt);
5197 auto*
Expr= DBuilder.createExpression(addr);
5199DBuilder.insertDeclare(Storage,
D,
Expr, DL, InsertPoint);
5201DBuilder.insertDeclare(Storage,
D,
Expr, DL, Builder.GetInsertBlock());
5204llvm::DILocalVariable *
5207 boolUsePointerValue) {
5209 returnEmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
5213structBlockLayoutChunk {
5214uint64_t OffsetInBits;
5217bool operator<(
constBlockLayoutChunk &l,
constBlockLayoutChunk &r) {
5218 returnl.OffsetInBits < r.OffsetInBits;
5222voidCGDebugInfo::collectDefaultFieldsForBlockLiteralDeclare(
5224 constllvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
5231BlockLayout.getElementOffsetInBits(0),
5233Fields.push_back(createFieldType(
"__align", Context.
IntTy,
Loc,
AS_public,
5234BlockLayout.getElementOffsetInBits(1),
5238BlockLayout.getElementOffsetInBits(0),
5240Fields.push_back(createFieldType(
"__flags", Context.
IntTy,
Loc,
AS_public,
5241BlockLayout.getElementOffsetInBits(1),
5245BlockLayout.getElementOffsetInBits(2), Unit, Unit));
5246 auto*FnTy =
Block.getBlockExpr()->getFunctionType();
5248Fields.push_back(createFieldType(
"__FuncPtr", FnPtrType,
Loc,
AS_public,
5249BlockLayout.getElementOffsetInBits(3),
5251Fields.push_back(createFieldType(
5256 Loc,
AS_public, BlockLayout.getElementOffsetInBits(4), Unit, Unit));
5263llvm::AllocaInst *Alloca,
5271llvm::DIFile *tunit = getOrCreateFile(loc);
5272 unsignedline = getLineNumber(loc);
5273 unsignedcolumn = getColumnNumber(loc);
5278 constllvm::StructLayout *blockLayout =
5282collectDefaultFieldsForBlockLiteralDeclare(block,
C, loc, *blockLayout, tunit,
5291BlockLayoutChunk chunk;
5292chunk.OffsetInBits =
5293blockLayout->getElementOffsetInBits(block.
CXXThisIndex);
5294chunk.Capture =
nullptr;
5295chunks.push_back(chunk);
5299 for(
const auto&capture :
blockDecl->captures()) {
5300 const VarDecl*variable = capture.getVariable();
5307BlockLayoutChunk chunk;
5308chunk.OffsetInBits =
5309blockLayout->getElementOffsetInBits(captureInfo.
getIndex());
5310chunk.Capture = &capture;
5311chunks.push_back(chunk);
5315llvm::array_pod_sort(chunks.begin(), chunks.end());
5317 for(
constBlockLayoutChunk &Chunk : chunks) {
5318uint64_t offsetInBits = Chunk.OffsetInBits;
5325cast_or_null<CXXMethodDecl>(
blockDecl->getNonClosureContext()))
5327 else if(
auto*RDecl = dyn_cast<CXXRecordDecl>(
blockDecl->getParent()))
5330llvm_unreachable(
"unexpected block declcontext");
5332fields.push_back(createFieldType(
"this",
type, loc,
AS_public,
5333offsetInBits, tunit, tunit));
5338StringRef name = variable->
getName();
5340llvm::DIType *fieldType;
5342 TypeInfoPtrInfo =
C.getTypeInfo(
C.VoidPtrTy);
5347EmitTypeForVarWithBlocksAttr(variable, &xoffset).BlockByRefWrapper;
5348fieldType = DBuilder.createPointerType(fieldType, PtrInfo.
Width);
5349fieldType = DBuilder.createMemberType(tunit, name, tunit, line,
5350PtrInfo.
Width, Align, offsetInBits,
5351llvm::DINode::FlagZero, fieldType);
5355offsetInBits, Align, tunit, tunit);
5357fields.push_back(fieldType);
5361llvm::raw_svector_ostream(typeName)
5364llvm::DINodeArray fieldsArray = DBuilder.getOrCreateArray(fields);
5366llvm::DIType *
type=
5367DBuilder.createStructType(tunit, typeName.str(), tunit, line,
5369llvm::DINode::FlagZero,
nullptr, fieldsArray);
5373llvm::DINode::DIFlags flags = llvm::DINode::FlagArtificial;
5374 auto*scope = cast<llvm::DILocalScope>(LexicalBlockStack.back());
5377 auto*debugVar = DBuilder.createParameterVariable(
5378scope, Name, ArgNo, tunit, line,
type, CGM.
getLangOpts().Optimize, flags);
5381DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
5383column, scope, CurInlinedAt),
5384Builder.GetInsertBlock());
5387llvm::DIDerivedType *
5388CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl*
D) {
5389 if(!
D|| !
D->isStaticDataMember())
5393 if(MI != StaticDataMemberCache.end()) {
5394assert(MI->second &&
"Static data member declaration should still exist");
5401 auto*Ctxt = cast<llvm::DICompositeType>(getDeclContextDescriptor(
D));
5402 returnCreateRecordStaticField(
D, Ctxt, cast<RecordDecl>(DC));
5405llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
5406 const RecordDecl*RD, llvm::DIFile *Unit,
unsignedLineNo,
5407StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) {
5408llvm::DIGlobalVariableExpression *GVE =
nullptr;
5410 for(
const auto*Field : RD->
fields()) {
5411llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
5412StringRef FieldName = Field->getName();
5415 if(FieldName.empty()) {
5416 if(
const auto*RT = dyn_cast<RecordType>(Field->getType()))
5417GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
5422GVE = DBuilder.createGlobalVariableExpression(
5423DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
5424Var->hasLocalLinkage());
5425Var->addDebugInfo(GVE);
5437 const auto*RD = dyn_cast<CXXRecordDecl>(RT->
getDecl());
5442 auto*TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD);
5450case TemplateArgument::Pack:
5451return ReferencesAnonymousEntity(TA.getPackAsArray());
5452case TemplateArgument::Type: {
5453struct ReferencesAnonymous
5454: public RecursiveASTVisitor<ReferencesAnonymous> {
5455bool RefAnon = false;
5456bool VisitRecordType(RecordType *RT) {
5457if (ReferencesAnonymousEntity(RT)) {
5464ReferencesAnonymous RT;
5465RT.TraverseType(TA.getAsType());
5478 boolReconstitutable =
true;
5480Reconstitutable =
false;
5484Reconstitutable =
false;
5487 boolVisitType(
Type*
T) {
5491Reconstitutable =
false;
5496 boolTraverseEnumType(
EnumType*ET) {
5499 if(
const auto*ED = dyn_cast<EnumDecl>(ET->
getDecl())) {
5501Reconstitutable =
false;
5505Reconstitutable =
false;
5515 returnReconstitutable;
5519Reconstitutable =
false;
5529ReconstitutableType
T;
5530 T.TraverseType(QT);
5531 return T.Reconstitutable;
5534boolCGDebugInfo::HasReconstitutableArgs(
5538case TemplateArgument::Template:
5545case TemplateArgument::Declaration:
5554case TemplateArgument::NullPtr:
5558case TemplateArgument::Pack:
5561return HasReconstitutableArgs(TA.getPackAsArray());
5562case TemplateArgument::Integral:
5567return TA.getAsIntegral().getBitWidth() <= 64 &&
5568IsReconstitutableType(TA.getIntegralType());
5569case TemplateArgument::StructuralValue:
5571case TemplateArgument::Type:
5572return IsReconstitutableType(TA.getAsType());
5573case TemplateArgument::Expression:
5574return IsReconstitutableType(TA.getAsExpr()->getType());
5576llvm_unreachable(
"Other, unresolved, template arguments should " 5577 "not be seen here");
5582std::string CGDebugInfo::GetName(
const Decl*
D,
bool Qualified)
const{
5584llvm::raw_string_ostream OS(Name);
5585 const NamedDecl*ND = dyn_cast<NamedDecl>(
D);
5588llvm::codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
5592TemplateNamesKind = llvm::codegenoptions::DebugTemplateNamesKind::Full;
5594std::optional<TemplateArgs> Args;
5596 boolIsOperatorOverload =
false;
5597 if(
auto*RD = dyn_cast<CXXRecordDecl>(ND)) {
5598Args = GetTemplateArgs(RD);
5599}
else if(
auto*FD = dyn_cast<FunctionDecl>(ND)) {
5600Args = GetTemplateArgs(FD);
5602IsOperatorOverload |=
5605}
else if(
auto*VD = dyn_cast<VarDecl>(ND)) {
5606Args = GetTemplateArgs(VD);
5630 boolReconstitutable =
5631Args && HasReconstitutableArgs(Args->Args) && !IsOperatorOverload;
5635 if(TemplateNamesKind == llvm::codegenoptions::DebugTemplateNamesKind::Full ||
5639 boolMangled = TemplateNamesKind ==
5640llvm::codegenoptions::DebugTemplateNamesKind::Mangled;
5646std::string EncodedOriginalName;
5647llvm::raw_string_ostream EncodedOriginalNameOS(EncodedOriginalName);
5655std::string CanonicalOriginalName;
5656llvm::raw_string_ostream OriginalOS(CanonicalOriginalName);
5658assert(EncodedOriginalName == CanonicalOriginalName);
5671llvm::TimeTraceScope TimeScope(
"DebugGlobalVariable", [&]() {
5672 returnGetName(
D,
true);
5678 if(Cached != DeclCache.end())
5679 returnVar->addDebugInfo(
5680cast<llvm::DIGlobalVariableExpression>(Cached->second));
5683llvm::DIFile *Unit =
nullptr;
5684llvm::DIScope *DContext =
nullptr;
5686StringRef DeclName, LinkageName;
5688llvm::MDTuple *TemplateParameters =
nullptr;
5689collectVarDeclProps(
D, Unit, LineNo,
T, DeclName, LinkageName,
5690TemplateParameters, DContext);
5694llvm::DIGlobalVariableExpression *GVE =
nullptr;
5702 "unnamed non-anonymous struct or union?");
5703GVE = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);
5710 if(
D->
hasAttr<CUDASharedAttr>())
5713 else if(
D->
hasAttr<CUDAConstantAttr>())
5717AppendAddressSpaceXDeref(AddressSpace,
Expr);
5719llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(
D);
5720GVE = DBuilder.createGlobalVariableExpression(
5721DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(
T, Unit),
5722Var->hasLocalLinkage(),
true,
5723 Expr.empty() ?
nullptr: DBuilder.createExpression(
Expr),
5724getOrCreateStaticDataMemberDeclarationOrNull(
D), TemplateParameters,
5725Align, Annotations);
5726Var->addDebugInfo(GVE);
5733 if(VD->
hasAttr<NoDebugAttr>())
5735llvm::TimeTraceScope TimeScope(
"DebugConstGlobalVariable", [&]() {
5736 returnGetName(VD,
true);
5741llvm::DIFile *Unit = getOrCreateFile(VD->
getLocation());
5742StringRef Name = VD->
getName();
5743llvm::DIType *Ty = getOrCreateType(VD->
getType(), Unit);
5745 if(
const auto*ECD = dyn_cast<EnumConstantDecl>(VD)) {
5746 const auto*ED = cast<EnumDecl>(ECD->getDeclContext());
5747assert(isa<EnumType>(ED->
getTypeForDecl()) &&
"Enum without EnumType?");
5760llvm::DIType *EDTy =
5762assert (EDTy->getTag() == llvm::dwarf::DW_TAG_enumeration_type);
5773 auto*VarD = dyn_cast<VarDecl>(VD);
5774 if(VarD && VarD->isStaticDataMember()) {
5775 auto*RD = cast<RecordDecl>(VarD->getDeclContext());
5776getDeclContextDescriptor(VarD);
5781RetainedTypes.push_back(
5786llvm::DIScope *DContext = getDeclContextDescriptor(VD);
5788 auto&GV = DeclCache[VD];
5792llvm::DIExpression *InitExpr = createConstantValueExpression(VD,
Init);
5793llvm::MDTuple *TemplateParameters =
nullptr;
5795 if(isa<VarTemplateSpecializationDecl>(VD))
5797llvm::DINodeArray parameterNodes = CollectVarTemplateParams(VarD, &*Unit);
5798TemplateParameters = parameterNodes.get();
5801GV.reset(DBuilder.createGlobalVariableExpression(
5802DContext, Name, StringRef(), Unit, getLineNumber(VD->
getLocation()), Ty,
5803 true,
true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),
5804TemplateParameters, Align));
5814llvm::DIFile *Unit = getOrCreateFile(
D->
getLocation());
5815StringRef Name =
D->getName();
5816llvm::DIType *Ty = getOrCreateType(
D->getType(), Unit);
5818llvm::DIScope *DContext = getDeclContextDescriptor(
D);
5819llvm::DIGlobalVariableExpression *GVE =
5820DBuilder.createGlobalVariableExpression(
5821DContext, Name, StringRef(), Unit, getLineNumber(
D->
getLocation()),
5822Ty,
false,
false,
nullptr,
nullptr,
nullptr, Align);
5823Var->addDebugInfo(GVE);
5831llvm::codegenoptions::DebugLineTablesOnly)
5834llvm::DILocation *DIL =
Value->getDebugLoc().get();
5838llvm::DIFile *Unit = DIL->getFile();
5839llvm::DIType *
Type= getOrCreateType(Ty, Unit);
5844 if(llvm::LoadInst *Load = dyn_cast<llvm::LoadInst>(
Value)) {
5845llvm::Value *Var = Load->getPointerOperand();
5850 autoDeclareTypeMatches = [&](
auto*DbgDeclare) {
5851 returnDbgDeclare->getVariable()->getType() ==
Type;
5853 if(any_of(llvm::findDbgDeclares(Var), DeclareTypeMatches) ||
5854any_of(llvm::findDVRDeclares(Var), DeclareTypeMatches))
5858llvm::DILocalVariable *
D=
5859DBuilder.createAutoVariable(LexicalBlockStack.back(),
"",
nullptr, 0,
5860 Type,
false, llvm::DINode::FlagArtificial);
5862 if(
autoInsertPoint =
Value->getInsertionPointAfterDef()) {
5863DBuilder.insertDbgValueIntrinsic(
Value,
D, DBuilder.createExpression(), DIL,
5876 const auto*
D= cast<ValueDecl>(GD.
getDecl());
5895 if(!(DI = getDeclarationOrDefinition(
5896AliaseeDecl.getCanonicalDecl().getDecl())))
5899llvm::DIScope *DContext = getDeclContextDescriptor(
D);
5902llvm::DIImportedEntity *ImportDI = DBuilder.createImportedDeclaration(
5903DContext, DI, getOrCreateFile(
Loc), getLineNumber(
Loc),
D->getName());
5916llvm::DIFile *
File= getOrCreateFile(
Loc);
5917llvm::DIGlobalVariableExpression *Debug =
5918DBuilder.createGlobalVariableExpression(
5919 nullptr, StringRef(), StringRef(), getOrCreateFile(
Loc),
5920getLineNumber(
Loc), getOrCreateType(S->getType(),
File),
true);
5921GV->addDebugInfo(Debug);
5924llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(
const Decl*
D) {
5925 if(!LexicalBlockStack.empty())
5926 returnLexicalBlockStack.back();
5927llvm::DIScope *Mod = getParentModuleOrNull(
D);
5928 returngetContextDescriptor(
D, Mod ? Mod : TheCU);
5940DBuilder.createImportedModule(
5942getOrCreateNamespace(NSDecl), getOrCreateFile(
Loc), getLineNumber(
Loc));
5947 if(llvm::DINode *
Target=
5950DBuilder.createImportedDeclaration(
5952getOrCreateFile(
Loc), getLineNumber(
Loc));
5960 "We shouldn't be codegening an invalid UsingDecl containing no decls");
5962 for(
const auto*USD : UD.
shadows()) {
5967 if(
const auto*FD = dyn_cast<FunctionDecl>(USD->getUnderlyingDecl()))
5968 if(
const auto*AT = FD->getType()
5971 if(AT->getDeducedType().isNull())
5985 "We shouldn't be codegening an invalid UsingEnumDecl" 5986 " containing no decls");
5988 for(
const auto*USD : UD.
shadows())
5993 if(CGM.
getCodeGenOpts().getDebuggerTuning() != llvm::DebuggerKind::LLDB)
5995 if(
Module*M = ID.getImportedModule()) {
5997 auto Loc= ID.getLocation();
5998DBuilder.createImportedDeclaration(
5999getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
6000getOrCreateModuleRef(Info, DebugTypeExtRefs), getOrCreateFile(
Loc),
6001getLineNumber(
Loc));
6005llvm::DIImportedEntity *
6009 auto&VH = NamespaceAliasCache[&NA];
6011 returncast<llvm::DIImportedEntity>(VH);
6012llvm::DIImportedEntity *R;
6014 if(
const auto*Underlying =
6017R = DBuilder.createImportedDeclaration(
6022R = DBuilder.createImportedDeclaration(
6025getOrCreateFile(
Loc), getLineNumber(
Loc), NA.
getName());
6031CGDebugInfo::getOrCreateNamespace(
const NamespaceDecl*NSDecl) {
6035 autoI = NamespaceCache.find(NSDecl);
6036 if(I != NamespaceCache.end())
6037 returncast<llvm::DINamespace>(I->second);
6039llvm::DIScope *Context = getDeclContextDescriptor(NSDecl);
6041llvm::DINamespace *NS =
6042DBuilder.createNameSpace(Context, NSDecl->
getName(), NSDecl->
isInline());
6043NamespaceCache[NSDecl].reset(NS);
6048assert(TheCU &&
"no main compile unit");
6049TheCU->setDWOId(Signature);
6055 for(
size_ti = 0; i != ObjCInterfaceCache.size(); ++i) {
6056ObjCInterfaceCacheEntry
E= ObjCInterfaceCache[i];
6057llvm::DIType *Ty =
E.Type->getDecl()->getDefinition()
6058? CreateTypeDefinition(
E.Type,
E.Unit)
6060DBuilder.replaceTemporary(llvm::TempDIType(
E.Decl), Ty);
6064 for(
const auto&
P: ObjCMethodCache) {
6065 if(
P.second.empty())
6068 QualTypeQTy(
P.first->getTypeForDecl(), 0);
6070assert(It != TypeCache.end());
6072llvm::DICompositeType *InterfaceDecl =
6073cast<llvm::DICompositeType>(It->second);
6075 autoCurElts = InterfaceDecl->getElements();
6079 for(
auto&SubprogramDirect :
P.second)
6080 if(CGM.
getCodeGenOpts().DwarfVersion >= 5 || SubprogramDirect.getInt())
6081EltTys.push_back(SubprogramDirect.getPointer());
6083llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
6084DBuilder.replaceArrays(InterfaceDecl, Elements);
6087 for(
const auto&
P: ReplaceMap) {
6089 auto*Ty = cast<llvm::DIType>(
P.second);
6090assert(Ty->isForwardDecl());
6092 autoIt = TypeCache.find(
P.first);
6093assert(It != TypeCache.end());
6096DBuilder.replaceTemporary(llvm::TempDIType(Ty),
6097cast<llvm::DIType>(It->second));
6100 for(
const auto&
P: FwdDeclReplaceMap) {
6102llvm::TempMDNode FwdDecl(cast<llvm::MDNode>(
P.second));
6103llvm::Metadata *Repl;
6105 autoIt = DeclCache.find(
P.first);
6109 if(It == DeclCache.end())
6114 if(
auto*GVE = dyn_cast_or_null<llvm::DIGlobalVariableExpression>(Repl))
6115Repl = GVE->getVariable();
6116DBuilder.replaceTemporary(std::move(FwdDecl), cast<llvm::MDNode>(Repl));
6121 for(
auto&RT : RetainedTypes)
6122 if(
autoMD = TypeCache[RT])
6123DBuilder.retainType(cast<llvm::DIType>(MD));
6125DBuilder.finalize();
6131 if(
auto*DieTy = getOrCreateType(Ty, TheCU->getFile()))
6132DBuilder.retainType(DieTy);
6137 if(
auto*DieTy = getOrCreateType(Ty, TheCU->getFile()))
6138DBuilder.retainType(DieTy);
6142 if(LexicalBlockStack.empty())
6143 returnllvm::DebugLoc();
6145llvm::MDNode *
Scope= LexicalBlockStack.back();
6150llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs()
const{
6154DebugKind == llvm::codegenoptions::NoDebugInfo ||
6155DebugKind == llvm::codegenoptions::LocTrackingOnly)
6156 returnllvm::DINode::FlagZero;
6161 boolSupportsDWARFv4Ext =
6163(CGM.
getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
6164CGM.
getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB);
6166 if(!SupportsDWARFv4Ext && CGM.
getCodeGenOpts().DwarfVersion < 5)
6167 returnllvm::DINode::FlagZero;
6169 returnllvm::DINode::FlagAllCallsDescribed;
6172llvm::DIExpression *
6180 returnDBuilder.createConstantValueExpression(
6181Val.
getFloat().bitcastToAPInt().getZExtValue());
6186llvm::APSInt
const&ValInt = Val.
getInt();
6187std::optional<uint64_t> ValIntOpt;
6188 if(ValInt.isUnsigned())
6189ValIntOpt = ValInt.tryZExtValue();
6190 else if(
autotmp = ValInt.trySExtValue())
6193ValIntOpt =
static_cast<uint64_t
>(*tmp);
6196 returnDBuilder.createConstantValueExpression(ValIntOpt.value());
Defines the clang::ASTContext interface.
static bool IsReconstitutableType(QualType QT)
static void stripUnusedQualifiers(Qualifiers &Q)
static bool hasCXXMangling(const TagDecl *TD, llvm::DICompileUnit *TheCU)
static bool IsArtificial(VarDecl const *VD)
Returns true if VD is a compiler-generated variable and should be treated as artificial for the purpo...
static bool needsTypeIdentifier(const TagDecl *TD, CodeGenModule &CGM, llvm::DICompileUnit *TheCU)
static bool shouldOmitDefinition(llvm::codegenoptions::DebugInfoKind DebugKind, bool DebugTypeExtRefs, const RecordDecl *RD, const LangOptions &LangOpts)
static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access, const RecordDecl *RD)
Convert an AccessSpecifier into the corresponding DINode flag.
static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func)
static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C)
static llvm::dwarf::Tag getTagForRecord(const RecordDecl *RD)
static llvm::SmallVector< TemplateArgument > GetTemplateArgs(const TemplateDecl *TD, const TemplateSpecializationType *Ty)
static bool isFunctionLocalClass(const CXXRecordDecl *RD)
isFunctionLocalClass - Return true if CXXRecordDecl is defined inside a function.
static uint32_t getDeclAlignIfRequired(const Decl *D, const ASTContext &Ctx)
static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I, CXXRecordDecl::method_iterator End)
static bool canUseCtorHoming(const CXXRecordDecl *RD)
static bool hasDefaultGetterName(const ObjCPropertyDecl *PD, const ObjCMethodDecl *Getter)
static bool isClassOrMethodDLLImport(const CXXRecordDecl *RD)
Return true if the class or any of its methods are marked dllimport.
static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx)
static bool hasDefaultSetterName(const ObjCPropertyDecl *PD, const ObjCMethodDecl *Setter)
static bool isDefinedInClangModule(const RecordDecl *RD)
Does a type definition exist in an imported clang module?
static llvm::dwarf::Tag getNextQualifier(Qualifiers &Q)
static bool IsDecomposedVarDecl(VarDecl const *VD)
Returns true if VD is a a holding variable (aka a VarDecl retrieved using BindingDecl::getHoldingVar)...
static SmallString< 256 > getTypeIdentifier(const TagType *Ty, CodeGenModule &CGM, llvm::DICompileUnit *TheCU)
static unsigned getDwarfCC(CallingConv CC)
static bool ReferencesAnonymousEntity(ArrayRef< TemplateArgument > Args)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Target Target
constexpr llvm::StringRef ClangTrapPrefix
static const NamedDecl * getDefinition(const Decl *D)
Defines the SourceManager interface.
Defines version macros and version-related utility functions for Clang.
__device__ __2f16 float c
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getRecordType(const RecordDecl *Decl) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getEnumType(const EnumDecl *Decl) const
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
CanQualType UnsignedLongTy
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedCharTy
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
unsigned getTargetAddressSpace(LangAS AS) const
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
bool hasExtendableVFPtr() const
hasVFPtr - Does this class have a virtual function table pointer that can be extended by a derived cl...
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not.
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
Module * getModuleOrNull() const
ASTFileSignature getSignature() const
StringRef getASTFile() const
StringRef getPath() const
std::string getModuleName() const
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
const BTFTypeTagAttr * getAttr() const
QualType getWrappedType() const
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
shadow_range shadows() const
A binding in a decomposition declaration.
Expr * getBinding() const
Get the expression to which this declaration is bound.
A fixed int type of a specified bitwidth.
A class which contains all the information about a particular captured value.
bool isByRef() const
Whether this is a "by ref" capture, i.e.
Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
VarDecl * getVariable() const
The variable being captured.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
QualType getPointeeType() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a C++ constructor within a class.
Represents a static or instance method of a struct/union/class.
unsigned size_overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isLambda() const
Determine whether this class describes a lambda function object.
capture_const_iterator captures_end() const
method_range methods() const
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
method_iterator method_begin() const
Method begin iterator.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
base_class_range vbases()
bool isDynamicClass() const
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
bool hasDefinition() const
method_iterator method_end() const
Method past-the-end iterator.
capture_const_iterator captures_begin() const
llvm::iterator_range< base_class_const_iterator > base_class_const_range
A wrapper class around a pointer that always points to its canonical declaration.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Represents a class template specialization, which refers to a class template with a given set of temp...
llvm::SmallVector< std::pair< std::string, std::string >, 0 > DebugPrefixMap
std::string CoverageNotesFile
The filename with path we use for coverage notes files.
std::string CoverageDataFile
The filename with path we use for coverage data files.
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
bool hasReducedDebugInfo() const
Check if type and variable info should be emitted.
bool hasMaybeUnusedDebugInfo() const
Check if maybe unused type info should be emitted.
ApplyInlineDebugLocation(CodeGenFunction &CGF, GlobalDecl InlinedFn)
Set up the CodeGenFunction's DebugInfo to produce inline locations for the function InlinedFn.
~ApplyInlineDebugLocation()
Restore everything back to the original state.
unsigned getIndex() const
CGBlockInfo - Information to generate a block literal.
unsigned CXXThisIndex
The field index of 'this' within the block, if there is one.
const BlockDecl * getBlockDecl() const
llvm::StructType * StructureType
const Capture & getCapture(const VarDecl *var) const
virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD)
Get the ABI-specific "this" parameter adjustment to apply in the prologue of a virtual function.
@ RAA_Indirect
Pass it as a pointer to temporary memory.
virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)
Create a null member pointer of the given type.
virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const =0
Returns how an argument of the given record type should be passed.
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)
Create a member pointer for the given method.
MangleContext & getMangleContext()
Gets the mangle context.
llvm::MDNode * getInlinedAt() const
llvm::DIType * getOrCreateStandaloneType(QualType Ty, SourceLocation Loc)
Emit standalone debug info for a type.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate a change in line/column information in the source file.
void EmitGlobalAlias(const llvm::GlobalValue *GV, const GlobalDecl Decl)
Emit information about global variable alias.
void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder)
Emit call to llvm.dbg.label for an label.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
void setInlinedAt(llvm::MDNode *InlinedAt)
Update the current inline scope.
void completeUnusedClass(const CXXRecordDecl &D)
void EmitUsingShadowDecl(const UsingShadowDecl &USD)
Emit a shadow decl brought in by a using or using-enum.
void EmitUsingEnumDecl(const UsingEnumDecl &UD)
Emit C++ using-enum declaration.
void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn)
Constructs the debug code for exiting a function.
void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke, QualType CalleeType, const FunctionDecl *CalleeDecl)
Emit debug info for an extern function being called.
void EmitUsingDecl(const UsingDecl &UD)
Emit C++ using declaration.
llvm::DIMacroFile * CreateTempMacroFile(llvm::DIMacroFile *Parent, SourceLocation LineLoc, SourceLocation FileLoc)
Create debug info for a file referenced by an #include directive.
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD)
void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about an external variable.
void emitFunctionStart(GlobalDecl GD, SourceLocation Loc, SourceLocation ScopeLoc, QualType FnType, llvm::Function *Fn, bool CurFnIsThunk)
Emit a call to llvm.dbg.function.start to indicate start of a new function.
llvm::DILocalVariable * EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder, bool UsePointerValue=false)
Emit call to llvm.dbg.declare for an argument variable declaration.
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the end of a new lexical block and pop the current block.
void EmitUsingDirective(const UsingDirectiveDecl &UD)
Emit C++ using directive.
void completeRequiredType(const RecordDecl *RD)
void EmitAndRetainType(QualType Ty)
Emit the type even if it might not be used.
void EmitInlineFunctionEnd(CGBuilderTy &Builder)
End an inlined function scope.
void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType, llvm::Function *Fn=nullptr)
Emit debug info for a function declaration.
void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV, const StringLiteral *S)
DebugInfo isn't attached to string literals by default.
llvm::DILocalVariable * EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder, const bool UsePointerValue=false)
Emit call to llvm.dbg.declare for an automatic variable declaration.
void completeClassData(const RecordDecl *RD)
void EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD)
Start a new scope for an inlined function.
void EmitImportDecl(const ImportDecl &ID)
Emit an @import declaration.
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, StringRef Name, unsigned ArgNo, llvm::AllocaInst *LocalAddr, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for the block-literal argument to a block invocation function.
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc)
CGDebugInfo(CodeGenModule &CGM)
void completeClass(const RecordDecl *RD)
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the beginning of a new lexical block and push the block onto the stack.
void setLocation(SourceLocation Loc)
Update the current source location.
llvm::DIMacro * CreateMacro(llvm::DIMacroFile *Parent, unsigned MType, SourceLocation LineLoc, StringRef Name, StringRef Value)
Create debug info for a macro defined by a #define directive or a macro undefined by a #undef directi...
llvm::DILocation * CreateTrapFailureMessageFor(llvm::DebugLoc TrapLocation, StringRef Category, StringRef FailureMsg)
Create a debug location from TrapLocation that adds an artificial inline frame where the frame name i...
llvm::DIType * getOrCreateRecordType(QualType Ty, SourceLocation L)
Emit record type's standalone debug info.
void EmitPseudoVariable(CGBuilderTy &Builder, llvm::Instruction *Value, QualType Ty)
Emit a pseudo variable and debug info for an intermediate value if it does not correspond to a variab...
std::string remapDIPath(StringRef) const
Remap a given path with the current debug prefix map.
void EmitExplicitCastType(QualType Ty)
Emit the type explicitly casted to.
void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy, SourceLocation Loc)
Add heapallocsite metadata for MSAllocator calls.
void setDwoId(uint64_t Signature)
Module debugging: Support for building PCMs.
QualType getFunctionType(const FunctionDecl *FD, QualType RetTy, const SmallVectorImpl< const VarDecl * > &Args)
llvm::DIType * getOrCreateInterfaceType(QualType Ty, SourceLocation Loc)
Emit an Objective-C interface type standalone debug info.
void completeType(const EnumDecl *ED)
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint=nullptr)
Emit call to llvm.dbg.declare for an imported variable declaration in a block.
llvm::DIImportedEntity * EmitNamespaceAlias(const NamespaceAliasDecl &NA)
Emit C++ namespace alias.
unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar)
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
CGDebugInfo * getDebugInfo()
This class organizes the cross-function state that is used while generating LLVM code.
const PreprocessorOptions & getPreprocessorOpts() const
ConstantAddress GetAddrOfMSGuidDecl(const MSGuidDecl *GD)
Get the address of a GUID.
llvm::Module & getModule() const
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the given function.
const IntrusiveRefCntPtr< llvm::vfs::FileSystem > & getFileSystem() const
const LangOptions & getLangOpts() const
int getUniqueBlockCount()
Fetches the global unique block count.
CodeGenTypes & getTypes()
const TargetInfo & getTarget() const
const llvm::DataLayout & getDataLayout() const
CGCXXABI & getCXXABI() const
ItaniumVTableContext & getItaniumVTableContext()
ASTContext & getContext() const
ConstantAddress GetAddrOfTemplateParamObject(const TemplateParamObjectDecl *TPO)
Get the address of a template parameter object.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
MicrosoftVTableContext & getMicrosoftVTableContext()
const HeaderSearchOptions & getHeaderSearchOpts() const
const TargetCodeGenInfo & getTargetCodeGenInfo()
const CodeGenOptions & getCodeGenOpts() const
StringRef getMangledName(GlobalDecl GD)
llvm::LLVMContext & getLLVMContext()
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
const GlobalDecl getMangledNameDecl(StringRef)
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
unsigned getTargetAddressSpace(QualType T) const
llvm::Constant * getPointer() const
llvm::Constant * emitAbstract(const Expr *E, QualType T)
Emit the result of the given expression as an abstract constant, asserting that it succeeded.
virtual bool shouldEmitDWARFBitFieldSeparators() const
Complex values, per C99 6.2.5p11.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
bool isObjCZeroArgSelector() const
@ CXXConversionFunctionName
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
bool isObjCOneArgSelector() const
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
static InputKind getInputKindForExtension(StringRef Extension)
getInputKindForExtension - Return the appropriate input kind for a file extension.
Represents a function declaration or definition.
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDeleted() const
Whether this function has been deleted.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
@ TK_FunctionTemplateSpecialization
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
CallingConv getCallConv() const
QualType getReturnType() const
GlobalDecl - represents a global declaration.
GlobalDecl getCanonicalDecl() const
DynamicInitKind getDynamicInitKind() const
const Decl * getDecl() const
QualType getWrappedType() const
One of these records is kept for each identifier that is lexed.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
bool isPreprocessed() const
uint64_t getMethodVTableIndex(GlobalDecl GD)
Locate a virtual function in the vtable.
CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, const CXXRecordDecl *VBase)
Return the offset in chars (relative to the vtable address point) where the offset of the virtual bas...
An lvalue reference type, per C++11 [dcl.ref].
Represents the declaration of a label.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::string ModuleName
The module currently being compiled as specified by -fmodule-name.
clang::ObjCRuntime ObjCRuntime
bool UseTargetPathSeparator
Indicates whether to use target's platform-specific file separator when FILE macro is used and when c...
virtual std::string getLambdaString(const CXXRecordDecl *Lambda)=0
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
QualType getPointeeType() const
const Type * getClass() const
unsigned getVBTableIndex(const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the index of VBase in the vbtable of Derived.
MethodVFTableLocation getMethodVFTableLocation(GlobalDecl GD)
const VTableLayout & getVFTableLayout(const CXXRecordDecl *RD, CharUnits VFPtrOffset)
Describes a module or submodule.
Module * Parent
The parent of this module.
std::string Name
The name of this module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
bool isExternallyVisible() const
Represents a C++ namespace alias.
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
bool isInline() const
Returns true if this is an inline namespace declaration.
ObjCCategoryDecl - Represents a category declaration.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCImplementationDecl * getImplementation() const
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Selector getSelector() const
bool isInstanceMethod() const
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a class type in Objective C.
QualType getBaseType() const
Gets the base type of this object type.
Represents one property declaration in an Objective-C interface.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
Represents a type parameter type in Objective C.
ObjCTypeParamDecl * getDecl() const
Represents a parameter to a function.
QualType getElementType() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void * getAsOpaquePtr() const
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
void removeObjCLifetime()
void removeAddressSpace()
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_iterator field_end() const
field_range fields() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
static SmallString< 64 > constructSetterName(StringRef Name)
Return the default setter name for the given identifier.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
std::string getAsString() const
Derive the full selector name (e.g.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
Stmt - This represents one statement.
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
TagDecl * getDecl() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
virtual std::optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual unsigned getVtblPtrAddressSpace() const
uint64_t getPointerAlign(LangAS AddrSpace) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Stores a list of template parameters for a TemplateDecl and its derived classes.
ArrayRef< NamedDecl * > asArray()
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getAliasedType() const
Get the aliased type, if this is a specialization of a type alias template.
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Represents a declaration of a type.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
bool isIncompleteArrayType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isExtVectorBoolType() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isMemberDataPointerType() const
bool isBitIntType() const
bool isComplexIntegerType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
TypedefNameDecl * getDecl() const
Represents a C++ using-declaration.
Represents C++ using-directive.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Represents a C++ using-enum-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
static bool hasVtableSlot(const CXXMethodDecl *MD)
Determine whether this function should be assigned a vtable slot.
ArrayRef< VTableComponent > vtable_components() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
const Expr * getInit() const
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Declaration of a variable template.
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > blockDecl
Matches block declarations.
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
The JSON file list parser is used to communicate input to InstallAPI.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
@ Result
The result type of a method or function.
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
@ Dtor_Deleting
Deleting dtor.
const FunctionProtoType * T
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Generic
not a target-specific vector type
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ CXXThis
Parameter for C++ 'this' argument.
@ ObjCSelf
Parameter for Objective-C 'self' argument.
std::string getClangFullVersion()
Retrieves a string representing the complete clang version, which includes the clang version number,...
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Structure with information about how a bitfield should be accessed.
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
unsigned Offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
unsigned Size
The total size of the bit-field, in bits.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
unsigned IsSigned
Whether the bit-field is signed.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
unsigned char PointerWidthInBits
The width of a pointer into the generic address space.
EvalResult is a struct with detailed info about an evaluated expression.
Extra information about a function prototype.
uint64_t Index
Method's index in the vftable.
Describes how types, statements, expressions, and declarations should be printed.
unsigned MSVCFormatting
Use whitespace and punctuation like MSVC does.
unsigned SplitTemplateClosers
Whether nested templates must be closed like 'a<b<c> >' rather than 'a<b<c>>'.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
unsigned AlwaysIncludeTypeForTemplateArgument
Whether to use type suffixes (eg: 1U) on integral non-type template parameters.
unsigned UsePreferredNames
Whether to use C++ template preferred_name attributes when printing templates.
unsigned UseEnumerators
Whether to print enumerator non-type template parameters with a matching enumerator name or via cast ...
unsigned SuppressInlineNamespace
Suppress printing parts of scope specifiers that correspond to inline namespaces.
const PrintingCallbacks * Callbacks
Callbacks to use to allow the behavior of printing to be customized.
A this pointer adjustment.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4