Lines Matching +full:capture +full:- +full:sd +full:- +full:lines

1 //===--- CGDebugInfo.cpp - Emit Debug Information for a Module ------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
67 if (auto *Decl = Ty->getAsRecordDecl())
68 if (Decl->hasAttr<MaxFieldAlignmentAttr>())
79 return D->hasAttr<AlignedAttr>() ? D->getMaxAlignment() : 0;
109 auto *DI = CGF->getDebugInfo();
115 OriginalLocation = CGF->Builder.getCurrentDebugLocation();
117 if (OriginalLocation && !DI->CGM.getExpressionLocationsEnabled())
121 DI->EmitLocation(CGF->Builder, TemporaryLocation);
126 CGF->Builder.SetCurrentDebugLocation(llvm::DebugLoc());
131 assert(!DI->LexicalBlockStack.empty());
132 CGF->Builder.SetCurrentDebugLocation(
133 llvm::DILocation::get(DI->LexicalBlockStack.back()->getContext(), 0, 0,
134 DI->LexicalBlockStack.back(), DI->getInlinedAt()));
139 init(E->getExprLoc());
145 this->CGF = nullptr;
157 CGF->Builder.SetCurrentDebugLocation(std::move(OriginalLocation));
164 this->CGF = nullptr;
170 CGF.Builder.getCurrentDebugLocation()->getInlinedAt()) &&
179 auto &DI = *CGF->getDebugInfo();
180 DI.EmitInlineFunctionEnd(CGF->Builder);
181 DI.EmitLocation(CGF->Builder, SavedLocation);
200 if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
206 LBF->getScope(), getOrCreateFile(CurLoc)));
217 return getContextDescriptor(cast<Decl>(D->getDeclContext()),
228 llvm::Metadata *V = I->second;
237 if (!RDecl->isDependentType())
239 TheCU->getFile());
266 // Apply -fdebug-prefix-map.
278 OS << (OMD->isInstanceMethod() ? '-' : '+') << '[';
279 const DeclContext *DC = OMD->getDeclContext();
281 OS << OID->getName();
283 OS << OID->getName();
285 if (OC->IsClassExtension()) {
286 OS << OC->getClassInterface()->getName();
288 OS << OC->getIdentifier()->getNameStart() << '('
289 << OC->getIdentifier()->getNameStart() << ')';
292 OS << OCD->getClassInterface()->getName() << '(' << OCD->getName() << ')';
294 OS << ' ' << OMD->getSelector().getAsString() << ']';
311 if (const IdentifierInfo *II = RD->getIdentifier())
312 return II->getName();
318 if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
319 assert(RD->getDeclContext() == D->getDeclContext() &&
321 assert(D->getDeclName().getAsIdentifierInfo() &&
323 return D->getDeclName().getAsIdentifierInfo()->getName();
333 Name = DD->getName();
338 Name = TND->getName();
342 if (CXXRD->isLambda())
347 SmallString<256> UnnamedType("<unnamed-type-");
371 auto Data = llvm::arrayRefFromStringRef(MemBuffer->getBuffer());
410 FileName = TheCU->getFile()->getFilename();
411 CSInfo = TheCU->getFile()->getChecksum();
417 FileName = TheCU->getFile()->getFilename();
428 if (llvm::Metadata *V = It->second)
455 // current directory and FileName for a more space-efficient encoding.
518 CGM.getFileSystem()->getCurrentWorkingDirectory();
532 // mismatched debug info (a CU with a DW_AT_file of "-", because that's what
544 // The main file name provided via the "-main-file-name" option contains just
551 MainFileDir = std::string(MainFile->getDir().getName());
569 if (MainFile->getName() == MainFileName &&
571 MainFile->getName().rsplit('.').second)
676 switch (BT->getKind()) {
690 "objc_class", TheCU, TheCU->getFile(), 0);
704 "objc_class", TheCU, TheCU->getFile(), 0);
710 ObjTy = DBuilder.createStructType(TheCU, "objc_object", TheCU->getFile(), 0,
716 ObjTy, "isa", TheCU->getFile(), 0, Size, 0, 0,
724 TheCU->getFile(), 0);
753 BT->getKind() == BuiltinType::SveCount
763 assert((BT->getKind() != BuiltinType::SveCount || Info.NumVectors == 1) &&
786 llvm::Type::getInt64Ty(CGM.getLLVMContext()), NumElems - 1));
792 getOrCreateType(Info.ElementType, TheCU->getFile());
833 4096 + 0xC22, // RISC-V VLENB CSR register.
842 // Element max index = count - 1
853 getOrCreateType(Info.ElementType, TheCU->getFile());
865 MangledName, TheCU, TheCU->getFile(), 0); \
875 MangledName, TheCU, TheCU->getFile(), 0); \
956 BTName = BT->getName(CGM.getLangOpts());
964 StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt";
965 llvm::dwarf::TypeKind Encoding = Ty->isUnsigned()
976 if (Ty->isComplexIntegerType())
1031 FunctionProtoType::ExtProtoInfo EPI = F->getExtProtoInfo();
1044 getOrCreateType(CGM.getContext().getFunctionType(F->getReturnType(),
1045 F->getParamTypes(), EPI),
1059 if (Ty->isObjCQualifiedIdType())
1063 Ty->getPointeeType(), Unit);
1069 Ty->getPointeeType(), Unit);
1074 switch (TheCU->getSourceLanguage()) {
1114 if (TD->isExternallyVisible())
1128 const TagDecl *TD = Ty->getDecl();
1133 if (RD->getDefinition())
1134 if (RD->isDynamicClass() &&
1148 if (RD->isStruct() || RD->isInterface())
1150 else if (RD->isUnion())
1155 assert(RD->isClass());
1164 const RecordDecl *RD = Ty->getDecl();
1167 llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
1169 getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
1175 const RecordDecl *D = RD->getDefinition();
1176 if (D && D->isCompleteDefinition())
1185 if (!CXXRD->hasDefinition() ||
1186 (CXXRD->hasDefinition() && !CXXRD->isTrivial()))
1222 StringRef Tag = BTFAttrTy->getAttr()->getBTFTypeTag();
1230 BTFAttrTy = dyn_cast<BTFTagAttributedType>(BTFAttrTy->getWrappedType());
1252 TheCU, TheCU->getFile(), 0);
1280 FType = CGM.getContext().getPointerType(Ty->getPointeeType());
1337 assert(Ty->isTypeAlias());
1346 ArrayRef SubstArgs = Ty->template_arguments();
1347 for (const NamedDecl *Param : TD->getTemplateParameters()->asArray()) {
1349 if (Param->isParameterPack()) {
1375 assert(Ty->isTypeAlias());
1376 llvm::DIType *Src = getOrCreateType(Ty->getAliasedType(), Unit);
1378 const TemplateDecl *TD = Ty->getTemplateName().getAsTemplateDecl();
1382 const auto *AliasDecl = cast<TypeAliasTemplateDecl>(TD)->getTemplatedDecl();
1383 if (AliasDecl->hasAttr<NoDebugAttr>())
1390 Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
1392 SourceLocation Loc = AliasDecl->getLocation();
1396 // https://github.com/llvm/llvm-project/issues/89774
1415 !Ty->isInstantiationDependentType()) {
1417 TemplateArgs Args = {TD->getTemplateParameters(), ArgVector};
1426 TD->getNameForDiagnostic(OS, PP, /*Qualified=*/false);
1442 // FIXME: Once -gsimple-template-names is enabled by default
1447 printTemplateArgumentList(OS, Ty->template_arguments(), PP,
1448 TD->getTemplateParameters());
1460 if (RD && RD->isClass())
1462 else if (RD && (RD->isStruct() || RD->isUnion()))
1484 getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit);
1486 if (Ty->getDecl()->hasAttr<NoDebugAttr>())
1491 SourceLocation Loc = Ty->getDecl()->getLocation();
1493 uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
1495 llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
1498 const DeclContext *DC = Ty->getDecl()->getDeclContext();
1500 Flags = getAccessFlag(Ty->getDecl()->getAccess(), cast<RecordDecl>(DC));
1502 return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
1504 getDeclContextDescriptor(Ty->getDecl()), Align,
1563 if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
1565 if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
1583 EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit));
1592 for (const QualType &ParamType : FPT->param_types())
1594 if (FPT->isVariadic())
1600 EltTypeArray, Flags, getDwarfCC(Ty->getCallConv()));
1607 StringRef Name = BitFieldDecl->getName();
1608 QualType Ty = BitFieldDecl->getType();
1609 if (BitFieldDecl->hasAttr<PreferredTypeAttr>())
1610 Ty = BitFieldDecl->getAttr<PreferredTypeAttr>()->getType();
1611 SourceLocation Loc = BitFieldDecl->getLocation();
1622 assert(SizeInBits > 0 && "found named 0-width bitfield");
1628 // un-reversed offsets.
1630 Offset = BitFieldInfo.StorageSize - BitFieldInfo.Size - Offset;
1632 llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
1647 Add a *single* zero-bitfield separator between two non-zero bitfields
1648 separated by one or more zero-bitfields. This is used to distinguish between
1671 // If we already emitted metadata for a 0-length bitfield, nothing to do here.
1676 if (!PreviousMDField || !PreviousMDField->isBitField() ||
1677 PreviousMDField->getSizeInBits() == 0)
1680 auto PreviousBitfield = RD->field_begin();
1681 std::advance(PreviousBitfield, BitFieldDecl->getFieldIndex() - 1);
1683 assert(PreviousBitfield->isBitField());
1686 if (!PreviousBitfield->isZeroLengthBitField(Context))
1689 QualType Ty = PreviousBitfield->getType();
1690 SourceLocation Loc = PreviousBitfield->getLocation();
1693 llvm::DIScope *RecordTy = BitFieldDI->getScope();
1699 cast<llvm::ConstantInt>(BitFieldDI->getStorageOffsetInBits())
1700 ->getZExtValue();
1703 getAccessFlag(PreviousBitfield->getAccess(), RD);
1723 if (!type->isIncompleteArrayType()) {
1760 // For C++11 Lambdas a Field will be the same as a Capture, but the Capture
1764 RecordDecl::field_iterator Field = CXXDecl->field_begin();
1766 for (CXXRecordDecl::capture_const_iterator I = CXXDecl->captures_begin(),
1767 E = CXXDecl->captures_end();
1772 assert(!Field->isBitField() && "lambdas don't have bitfield members!");
1774 StringRef VName = V->getName();
1778 VName, Field->getType(), Loc, Field->getAccess(),
1787 llvm::DIFile *VUnit = getOrCreateFile(f->getLocation());
1788 QualType type = f->getType();
1792 ThisName, type, f->getLocation(), f->getAccess(),
1805 Var = Var->getCanonicalDecl();
1806 llvm::DIFile *VUnit = getOrCreateFile(Var->getLocation());
1807 llvm::DIType *VTy = getOrCreateType(Var->getType(), VUnit);
1809 unsigned LineNumber = getLineNumber(Var->getLocation());
1810 StringRef VName = Var->getName();
1815 if (Var->getInit()) {
1816 const APValue *Value = Var->evaluateValue();
1818 if (Value->isInt())
1819 C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
1820 if (Value->isFloat())
1821 C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
1825 llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
1832 StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
1840 StringRef name = field->getName();
1841 QualType type = field->getType();
1844 if (name.empty() && !type->isRecordType())
1848 if (field->isBitField()) {
1858 createFieldType(name, type, field->getLocation(), field->getAccess(),
1871 SourceLocation Loc = TD->getLocation();
1882 if (CXXDecl && CXXDecl->isLambda())
1887 // Field number for non-static fields.
1890 // Static and non-static members should appear in the same order as
1892 for (const auto *I : record->decls())
1894 if (V->hasAttr<NoDebugAttr>())
1907 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
1909 assert(MI->second &&
1911 elements.push_back(MI->second);
1928 cast<RecordDecl>(I)->isAnonymousStructOrUnion())
1930 if (!nestedType->isImplicit() &&
1931 nestedType->getDeclContext() == record)
1941 const FunctionProtoType *Func = Method->getType()->getAs<FunctionProtoType>();
1942 if (Method->isStatic())
1945 return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit);
1950 FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
1966 Func->getReturnType(), Func->getParamTypes(), EPI),
1968 llvm::DITypeRefArray Args = OriginalFunc->getTypeArray();
1977 const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl();
1984 getOrCreateType(ThisPtrTy->getPointeeType(), Unit);
2006 return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
2007 getDwarfCC(Func->getCallConv()));
2010 /// isFunctionLocalClass - Return true if CXXRecordDecl is defined
2013 if (const auto *NRD = dyn_cast<CXXRecordDecl>(RD->getDeclContext()))
2015 if (isa<FunctionDecl>(RD->getDeclContext()))
2032 // property to use here. It may've been intended to model "is non-external
2033 // type" but misses cases of non-function-local but non-external classes such
2034 // as those in anonymous namespaces as well as the reverse - external types
2035 // that are function local, such as those in (non-local) inline functions.
2036 if (!IsCtorOrDtor && !isFunctionLocalClass(Method->getParent()))
2042 if (!Method->isImplicit()) {
2043 MethodDefUnit = getOrCreateFile(Method->getLocation());
2044 MethodLine = getLineNumber(Method->getLocation());
2055 if (Method->isPureVirtual())
2076 // C++ ABI does not include all virtual methods from non-primary bases in
2079 if (Method->size_overridden_methods() == 0)
2082 // The 'this' adjustment accounts for both the virtual and non-virtual
2092 if (Method->getCanonicalDecl()->isDeleted())
2095 if (Method->isNoReturn())
2098 if (Method->isStatic())
2100 if (Method->isImplicit())
2102 Flags |= getAccessFlag(Method->getAccess(), Method->getParent());
2104 if (CXXC->isExplicit())
2107 if (CXXC->isExplicit())
2110 if (Method->hasPrototype())
2112 if (Method->getRefQualifier() == RQ_LValue)
2114 if (Method->getRefQualifier() == RQ_RValue)
2116 if (!Method->isExternallyVisible())
2125 completeUnusedClass(*CD->getParent());
2133 SPCache[Method->getCanonicalDecl()].reset(SP);
2145 for (const auto *I : RD->decls()) {
2157 if (!Method || Method->isImplicit() || Method->hasAttr<NoDebugAttr>())
2160 if (Method->getType()->castAs<FunctionProtoType>()->getContainedAutoType())
2167 // This situation can arise in the vtable-based debug info reduction where
2168 // implicit members are emitted in a non-vtable TU.
2169 auto MI = SPCache.find(Method->getCanonicalDecl());
2172 : static_cast<llvm::Metadata *>(MI->second));
2180 CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
2186 CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
2200 cast<CXXRecordDecl>(BI.getType()->castAs<RecordType>()->getDecl());
2210 // virtual base offset offset is -ve. The code generator emits dwarf
2212 BaseOffset = 0 - CGM.getItaniumVTableContext()
2229 // BI->isVirtual() and bits when not.
2250 Name = Args.TList->getParam(i)->getName();
2273 !D->hasAttr<CUDADeviceAttr>()) {
2281 MD && MD->isImplicitObjectMemberFunction())
2289 // These five lines (& possibly the above member function pointer
2299 if (T->isRecordType())
2301 SourceLocation(), TPO->getValue(), TPO->getType());
2306 V = V->stripPointerCasts();
2315 // Special case member data pointer null values since they're actually -1
2320 // CodeGen grows handling for values of non-null member function
2323 if (MPT->isMemberDataPointer())
2341 TA.getAsTemplate().getAsTemplateDecl()->printQualifiedName(
2354 QualType T = E->getType();
2355 if (E->isGLValue())
2361 TheCU, Name, TTy, defaultParameter, V->stripPointerCasts()));
2375 if (FD->getTemplatedKind() ==
2377 const TemplateParameterList *TList = FD->getTemplateSpecializationInfo()
2378 ->getTemplate()
2379 ->getTemplateParameters();
2380 return {{TList, FD->getTemplateSpecializationArgs()->asArray()}};
2392 VarTemplateDecl *T = TS->getSpecializedTemplate();
2393 const TemplateParameterList *TList = T->getTemplateParameters();
2394 auto TA = TS->getTemplateArgs().asArray();
2404 TSpecial->getSpecializedTemplate()->getTemplateParameters();
2405 const TemplateArgumentList &TAList = TSpecial->getTemplateArgs();
2428 if (!D->hasAttr<BTFDeclTagAttr>())
2432 for (const auto *I : D->specific_attrs<BTFDeclTagAttr>()) {
2435 llvm::MDString::get(CGM.getLLVMContext(), I->getBTFDeclTag())};
2464 return internString("_vptr$", RD->getNameAsString());
2474 return InitFn->getName();
2485 VD->printQualifiedName(OS, getPrintingPolicy());
2512 printTemplateArgumentList(OS, VTpl->getTemplateArgs().asArray(),
2524 if (!RD->isDynamicClass())
2547 VFTLayout.vtable_components().size() - CGM.getLangOpts().RTTIData;
2606 if (AllocatedTy->isVoidType())
2611 CI->setMetadata("heapallocsite", node);
2620 if (I == TypeCache.end() || !cast<llvm::DIType>(I->second)->isForwardDecl())
2622 llvm::DIType *Res = CreateTypeDefinition(Ty->castAs<EnumType>());
2623 assert(!Res->isForwardDecl());
2635 if (RD->hasAttr<DLLImportAttr>())
2637 for (const CXXMethodDecl *MD : RD->methods())
2638 if (MD->hasAttr<DLLImportAttr>())
2646 if (!RD || !RD->isFromASTFile())
2649 if (!RD->isExternallyVisible() && RD->getName().empty())
2652 if (!CXXDecl->isCompleteDefinition())
2655 auto TemplateKind = CXXDecl->getTemplateSpecializationKind();
2662 Explicit = TD->isExplicitInstantiationOrSpecialization();
2663 if (!Explicit && CXXDecl->getEnclosingNamespaceContext())
2666 if (CXXDecl->field_begin() == CXXDecl->field_end())
2668 if (!CXXDecl->field_begin()->isFromASTFile())
2677 if (CXXRD->isDynamicClass() &&
2683 if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
2695 if (I != TypeCache.end() && !cast<llvm::DIType>(I->second)->isForwardDecl())
2701 auto [Res, PrefRes] = CreateTypeDefinition(Ty->castAs<RecordType>());
2702 assert(!Res->isForwardDecl());
2709 if (FunctionDecl *Tmpl = MD->getInstantiatedFromMemberFunction())
2710 if (!Tmpl->isImplicit() && Tmpl->isThisDeclarationADefinition() &&
2711 !MD->getMemberSpecializationInfo()->isExplicitSpecialization())
2728 if (RD->isLambda() || RD->isAggregate() ||
2729 RD->hasTrivialDefaultConstructor() ||
2730 RD->hasConstexprNonCopyMoveConstructor())
2733 for (const CXXConstructorDecl *Ctor : RD->ctors()) {
2734 if (Ctor->isCopyOrMoveConstructor())
2736 if (!Ctor->isDeleted())
2745 if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
2748 if (auto *ES = RD->getASTContext().getExternalSource())
2749 if (ES->hasExternalDefinitions(RD) == ExternalASTSource::EK_Always)
2759 RD->hasAttr<StandaloneDebugAttr>())
2765 if (!RD->isCompleteDefinitionRequired())
2779 if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
2784 if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
2785 Spec = SD->getSpecializationKind();
2788 hasExplicitMemberDefinition(CXXDecl->method_begin(),
2789 CXXDecl->method_end()))
2807 if (T && T->isForwardDecl())
2812 RecordDecl *RD = Ty->getDecl();
2831 auto const *PNA = RD->getAttr<PreferredNameAttr>();
2835 return getOrCreateType(PNA->getTypedefType(), Unit);
2840 RecordDecl *RD = Ty->getDecl();
2843 llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
2853 const RecordDecl *D = RD->getDefinition();
2854 if (!D || !D->isCompleteDefinition())
2862 RegionMap[Ty->getDecl()].reset(FwdDecl);
2884 RegionMap.erase(Ty->getDecl());
2889 if (FwdDecl->isTemporary())
2893 RegionMap[Ty->getDecl()].reset(FwdDecl);
2905 return getOrCreateType(Ty->getBaseType(), Unit);
2911 SourceLocation Loc = Ty->getDecl()->getLocation();
2915 getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
2916 Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
2917 getDeclContextDescriptor(Ty->getDecl()));
2927 assert(Getter->getDeclName().isObjCZeroArgSelector());
2928 return PD->getName() ==
2929 Getter->getDeclName().getObjCSelector().getNameForSlot(0);
2939 assert(Setter->getDeclName().isObjCOneArgSelector());
2940 return SelectorTable::constructSetterName(PD->getName()) ==
2941 Setter->getDeclName().getObjCSelector().getNameForSlot(0);
2946 ObjCInterfaceDecl *ID = Ty->getDecl();
2953 if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition() &&
2954 !ID->getImplementation())
2956 ID->getName(),
2960 llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
2961 unsigned Line = getLineNumber(ID->getLocation());
2963 static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
2965 // If this is just a forward declaration return a special forward-declaration
2967 ObjCInterfaceDecl *Def = ID->getDefinition();
2968 if (!Def || !Def->getImplementation()) {
2971 llvm::dwarf::DW_TAG_structure_type, ID->getName(), Mod ? Mod : TheCU,
2988 return cast<llvm::DIModule>(ModRef->second);
2990 // Macro definitions that were defined with "-D" on the command line.
3002 OS << "\"-" << (Undef ? 'U' : 'D');
3018 bool IsRootModule = M ? !M->Parent : true;
3019 // When a module name is specified as -fmodule-name, that module gets a
3023 assert(StringRef(M->Name).starts_with(CGM.getLangOpts().ModuleName) &&
3024 "clang module without ASTFile must be specified by -fmodule-name");
3027 auto RemapPath = [this](StringRef Path) -> std::string {
3030 StringRef CompDir = TheCU->getDirectory();
3039 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
3058 TheCU->getSourceLanguage(),
3060 DIB.createFile(Mod.getModuleName(), TheCU->getDirectory()),
3061 TheCU->getProducer(), false, StringRef(), 0, RemapPath(PCM),
3068 : getOrCreateModuleRef(ASTSourceDescriptor(*M->Parent),
3080 ObjCInterfaceDecl *ID = Ty->getDecl();
3081 llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
3082 unsigned Line = getLineNumber(ID->getLocation());
3083 unsigned RuntimeLang = TheCU->getSourceLanguage();
3090 if (ID->getImplementation())
3095 Mod ? Mod : Unit, ID->getName(), DefUnit, Line, Size, Align, Flags,
3103 RegionMap[Ty->getDecl()].reset(RealDecl);
3108 ObjCInterfaceDecl *SClass = ID->getSuperClass();
3122 SourceLocation Loc = PD->getLocation();
3125 ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
3126 ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
3128 PD->getName(), PUnit, PLine,
3130 : getSelectorName(PD->getGetterName()),
3132 : getSelectorName(PD->getSetterName()),
3133 PD->getPropertyAttributes(), getOrCreateType(PD->getType(), PUnit));
3146 return std::make_pair(PD->isClassProperty(), PD->getIdentifier());
3148 for (const ObjCCategoryDecl *ClassExt : ID->known_extensions())
3149 for (auto *PD : ClassExt->properties()) {
3153 for (const auto *PD : ID->properties()) {
3164 for (ObjCIvarDecl *Field = ID->all_declared_ivar_begin(); Field;
3165 Field = Field->getNextIvar(), ++FieldNo) {
3166 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
3170 StringRef FieldName = Field->getName();
3177 llvm::DIFile *FieldDefUnit = getOrCreateFile(Field->getLocation());
3178 unsigned FieldLine = getLineNumber(Field->getLocation());
3179 QualType FType = Field->getType();
3183 if (!FType->isIncompleteArrayType()) {
3186 FieldSize = Field->isBitField()
3187 ? Field->getBitWidthValue(CGM.getContext())
3195 // non-fragile ABI. For bitfields, use the bit offset into the first
3197 if (Field->isBitField()) {
3209 if (Field->getAccessControl() == ObjCIvarDecl::Protected)
3211 else if (Field->getAccessControl() == ObjCIvarDecl::Private)
3213 else if (Field->getAccessControl() == ObjCIvarDecl::Public)
3216 if (Field->isBitField())
3220 if (ObjCImplementationDecl *ImpD = ID->getImplementation()) {
3222 ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) {
3223 if (ObjCPropertyDecl *PD = PImpD->getPropertyDecl()) {
3224 SourceLocation Loc = PD->getLocation();
3227 ObjCMethodDecl *Getter = PImpD->getGetterMethodDecl();
3228 ObjCMethodDecl *Setter = PImpD->getSetterMethodDecl();
3230 PD->getName(), PUnit, PLine,
3233 : getSelectorName(PD->getGetterName()),
3236 : getSelectorName(PD->getSetterName()),
3237 PD->getPropertyAttributes(),
3238 getOrCreateType(PD->getType(), PUnit));
3257 if (Ty->isExtVectorBoolType()) {
3271 return CreateType(CharVecTy->getAs<VectorType>(), Unit);
3274 llvm::DIType *ElementTy = getOrCreateType(Ty->getElementType(), Unit);
3275 int64_t Count = Ty->getNumElements();
3282 SizeExpr->getSecond() /*count*/, nullptr /*lowerBound*/,
3287 llvm::Type::getInt64Ty(CGM.getLLVMContext()), Count ? Count : -1));
3305 llvm::DIType *ElementTy = getOrCreateType(Ty->getElementType(), Unit);
3313 llvm::Type::getInt64Ty(CGM.getLLVMContext()), Ty->getNumColumns()));
3316 llvm::Type::getInt64Ty(CGM.getLLVMContext()), Ty->getNumRows()));
3336 } else if (Ty->isIncompleteArrayType()) {
3338 if (Ty->getElementType()->isIncompleteType())
3341 Align = getTypeAlignIfRequired(Ty->getElementType(), CGM.getContext());
3342 } else if (Ty->isIncompleteType()) {
3358 // it's -1. This allows us to represent a subrange with an array of 0
3364 int64_t Count = -1; // Count == -1 is an unbounded array.
3366 Count = CAT->getZExtSize();
3368 if (Expr *Size = VAT->getSizeExpr()) {
3370 if (Size->EvaluateAsInt(Result, CGM.getContext()))
3378 SizeNode->getSecond() /*count*/, nullptr /*lowerBound*/,
3388 EltTy = Ty->getElementType();
3400 Ty->getPointeeType(), Unit);
3411 return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
3419 if (!Ty->isIncompleteType()) {
3424 switch (Ty->getMostRecentCXXRecordDecl()->getMSInheritanceModel()) {
3440 llvm::DIType *ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U);
3441 if (Ty->isMemberDataPointerType())
3443 getOrCreateType(Ty->getPointeeType(), U), ClassType, Size, /*Align=*/0,
3447 Ty->getPointeeType()->castAs<FunctionProtoType>();
3450 CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()),
3456 auto *FromTy = getOrCreateType(Ty->getValueType(), U);
3461 return getOrCreateType(Ty->getElementType(), U);
3465 const EnumDecl *ED = Ty->getDecl();
3469 if (!ED->getTypeForDecl()->isIncompleteType()) {
3470 Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
3477 DebugTypeExtRefs && ED->isFromASTFile() && ED->getDefinition();
3481 if (isImportedFromModule || !ED->getDefinition()) {
3489 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
3493 unsigned Line = getLineNumber(ED->getLocation());
3494 StringRef EDName = ED->getName();
3509 const EnumDecl *ED = Ty->getDecl();
3512 if (!ED->getTypeForDecl()->isIncompleteType()) {
3513 Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
3520 ED = ED->getDefinition();
3521 for (const auto *Enum : ED->enumerators()) {
3523 DBuilder.createEnumerator(Enum->getName(), Enum->getInitVal()));
3529 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
3530 unsigned Line = getLineNumber(ED->getLocation());
3532 llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
3534 EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy,
3535 /*RunTimeLang=*/0, Identifier, ED->isScoped());
3565 createInlinedTrapSubprogram(FuncName, TrapLocation->getFile());
3579 switch (T->getTypeClass()) {
3584 if (Spec->isTypeAlias())
3586 T = Spec->desugar();
3590 T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType();
3593 T = cast<TypeOfType>(T)->getUnmodifiedType();
3596 T = cast<DecltypeType>(T)->getUnderlyingType();
3599 T = cast<UnaryTransformType>(T)->getUnderlyingType();
3602 T = cast<AttributedType>(T)->getEquivalentType();
3605 T = cast<BTFTagAttributedType>(T)->getWrappedType();
3608 T = cast<CountAttributedType>(T)->desugar();
3611 T = cast<ElaboratedType>(T)->getNamedType();
3614 T = cast<UsingType>(T)->getUnderlyingType();
3617 T = cast<ParenType>(T)->getInnerType();
3620 T = cast<MacroQualifiedType>(T)->getUnderlyingType();
3623 T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
3627 QualType DT = cast<DeducedType>(T)->getDeducedType();
3633 T = cast<PackIndexingType>(T)->getSelectedType();
3639 T = cast<AdjustedType>(T)->getAdjustedType();
3653 if (llvm::Metadata *V = It->second)
3661 const ClassTemplateSpecializationDecl &SD) {
3662 completeUnusedClass(SD);
3704 if (isa<RecordDecl>(D) && !cast<RecordDecl>(D)->getDefinition())
3706 if (DebugTypeExtRefs && D->isFromASTFile()) {
3709 auto Idx = D->getOwningModuleID();
3710 auto Info = Reader->getSourceDescriptor(Idx);
3719 // like the output of -fno-standalone-debug). On the other hand,
3724 if (Module *M = D->getOwningModule()) {
3725 // This is a (sub-)module.
3743 switch (Ty->getTypeClass()) {
3836 // a non-forward decl. Go ahead and create a non-forward decl
3838 if (T && !T->isForwardDecl())
3847 DBuilder.replaceArrays(Res, T ? T->getElements() : llvm::DINodeArray());
3856 RecordDecl *RD = Ty->getDecl();
3860 const SourceLocation Loc = RD->getLocation();
3874 if (T && (!T->isForwardDecl() || !RD->getDefinition()))
3879 const RecordDecl *D = RD->getDefinition();
3880 if (!D || !D->isCompleteDefinition())
3901 // Record if a C++ record is non-trivial type.
3902 if (!CXXRD->isTrivial())
3906 if (CXXRD->isAnonymousStructOrUnion())
3909 Flags |= getAccessFlag(CXXRD->getAccess(),
3910 dyn_cast<CXXRecordDecl>(CXXRD->getDeclContext()));
3920 switch (RealDecl->getTag()) {
3929 // them distinct if they are ODR-uniqued.
3943 RegionMap[Ty->getDecl()].reset(RealDecl);
3958 // Seek non-virtual primary base root.
3967 ContainingType = getOrCreateType(QualType(PBase->getTypeForDecl(), 0),
3968 getOrCreateFile(RD->getLocation()));
3969 } else if (RD->isDynamicClass())
3996 if (FD->getType()->getAs<FunctionProtoType>())
3998 if (FD->hasPrototype())
4017 dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
4020 dyn_cast_or_null<RecordDecl>(FD->getDeclContext())) {
4026 // Check if it is a noreturn-marked function
4027 if (FD->isNoReturn())
4039 Unit = getOrCreateFile(VD->getLocation());
4040 LineNo = getLineNumber(VD->getLocation());
4042 setLocation(VD->getLocation());
4044 T = VD->getType();
4045 if (T->isIncompleteArrayType()) {
4048 QualType ET = CGM.getContext().getAsArrayType(T)->getElementType();
4054 Name = VD->getName();
4055 if (VD->getDeclContext() && !isa<FunctionDecl>(VD->getDeclContext()) &&
4056 !isa<ObjCMethodDecl>(VD->getDeclContext()))
4071 // FIXME: Generalize this for even non-member global variables where the
4073 // we have support for emitting declarations of (non-member) global variables.
4074 const DeclContext *DC = VD->isStaticDataMember() ? VD->getLexicalDeclContext()
4075 : VD->getDeclContext();
4076 // When a record type contains an in-line initialization of a static data
4082 if (DC->isRecord())
4095 SourceLocation Loc = GD.getDecl()->getLocation();
4105 for (const ParmVarDecl *Parm : FD->parameters())
4106 ArgTypes.push_back(Parm->getType());
4108 CallingConv CC = FD->getType()->castAs<FunctionType>()->getCallConv();
4110 FD->getReturnType(), ArgTypes, FunctionProtoType::ExtProtoInfo(CC));
4111 if (!FD->isExternallyVisible())
4129 const FunctionDecl *CanonDecl = FD->getCanonicalDecl();
4148 SourceLocation Loc = VD->getLocation();
4159 !VD->isExternallyVisible(), nullptr, TemplateParameters, Align);
4162 std::make_tuple(cast<VarDecl>(VD->getCanonicalDecl())),
4168 // We only need a declaration (not a definition) of the type - so use whatever
4174 getOrCreateFile(TD->getLocation()));
4175 auto I = DeclCache.find(D->getCanonicalDecl());
4178 auto N = I->second;
4180 return GVE->getVariable();
4186 auto IE = ImportedDeclCache.find(D->getCanonicalDecl());
4189 auto N = IE->second;
4216 auto MI = SPCache.find(FD->getCanonicalDecl());
4218 if (const auto *MD = dyn_cast<CXXMethodDecl>(FD->getCanonicalDecl())) {
4219 return CreateCXXMemberFunction(MD, getOrCreateFile(MD->getLocation()),
4224 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
4225 if (SP && !SP->isDefinition())
4229 for (auto *NextFD : FD->redecls()) {
4230 auto MI = SPCache.find(NextFD->getCanonicalDecl());
4232 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(MI->second);
4233 if (SP && !SP->isDefinition())
4250 if (CGM.getCodeGenOpts().DwarfVersion < 5 && !OMD->isDirectMethod())
4253 if (OMD->isDirectMethod())
4258 auto *ID = dyn_cast_or_null<ObjCInterfaceDecl>(D->getDeclContext());
4260 ID = OMD->getClassInterface();
4263 QualType QTy(ID->getTypeForDecl(), 0);
4267 auto *InterfaceType = cast<llvm::DICompositeType>(It->second);
4270 InterfaceType->getFile(), LineNo, FnType, LineNo, Flags, SPFlags);
4272 ObjCMethodCache[ID].push_back({FD, OMD->isDirectMethod()});
4276 // getOrCreateFunctionType - Construct type. If it is a c++ method, include
4285 // Create fake but valid subroutine type. Otherwise -verify would fail, and
4293 const auto *FTy = FnType->getAs<FunctionType>();
4294 CallingConv CC = FTy ? FTy->getCallConv() : CallingConv::CC_C;
4301 QualType ResultTy = OMethod->getReturnType();
4306 QualType(OMethod->getClassInterface()->getTypeForDecl(), 0));
4311 if (auto *SelfDecl = OMethod->getSelfDecl())
4312 SelfDeclTy = SelfDecl->getType();
4314 if (FPT->getNumParams() > 1)
4315 SelfDeclTy = FPT->getParamType(0);
4323 for (const auto *PI : OMethod->parameters())
4324 Elts.push_back(getOrCreateType(PI->getType(), F));
4326 if (OMethod->isVariadic())
4337 if (FD->isVariadic()) {
4339 EltTys.push_back(getOrCreateType(FD->getReturnType(), F));
4341 for (QualType ParamType : FPT->param_types())
4357 if (const auto *SrcFnTy = FD->getType()->getAs<FunctionType>())
4358 CC = SrcFnTy->getCallConv();
4361 ArgTypes.push_back(VD->getType());
4384 LinkageName = Fn->getName();
4387 auto FI = SPCache.find(FD->getCanonicalDecl());
4389 auto *SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
4390 if (SP && SP->isDefinition()) {
4407 Name = Fn->getName();
4421 if (!HasDecl || D->isImplicit() || D->hasAttr<ArtificialAttr>() ||
4431 if (Fn->hasLocalLinkage())
4461 Fn->setSubprogram(SP);
4466 DeclCache[D->getCanonicalDecl()].reset(SP);
4507 if (D->isImplicit()) {
4530 llvm::DITypeRefArray ParamTypes = STy->getTypeArray();
4532 for (ParmVarDecl *PD : FD->parameters()) {
4535 SP, PD->getName(), ArgNo, Unit, LineNo, ParamTypes[ArgNo], true,
4543 Fn->setSubprogram(SP);
4553 auto *Func = CallOrInvoke->getCalledFunction();
4556 if (Func->getSubprogram())
4561 if (CalleeDecl->hasAttr<NoDebugAttr>() ||
4568 if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
4569 EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
4575 auto FI = SPCache.find(FD->getCanonicalDecl());
4578 SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
4579 if (!SP || !SP->isDefinition())
4584 EmitLocation(Builder, FD->getLocation());
4671 if (Fn && Fn->getSubprogram())
4672 DBuilder.finalizeSubprogram(Fn->getSubprogram());
4683 llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
4684 QualType Type = VD->getType();
4718 CharUnits NumPaddingBytes = AlignedOffsetInBytes - FieldOffsetInBytes;
4735 Unit, VD->getName(), Unit, 0, FieldSize, FieldAlign, FieldOffset,
4753 if (VD->hasAttr<NoDebugAttr>())
4757 VD->isImplicit() || (isa<Decl>(VD->getDeclContext()) &&
4758 cast<Decl>(VD->getDeclContext())->isImplicit());
4761 Unit = getOrCreateFile(VD->getLocation());
4764 if (VD->hasAttr<BlocksAttr>())
4767 Ty = getOrCreateType(VD->getType(), Unit);
4778 Line = getLineNumber(VD->getLocation());
4779 Column = getColumnNumber(VD->getLocation());
4783 if (VD->isImplicit())
4788 unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(VD->getType());
4794 if (IPD->getParameterKind() == ImplicitParamKind::CXXThis ||
4795 IPD->getParameterKind() == ImplicitParamKind::ObjCSelf)
4804 StringRef Name = VD->getName();
4808 if (VD->isEscapingByref()) {
4822 } else if (const auto *RT = dyn_cast<RecordType>(VD->getType())) {
4825 const RecordDecl *RD = RT->getDecl();
4826 if (RD->isUnion() && RD->isAnonymousStructOrUnion()) {
4834 for (const auto *Field : RD->fields()) {
4835 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
4836 StringRef FieldName = Field->getName();
4839 if (FieldName.empty() && !isa<RecordType>(Field->getType()))
4882 auto RemapCoroArgToLocalVar = [&]() -> llvm::DILocalVariable * {
4883 // The scope of parameter and move-parameter should be distinct
4885 if (!isa<llvm::DISubprogram>(Scope) || !Scope->isDistinct())
4891 DeclGroupRef DeclGroup = DeclStmtPtr->getDeclGroup();
4900 ParmVarDecl *PD = const_cast<ParmVarDecl *>(Iter->first);
4902 return DbgPair.first == PD && DbgPair.second->getScope() == Scope;
4905 return const_cast<llvm::DILocalVariable *>(Iter2->second);
4933 if (BD->hasAttr<NoDebugAttr>())
4937 if (isa<DeclRefExpr>(BD->getBinding()))
4940 llvm::DIFile *Unit = getOrCreateFile(BD->getLocation());
4941 llvm::DIType *Ty = getOrCreateType(BD->getType(), Unit);
4949 unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(BD->getType());
4963 unsigned Line = getLineNumber(BD->getLocation());
4964 unsigned Column = getColumnNumber(BD->getLocation());
4965 StringRef Name = BD->getName();
4972 if (const MemberExpr *ME = dyn_cast<MemberExpr>(BD->getBinding())) {
4973 if (const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
4974 const unsigned fieldIndex = FD->getFieldIndex();
4976 (const CXXRecordDecl *)FD->getParent();
4980 if (FD->isBitField()) {
4982 CGM.getTypes().getCGRecordLayout(FD->getParent());
4998 const uint64_t TypeSize = CGM.getContext().getTypeSize(BD->getType());
5002 "Unexpected non-bitfield with non-byte-aligned offset");
5009 dyn_cast<ArraySubscriptExpr>(BD->getBinding())) {
5010 if (const IntegerLiteral *IL = dyn_cast<IntegerLiteral>(ASE->getIdx())) {
5011 const uint64_t value = IL->getValue().getZExtValue();
5012 const uint64_t typeSize = CGM.getContext().getTypeSize(BD->getType());
5039 for (auto *B : DD->bindings()) {
5041 VD->getType()->isReferenceType());
5055 if (D->hasAttr<NoDebugAttr>())
5059 llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
5062 unsigned Line = getLineNumber(D->getLocation());
5063 unsigned Column = getColumnNumber(D->getLocation());
5065 StringRef Name = D->getName();
5094 if (VD->hasAttr<NoDebugAttr>())
5097 bool isByRef = VD->hasAttr<BlocksAttr>();
5100 llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
5105 Ty = getOrCreateType(VD->getType(), Unit);
5107 // Self is passed along as an implicit non-arg variable in a
5110 if (IPD->getParameterKind() == ImplicitParamKind::ObjCSelf)
5111 Ty = CreateSelfType(VD->getType(), Ty);
5115 getLineNumber(VD->getLocation().isValid() ? VD->getLocation() : CurLoc);
5116 unsigned Column = getColumnNumber(VD->getLocation());
5122 ->getElementOffset(blockInfo.getCapture(VD).getIndex()));
5145 cast<llvm::DILocalScope>(LexicalBlockStack.back()), VD->getName(), Unit,
5169 const BlockDecl::Capture *Capture;
5200 auto *FnTy = Block.getBlockExpr()->getFunctionType();
5201 auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar());
5224 SourceLocation loc = blockDecl->getCaretLocation();
5229 // Build the debug-info type for the block literal.
5243 // 'this' capture.
5244 if (blockDecl->capturesCXXThis()) {
5247 blockLayout->getElementOffsetInBits(block.CXXThisIndex);
5248 chunk.Capture = nullptr;
5253 for (const auto &capture : blockDecl->captures()) {
5254 const VarDecl *variable = capture.getVariable();
5255 const CGBlockInfo::Capture &captureInfo = block.getCapture(variable);
5263 blockLayout->getElementOffsetInBits(captureInfo.getIndex());
5264 chunk.Capture = &capture;
5273 const BlockDecl::Capture *capture = Chunk.Capture;
5275 // If we have a null capture, this must be the C++ 'this' capture.
5276 if (!capture) {
5279 cast_or_null<CXXMethodDecl>(blockDecl->getNonClosureContext()))
5280 type = Method->getThisType();
5281 else if (auto *RDecl = dyn_cast<CXXRecordDecl>(blockDecl->getParent()))
5282 type = QualType(RDecl->getTypeForDecl(), 0);
5291 const VarDecl *variable = capture->getVariable();
5292 StringRef name = variable->getName();
5295 if (capture->isByRef()) {
5308 fieldType = createFieldType(name, variable->getType(), loc, AS_public,
5343 if (!D || !D->isStaticDataMember())
5346 auto MI = StaticDataMemberCache.find(D->getCanonicalDecl());
5348 assert(MI->second && "Static data member declaration should still exist");
5349 return MI->second;
5354 auto DC = D->getDeclContext();
5364 for (const auto *Field : RD->fields()) {
5365 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
5366 StringRef FieldName = Field->getName();
5370 if (const auto *RT = dyn_cast<RecordType>(Field->getType()))
5371 GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
5378 Var->hasLocalLinkage());
5379 Var->addDebugInfo(GVE);
5388 // But so long as it's not one of those, it doesn't matter if some sub-type
5389 // of the record (a template parameter) can't be reconstituted - because the
5390 // un-reconstitutable type itself will carry its own name.
5391 const auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl());
5394 if (!RD->getIdentifier())
5399 return ReferencesAnonymousEntity(TSpecial->getTemplateArgs().asArray());
5444 if (T->isBitIntType()) {
5453 if (const auto *ED = dyn_cast<EnumDecl>(ET->getDecl())) {
5454 if (!ED->getIdentifier()) {
5458 if (!ED->isExternallyVisible()) {
5467 Reconstitutable &= !isNoexceptExceptionSpec(FT->getExceptionSpecType());
5468 Reconstitutable &= !FT->getNoReturnAttr();
5493 // Easy to reconstitute - the value of the parameter in the debug
5496 // representational limitation - maybe DWARF could be
5500 // Reference and pointer non-type template parameters point to
5502 // variables) represented as an address - not a reference to the
5504 // possibly impossible to rebuild the original name - looking up
5518 // harder to parse back into a large integer, etc - so punting on
5519 // this for now. Re-parsing the integers back into APInt is
5528 return IsReconstitutableType(TA.getAsExpr()->getType());
5555 auto NameKind = ND->getDeclName().getNameKind();
5573 // annotating them as such - this would remove the ambiguity.
5585 Args && HasReconstitutableArgs(Args->Args) && !IsOperatorOverload;
5591 ND->getNameForDiagnostic(OS, PP, Qualified);
5599 OS << ND->getDeclName();
5602 EncodedOriginalNameOS << ND->getDeclName();
5606 printTemplateArgumentList(OS, Args->Args, PP);
5607 printTemplateArgumentList(EncodedOriginalNameOS, Args->Args, PP);
5611 ND->getNameForDiagnostic(OriginalOS, PP, Qualified);
5622 if (D->hasAttr<NoDebugAttr>())
5631 auto Cached = DeclCache.find(D->getCanonicalDecl());
5633 return Var->addDebugInfo(
5634 cast<llvm::DIGlobalVariableExpression>(Cached->second));
5646 // Attempt to store one global variable for the declaration - even if we
5653 if (T->isUnionType() && DeclName.empty()) {
5654 const RecordDecl *RD = T->castAs<RecordType>()->getDecl();
5655 assert(RD->isAnonymousStructOrUnion() &&
5656 "unnamed non-anonymous struct or union?");
5662 unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(D->getType());
5664 if (D->hasAttr<CUDASharedAttr>())
5667 else if (D->hasAttr<CUDAConstantAttr>())
5676 Var->hasLocalLinkage(), true,
5680 Var->addDebugInfo(GVE);
5682 DeclCache[D->getCanonicalDecl()].reset(GVE);
5687 if (VD->hasAttr<NoDebugAttr>())
5695 llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
5696 StringRef Name = VD->getName();
5697 llvm::DIType *Ty = getOrCreateType(VD->getType(), Unit);
5700 const auto *ED = cast<EnumDecl>(ECD->getDeclContext());
5701 assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?");
5708 if (isa<RecordDecl>(ED->getDeclContext()))
5715 getOrCreateType(QualType(ED->getTypeForDecl(), 0), Unit);
5716 assert (EDTy->getTag() == llvm::dwarf::DW_TAG_enumeration_type);
5723 if (isa<FunctionDecl>(VD->getDeclContext()))
5726 VD = cast<ValueDecl>(VD->getCanonicalDecl());
5728 if (VarD && VarD->isStaticDataMember()) {
5729 auto *RD = cast<RecordDecl>(VarD->getDeclContext());
5756 DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
5764 if (D->hasAttr<NoDebugAttr>())
5768 llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
5769 StringRef Name = D->getName();
5770 llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
5775 DContext, Name, StringRef(), Unit, getLineNumber(D->getLocation()),
5777 Var->addDebugInfo(GVE);
5782 // Only when -g2 or above is specified, debug info for variables will be
5788 llvm::DILocation *DIL = Value->getDebugLoc().get();
5792 llvm::DIFile *Unit = DIL->getFile();
5799 llvm::Value *Var = Load->getPointerOperand();
5803 // variable for type-casted value.
5805 return DbgDeclare->getVariable()->getType() == Type;
5816 if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
5831 if (D->hasAttr<NoDebugAttr>())
5834 auto AliaseeDecl = CGM.getMangledNameDecl(GV->getName());
5838 // FIXME: Aliasee not declared yet - possibly declared later
5854 auto Loc = D->getLocation();
5857 DContext, DI, getOrCreateFile(Loc), getLineNumber(Loc), D->getName());
5865 SourceLocation Loc = S->getStrTokenLoc(0);
5874 getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
5875 GV->addDebugInfo(Debug);
5889 if (!NSDecl->isAnonymousNamespace() ||
5921 if (const auto *FD = dyn_cast<FunctionDecl>(USD->getUnderlyingDecl()))
5922 if (const auto *AT = FD->getType()
5923 ->castAs<FunctionProtoType>()
5924 ->getContainedAutoType())
5925 if (AT->getDeducedType().isNull())
5929 // Emitting one decl is sufficient - debuggers can detect that this is an
5991 return cast<llvm::DINamespace>(I->second);
5996 DBuilder.createNameSpace(Context, NSDecl->getName(), NSDecl->isInline());
6003 TheCU->setDWOId(Signature);
6007 // Creating types might create further types - invalidating the current
6011 llvm::DIType *Ty = E.Type->getDecl()->getDefinition()
6022 QualType QTy(P.first->getTypeForDecl(), 0);
6027 cast<llvm::DICompositeType>(It->second);
6029 auto CurElts = InterfaceDecl->getElements();
6044 assert(Ty->isForwardDecl());
6048 assert(It->second);
6051 cast<llvm::DIType>(It->second));
6066 Repl = It->second;
6069 Repl = GVE->getVariable();
6085 if (auto *DieTy = getOrCreateType(Ty, TheCU->getFile()))
6091 if (auto *DieTy = getOrCreateType(Ty, TheCU->getFile()))
6105 // Call site-related attributes are only useful in optimized programs, and
6112 // Call site-related attributes are available in DWARF v5. Some debuggers,
6113 // while not fully DWARF v5-compliant, may accept these attributes as if they
6130 if (CGM.getContext().getTypeSize(VD->getType()) > 64)