Lines Matching +full:local +full:- +full:bd +full:- +full:address +full:- +full:broken

1 //===- ASTContext.cpp - Context to hold long-lived AST nodes --------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
125 if (D->isImplicit())
130 if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
135 if (VD->isStaticDataMember() &&
136 VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
141 if (CRD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
146 TemplateSpecializationKind TSK = CTSD->getSpecializationKind();
153 if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
158 // decl-specifier-seq of some other declaration, it doesn't get comment
159 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
175 // For Objective-C declarations we generally don't expect to have multiple
186 BaseLocation = D->getBeginLoc();
188 BaseLocation = D->getLocation();
190 if (!D->getLocation().isMacroID()) {
193 const auto *DeclCtx = D->getDeclContext();
203 Decl::castFromDeclContext(DeclCtx)->getLocation().isMacroID())) {
211 Locations.emplace_back(SourceMgr.getSpellingLoc(D->getBeginLoc()));
241 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
242 if ((CommentBehindDecl->isDocumentation() ||
244 CommentBehindDecl->isTrailingComment() &&
252 OffsetCommentBehindDecl->first)) {
263 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
264 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
266 // Check that we actually have a non-member Doxygen comment.
267 if (!(CommentBeforeDecl->isDocumentation() ||
269 CommentBeforeDecl->isTrailingComment())
285 DeclLocDecomp.second - CommentEndOffset);
305 ExternalSource->ReadComments();
317 if (!CommentsInThisFile || CommentsInThisFile->empty())
340 if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate())
344 if (FD->getTemplateSpecializationKind() != TSK_ImplicitInstantiation)
348 if (const FunctionTemplateDecl *FTD = FD->getPrimaryTemplate())
353 FD->getInstantiatedFromMemberFunction())
361 if (VD->isStaticDataMember())
362 if (const VarDecl *MemberDecl = VD->getInstantiatedFromStaticDataMember())
369 if (const ClassTemplateDecl *CTD = CRD->getDescribedClassTemplate())
375 if (CTSD->getSpecializationKind() != TSK_ImplicitInstantiation)
379 PU = CTSD->getSpecializedTemplateOrPartial();
388 CRD->getMemberSpecializationInfo())
389 return *Info->getInstantiatedFrom();
395 if (const EnumDecl *MemberDecl = ED->getInstantiatedFromMemberEnum())
421 return DeclComment->second;
426 const Decl *CanonicalD = D->getCanonicalDecl();
434 *OriginalDecl = RedeclComment->second;
435 auto CommentAtRedecl = DeclRawComments.find(RedeclComment->second);
438 return CommentAtRedecl->second;
444 auto LastCheckedRedecl = [this, CanonicalD]() -> const Decl * {
448 for (const auto Redecl : D->redecls()) {
483 const DeclContext *DC = ObjCMethod->getDeclContext();
485 const ObjCInterfaceDecl *ID = IMD->getClassInterface();
489 for (const auto *Ext : ID->known_extensions()) {
491 Ext->getMethod(ObjCMethod->getSelector(),
492 ObjCMethod->isInstanceMethod()))
505 if (D->isInvalidDecl())
509 SourceLocation Loc = D->getLocation();
512 // The location doesn't have to be precise - we care only about the file.
522 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
523 CommentsInThisFile->rbegin()->second->isAttached())
530 // declaration, but also comments that *follow* the declaration -- thanks to
535 if (D->isInvalidDecl())
552 comments::FullComment *FC = DocComment->parse(*this, PP, D);
553 ParsedComments[D->getCanonicalDecl()] = FC;
563 ThisDeclInfo->CommentDecl = D;
564 ThisDeclInfo->IsFilled = false;
565 ThisDeclInfo->fill();
566 ThisDeclInfo->CommentDecl = FC->getDecl();
567 if (!ThisDeclInfo->TemplateParameters)
568 ThisDeclInfo->TemplateParameters = FC->getDeclInfo()->TemplateParameters;
570 new (*this) comments::FullComment(FC->getBlocks(),
577 return RC ? RC->parse(*this, nullptr, D) : nullptr;
583 if (!D || D->isInvalidDecl())
587 const Decl *Canonical = D->getCanonicalDecl();
593 comments::FullComment *FC = Pos->second;
597 return Pos->second;
607 if (OMD && OMD->isPropertyAccessor())
608 if (const ObjCPropertyDecl *PDecl = OMD->findPropertyDecl())
621 QualType QT = TD->getUnderlyingType();
622 if (const auto *TT = QT->getAs<TagType>())
623 if (const Decl *TD = TT->getDecl())
628 while (IC->getSuperClass()) {
629 IC = IC->getSuperClass();
635 if (const ObjCInterfaceDecl *IC = CD->getClassInterface())
640 if (!(RD = RD->getDefinition()))
642 // Check non-virtual bases.
643 for (const auto &I : RD->bases()) {
649 if (const CXXRecordDecl *NonVirtualBase = Ty->getAsCXXRecordDecl()) {
650 if (!(NonVirtualBase= NonVirtualBase->getDefinition()))
658 for (const auto &I : RD->vbases()) {
664 if (const CXXRecordDecl *VirtualBase = Ty->getAsCXXRecordDecl()) {
665 if (!(VirtualBase= VirtualBase->getDefinition()))
682 comments::FullComment *FC = RC->parse(*this, PP, D);
691 ID.AddInteger(Parm->getDepth());
692 ID.AddInteger(Parm->getPosition());
693 ID.AddBoolean(Parm->isParameterPack());
695 TemplateParameterList *Params = Parm->getTemplateParameters();
696 ID.AddInteger(Params->size());
697 for (TemplateParameterList::const_iterator P = Params->begin(),
698 PEnd = Params->end();
702 ID.AddBoolean(TTP->isParameterPack());
703 if (TTP->isExpandedParameterPack()) {
705 ID.AddInteger(TTP->getNumExpansionParameters());
713 ID.AddBoolean(NTTP->isParameterPack());
714 ID.AddPointer(C.getUnconstrainedType(C.getCanonicalType(NTTP->getType()))
716 if (NTTP->isExpandedParameterPack()) {
718 ID.AddInteger(NTTP->getNumExpansionTypes());
719 for (unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
720 QualType T = NTTP->getExpansionType(I);
744 return Canonical->getParam();
747 TemplateParameterList *Params = TTP->getTemplateParameters();
749 CanonParams.reserve(Params->size());
750 for (TemplateParameterList::const_iterator P = Params->begin(),
751 PEnd = Params->end();
754 // template-parameters are equivalent, constraints are ignored.
758 TTP->getDepth(), TTP->getIndex(), nullptr, false,
759 TTP->isParameterPack(), /*HasTypeConstraint=*/false,
760 TTP->isExpandedParameterPack()
761 ? std::optional<unsigned>(TTP->getNumExpansionParameters())
765 QualType T = getUnconstrainedType(getCanonicalType(NTTP->getType()));
768 if (NTTP->isExpandedParameterPack()) {
771 for (unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
772 ExpandedTypes.push_back(getCanonicalType(NTTP->getExpansionType(I)));
780 NTTP->getDepth(),
781 NTTP->getPosition(), nullptr,
790 NTTP->getDepth(),
791 NTTP->getPosition(), nullptr,
793 NTTP->isParameterPack(),
803 *this, getTranslationUnitDecl(), SourceLocation(), TTP->getDepth(),
804 TTP->getPosition(), TTP->isParameterPack(), nullptr, /*Typename=*/false,
914 if (auto *R = const_cast<ASTRecordLayout *>((I++)->second))
915 R->Destroy(*this);
921 if (auto *R = const_cast<ASTRecordLayout *>((I++)->second))
922 R->Destroy(*this);
929 A->second->~AttrVec();
933 Value.second->~PerModuleInitializers();
966 counts[(unsigned)T->getTypeClass()]++;
1008 ExternalSource->PrintStats();
1018 Listener->RedefinedHiddenDefinition(ND, M);
1020 MergedDefModules[cast<NamedDecl>(ND->getCanonicalDecl())].push_back(M);
1024 auto It = MergedDefModules.find(cast<NamedDecl>(ND->getCanonicalDecl()));
1028 auto &Merged = It->second;
1039 MergedDefModules.find(cast<NamedDecl>(Def->getCanonicalDecl()));
1042 return MergedIt->second;
1056 Initializers.push_back(Source->GetExternalDecl(ID));
1066 auto It = ModuleInitializers.find(ID->getImportedModule());
1073 auto &Imported = *It->second;
1085 Inits->Initializers.push_back(D);
1093 Inits->LazyInitializers.insert(Inits->LazyInitializers.end(),
1102 auto *Inits = It->second;
1103 Inits->resolve(*this);
1104 return Inits->Initializers;
1108 assert(M->isNamedModule());
1126 return Iter->second;
1129 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1130 .first->second;
1151 BuiltinTemplate->setImplicit();
1152 getTranslationUnitDecl()->addDecl(BuiltinTemplate);
1183 NewDecl->setImplicit();
1184 NewDecl->addAttr(TypeVisibilityAttr::CreateImplicit(
1195 NewDecl->setImplicit();
1219 assert((!this->Target || this->Target == &Target) &&
1223 this->Target = &Target;
1224 this->AuxTarget = AuxTarget;
1264 // C11 extension ISO/IEC TS 18661-3
1293 // GNU extension, 128-bit integers.
1300 else // -fshort-wchar makes wchar_t be unsigned.
1305 // C99 (or C++ using -fno-wchar).
1324 // Placeholder type for type-dependent expressions whose type is
1327 // help diagnose failures to properly check for type-dependent
1340 // Placeholder type for pseudo-objects.
1343 // "any" type; useful for debugger-like clients.
1388 (AuxTarget && AuxTarget->hasAArch64SVETypes())) {
1409 if (Target.getTriple().isWasm() && Target.hasFeature("reference-types")) {
1416 (AuxTarget && AuxTarget->getTriple().isAMDGPU())) {
1454 getTranslationUnitDecl()->addDecl(MSGuidTagDecl);
1476 Pos->second->~AttrVec();
1484 assert(Var->isStaticDataMember() && "Not a static data member");
1496 return Pos->second;
1503 assert(Inst->isStaticDataMember() && "Not a static data member");
1504 assert(Tmpl->isStaticDataMember() && "Not a static data member");
1565 assert(!Inst->getDeclName() && "Instantiated field decl is not unnamed");
1566 assert(!Tmpl->getDeclName() && "Template field decl is not unnamed");
1586 return Range.end() - Range.begin();
1592 OverriddenMethods.find(Method->getCanonicalDecl());
1595 return overridden_method_range(Pos->second.begin(), Pos->second.end());
1600 assert(Method->isCanonicalDecl() && Overridden->isCanonicalDecl());
1620 Method->getOverriddenMethods(OverDecls);
1625 assert(!Import->getNextLocalImport() &&
1627 assert(!Import->isFromASTFile() && "Non-local import declaration");
1634 LastLocalImport->setNextLocalImport(Import);
1638 //===----------------------------------------------------------------------===//
1640 //===----------------------------------------------------------------------===//
1642 /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
1645 switch (T->castAs<BuiltinType>()->getKind()) {
1649 return Target->getBFloat16Format();
1651 return Target->getHalfFormat();
1653 return Target->getHalfFormat();
1654 case BuiltinType::Float: return Target->getFloatFormat();
1655 case BuiltinType::Double: return Target->getDoubleFormat();
1657 return Target->getIbm128Format();
1660 return AuxTarget->getLongDoubleFormat();
1661 return Target->getLongDoubleFormat();
1664 return AuxTarget->getFloat128Format();
1665 return Target->getFloat128Format();
1670 unsigned Align = Target->getCharWidth();
1672 const unsigned AlignFromAttr = D->getMaxAlignment();
1685 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1693 QualType T = VD->getType();
1694 if (const auto *RT = T->getAs<ReferenceType>()) {
1696 T = RT->getPointeeType();
1698 T = getPointerType(RT->getPointeeType());
1701 if (T->isFunctionType())
1703 else if (!BaseT->isIncompleteType()) {
1705 // large-array alignment on the target.
1707 unsigned MinWidth = Target->getLargeArrayMinWidth();
1710 Align = std::max(Align, Target->getLargeArrayAlign());
1713 Align = std::max(Align, Target->getLargeArrayAlign());
1718 Align = Target->getCharWidth();
1723 if (VD->hasGlobalStorage() && !ForAlignof) {
1725 !BaseT->isIncompleteType() ? getTypeSize(T.getTypePtr()) : 0;
1731 // a max-field-alignment constraint (#pragma pack). So calculate
1735 const RecordDecl *Parent = Field->getParent();
1737 if (!Parent->isInvalidDecl()) {
1744 uint64_t Offset = Layout.getFieldOffset(Field->getFieldIndex());
1762 if (MaxAlignedAttr && VD && VD->getStorageClass() == SC_Static)
1769 return toCharUnitsFromBits(Target->getExnObjectAlignment());
1772 // getTypeInfoDataSizeInChars - Return the size of a type, in
1780 // of a base-class subobject. We decide whether that's possible
1783 if (const auto *RT = T->getAs<RecordType>();
1784 RT && !RT->getDecl()->isInvalidDecl()) {
1785 const ASTRecordLayout &layout = getASTRecordLayout(RT->getDecl());
1793 /// getConstantArrayInfoInChars - Performing the computation in CharUnits
1798 TypeInfoChars EltInfo = Context.getTypeInfoInChars(CAT->getElementType());
1799 uint64_t Size = CAT->getZExtSize();
1801 (uint64_t)(-1)/Size) &&
1827 // just uses the rank-based promotion rules for all types.
1831 if (const auto *BT = T->getAs<BuiltinType>())
1832 switch (BT->getKind()) {
1852 if (const auto *ET = T->getAs<EnumType>()) {
1853 if (T->isDependentType() || ET->getDecl()->getPromotionType().isNull() ||
1854 ET->getDecl()->isScoped())
1874 if (const auto *TT = T->getAs<TypedefType>())
1875 if (unsigned Align = TT->getDecl()->getMaxAlignment())
1880 if (!T->isIncompleteType())
1885 if (const auto *TT = T->getAs<TypedefType>())
1886 if (unsigned Align = TT->getDecl()->getMaxAlignment())
1890 if (const auto *TT = T->getAs<TagType>())
1891 return TT->getDecl()->getMaxAlignment();
1899 return I->second;
1907 /// getTypeInfoImpl - Return the size of the specified type, in bits. This
1918 switch (T->getTypeClass()) {
1925 assert(!T->isDependentType() && "should not see dependent types here"); \
1926 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
1941 // Model non-constant sized arrays as size zero, but track the alignment.
1944 Size = CAT->getZExtSize();
1946 TypeInfo EltInfo = getTypeInfo(cast<ArrayType>(T)->getElementType());
1947 assert((Size == 0 || EltInfo.Width <= (uint64_t)(-1) / Size) &&
1961 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
1962 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
1963 : EltInfo.Width * VT->getNumElements();
1969 // This happens for non-power-of-2 length vectors.
1970 if (Align & (Align-1)) {
1975 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
1978 if (VT->getVectorKind() == VectorKind::SveFixedLengthData)
1979 // Adjust the alignment for fixed-length SVE vectors. This is important
1980 // for non-power-of-2 vector lengths.
1982 else if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
1983 // Adjust the alignment for fixed-length SVE predicates.
1985 else if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
1986 VT->getVectorKind() == VectorKind::RVVFixedLengthMask)
1987 // Adjust the alignment for fixed-length RVV vectors.
1994 TypeInfo ElementInfo = getTypeInfo(MT->getElementType());
1998 Width = ElementInfo.Width * MT->getNumRows() * MT->getNumColumns();
2004 switch (cast<BuiltinType>(T)->getKind()) {
2012 Width = Target->getBoolWidth();
2013 Align = Target->getBoolAlign();
2020 Width = Target->getCharWidth();
2021 Align = Target->getCharAlign();
2025 Width = Target->getWCharWidth();
2026 Align = Target->getWCharAlign();
2029 Width = Target->getChar16Width();
2030 Align = Target->getChar16Align();
2033 Width = Target->getChar32Width();
2034 Align = Target->getChar32Align();
2038 Width = Target->getShortWidth();
2039 Align = Target->getShortAlign();
2043 Width = Target->getIntWidth();
2044 Align = Target->getIntAlign();
2048 Width = Target->getLongWidth();
2049 Align = Target->getLongAlign();
2053 Width = Target->getLongLongWidth();
2054 Align = Target->getLongLongAlign();
2059 Align = Target->getInt128Align();
2065 Width = Target->getShortAccumWidth();
2066 Align = Target->getShortAccumAlign();
2072 Width = Target->getAccumWidth();
2073 Align = Target->getAccumAlign();
2079 Width = Target->getLongAccumWidth();
2080 Align = Target->getLongAccumAlign();
2086 Width = Target->getShortFractWidth();
2087 Align = Target->getShortFractAlign();
2093 Width = Target->getFractWidth();
2094 Align = Target->getFractAlign();
2100 Width = Target->getLongFractWidth();
2101 Align = Target->getLongFractAlign();
2104 if (Target->hasBFloat16Type()) {
2105 Width = Target->getBFloat16Width();
2106 Align = Target->getBFloat16Align();
2110 AuxTarget->hasBFloat16Type()) {
2111 Width = AuxTarget->getBFloat16Width();
2112 Align = AuxTarget->getBFloat16Align();
2117 if (Target->hasFloat16Type() || !getLangOpts().OpenMP ||
2119 Width = Target->getHalfWidth();
2120 Align = Target->getHalfAlign();
2124 Width = AuxTarget->getHalfWidth();
2125 Align = AuxTarget->getHalfAlign();
2129 Width = Target->getFloatWidth();
2130 Align = Target->getFloatAlign();
2133 Width = Target->getDoubleWidth();
2134 Align = Target->getDoubleAlign();
2137 Width = Target->getIbm128Width();
2138 Align = Target->getIbm128Align();
2142 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2143 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2144 Width = AuxTarget->getLongDoubleWidth();
2145 Align = AuxTarget->getLongDoubleAlign();
2147 Width = Target->getLongDoubleWidth();
2148 Align = Target->getLongDoubleAlign();
2152 if (Target->hasFloat128Type() || !getLangOpts().OpenMP ||
2154 Width = Target->getFloat128Width();
2155 Align = Target->getFloat128Align();
2159 Width = AuxTarget->getFloat128Width();
2160 Align = AuxTarget->getFloat128Align();
2165 Width = Target->getPointerWidth(LangAS::Default);
2166 Align = Target->getPointerAlign(LangAS::Default);
2171 Width = Target->getPointerWidth(LangAS::Default);
2172 Align = Target->getPointerAlign(LangAS::Default);
2185 AS = Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T));
2186 Width = Target->getPointerWidth(AS);
2187 Align = Target->getPointerAlign(AS);
2189 // The SVE types are effectively target-specific. The length of an
2248 Width = Target->getPointerWidth(LangAS::Default);
2249 Align = Target->getPointerAlign(LangAS::Default);
2252 AS = cast<BlockPointerType>(T)->getPointeeType().getAddressSpace();
2253 Width = Target->getPointerWidth(AS);
2254 Align = Target->getPointerAlign(AS);
2260 AS = cast<ReferenceType>(T)->getPointeeType().getAddressSpace();
2261 Width = Target->getPointerWidth(AS);
2262 Align = Target->getPointerAlign(AS);
2265 AS = cast<PointerType>(T)->getPointeeType().getAddressSpace();
2266 Width = Target->getPointerWidth(AS);
2267 Align = Target->getPointerAlign(AS);
2271 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2279 TypeInfo EltInfo = getTypeInfo(cast<ComplexType>(T)->getElementType());
2285 return getTypeInfo(cast<ObjCObjectType>(T)->getBaseType().getTypePtr());
2288 return getTypeInfo(cast<AdjustedType>(T)->getAdjustedType().getTypePtr());
2291 if (ObjCI->getDecl()->isInvalidDecl()) {
2296 const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
2303 Align = Target->getBitIntAlign(EIT->getNumBits());
2304 Width = Target->getBitIntWidth(EIT->getNumBits());
2311 if (TT->getDecl()->isInvalidDecl()) {
2318 const EnumDecl *ED = ET->getDecl();
2320 getTypeInfo(ED->getIntegerType()->getUnqualifiedDesugaredType());
2321 if (unsigned AttrAlign = ED->getMaxAlignment()) {
2329 const RecordDecl *RD = RT->getDecl();
2333 AlignRequirement = RD->hasAttr<AlignedAttr>()
2340 return getTypeInfo(cast<SubstTemplateTypeParmType>(T)->
2346 assert(!A->getDeducedType().isNull() &&
2348 return getTypeInfo(A->getDeducedType().getTypePtr());
2352 return getTypeInfo(cast<ParenType>(T)->getInnerType().getTypePtr());
2356 cast<MacroQualifiedType>(T)->getUnderlyingType().getTypePtr());
2359 return getTypeInfo(cast<ObjCTypeParamType>(T)->desugar().getTypePtr());
2362 return getTypeInfo(cast<UsingType>(T)->desugar().getTypePtr());
2366 TypeInfo Info = getTypeInfo(TT->desugar().getTypePtr());
2370 if (unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2382 return getTypeInfo(cast<ElaboratedType>(T)->getNamedType().getTypePtr());
2386 cast<AttributedType>(T)->getEquivalentType().getTypePtr());
2389 return getTypeInfo(cast<CountAttributedType>(T)->desugar().getTypePtr());
2393 cast<BTFTagAttributedType>(T)->getWrappedType().getTypePtr());
2397 TypeInfo Info = getTypeInfo(cast<AtomicType>(T)->getValueType());
2402 // An otherwise zero-sized type should still generate an
2404 Width = Target->getCharWidth();
2406 } else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2421 Width = Target->getPointerWidth(LangAS::opencl_global);
2422 Align = Target->getPointerAlign(LangAS::opencl_global);
2433 return I->second;
2436 if (const auto *RT = T->getAs<RecordType>()) {
2437 const RecordDecl *RD = RT->getDecl();
2440 } else if (const auto *ObjCI = T->getAs<ObjCInterfaceType>()) {
2441 const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
2444 UnadjustedAlign = getTypeAlign(T->getUnqualifiedDesugaredType());
2453 getTargetInfo().getTriple(), Target->getTargetOpts().FeatureMap);
2457 /// toCharUnitsFromBits - Convert a size in bits to a size in characters.
2462 /// toBits - Convert a size in characters to a size in characters.
2467 /// getTypeSizeInChars - Return the size of the specified type, in characters.
2476 /// getTypeAlignInChars - Return the ABI-specified alignment of a type, in
2485 /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a
2495 /// getPreferredTypeAlign - Return the "preferred" alignment of the specified
2499 /// the preferred alignment is ABI-impacting, and not an optimization.)
2504 T = T->getBaseElementTypeUnsafe();
2507 if (T->isMemberPointerType())
2510 if (!Target->allowsLargerPreferedTypeAlignment())
2513 if (const auto *RT = T->getAs<RecordType>()) {
2514 const RecordDecl *RD = RT->getDecl();
2521 RD->isInvalidDecl())
2534 if (const auto *CT = T->getAs<ComplexType>())
2535 T = CT->getElementType().getTypePtr();
2536 if (const auto *ET = T->getAs<EnumType>())
2537 T = ET->getDecl()->getIntegerType().getTypePtr();
2538 if (T->isSpecificBuiltinType(BuiltinType::Double) ||
2539 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2540 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2541 (T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2542 Target->defaultsToAIXPowerAlignment()))
2551 /// getTargetDefaultAlignForAttributeAligned - Return the default alignment
2558 /// getAlignOfGlobalVar - Return the alignment in bits that should be given
2566 /// getAlignOfGlobalVarInChars - Return the alignment in characters that
2575 // Make the default handling as that of a non-weak definition in the
2577 bool HasNonWeakDef = !VD || (VD->hasDefinition() && !VD->isWeak());
2584 while (const CXXRecordDecl *Base = Layout->getBaseSharingVBPtr()) {
2585 Offset += Layout->getBaseClassOffset(Base);
2596 const CXXRecordDecl *RD = cast<CXXRecordDecl>(MPD->getDeclContext());
2606 ThisAdjustment = -ThisAdjustment;
2610 /// DeepCollectObjCIvars -
2618 if (const ObjCInterfaceDecl *SuperClass = OI->getSuperClass())
2621 llvm::append_range(Ivars, OI->ivars());
2624 for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2625 Iv= Iv->getNextIvar())
2630 /// CollectInheritedProtocols - Collect all protocols in current class and
2637 for (auto *Proto : OI->all_referenced_protocols()) {
2642 for (const auto *Cat : OI->visible_categories())
2645 if (ObjCInterfaceDecl *SD = OI->getSuperClass())
2648 SD = SD->getSuperClass();
2651 for (auto *Proto : OC->protocols()) {
2657 const_cast<ObjCProtocolDecl *>(OP->getCanonicalDecl())).second)
2660 for (auto *Proto : OP->protocols())
2668 assert(RD->isUnion() && "Must be union type");
2669 CharUnits UnionSize = Context.getTypeSizeInChars(RD->getTypeForDecl());
2671 for (const auto *Field : RD->fields()) {
2672 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2675 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2679 return !RD->field_empty();
2702 if (Field->getType()->isRecordType()) {
2703 const RecordDecl *RD = Field->getType()->getAsRecordDecl();
2704 if (!RD->isUnion())
2711 bool IsBitIntType = Field->getType()->isBitIntType();
2712 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2713 !Context.hasUniqueObjectRepresentations(Field->getType(),
2718 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2719 if (Field->isBitField()) {
2722 if (Field->isUnnamedBitField())
2725 int64_t BitfieldSize = Field->getBitWidthValue(Context);
2728 cast<BitIntType>(Field->getType())->getNumBits())
2735 Field->getType(), CheckIfTriviallyCopyable)) {
2772 assert(!RD->isUnion() && "Must be struct/class type");
2777 if (ClassDecl->isDynamicClass())
2781 for (const auto &Base : ClassDecl->bases()) {
2782 // Empty types can be inherited from, and non-empty types can potentially
2784 Bases.emplace_back(Base.getType()->getAsCXXRecordDecl());
2801 RD->fields(), CurOffsetInBits, Context, Layout,
2815 // (9.1) - T is trivially copyable, and
2816 // (9.2) - any two objects of type T with the same value have the same
2818 // - two objects of array or non-union class type are considered to have
2821 // - two objects of union type are considered to have the same value if
2825 // implementation-defined. [ Note: If a type has padding bits, the condition
2827 // types. -- end note ]
2831 if (Ty->isArrayType())
2835 assert((Ty->isVoidType() || !Ty->isIncompleteType()) &&
2839 // (9.1) - T is trivially copyable...
2844 if (Ty->isIntegralOrEnumerationType()) {
2846 if (const auto *BIT = Ty->getAs<BitIntType>())
2847 return getTypeSize(BIT) == BIT->getNumBits();
2853 if (Ty->isPointerType())
2856 if (const auto *MPT = Ty->getAs<MemberPointerType>())
2857 return !ABI->getMemberPointerInfo(MPT).HasPadding;
2859 if (Ty->isRecordType()) {
2860 const RecordDecl *Record = Ty->castAs<RecordType>()->getDecl();
2862 if (Record->isInvalidDecl())
2865 if (Record->isUnion())
2879 // Obj-C block pointers
2880 // Obj-C object pointers
2883 // There're also Obj-C class types and the Obj-C selector type, but I think it
2892 for (const auto *Ext : OI->known_extensions())
2893 count += Ext->ivar_size();
2897 if (ObjCImplementationDecl *ImplDecl = OI->getImplementation())
2898 count += ImplDecl->ivar_size();
2908 if (E->getType()->isNullPtrType()) return true;
2910 if (E->getType()->isAnyPointerType() &&
2911 E->IgnoreParenCasts()->isNullPointerConstant(*this,
2927 return cast<ObjCImplementationDecl>(I->second);
2937 return cast<ObjCCategoryImplDecl>(I->second);
2968 if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->getDeclContext()))
2970 if (const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->getDeclContext()))
2971 return CD->getClassInterface();
2972 if (const auto *IMD = dyn_cast<ObjCImplDecl>(ND->getDeclContext()))
2973 return IMD->getClassInterface();
2982 assert(VD->hasAttr<BlocksAttr>() &&
2983 "getBlockVarCopyInits - not __block var");
2986 return I->second;
2994 assert(VD->hasAttr<BlocksAttr>() &&
2995 "setBlockVarCopyInits - not __block var");
3016 DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
3028 return getObjCLayout(D->getClassInterface(), D);
3043 //===----------------------------------------------------------------------===//
3045 //===----------------------------------------------------------------------===//
3057 assert(eq->getQualifiers() == quals);
3063 if (!baseType->isCanonicalUnqualified()) {
3064 SplitQualType canonSplit = baseType->getCanonicalTypeInternal().split();
3068 // Re-find the insert position.
3088 // If this type already has an address space specified, it cannot get
3098 // If the type is not qualified with an address space, just return it
3107 if (T.getTypePtr()->isArrayType()) {
3116 // If the type no longer has an address space after stripping qualifiers,
3128 // Removal of the address space can mean there are no longer any
3129 // non-fast qualifiers, so creating an ExtQualType isn't possible (asserts)
3139 assert(RD->isPolymorphic() &&
3144 MC->mangleCXXVTable(RD, Out);
3165 // FIXME: Consider address space qualifiers.
3171 switch (T->getTypeClass()) {
3174 Ctx, OS, cast<AtomicType>(T)->getValueType());
3179 cast<ReferenceType>(T)->getPointeeType());
3184 cast<ReferenceType>(T)->getPointeeType());
3203 Ctx, OS, cast<ComplexType>(T)->getElementType());
3219 Ctx, OS, cast<ArrayType>(T)->getElementType());
3232 QualType UnderlyingType = cast<EnumType>(T)->getDecl()->getIntegerType();
3248 // what the user meant. This behavior is non-conforming.
3253 encodeTypeForFunctionPointerAuth(Ctx, OS, FuncType->getReturnType());
3255 for (QualType Param : FPT->param_types()) {
3259 if (FPT->isVariadic())
3268 const auto *MPT = T->getAs<MemberPointerType>();
3269 encodeTypeForFunctionPointerAuth(Ctx, OS, QualType(MPT->getClass(), 0));
3270 encodeTypeForFunctionPointerAuth(Ctx, OS, MPT->getPointeeType());
3286 const auto *BTy = T->getAs<BuiltinType>();
3287 switch (BTy->getKind()) {
3343 // Don't bother discriminating based on these seldom-used types.
3368 const RecordDecl *RD = T->getAs<RecordType>()->getDecl();
3369 const IdentifierInfo *II = RD->getIdentifier();
3387 if (const TypedefNameDecl *Typedef = RD->getTypedefNameForAnonDecl())
3388 II = Typedef->getDeclName().getAsIdentifierInfo();
3394 OS << II->getLength() << II->getName();
3405 llvm_unreachable("unexpected non-canonical or dependent type!");
3411 assert(!T->isDependentType() &&
3417 if (T->isFunctionPointerType() || T->isFunctionReferenceType())
3418 T = T->getPointeeType();
3420 if (T->isFunctionType()) {
3425 MC->mangleCanonicalTypeName(T, Out);
3437 if (const auto *ptr = T->getAs<PointerType>()) {
3438 QualType Pointee = ptr->getPointeeType();
3439 if (Pointee->isAnyPointerType()) {
3460 if (const PointerType *Ptr = T->getAs<PointerType>()) {
3461 QualType Pointee = Ptr->getPointeeType();
3472 assert(WrappedTy->isPointerType() || WrappedTy->isArrayType());
3497 if (T->getExtInfo() == Info)
3502 Result = getFunctionNoProtoType(FNPT->getReturnType(), Info);
3505 FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
3507 Result = getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI);
3515 FD = FD->getMostRecentDecl();
3517 const auto *FPT = FD->getType()->castAs<FunctionProtoType>();
3518 FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
3519 FD->setType(getFunctionType(ResultType, FPT->getParamTypes(), EPI));
3520 if (FunctionDecl *Next = FD->getPreviousDecl())
3526 L->DeducedReturnType(FD, ResultType);
3538 getFunctionTypeWithExceptionSpec(PT->getInnerType(), ESI));
3543 getFunctionTypeWithExceptionSpec(MQT->getUnderlyingType(), ESI),
3544 MQT->getMacroIdentifier());
3546 // Might have a calling-convention attribute.
3549 AT->getAttrKind(),
3550 getFunctionTypeWithExceptionSpec(AT->getModifiedType(), ESI),
3551 getFunctionTypeWithExceptionSpec(AT->getEquivalentType(), ESI));
3555 const auto *Proto = Orig->castAs<FunctionProtoType>();
3557 Proto->getReturnType(), Proto->getParamTypes(),
3558 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3570 if (const auto *Proto = T->getAs<FunctionProtoType>()) {
3571 QualType RetTy = removePtrSizeAddrSpace(Proto->getReturnType());
3572 SmallVector<QualType, 16> Args(Proto->param_types().size());
3574 Args[i] = removePtrSizeAddrSpace(Proto->param_types()[i]);
3575 return getFunctionType(RetTy, Args, Proto->getExtProtoInfo());
3578 if (const FunctionNoProtoType *Proto = T->getAs<FunctionNoProtoType>()) {
3579 QualType RetTy = removePtrSizeAddrSpace(Proto->getReturnType());
3580 return getFunctionNoProtoType(RetTy, Proto->getExtInfo());
3597 getFunctionTypeWithExceptionSpec(FD->getType(), ESI);
3598 FD->setType(Updated);
3604 if (TypeSourceInfo *TSInfo = FD->getTypeSourceInfo()) {
3605 // If the type and the type-as-written differ, we may need to update
3606 // the type-as-written too.
3607 if (TSInfo->getType() != FD->getType())
3608 Updated = getFunctionTypeWithExceptionSpec(TSInfo->getType(), ESI);
3614 TypeLoc::getFullDataSizeForType(TSInfo->getType()) &&
3616 TSInfo->overrideType(Updated);
3620 /// getComplexType - Return the uniqued reference to the type for a complex
3648 /// getPointerType - Return the uniqued reference to the type for a pointer to
3718 assert((T->isArrayType() || T->isFunctionType()) && "T does not decay");
3727 if (T->isArrayType())
3734 if (T->isFunctionType())
3741 if (Ty->isArrayParameterType())
3743 assert(Ty->isConstantArrayType() && "Ty must be an array type.");
3746 ATy->Profile(ID, *this, ATy->getElementType(), ATy->getZExtSize(),
3747 ATy->getSizeExpr(), ATy->getSizeModifier(),
3748 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
3771 /// getBlockPointerType - Return the uniqued reference to the type for
3774 assert(T->isFunctionType() && "block of function types only");
3803 /// getLValueReferenceType - Return the uniqued reference to the type for an
3807 assert((!T->isPlaceholderType() ||
3808 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
3821 const auto *InnerRef = T->getAs<ReferenceType>();
3827 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() : T);
3844 /// getRValueReferenceType - Return the uniqued reference to the type for an
3847 assert((!T->isPlaceholderType() ||
3848 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
3861 const auto *InnerRef = T->getAs<ReferenceType>();
3867 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() : T);
3883 /// getMemberPointerType - Return the uniqued reference to the type for a
3899 if (!T.isCanonical() || !Cls->isCanonicalUnqualified()) {
3914 /// getConstantArrayType - Return the unique reference to the type for an
3921 assert((EltTy->isDependentType() ||
3922 EltTy->isIncompleteType() || EltTy->isConstantSizeType()) &&
3925 // We only need the size as part of the type if it's instantiation-dependent.
3926 if (SizeExpr && !SizeExpr->isInstantiationDependent())
3932 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
3944 // is instantiation-dependent, this won't be a canonical type either, so fill
3967 /// getVariableArrayDecayedType - Turns the given type, which may be
3968 /// variably-modified, into the corresponding type with all the known
3972 if (!type->isVariablyModifiedType()) return type;
3978 switch (ty->getTypeClass()) {
3983 llvm_unreachable("didn't desugar past all non-canonical types?");
3985 // These types should never be variably-modified.
4018 llvm_unreachable("type should never be variably-modified");
4020 // These types can be variably-modified but should never need to
4029 // These types can be variably-modified. All these modifications
4031 // TODO: if we ever care about optimizing VLAs, there are no-op
4035 cast<PointerType>(ty)->getPointeeType()));
4041 getVariableArrayDecayedType(lv->getPointeeType()),
4042 lv->isSpelledAsLValue());
4049 getVariableArrayDecayedType(lv->getPointeeType()));
4055 result = getAtomicType(getVariableArrayDecayedType(at->getValueType()));
4062 getVariableArrayDecayedType(cat->getElementType()),
4063 cat->getSize(),
4064 cat->getSizeExpr(),
4065 cat->getSizeModifier(),
4066 cat->getIndexTypeCVRQualifiers());
4073 getVariableArrayDecayedType(dat->getElementType()),
4074 dat->getSizeExpr(),
4075 dat->getSizeModifier(),
4076 dat->getIndexTypeCVRQualifiers(),
4077 dat->getBracketsRange());
4085 getVariableArrayType(getVariableArrayDecayedType(iat->getElementType()),
4087 iat->getIndexTypeCVRQualifiers(), SourceRange());
4095 getVariableArrayDecayedType(vat->getElementType()),
4097 vat->getIndexTypeCVRQualifiers(), vat->getBracketsRange());
4102 // Apply the top-level qualifiers from the original.
4106 /// getVariableArrayType - Returns a non-unique reference to the type for a
4133 /// getDependentSizedArrayType - Returns a non-unique reference to
4134 /// the type for a dependently-sized array of the specified element
4141 assert((!numElements || numElements->isTypeDependent() ||
4142 numElements->isValueDependent()) &&
4143 "Size must be type- or value-dependent!");
4157 // Dependently-sized array types that do not have a specified number
4188 canonTy->getSizeExpr() == numElements)
4246 switch (Ty->getKind()) {
4370 /// getExternrefType - Return a WebAssembly externref type, which represents an
4373 if (Target->getTriple().isWasm() && Target->hasFeature("reference-types")) {
4383 /// getScalableVectorType - Return the unique reference to a scalable vector
4384 /// type of the specified element type and size. VectorType must be a built-in
4388 if (Target->hasAArch64SVETypes()) {
4392 if (!EltTy->isBooleanType() && \
4393 ((EltTy->hasIntegerRepresentation() && \
4394 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4395 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4397 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4403 if (EltTy->isBooleanType() && NumElts == NumEls) \
4407 } else if (Target->hasRISCVVTypes()) {
4411 if (!EltTy->isBooleanType() && \
4412 ((EltTy->hasIntegerRepresentation() && \
4413 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4414 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4416 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4421 if (EltTy->isBooleanType() && NumElts == NumEls) \
4428 /// getVectorType - Return the unique reference to a vector type of
4429 /// the specified element type and size. VectorType must be a built-in type.
4432 assert(vecType->isBuiltinType() ||
4433 (vecType->isBitIntType() &&
4434 // Only support _BitInt elements with byte-sized power of 2 NumBits.
4435 llvm::isPowerOf2_32(vecType->castAs<BitIntType>()->getNumBits()) &&
4436 vecType->castAs<BitIntType>()->getNumBits() >= 8));
4486 "Dependent-sized vector_size canonical type broken");
4501 /// getExtVectorType - Return the unique reference to an extended vector type of
4502 /// the specified element type and size. VectorType must be a built-in type.
4505 assert(vecType->isBuiltinType() || vecType->isDependentType() ||
4506 (vecType->isBitIntType() &&
4507 // Only support _BitInt elements with byte-sized power of 2 NumBits.
4508 llvm::isPowerOf2_32(vecType->castAs<BitIntType>()->getNumBits()) &&
4509 vecType->castAs<BitIntType>()->getNumBits() >= 8));
4550 // the canonical type for a newly-built type.
4562 assert(!CanonCheck && "Dependent-sized ext_vector canonical type broken");
4629 assert(!CanonCheck && "Dependent-sized matrix canonical type broken");
4638 if (Canon->getElementType() == ElementTy && Canon->getRowExpr() == RowExpr &&
4639 Canon->getRowExpr() == ColumnExpr)
4642 // Use Canon as the canonical type for newly-built type.
4653 assert(AddrSpaceExpr->isInstantiationDependent());
4674 canonTy->getAddrSpaceExpr() == AddrSpaceExpr)
4691 /// getFunctionNoProtoType - Return a K&R style C function type like 'int()'.
4758 // value-dependent.
4763 // expansions (so we can't tell whether it's non-throwing) and all its
4770 if (ET->getAs<PackExpansionType>())
4798 // If we find a pre-existing equivalent FunctionProtoType, we can just reuse
4804 EPI.ExceptionSpec.NoexceptExpr == FPT->getNoexceptExpr())
4827 "given non-canonical parameters constructing canonical type");
4847 // We don't know yet. It shouldn't matter what we pick here; no-one
4859 if (ET->getAs<PackExpansionType>())
4950 // OpenCL v1.1 s6.5.3: a string literal is in the constant address space.
4979 assert(NumBitsExpr->isInstantiationDependent() && "Only good for dependent");
5002 if (RD->getDescribedClassTemplate() &&
5009 /// getInjectedClassNameType - Return the unique reference to the
5014 if (Decl->TypeForDecl) {
5015 assert(isa<InjectedClassNameType>(Decl->TypeForDecl));
5016 } else if (CXXRecordDecl *PrevDecl = Decl->getPreviousDecl()) {
5017 assert(PrevDecl->TypeForDecl && "previous declaration has no type");
5018 Decl->TypeForDecl = PrevDecl->TypeForDecl;
5019 assert(isa<InjectedClassNameType>(Decl->TypeForDecl));
5023 Decl->TypeForDecl = newType;
5026 return QualType(Decl->TypeForDecl, 0);
5029 /// getTypeDeclType - Return the unique reference to the type for the
5033 assert(!Decl->TypeForDecl && "TypeForDecl present in slow case");
5042 assert(Record->isFirstDecl() && "struct/union has previous declaration");
5046 assert(Enum->isFirstDecl() && "enum has previous declaration");
5053 return QualType(Decl->TypeForDecl, 0);
5056 /// getTypedefType - Return the unique reference to the type for the
5060 if (!Decl->TypeForDecl) {
5062 Underlying = Decl->getUnderlyingType();
5065 Decl->TypeForDecl = NewType;
5069 if (Underlying.isNull() || Decl->getUnderlyingType() == Underlying)
5070 return QualType(Decl->TypeForDecl, 0);
5071 assert(hasSameType(Decl->getUnderlyingType(), Underlying));
5078 assert(!T->typeMatchesDecl() &&
5079 "non-divergent case should be handled with TypeDecl");
5102 cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl();
5105 QualType Canon = Underlying->getCanonicalTypeInternal();
5106 assert(TypeForDecl->getCanonicalTypeInternal() == Canon);
5120 if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
5122 if (const RecordDecl *PrevDecl = Decl->getPreviousDecl())
5123 if (PrevDecl->TypeForDecl)
5124 return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
5127 Decl->TypeForDecl = newType;
5133 if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
5135 if (const EnumDecl *PrevDecl = Decl->getPreviousDecl())
5136 if (PrevDecl->TypeForDecl)
5137 return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
5140 Decl->TypeForDecl = newType;
5147 if (Decl->TypeForDecl)
5148 return QualType(Decl->TypeForDecl, 0);
5151 Decl->getCanonicalDecl())
5152 if (CanonicalDecl->TypeForDecl)
5153 return QualType(Decl->TypeForDecl = CanonicalDecl->TypeForDecl, 0);
5157 Decl->TypeForDecl = newType;
5203 /// Retrieve a substitution-result type.
5234 assert(P.getKind() == TemplateArgument::Type && "Pack contains a non-type");
5248 if (!AssociatedDecl->isCanonicalDecl() ||
5251 AssociatedDecl->getCanonicalDecl(), Index, Final, CanonArgPack);
5288 assert(!TypeCheck && "Template type parameter canonical type broken");
5312 DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>();
5355 bool IsTypeAlias = TD && TD->isTypeAlias();
5368 // Allocate the (non-canonical) template specialization type, but don't
5416 assert(Spec->isDependentType() &&
5417 "Non-dependent template-id type must have a canonical type");
5437 assert(!CheckT && "Elaborated canonical type broken");
5465 assert(!CheckT && "Paren canonical type broken");
5530 assert((!NNS || NNS->isDependent()) &&
5531 "nested-name-specifier must be dependent");
5562 assert(!Nothing && "canonical type broken");
5579 if (TTP->isParameterPack())
5585 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*this);
5589 // lvalue-to-rvalue conversion applied to a const-qualified lvalue.
5590 if (T->isRecordType())
5594 Expr::getValueKindForType(NTTP->getType()), NTTP->getLocation());
5596 if (NTTP->isParameterPack())
5598 PackExpansionExpr(DependentTy, E, NTTP->getLocation(), std::nullopt);
5604 if (TTP->isParameterPack())
5610 if (Param->isTemplateParameterPack())
5619 Args.reserve(Args.size() + Params->size());
5628 assert((!ExpectPackInType || Pattern->containsUnexpandedParameterPack()) &&
5656 /// CmpProtocolNames - Comparison predicate for sorting protocols
5660 return DeclarationName::compare((*LHS)->getDeclName(), (*RHS)->getDeclName());
5666 if (Protocols[0]->getCanonicalDecl() != Protocols[0])
5670 if (CmpProtocolNames(&Protocols[i - 1], &Protocols[i]) >= 0 ||
5671 Protocols[i]->getCanonicalDecl() != Protocols[i])
5683 P = P->getCanonicalDecl();
5721 if (const auto *baseObject = baseType->getAs<ObjCObjectType>())
5722 effectiveTypeArgs = baseObject->getTypeArgs();
5726 // sorted-and-uniqued list of protocols and the type arguments
5775 /// Apply Objective-C protocol qualifiers to the given type.
5785 return getObjCTypeParamType(objT->getDecl(), protocols);
5792 const ObjCObjectType *objT = objPtr->getObjectType();
5795 protocolsVec.append(objT->qual_begin(),
5796 objT->qual_end());
5800 objT->getBaseType(),
5801 objT->getTypeArgsAsWritten(),
5803 objT->isKindOfTypeAsWritten());
5813 return getObjCObjectType(objT->getBaseType(),
5814 objT->getTypeArgsAsWritten(),
5816 objT->isKindOfTypeAsWritten());
5820 if (type->isObjCObjectType()) {
5829 // id<protocol-list>
5830 if (type->isObjCIdType()) {
5831 const auto *objPtr = type->castAs<ObjCObjectPointerType>();
5833 objPtr->isKindOfType());
5837 // Class<protocol-list>
5838 if (type->isObjCClassType()) {
5839 const auto *objPtr = type->castAs<ObjCObjectPointerType>();
5841 objPtr->isKindOfType());
5854 ObjCTypeParamType::Profile(ID, Decl, Decl->getUnderlyingType(), protocols);
5861 QualType Canonical = getCanonicalType(Decl->getUnderlyingType());
5882 New->setTypeSourceInfo(getTrivialTypeSourceInfo(Orig->getUnderlyingType()));
5884 auto NewTypeParamTy = cast<ObjCTypeParamType>(New->getTypeForDecl());
5886 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
5888 New->setTypeForDecl(UpdatedTy.getTypePtr());
5891 /// ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's
5892 /// protocol list adopt all protocols in QT's qualified-id protocol
5896 if (!QT->isObjCQualifiedIdType())
5899 if (const auto *OPT = QT->getAs<ObjCObjectPointerType>()) {
5901 for (auto *Proto : OPT->quals()) {
5902 if (!IC->ClassImplementsProtocol(Proto, false))
5910 /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in
5911 /// QT's qualified-id protocol list adopt all protocols in IDecl's list
5915 if (!QT->isObjCQualifiedIdType())
5917 const auto *OPT = QT->getAs<ObjCObjectPointerType>();
5920 if (!IDecl->hasDefinition())
5929 for (auto *Proto : OPT->quals()) {
5946 for (auto *Proto : OPT->quals()) {
5957 /// getObjCObjectPointerType - Return a ObjCObjectPointerType type for
5988 /// getObjCInterfaceType - Return the unique reference to the type for the
5992 if (Decl->TypeForDecl)
5993 return QualType(Decl->TypeForDecl, 0);
5996 assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl");
5997 Decl->TypeForDecl = PrevDecl->TypeForDecl;
5998 return QualType(PrevDecl->TypeForDecl, 0);
6002 if (const ObjCInterfaceDecl *Def = Decl->getDefinition())
6007 Decl->TypeForDecl = T;
6012 /// getTypeOfExprType - Unlike many "get<Type>" functions, we can't unique
6019 if (tofExpr->isTypeDependent()) {
6040 QualType Canonical = getCanonicalType(tofExpr->getType());
6048 /// getTypeOfType - Unlike many "get<Type>" functions, we don't unique
6061 /// getReferenceQualifiedType - Given an expr, will return the type for
6062 /// that expression, as in [dcl.type.simple]p4 but without taking id-expressions
6067 QualType T = E->getType();
6068 switch (E->getValueKind()) {
6069 // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
6073 // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
6077 // - otherwise, decltype(e) is the type of e.
6093 // unique dependent type. Two such decltype-specifiers refer to the same
6095 if (e->isInstantiationDependent()) {
6123 if (FullySubstituted && Index != -1) {
6151 /// getUnaryTransformationType - We don't unique these, since the memory
6159 if (BaseType->isDependentType()) {
6207 ConceptDecl *CanonicalConcept = TypeConstraintConcept->getCanonicalDecl();
6217 assert(!Nothing && "canonical type broken");
6236 /// getAutoType - Return the uniqued reference to the 'auto' type which has been
6238 /// canonical deduced-but-dependent 'auto' type.
6254 // Remove a type-constraint from a top-level auto or decltype(auto).
6255 if (auto *AT = CanonT->getAs<AutoType>()) {
6256 if (!AT->isConstrained())
6258 return getQualifiedType(getAutoType(QualType(), AT->getKeyword(),
6259 AT->isDependentType(),
6260 AT->containsUnexpandedParameterPack()),
6265 // non-type template parameter at the moment. Once we lift that restriction,
6267 assert(!CanonT->getContainedAutoType() ||
6268 !CanonT->getContainedAutoType()->isConstrained());
6274 /// such type, or the canonical deduced-but-dependent such type.
6289 DTST->Profile(TempID);
6296 /// getAtomicType - Return the uniqued reference to the atomic type for
6324 /// getAutoDeductType - Get type pattern for deducing against 'auto'.
6335 /// getAutoRRefDeductType - Get type pattern for deducing against 'auto &&'.
6343 /// getTagDeclType - Return the unique reference to the type for the
6352 /// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
6356 return getFromTargetType(Target->getSizeType());
6362 return getFromTargetType(Target->getSignedSizeType());
6365 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
6367 return getFromTargetType(Target->getIntMaxType());
6370 /// getUIntMaxType - Return the unique type for "uintmax_t" (C99 7.18.1.5).
6372 return getFromTargetType(Target->getUIntMaxType());
6375 /// getSignedWCharType - Return the type of "signed wchar_t".
6382 /// getUnsignedWCharType - Return the type of "unsigned wchar_t".
6390 return getFromTargetType(Target->getIntPtrType());
6397 /// getPointerDiffType - Return the unique type for "ptrdiff_t" (C99 7.17)
6398 /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
6400 return getFromTargetType(Target->getPtrDiffType(LangAS::Default));
6407 return getFromTargetType(Target->getUnsignedPtrDiffType(LangAS::Default));
6413 return getFromTargetType(Target->getProcessIDType());
6416 //===----------------------------------------------------------------------===//
6418 //===----------------------------------------------------------------------===//
6449 dyn_cast<ArrayType>(splitType.Ty->getUnqualifiedDesugaredType());
6458 QualType elementType = AT->getElementType();
6474 return getConstantArrayType(unqualElementType, CAT->getSize(),
6475 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
6479 return getIncompleteArrayType(unqualElementType, IAT->getSizeModifier(), 0);
6484 VAT->getSizeExpr(),
6485 VAT->getSizeModifier(),
6486 VAT->getIndexTypeCVRQualifiers(),
6487 VAT->getBracketsRange());
6491 return getDependentSizedArrayType(unqualElementType, DSAT->getSizeExpr(),
6492 DSAT->getSizeModifier(), 0,
6498 /// cv-decomposition of two types per C++ [conv.qual].
6520 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
6533 T1 = AT1->getElementType();
6534 T2 = AT2->getElementType();
6542 /// unwrapped. Top-level qualifiers on T1 and T2 are ignored.
6545 /// "unwraps" pointer and pointer-to-member types to compare them at each
6557 const auto *T1PtrType = T1->getAs<PointerType>();
6558 const auto *T2PtrType = T2->getAs<PointerType>();
6560 T1 = T1PtrType->getPointeeType();
6561 T2 = T2PtrType->getPointeeType();
6565 const auto *T1MPType = T1->getAs<MemberPointerType>();
6566 const auto *T2MPType = T2->getAs<MemberPointerType>();
6568 hasSameUnqualifiedType(QualType(T1MPType->getClass(), 0),
6569 QualType(T2MPType->getClass(), 0))) {
6570 T1 = T1MPType->getPointeeType();
6571 T2 = T2MPType->getPointeeType();
6576 const auto *T1OPType = T1->getAs<ObjCObjectPointerType>();
6577 const auto *T2OPType = T2->getAs<ObjCObjectPointerType>();
6579 T1 = T1OPType->getPointeeType();
6580 T2 = T2OPType->getPointeeType();
6628 return DeclarationNameInfo(Name.getAsTemplateDecl()->getDeclName(),
6634 return DeclarationNameInfo((*Storage->begin())->getDeclName(), NameLoc);
6639 return DeclarationNameInfo(Storage->getDeclName(), NameLoc);
6645 if (DTN->isIdentifier()) {
6646 DName = DeclarationNames.getIdentifier(DTN->getIdentifier());
6649 DName = DeclarationNames.getCXXOperatorName(DTN->getOperator());
6660 return DeclarationNameInfo(subst->getParameter()->getDeclName(),
6667 return DeclarationNameInfo(subst->getParameterPack()->getDeclName(),
6671 return DeclarationNameInfo(Name.getAsUsingShadowDecl()->getDeclName(),
6689 return TemplateName(cast<TemplateDecl>(Template->getCanonicalDecl()));
6698 assert(DTN && "Non-dependent template names must refer to template decls.");
6699 return DTN->CanonicalTemplateName;
6705 return getCanonicalTemplateName(subst->getReplacement());
6712 getCanonicalTemplateArgument(subst->getArgumentPack());
6714 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
6715 subst->getFinal(), subst->getIndex());
6736 XCE->Profile(XCEID, *this, /*Canonical=*/true, /*ProfileLambdaExpr=*/true);
6737 YCE->Profile(YCEID, *this, /*Canonical=*/true, /*ProfileLambdaExpr=*/true);
6749 auto *NCX = XTC->getNamedConcept();
6750 auto *NCY = YTC->getNamedConcept();
6753 if (XTC->getConceptReference()->hasExplicitTemplateArgs() !=
6754 YTC->getConceptReference()->hasExplicitTemplateArgs())
6756 if (XTC->getConceptReference()->hasExplicitTemplateArgs())
6757 if (XTC->getConceptReference()
6758 ->getTemplateArgsAsWritten()
6759 ->NumTemplateArgs !=
6760 YTC->getConceptReference()->getTemplateArgsAsWritten()->NumTemplateArgs)
6778 return isSameConstraintExpr(XTC->getImmediatelyDeclaredConstraint(),
6779 YTC->getImmediatelyDeclaredConstraint());
6784 if (X->getKind() != Y->getKind())
6789 if (TX->isParameterPack() != TY->isParameterPack())
6791 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
6793 return isSameTypeConstraint(TX->getTypeConstraint(),
6794 TY->getTypeConstraint());
6799 return TX->isParameterPack() == TY->isParameterPack() &&
6800 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
6801 isSameConstraintExpr(TX->getPlaceholderTypeConstraint(),
6802 TY->getPlaceholderTypeConstraint());
6807 return TX->isParameterPack() == TY->isParameterPack() &&
6808 isSameTemplateParameterList(TX->getTemplateParameters(),
6809 TY->getTemplateParameters());
6814 if (X->size() != Y->size())
6817 for (unsigned I = 0, N = X->size(); I != N; ++I)
6818 if (!isSameTemplateParameter(X->getParam(I), Y->getParam(I)))
6821 return isSameConstraintExpr(X->getRequiresClause(), Y->getRequiresClause());
6833 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
6836 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
6837 TTPY->getDefaultArgument().getArgument().getAsType());
6842 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
6846 NTTPX->getDefaultArgument().getArgument().getAsExpr()->IgnoreImpCasts();
6848 NTTPY->getDefaultArgument().getArgument().getAsExpr()->IgnoreImpCasts();
6850 DefaultArgumentX->Profile(XID, *this, /*Canonical=*/true);
6851 DefaultArgumentY->Profile(YID, *this, /*Canonical=*/true);
6858 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
6861 const TemplateArgument &TAX = TTPX->getDefaultArgument().getArgument();
6862 const TemplateArgument &TAY = TTPY->getDefaultArgument().getArgument();
6867 if (auto *NS = X->getAsNamespace())
6869 if (auto *NAS = X->getAsNamespaceAlias())
6870 return NAS->getNamespace();
6878 if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
6880 } else if (X->getKind() != Y->getKind())
6885 switch (X->getKind()) {
6887 if (X->getAsIdentifier() != Y->getAsIdentifier())
6896 if (X->getAsType()->getCanonicalTypeInternal() !=
6897 Y->getAsType()->getCanonicalTypeInternal())
6906 auto *PX = X->getPrefix();
6907 auto *PY = Y->getPrefix();
6921 auto AEnableIfAttrs = A->specific_attrs<EnableIfAttr>();
6922 auto BEnableIfAttrs = B->specific_attrs<EnableIfAttr>();
6935 (*Cand1A)->getCond()->Profile(Cand1ID, A->getASTContext(), true);
6936 (*Cand2A)->getCond()->Profile(Cand2ID, B->getASTContext(), true);
6948 // so it cannot rely on AST invariants being met. Non-trivial accessors
6954 if (X->getDeclName() != Y->getDeclName())
6962 if (!declaresSameEntity(cast<Decl>(X->getDeclContext()->getRedeclContext()),
6963 cast<Decl>(Y->getDeclContext()->getRedeclContext())))
6970 return hasSameType(TypedefX->getUnderlyingType(),
6971 TypedefY->getUnderlyingType());
6974 if (X->getKind() != Y->getKind())
6977 // Objective-C classes and protocols with the same name always match.
6990 return (TagX->getTagKind() == TagY->getTagKind()) ||
6991 ((TagX->getTagKind() == TagTypeKind::Struct ||
6992 TagX->getTagKind() == TagTypeKind::Class ||
6993 TagX->getTagKind() == TagTypeKind::Interface) &&
6994 (TagY->getTagKind() == TagTypeKind::Struct ||
6995 TagY->getTagKind() == TagTypeKind::Class ||
6996 TagY->getTagKind() == TagTypeKind::Interface));
7000 // FIXME: This needs to cope with merging of prototyped/non-prototyped
7006 if (CtorX->getInheritedConstructor() &&
7007 !isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7008 CtorY->getInheritedConstructor().getConstructor()))
7012 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7017 if (FuncX->isMultiVersion()) {
7018 const auto *TAX = FuncX->getAttr<TargetAttr>();
7019 const auto *TAY = FuncY->getAttr<TargetAttr>();
7022 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7028 if ((FuncX->isMemberLikeConstrainedFriend() ||
7029 FuncY->isMemberLikeConstrainedFriend()) &&
7030 !FuncX->getLexicalDeclContext()->Equals(
7031 FuncY->getLexicalDeclContext())) {
7035 if (!isSameConstraintExpr(FuncX->getTrailingRequiresClause(),
7036 FuncY->getTrailingRequiresClause()))
7044 FD = FD->getCanonicalDecl();
7045 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7046 : FD->getType();
7053 auto *XFPT = XT->getAs<FunctionProtoType>();
7054 auto *YFPT = YT->getAs<FunctionProtoType>();
7056 (isUnresolvedExceptionSpec(XFPT->getExceptionSpecType()) ||
7057 isUnresolvedExceptionSpec(YFPT->getExceptionSpecType())) &&
7063 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7070 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7073 if (VarX->getType().isNull() || VarY->getType().isNull())
7076 if (hasSameType(VarX->getType(), VarY->getType()))
7084 const ArrayType *VarXTy = getAsArrayType(VarX->getType());
7085 const ArrayType *VarYTy = getAsArrayType(VarY->getType());
7088 if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType())
7089 return hasSameType(VarXTy->getElementType(), VarYTy->getElementType());
7097 return NamespaceX->isInline() == NamespaceY->isInline();
7108 if (!isSameConstraintExpr(ConceptX->getConstraintExpr(),
7109 ConceptY->getConstraintExpr()))
7113 return isSameEntity(TemplateX->getTemplatedDecl(),
7114 TemplateY->getTemplatedDecl()) &&
7115 isSameTemplateParameterList(TemplateX->getTemplateParameters(),
7116 TemplateY->getTemplateParameters());
7122 // FIXME: Also check the bitwidth is odr-equivalent, if any.
7123 return hasSameType(FDX->getType(), FDY->getType());
7129 return IFDX->getAnonField()->getCanonicalDecl() ==
7130 IFDY->getAnonField()->getCanonicalDecl();
7135 // FIXME: Also check the value is odr-equivalent.
7141 return declaresSameEntity(USX->getTargetDecl(), USY->getTargetDecl());
7148 return isSameQualifier(UX->getQualifier(), UY->getQualifier()) &&
7149 UX->hasTypename() == UY->hasTypename() &&
7150 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7154 return isSameQualifier(UX->getQualifier(), UY->getQualifier()) &&
7155 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7159 UX->getQualifier(),
7160 cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
7163 // Using-pack declarations are only created by instantiation, and match if
7167 UX->getInstantiatedFromUsingDecl(),
7168 cast<UsingPackDecl>(Y)->getInstantiatedFromUsingDecl());
7174 return NAX->getNamespace()->Equals(NAY->getNamespace());
7190 auto *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());
7240 switch (NNS->getKind()) {
7244 getCanonicalNestedNameSpecifier(NNS->getPrefix()),
7245 NNS->getAsIdentifier());
7248 // A namespace is canonical; build a nested-name-specifier with
7251 NNS->getAsNamespace()->getFirstDecl());
7254 // A namespace is canonical; build a nested-name-specifier with
7258 NNS->getAsNamespaceAlias()->getNamespace()->getFirstDecl());
7264 const Type *T = getCanonicalType(NNS->getAsType());
7266 // If we have some kind of dependent-named type (e.g., "typename T::type"),
7268 // as the canonical nested-name-specifier. This is required to canonicalize
7269 // a dependent nested-name-specifier involving typedefs of dependent-name
7273 if (const auto *DNT = T->getAs<DependentNameType>())
7274 return NestedNameSpecifier::Create(*this, DNT->getQualifier(),
7275 DNT->getIdentifier());
7276 if (const auto *DTST = T->getAs<DependentTemplateSpecializationType>())
7277 return NestedNameSpecifier::Create(*this, DTST->getQualifier(), true, T);
7293 // Handle the non-qualified case efficiently.
7322 QualType NewEltTy = getQualifiedType(ATy->getElementType(), qs);
7325 return cast<ArrayType>(getConstantArrayType(NewEltTy, CAT->getSize(),
7326 CAT->getSizeExpr(),
7327 CAT->getSizeModifier(),
7328 CAT->getIndexTypeCVRQualifiers()));
7331 IAT->getSizeModifier(),
7332 IAT->getIndexTypeCVRQualifiers()));
7337 DSAT->getSizeExpr(),
7338 DSAT->getSizeModifier(),
7339 DSAT->getIndexTypeCVRQualifiers(),
7340 DSAT->getBracketsRange()));
7344 VAT->getSizeExpr(),
7345 VAT->getSizeModifier(),
7346 VAT->getIndexTypeCVRQualifiers(),
7347 VAT->getBracketsRange()));
7351 if (getLangOpts().HLSL && T->isConstantArrayType())
7353 if (T->isArrayType() || T->isFunctionType())
7366 // A throw-expression initializes a temporary object, called the exception
7367 // object, the type of which is determined by removing any top-level
7368 // cv-qualifiers from the static type of the operand of throw and adjusting
7372 if (T->isArrayType() || T->isFunctionType())
7377 /// getArrayDecayedType - Return the properly qualified result of decaying the
7378 /// specified array type to a pointer. This operation is non-trivial when
7391 QualType PtrTy = getPointerType(PrettyArrayType->getElementType());
7393 // int x[restrict 4] -> int *restrict
7395 PrettyArrayType->getIndexTypeQualifiers());
7397 // int x[_Nullable] -> int * _Nullable
7398 if (auto Nullability = Ty->getNullability()) {
7399 Result = const_cast<ASTContext *>(this)->getAttributedType(
7406 return getBaseElementType(array->getElementType());
7413 const ArrayType *array = split.Ty->getAsArrayTypeUnsafe();
7416 type = array->getElementType();
7423 /// getConstantArrayElementCount - Returns number of constant array elements.
7428 ElementCount *= CA->getZExtSize();
7430 CA->getElementType()->getAsArrayTypeUnsafe());
7443 ElementCount *= AILE->getArraySize().getZExtValue();
7444 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->getSubExpr());
7450 /// getFloatingRank - Return a relative rank for floating point types.
7451 /// This routine will assert if passed a built-in type that isn't a float.
7453 if (const auto *CT = T->getAs<ComplexType>())
7454 return getFloatingRank(CT->getElementType());
7456 switch (T->castAs<BuiltinType>()->getKind()) {
7469 /// getFloatingTypeOrder - Compare the rank of the two specified floating
7472 /// LHS < RHS, return -1.
7481 return -1;
7490 /// getIntegerRank - Return an integer conversion rank (C99 6.3.1.1p1). This
7491 /// routine will assert if passed a built-in type that isn't an integer or enum,
7494 assert(T->isCanonicalUnqualified() && "T should be canonicalized");
7499 return 0 + (EIT->getNumBits() << 3);
7501 switch (cast<BuiltinType>(T)->getKind()) {
7502 default: llvm_unreachable("getIntegerRank(): not a built-in integer");
7532 getFromTargetType(Target->getChar16Type()).getTypePtr());
7535 getFromTargetType(Target->getChar32Type()).getTypePtr());
7539 getFromTargetType(Target->getWCharType()).getTypePtr());
7546 /// \returns the type this bit-field will promote to, or NULL if no
7549 if (E->isTypeDependent() || E->isValueDependent())
7553 // If the bit-field has an enumerated type, it is treated as any other
7555 if (getLangOpts().CPlusPlus && E->getType()->isEnumeralType())
7558 // FIXME: We should not do this unless E->refersToBitField() is true. This
7559 // matters in C where getSourceBitField() will find bit-fields for various
7560 // cases where the source expression is not a bit-field designator.
7562 FieldDecl *Field = E->getSourceBitField(); // FIXME: conditional bit-fields?
7566 QualType FT = Field->getType();
7568 uint64_t BitWidth = Field->getBitWidthValue(*this);
7571 // A prvalue for an integral bit-field can be converted to a prvalue of type
7572 // int if int can represent all the values of the bit-field; otherwise, it
7574 // values of the bit-field. If the bit-field is larger yet, no integral
7577 // [For a bit-field of type _Bool, int, signed int, or unsigned int:]
7579 // the width, for a bit-field), the value is converted to an int; otherwise,
7584 // FIXME: C does not permit promotion of an enum bit-field whose rank is
7588 // The value from a bit-field of a bit-precise integer type is converted to
7589 // the corresponding bit-precise integer type. (The rest is the same as in
7591 if (QualType QT = Field->getType(); QT->isBitIntType())
7598 return FT->isSignedIntegerType() ? IntTy : UnsignedIntTy;
7600 // Bit-fields wider than int are not subject to promotions, and therefore act
7602 // deliberately do not follow (GCC follows a pre-standard resolution to
7603 // C's DR315 which treats bit-width as being part of the type, and this leaks
7608 /// getPromotedIntegerType - Returns the type that Promotable will
7614 if (const auto *ET = Promotable->getAs<EnumType>())
7615 return ET->getDecl()->getPromotionType();
7617 if (const auto *BT = Promotable->getAs<BuiltinType>()) {
7624 if (BT->getKind() == BuiltinType::WChar_S ||
7625 BT->getKind() == BuiltinType::WChar_U ||
7626 BT->getKind() == BuiltinType::Char8 ||
7627 BT->getKind() == BuiltinType::Char16 ||
7628 BT->getKind() == BuiltinType::Char32) {
7629 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
7636 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
7644 if (Promotable->isSignedIntegerType())
7648 assert(Promotable->isUnsignedIntegerType() && PromotableSize <= IntSize);
7658 if (T->isArrayType())
7660 else if (const auto *PT = T->getAs<PointerType>())
7661 T = PT->getPointeeType();
7662 else if (const auto *RT = T->getAs<ReferenceType>())
7663 T = RT->getPointeeType();
7674 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
7675 return ET->getDecl()->getIntegerType().getTypePtr();
7679 /// getIntegerTypeOrder - Returns the highest ranked integer type:
7681 /// LHS < RHS, return -1.
7694 bool LHSUnsigned = LHSC->isUnsignedIntegerType();
7695 bool RHSUnsigned = RHSC->isUnsignedIntegerType();
7702 return LHSRank > RHSRank ? 1 : -1;
7714 return -1;
7719 return -1;
7734 CFConstantStringTagDecl->startDefinition();
7742 /// Objective-C ABI
7781 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()), "_swift_rc" };
7797 Field->setAccess(AS_public);
7798 CFConstantStringTagDecl->addDecl(Field);
7801 CFConstantStringTagDecl->completeDefinition();
7817 // getCFConstantStringType - Return the type used for constant CFStrings.
7825 getTranslationUnitDecl()->addDecl(ObjCSuperTypeDecl);
7832 const auto *TD = T->castAs<TypedefType>();
7833 CFConstantStringTypeDecl = cast<TypedefDecl>(TD->getDecl());
7835 CFConstantStringTypeDecl->getUnderlyingType()->castAs<RecordType>();
7836 CFConstantStringTagDecl = TagType->getDecl();
7846 RD->startDefinition();
7863 Field->setAccess(AS_public);
7864 RD->addDecl(Field);
7867 RD->completeDefinition();
7881 RD->startDefinition();
7903 Field->setAccess(AS_public);
7904 RD->addDecl(Field);
7907 RD->completeDefinition();
7923 switch (BT->getKind()) {
7950 return Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T));
7953 /// BlockRequiresCopying - Returns true if byref variable "D" of type "Ty"
7958 if (const CXXRecordDecl *record = Ty->getAsCXXRecordDecl()) {
7960 if (!copyExpr && record->hasTrivialDestructor()) return false;
7965 // The block needs copy/destroy helpers if Ty is non-trivial to destructively
7970 if (!Ty->isObjCRetainableType()) return false;
7985 // non-triviality.
7992 return (Ty->isBlockPointerType() || isObjCNSObjectType(Ty) ||
7993 Ty->isObjCObjectPointerType());
8004 if (Ty->isRecordType()) {
8009 } else if (Ty->isObjCObjectPointerType() || Ty->isBlockPointerType()) {
8020 const llvm::Triple &T = Target->getTriple();
8029 const llvm::Triple &T = Target->getTriple();
8047 if (IdentifierInfo *II = TT->getDecl()->getIdentifier())
8048 return II->isStr("BOOL");
8053 /// getObjCEncodingTypeSize returns size of type for objective-c encoding
8056 if (!type->isIncompleteArrayType() && type->isIncompleteType())
8062 if (sz.isPositive() && type->isIntegralOrEnumerationType())
8065 else if (type->isArrayType())
8072 VD->isStaticDataMember() &&
8073 VD->getType()->isIntegralOrEnumerationType() &&
8074 !VD->getFirstDecl()->isOutOfLine() && VD->getFirstDecl()->hasInit();
8079 if (!VD->isInline())
8083 auto *First = VD->getFirstDecl();
8084 if (First->isInlineSpecified() || !First->isStaticDataMember())
8087 // If there's a file-context declaration in this translation unit, it's a
8088 // non-discardable definition.
8089 for (auto *D : VD->redecls())
8090 if (D->getLexicalDeclContext()->isFileContext() &&
8091 !D->isInlineSpecified() && (D->isConstexpr() || First->isConstexpr()))
8102 /// getObjCEncodingForBlock - Return the encoded type for this block
8107 const BlockDecl *Decl = Expr->getBlockDecl();
8109 Expr->getType()->castAs<BlockPointerType>()->getPointeeType();
8110 QualType BlockReturnTy = BlockTy->castAs<FunctionType>()->getReturnType();
8122 for (auto *PI : Decl->parameters()) {
8123 QualType PType = PI->getType();
8127 assert(sz.isPositive() && "BlockExpr - Incomplete param type");
8137 for (auto *PVDecl : Decl->parameters()) {
8138 QualType PType = PVDecl->getOriginalType();
8140 dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
8144 PType = PVDecl->getType();
8145 } else if (PType->isFunctionType())
8146 PType = PVDecl->getType();
8163 getObjCEncodingForType(Decl->getReturnType(), S);
8166 for (auto *PI : Decl->parameters()) {
8167 QualType PType = PI->getType();
8173 "getObjCEncodingForFunctionDecl - Incomplete param type");
8180 for (auto *PVDecl : Decl->parameters()) {
8181 QualType PType = PVDecl->getOriginalType();
8183 dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
8187 PType = PVDecl->getType();
8188 } else if (PType->isFunctionType())
8189 PType = PVDecl->getType();
8198 /// getObjCEncodingForMethodParameter - Return the encoded type for a single
8216 /// getObjCEncodingForMethodDecl - Return the encoded type for this method
8223 getObjCEncodingForMethodParameter(Decl->getObjCDeclQualifier(),
8224 Decl->getReturnType(), S, Extended);
8232 for (ObjCMethodDecl::param_const_iterator PI = Decl->param_begin(),
8233 E = Decl->sel_param_end(); PI != E; ++PI) {
8234 QualType PType = (*PI)->getType();
8240 "getObjCEncodingForMethodDecl - Incomplete param type");
8249 for (ObjCMethodDecl::param_const_iterator PI = Decl->param_begin(),
8250 E = Decl->sel_param_end(); PI != E; ++PI) {
8252 QualType PType = PVDecl->getOriginalType();
8254 dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
8258 PType = PVDecl->getType();
8259 } else if (PType->isFunctionType())
8260 PType = PVDecl->getType();
8261 getObjCEncodingForMethodParameter(PVDecl->getObjCDeclQualifier(),
8277 for (auto *PID : CID->property_impls())
8278 if (PID->getPropertyDecl() == PD)
8282 for (auto *PID : OID->property_impls())
8283 if (PID->getPropertyDecl() == PD)
8289 /// getObjCEncodingForPropertyDecl - Return the encoded type for this
8290 /// property declaration. If non-NULL, Container must be either an
8293 /// Property attributes are stored as a comma-delimited C string. The simple
8301 /// kPropertyReadOnly = 'R', // property is read-only.
8308 /// kPropertyType = 'T' // followed by old-style type encoding.
8311 /// kPropertyNonAtomic = 'N' // property non-atomic
8324 if (PropertyImpDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
8336 getObjCEncodingForPropertyType(PD->getType(), S);
8338 if (PD->isOptional())
8341 if (PD->isReadOnly()) {
8343 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_copy)
8345 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_retain)
8347 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
8350 switch (PD->getSetterKind()) {
8363 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_nonatomic)
8366 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_getter) {
8368 S += PD->getGetterName().getAsString();
8371 if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_setter) {
8373 S += PD->getSetterName().getAsString();
8377 const ObjCIvarDecl *OID = SynthesizePID->getPropertyIvarDecl();
8379 S += OID->getNameAsString();
8386 /// getLegacyIntegralTypeEncoding -
8387 /// Another legacy compatibility encoding: 32-bit longs are encoded as
8391 if (PointeeTy->getAs<TypedefType>()) {
8392 if (const auto *BT = PointeeTy->getAs<BuiltinType>()) {
8393 if (BT->getKind() == BuiltinType::ULong && getIntWidth(PointeeTy) == 32)
8396 if (BT->getKind() == BuiltinType::Long && getIntWidth(PointeeTy) == 32)
8433 BuiltinType::Kind kind = BT->getKind();
8445 return C->getTargetInfo().getLongWidth() == 32 ? 'L' : 'Q';
8455 return C->getTargetInfo().getLongWidth() == 32 ? 'l' : 'q';
8505 DiagnosticsEngine &Diags = C->getDiagnostics();
8508 Diags.Report(DiagID) << BT->getName(C->getPrintingPolicy());
8543 EnumDecl *Enum = ET->getDecl();
8545 // The encoding of an non-fixed enum type is always 'i', regardless of size.
8546 if (!Enum->isFixed())
8550 const auto *BT = Enum->getIntegerType()->castAs<BuiltinType>();
8556 assert(FD->isBitField() && "not a bitfield - getObjCEncodingForTypeImpl");
8568 // On a 32-bit system, the encoding for flags would be b2 for the NeXT
8573 if (Ctx->getLangOpts().ObjCRuntime.isGNUFamily()) {
8577 Offset = Ctx->lookupFieldBitOffset(IVD->getContainingInterface(), nullptr,
8580 const RecordDecl *RD = FD->getParent();
8581 const ASTRecordLayout &RL = Ctx->getASTRecordLayout(RD);
8582 Offset = RL.getFieldOffset(FD->getFieldIndex());
8587 if (const auto *ET = T->getAs<EnumType>())
8590 const auto *BT = T->castAs<BuiltinType>();
8594 S += llvm::utostr(FD->getBitWidthValue(*Ctx));
8601 T = T->getBaseElementTypeUnsafe();
8603 if (auto *PT = T->getAs<PointerType>())
8605 PT->getPointeeType().getTypePtr(), false);
8607 auto *CXXRD = T->getAsCXXRecordDecl();
8615 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
8618 for (const auto &B : CXXRD->bases())
8623 for (auto *FD : CXXRD->fields())
8624 if (hasTemplateSpecializationInEncodedString(FD->getType().getTypePtr(),
8637 switch (CT->getTypeClass()) {
8640 if (FD && FD->isBitField())
8650 getObjCEncodingForTypeImpl(T->castAs<ComplexType>()->getElementType(), S,
8657 getObjCEncodingForTypeImpl(T->castAs<AtomicType>()->getValueType(), S,
8668 const auto *PT = T->castAs<PointerType>();
8669 if (PT->isObjCSelType()) {
8673 PointeeTy = PT->getPointeeType();
8675 PointeeTy = T->castAs<ReferenceType>()->getPointeeType();
8679 // For historical/compatibility reasons, the read-only qualifier of the
8680 // pointee gets emitted _before_ the '^'. The read-only qualifier of
8683 if (T->getAs<TypedefType>()) {
8690 while (auto PT = P->getAs<PointerType>())
8691 P = PT->getPointeeType();
8702 S.replace(S.end()-2, S.end(), "rn");
8705 if (PointeeTy->isCharType()) {
8712 } else if (const auto *RTy = PointeeTy->getAs<RecordType>()) {
8714 if (RTy->getDecl()->getIdentifier() == &Idents.get("objc_class")) {
8719 if (RTy->getDecl()->getIdentifier() == &Idents.get("objc_object")) {
8755 AT->getElementType(), S,
8761 S += llvm::utostr(CAT->getZExtSize());
8770 AT->getElementType(), S,
8784 RecordDecl *RDecl = cast<RecordType>(CT)->getDecl();
8785 S += RDecl->isUnion() ? '(' : '{';
8787 if (const IdentifierInfo *II = RDecl->getIdentifier()) {
8788 S += II->getName();
8790 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
8800 if (!RDecl->isUnion()) {
8803 for (const auto *Field : RDecl->fields()) {
8806 S += Field->getNameAsString();
8810 // Special case bit-fields.
8811 if (Field->isBitField()) {
8812 getObjCEncodingForTypeImpl(Field->getType(), S,
8816 QualType qt = Field->getType();
8826 S += RDecl->isUnion() ? ')' : '}';
8831 const auto *BT = T->castAs<BlockPointerType>();
8832 S += "@?"; // Unlike a pointer-to-function, which is "^?".
8834 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
8838 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
8844 for (const auto &I : FPT->param_types())
8856 if (Ty->isObjCIdType()) {
8860 else if (Ty->isObjCClassType()) {
8871 ObjCInterfaceDecl *OI = T->castAs<ObjCObjectType>()->getInterface();
8873 S += OI->getObjCRuntimeNameAsString();
8880 if (Field->isBitField())
8881 getObjCEncodingForTypeImpl(Field->getType(), S,
8885 getObjCEncodingForTypeImpl(Field->getType(), S,
8895 const auto *OPT = T->castAs<ObjCObjectPointerType>();
8896 if (OPT->isObjCIdType()) {
8901 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
8909 if (OPT->isObjCQualifiedIdType()) {
8920 for (const auto *I : OPT->quals()) {
8922 S += I->getObjCRuntimeNameAsString();
8931 if (OPT->getInterfaceDecl() &&
8934 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
8935 for (const auto *I : OPT->quals()) {
8937 S += I->getObjCRuntimeNameAsString();
8994 assert(RDecl && "Expected non-null RecordDecl");
8995 assert(!RDecl->isUnion() && "Should not be called for unions");
8996 if (!RDecl->getDefinition() || RDecl->getDefinition()->isInvalidDecl())
9004 for (const auto &BI : CXXRec->bases()) {
9006 CXXRecordDecl *base = BI.getType()->getAsCXXRecordDecl();
9007 if (base->isEmpty())
9016 for (FieldDecl *Field : RDecl->fields()) {
9017 if (!Field->isZeroLengthBitField(*this) && Field->isZeroSize(*this))
9019 uint64_t offs = layout.getFieldOffset(Field->getFieldIndex());
9025 for (const auto &BI : CXXRec->vbases()) {
9026 CXXRecordDecl *base = BI.getType()->getAsCXXRecordDecl();
9027 if (base->isEmpty())
9050 if (CXXRec && CXXRec->isDynamicClass() &&
9051 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9054 std::string recname = CXXRec->getNameAsString();
9065 if (!RDecl->hasFlexibleArrayMember()) {
9074 assert(CurOffs <= CurLayObj->first);
9075 if (CurOffs < CurLayObj->first) {
9076 uint64_t padding = CurLayObj->first - CurOffs;
9079 // the encoding will be out-of-sync with the real layout.
9088 NamedDecl *dcl = CurLayObj->second;
9099 assert(!base->isEmpty());
9107 S += field->getNameAsString();
9111 if (field->isBitField()) {
9112 EncodeBitField(this, S, field->getType(), field);
9114 CurOffs += field->getBitWidthValue(*this);
9117 QualType qt = field->getType();
9123 CurOffs += getTypeSize(field->getType());
9186 //===----------------------------------------------------------------------===//
9188 //===----------------------------------------------------------------------===//
9193 QualType T = Context->getPointerType(Context->CharTy);
9194 return Context->buildImplicitTypedef(T, Name);
9207 QualType T = Context->getPointerType(Context->VoidTy);
9208 return Context->buildImplicitTypedef(T, "__builtin_va_list");
9214 RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list");
9215 if (Context->getLangOpts().CPlusPlus) {
9218 const_cast<ASTContext &>(*Context), Context->getTranslationUnitDecl(),
9220 &Context->Idents.get("std"),
9222 NS->setImplicit();
9223 VaListTagDecl->setDeclContext(NS);
9226 VaListTagDecl->startDefinition();
9233 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
9237 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
9241 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9245 FieldTypes[3] = Context->IntTy;
9249 FieldTypes[4] = Context->IntTy;
9258 &Context->Idents.get(FieldNames[i]),
9263 Field->setAccess(AS_public);
9264 VaListTagDecl->addDecl(Field);
9266 VaListTagDecl->completeDefinition();
9267 Context->VaListTagDecl = VaListTagDecl;
9268 QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9271 return Context->buildImplicitTypedef(VaListTagType, "__builtin_va_list");
9278 VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9279 VaListTagDecl->startDefinition();
9286 FieldTypes[0] = Context->UnsignedCharTy;
9290 FieldTypes[1] = Context->UnsignedCharTy;
9294 FieldTypes[2] = Context->UnsignedShortTy;
9298 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9302 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
9310 &Context->Idents.get(FieldNames[i]),
9315 Field->setAccess(AS_public);
9316 VaListTagDecl->addDecl(Field);
9318 VaListTagDecl->completeDefinition();
9319 Context->VaListTagDecl = VaListTagDecl;
9320 QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9324 Context->buildImplicitTypedef(VaListTagType, "__va_list_tag");
9327 Context->getTypedefType(VaListTagTypedefDecl);
9330 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
9331 QualType VaListTagArrayType = Context->getConstantArrayType(
9333 return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
9340 VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9341 VaListTagDecl->startDefinition();
9348 FieldTypes[0] = Context->UnsignedIntTy;
9352 FieldTypes[1] = Context->UnsignedIntTy;
9356 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9360 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9369 &Context->Idents.get(FieldNames[i]),
9374 Field->setAccess(AS_public);
9375 VaListTagDecl->addDecl(Field);
9377 VaListTagDecl->completeDefinition();
9378 Context->VaListTagDecl = VaListTagDecl;
9379 QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9384 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
9385 QualType VaListTagArrayType = Context->getConstantArrayType(
9387 return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
9392 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 4);
9393 QualType IntArrayType = Context->getConstantArrayType(
9394 Context->IntTy, Size, nullptr, ArraySizeModifier::Normal, 0);
9395 return Context->buildImplicitTypedef(IntArrayType, "__builtin_va_list");
9401 RecordDecl *VaListDecl = Context->buildImplicitRecord("__va_list");
9402 if (Context->getLangOpts().CPlusPlus) {
9406 Context->getTranslationUnitDecl(),
9408 SourceLocation(), &Context->Idents.get("std"),
9410 NS->setImplicit();
9411 VaListDecl->setDeclContext(NS);
9414 VaListDecl->startDefinition();
9421 &Context->Idents.get("__ap"),
9422 Context->getPointerType(Context->VoidTy),
9427 Field->setAccess(AS_public);
9428 VaListDecl->addDecl(Field);
9431 VaListDecl->completeDefinition();
9432 Context->VaListTagDecl = VaListDecl;
9435 QualType T = Context->getRecordType(VaListDecl);
9436 return Context->buildImplicitTypedef(T, "__builtin_va_list");
9443 VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9444 VaListTagDecl->startDefinition();
9451 FieldTypes[0] = Context->LongTy;
9455 FieldTypes[1] = Context->LongTy;
9459 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9463 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9472 &Context->Idents.get(FieldNames[i]),
9477 Field->setAccess(AS_public);
9478 VaListTagDecl->addDecl(Field);
9480 VaListTagDecl->completeDefinition();
9481 Context->VaListTagDecl = VaListTagDecl;
9482 QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9487 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
9488 QualType VaListTagArrayType = Context->getConstantArrayType(
9491 return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
9497 VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9498 VaListTagDecl->startDefinition();
9505 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
9509 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
9513 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9520 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
9524 Field->setAccess(AS_public);
9525 VaListTagDecl->addDecl(Field);
9527 VaListTagDecl->completeDefinition();
9528 Context->VaListTagDecl = VaListTagDecl;
9529 QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9533 Context->buildImplicitTypedef(VaListTagType, "__va_list_tag");
9535 QualType VaListTagTypedefType = Context->getTypedefType(VaListTagTypedefDecl);
9538 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
9539 QualType VaListTagArrayType = Context->getConstantArrayType(
9542 return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
9573 BuiltinVaListDecl = CreateVaListDecl(this, Target->getBuiltinVaListKind());
9574 assert(BuiltinVaListDecl->isImplicit());
9598 if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin &&
9599 BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID()))
9601 return BuiltinInfo.canBeRedeclared(FD->getBuiltinID());
9611 /// Retrieve the template name that corresponds to a non-empty
9616 unsigned size = End - Begin;
9623 NamedDecl **Storage = OT->getStorage();
9629 isa<FunctionTemplateDecl>(D->getUnderlyingDecl())));
9636 /// Retrieve a template name representing an unqualified-id that has been
9672 assert((!NNS || NNS->isDependent()) &&
9695 assert(!CheckQTN && "Dependent type name canonicalization broken");
9708 assert((!NNS || NNS->isDependent()) &&
9732 assert(!CheckQTN && "Dependent template name canonicalization broken");
9782 /// getFromTargetType - Given one of the integer types provided by
9803 //===----------------------------------------------------------------------===//
9805 //===----------------------------------------------------------------------===//
9807 /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
9817 // Default behaviour under objective-C's gc is for ObjC pointers
9821 if (Ty->isObjCObjectPointerType() || Ty->isBlockPointerType())
9823 else if (Ty->isPointerType())
9824 return getObjCGCAttrKind(Ty->castAs<PointerType>()->getPointeeType());
9829 QualType CT = Ty->getCanonicalTypeInternal();
9831 CT = AT->getElementType();
9832 assert(CT->isAnyPointerType() || CT->isBlockPointerType());
9838 //===----------------------------------------------------------------------===//
9840 //===----------------------------------------------------------------------===//
9842 /// areCompatVectorTypes - Return true if the two specified vector types are
9846 assert(LHS->isCanonicalUnqualified() && RHS->isCanonicalUnqualified());
9847 return LHS->getElementType() == RHS->getElementType() &&
9848 LHS->getNumElements() == RHS->getNumElements();
9851 /// areCompatMatrixTypes - Return true if the two specified matrix types are
9855 assert(LHS->isCanonicalUnqualified() && RHS->isCanonicalUnqualified());
9856 return LHS->getElementType() == RHS->getElementType() &&
9857 LHS->getNumRows() == RHS->getNumRows() &&
9858 LHS->getNumColumns() == RHS->getNumColumns();
9863 assert(FirstVec->isVectorType() && "FirstVec should be a vector type");
9864 assert(SecondVec->isVectorType() && "SecondVec should be a vector type");
9871 const auto *First = FirstVec->castAs<VectorType>();
9872 const auto *Second = SecondVec->castAs<VectorType>();
9873 if (First->getNumElements() == Second->getNumElements() &&
9874 hasSameType(First->getElementType(), Second->getElementType()) &&
9875 First->getVectorKind() != VectorKind::AltiVecPixel &&
9876 First->getVectorKind() != VectorKind::AltiVecBool &&
9877 Second->getVectorKind() != VectorKind::AltiVecPixel &&
9878 Second->getVectorKind() != VectorKind::AltiVecBool &&
9879 First->getVectorKind() != VectorKind::SveFixedLengthData &&
9880 First->getVectorKind() != VectorKind::SveFixedLengthPredicate &&
9881 Second->getVectorKind() != VectorKind::SveFixedLengthData &&
9882 Second->getVectorKind() != VectorKind::SveFixedLengthPredicate &&
9883 First->getVectorKind() != VectorKind::RVVFixedLengthData &&
9884 Second->getVectorKind() != VectorKind::RVVFixedLengthData &&
9885 First->getVectorKind() != VectorKind::RVVFixedLengthMask &&
9886 Second->getVectorKind() != VectorKind::RVVFixedLengthMask)
9892 /// getSVETypeSize - Return SVE vector or predicate register size.
9894 assert(Ty->isSveVLSBuiltinType() && "Invalid SVE Type");
9895 if (Ty->getKind() == BuiltinType::SveBool ||
9896 Ty->getKind() == BuiltinType::SveCount)
9904 if (const auto *BT = FirstType->getAs<BuiltinType>()) {
9905 if (const auto *VT = SecondType->getAs<VectorType>()) {
9908 if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
9909 return BT->getKind() == BuiltinType::SveBool;
9910 else if (VT->getVectorKind() == VectorKind::SveFixedLengthData)
9911 return VT->getElementType().getCanonicalType() ==
9912 FirstType->getSveEltType(*this);
9913 else if (VT->getVectorKind() == VectorKind::Generic)
9915 hasSameType(VT->getElementType(),
9929 const auto *BT = FirstType->getAs<BuiltinType>();
9933 const auto *VecTy = SecondType->getAs<VectorType>();
9934 if (VecTy && (VecTy->getVectorKind() == VectorKind::SveFixedLengthData ||
9935 VecTy->getVectorKind() == VectorKind::Generic)) {
9941 if (BT->getKind() == BuiltinType::SveBool &&
9942 VecTy->getVectorKind() == VectorKind::SveFixedLengthData)
9950 if (VecTy->getVectorKind() == VectorKind::Generic &&
9954 // If -flax-vector-conversions=all is specified, the types are
9959 // If -flax-vector-conversions=integer is specified, the types are
9962 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
9963 FirstType->getSveEltType(*this)->isIntegerType();
9973 /// getRVVTypeSize - Return RVV vector register size.
9975 assert(Ty->isRVVVLSBuiltinType() && "Invalid RVV Type");
9987 return VScale->first * MinElts * EltSize;
9993 ((FirstType->isRVVSizelessBuiltinType() && SecondType->isVectorType()) ||
9994 (FirstType->isVectorType() && SecondType->isRVVSizelessBuiltinType())) &&
9998 if (const auto *BT = FirstType->getAs<BuiltinType>()) {
9999 if (const auto *VT = SecondType->getAs<VectorType>()) {
10000 if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) {
10002 return FirstType->isRVVVLSBuiltinType() &&
10006 if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
10007 VT->getVectorKind() == VectorKind::Generic)
10008 return FirstType->isRVVVLSBuiltinType() &&
10010 hasSameType(VT->getElementType(),
10024 ((FirstType->isRVVSizelessBuiltinType() && SecondType->isVectorType()) ||
10025 (FirstType->isVectorType() && SecondType->isRVVSizelessBuiltinType())) &&
10029 const auto *BT = FirstType->getAs<BuiltinType>();
10033 if (!BT->isRVVVLSBuiltinType())
10036 const auto *VecTy = SecondType->getAs<VectorType>();
10037 if (VecTy && VecTy->getVectorKind() == VectorKind::Generic) {
10045 // If -flax-vector-conversions=all is specified, the types are
10050 // If -flax-vector-conversions=integer is specified, the types are
10053 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10054 FirstType->getRVVEltType(*this)->isIntegerType();
10068 if (Attr->getAttrKind() == attr::ObjCOwnership)
10071 Ty = Attr->getModifiedType();
10075 Ty = Paren->getInnerType();
10086 //===----------------------------------------------------------------------===//
10087 // ObjCQualifiedIdTypesAreCompatible - Compatibility testing for qualified id's.
10088 //===----------------------------------------------------------------------===//
10090 /// ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the
10097 for (auto *PI : rProto->protocols())
10103 /// ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and
10107 for (auto *lhsProto : lhs->quals()) {
10109 for (auto *rhsProto : rhs->quals()) {
10121 /// ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an
10127 if (lhs->isObjCIdType() || rhs->isObjCIdType())
10131 if (lhs->isObjCClassType() || lhs->isObjCQualifiedClassType() ||
10132 rhs->isObjCClassType() || rhs->isObjCQualifiedClassType())
10135 if (lhs->isObjCQualifiedIdType()) {
10136 if (rhs->qual_empty()) {
10139 if (ObjCInterfaceDecl *rhsID = rhs->getInterfaceDecl()) {
10140 for (auto *I : lhs->quals()) {
10144 if (!rhsID->ClassImplementsProtocol(I, true))
10152 for (auto *lhsProto : lhs->quals()) {
10158 for (auto *rhsProto : rhs->quals()) {
10167 if (ObjCInterfaceDecl *rhsID = rhs->getInterfaceDecl()) {
10168 for (auto *I : lhs->quals()) {
10172 if (rhsID->ClassImplementsProtocol(I, true)) {
10185 assert(rhs->isObjCQualifiedIdType() && "One of the LHS/RHS should be id<x>");
10187 if (lhs->getInterfaceType()) {
10189 for (auto *lhsProto : lhs->quals()) {
10197 for (auto *rhsProto : rhs->quals()) {
10210 if (ObjCInterfaceDecl *lhsID = lhs->getInterfaceDecl()) {
10216 if (LHSInheritedProtocols.empty() && lhs->qual_empty())
10220 for (auto *rhsProto : rhs->quals()) {
10236 /// canAssignObjCInterfaces - Return true if the two interface types are
10241 const ObjCObjectType* LHS = LHSOPT->getObjectType();
10242 const ObjCObjectType* RHS = RHSOPT->getObjectType();
10244 // If either type represents the built-in 'id' type, return true.
10245 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
10250 auto finish = [&](bool succeeded) -> bool {
10254 if (!RHS->isKindOfType())
10259 return canAssignObjCInterfaces(RHSOPT->stripObjCKindOfTypeAndQuals(*this),
10260 LHSOPT->stripObjCKindOfTypeAndQuals(*this));
10265 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
10270 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
10274 // Casts from Class to Class<Foo>, or vice-versa, are allowed.
10275 if (LHS->isObjCClass() && RHS->isObjCClass()) {
10279 // If we have 2 user-defined types, fall into that path.
10280 if (LHS->getInterface() && RHS->getInterface()) {
10287 /// canAssignObjCInterfacesInBlockPointer - This routine is specifically written
10288 /// for providing type-safety for objective-c pointers used to pass/return
10299 auto finish = [&](bool succeeded) -> bool {
10304 if (!Expected->isKindOfType())
10310 RHSOPT->stripObjCKindOfTypeAndQuals(*this),
10311 LHSOPT->stripObjCKindOfTypeAndQuals(*this),
10315 if (RHSOPT->isObjCBuiltinType() || LHSOPT->isObjCIdType())
10318 if (LHSOPT->isObjCBuiltinType()) {
10319 return finish(RHSOPT->isObjCBuiltinType() ||
10320 RHSOPT->isObjCQualifiedIdType());
10323 if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) {
10327 // Or corrected type checking as in non-compat mode.
10336 const ObjCInterfaceType* LHS = LHSOPT->getInterfaceType();
10337 const ObjCInterfaceType* RHS = RHSOPT->getInterfaceType();
10338 if (LHS && RHS) { // We have 2 user-defined types.
10340 if (LHS->getDecl()->isSuperClassOf(RHS->getDecl()))
10342 if (RHS->getDecl()->isSuperClassOf(LHS->getDecl()))
10351 /// Comparison routine for Objective-C protocols to be used with
10355 return (*lhs)->getName().compare((*rhs)->getName());
10358 /// getIntersectionOfProtocols - This routine finds the intersection of set
10359 /// of protocols inherited from two distinct objective-c pointer objects with
10362 /// the conditional expression involving two objective-c pointer objects.
10370 const ObjCObjectType* LHS = LHSOPT->getObjectType();
10371 const ObjCObjectType* RHS = RHSOPT->getObjectType();
10372 assert(LHS->getInterface() && "LHS must have an interface base");
10373 assert(RHS->getInterface() && "RHS must have an interface base");
10379 for (auto *proto : LHS->quals()) {
10384 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
10390 for (auto *proto : RHS->quals()) {
10395 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
10410 llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool {
10424 const auto *lhsOPT = lhs->getAs<ObjCObjectPointerType>();
10425 const auto *rhsOPT = rhs->getAs<ObjCObjectPointerType>();
10430 const auto *lhsBlock = lhs->getAs<BlockPointerType>();
10431 const auto *rhsBlock = rhs->getAs<BlockPointerType>();
10437 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
10438 (rhsOPT && rhsOPT->isObjCIdType() && lhsBlock))
10444 // Check that the given Objective-C type argument lists are equivalent.
10453 ObjCTypeParamList *typeParams = iface->getTypeParamList();
10461 switch (typeParams->begin()[i]->getVariance()) {
10488 const ObjCObjectType *LHS = Lptr->getObjectType();
10489 const ObjCObjectType *RHS = Rptr->getObjectType();
10490 const ObjCInterfaceDecl* LDecl = LHS->getInterface();
10491 const ObjCInterfaceDecl* RDecl = RHS->getInterface();
10499 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
10501 // Follow the left-hand side up the class hierarchy until we either hit a
10508 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
10510 if (declaresSameEntity(LHS->getInterface(), RDecl)) {
10512 ArrayRef<QualType> LHSTypeArgs = LHS->getTypeArgsAsWritten();
10514 if (LHS->isSpecialized() && RHS->isSpecialized()) {
10516 if (!sameObjCTypeArgs(*this, LHS->getInterface(),
10517 LHS->getTypeArgs(), RHS->getTypeArgs(),
10520 } else if (LHS->isSpecialized() != RHS->isSpecialized()) {
10529 getIntersectionOfProtocols(*this, LHS->getInterface(), Lptr, Rptr,
10537 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
10538 QualType Result = getObjCInterfaceType(LHS->getInterface());
10540 anyKindOf || LHS->isKindOfType());
10548 QualType LHSSuperType = LHS->getSuperClassType();
10552 LHS = LHSSuperType->castAs<ObjCObjectType>();
10558 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
10560 LHS = KnownLHS->second;
10563 ArrayRef<QualType> RHSTypeArgs = RHS->getTypeArgsAsWritten();
10565 if (LHS->isSpecialized() && RHS->isSpecialized()) {
10567 if (!sameObjCTypeArgs(*this, LHS->getInterface(),
10568 LHS->getTypeArgs(), RHS->getTypeArgs(),
10571 } else if (LHS->isSpecialized() != RHS->isSpecialized()) {
10580 getIntersectionOfProtocols(*this, RHS->getInterface(), Lptr, Rptr,
10587 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
10588 QualType Result = getObjCInterfaceType(RHS->getInterface());
10590 anyKindOf || RHS->isKindOfType());
10598 QualType RHSSuperType = RHS->getSuperClassType();
10602 RHS = RHSSuperType->castAs<ObjCObjectType>();
10610 assert(LHS->getInterface() && "LHS is not an interface type");
10611 assert(RHS->getInterface() && "RHS is not an interface type");
10615 ObjCInterfaceDecl *LHSInterface = LHS->getInterface();
10616 bool IsSuperClass = LHSInterface->isSuperClassOf(RHS->getInterface());
10623 if (LHS->getNumProtocols() > 0) {
10629 CollectInheritedProtocols(RHS->getInterface(), SuperClassInheritedProtocols);
10632 for (auto *RHSPI : RHS->quals())
10638 for (const auto *LHSProto : LHS->quals()) {
10641 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
10651 if (LHS->isSpecialized()) {
10655 while (!declaresSameEntity(RHSSuper->getInterface(), LHSInterface))
10656 RHSSuper = RHSSuper->getSuperClassType()->castAs<ObjCObjectType>();
10659 if (RHSSuper->isSpecialized() &&
10660 !sameObjCTypeArgs(*this, LHS->getInterface(),
10661 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
10672 const auto *LHSOPT = LHS->getAs<ObjCObjectPointerType>();
10673 const auto *RHSOPT = RHS->getAs<ObjCObjectPointerType>();
10684 getObjCObjectPointerType(To)->castAs<ObjCObjectPointerType>(),
10685 getObjCObjectPointerType(From)->castAs<ObjCObjectPointerType>());
10688 /// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,
10708 /// mergeTransparentUnionType - if T is a transparent union type and a member
10714 if (const RecordType *UT = T->getAsUnionType()) {
10715 RecordDecl *UD = UT->getDecl();
10716 if (UD->hasAttr<TransparentUnionAttr>()) {
10717 for (const auto *I : UD->fields()) {
10718 QualType ET = I->getType().getUnqualifiedType();
10729 /// mergeFunctionParameterTypes - merge two types which appear as function
10754 const auto *lbase = lhs->castAs<FunctionType>();
10755 const auto *rbase = rhs->castAs<FunctionType>();
10764 QualType RHS = rbase->getReturnType();
10765 QualType LHS = lbase->getReturnType();
10772 retType = mergeTypes(lbase->getReturnType(), rbase->getReturnType(), false,
10780 CanQualType LRetType = getCanonicalType(lbase->getReturnType());
10781 CanQualType RRetType = getCanonicalType(rbase->getReturnType());
10793 // FIXME: should we error if lbase->getRegParmAttr() != 0 &&
10794 // rbase->getRegParmAttr() != 0 &&
10795 // lbase->getRegParmAttr() != rbase->getRegParmAttr()?
10796 FunctionType::ExtInfo lbaseInfo = lbase->getExtInfo();
10797 FunctionType::ExtInfo rbaseInfo = rbase->getExtInfo();
10832 // higher-order functions (taking noreturn callbacks!), which is uncommon to
10848 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
10851 if (lproto->getNumParams() != rproto->getNumParams())
10854 // Variadic and non-variadic functions aren't compatible
10855 if (lproto->isVariadic() != rproto->isVariadic())
10858 if (lproto->getMethodQuals() != rproto->getMethodQuals())
10862 FunctionEffectsRef LHSFX = lproto->getFunctionEffects();
10863 FunctionEffectsRef RHSFX = rproto->getFunctionEffects();
10893 for (unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
10894 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
10895 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
10919 FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo();
10933 assert((AllowCXX || !proto->hasExceptionSpec()) && "C++ shouldn't be here");
10934 if (proto->isVariadic())
10941 for (unsigned i = 0, n = proto->getNumParams(); i < n; ++i) {
10942 QualType paramTy = proto->getParamType(i);
10946 if (const auto *Enum = paramTy->getAs<EnumType>()) {
10947 paramTy = Enum->getDecl()->getIntegerType();
10960 FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo();
10964 return getFunctionType(retType, proto->getParamTypes(), EPI);
10972 /// Given that we have an enum type and a non-enum type, try to merge them.
10979 QualType underlyingType = ET->getDecl()->getIntegerType();
10987 if (isBlockReturnType && other->isIntegerType() &&
11005 auto *LHSRefTy = LHS->getAs<ReferenceType>();
11006 auto *RHSRefTy = RHS->getAs<ReferenceType>();
11008 LHS->getTypeClass() == RHS->getTypeClass())
11009 return mergeTypes(LHSRefTy->getPointeeType(), RHSRefTy->getPointeeType(),
11050 if (GC_L == Qualifiers::Strong && RHSCan->isObjCObjectPointerType()) {
11053 if (GC_R == Qualifiers::Strong && LHSCan->isObjCObjectPointerType()) {
11061 Type::TypeClass LHSClass = LHSCan->getTypeClass();
11062 Type::TypeClass RHSClass = RHSCan->getTypeClass();
11079 // Canonicalize ExtVector -> Vector.
11086 // returns into block int returns, not vice-versa.
11087 if (const auto *ETy = LHS->getAs<EnumType>()) {
11090 if (const EnumType* ETy = RHS->getAs<EnumType>()) {
11095 if (LHS->isObjCIdType() && RHS->isBlockPointerType())
11097 if (RHS->isObjCIdType() && LHS->isBlockPointerType())
11102 if (const auto *AT = LHS->getAs<AutoType>()) {
11103 if (!AT->isDeduced() && AT->isGNUAutoType())
11106 if (const auto *AT = RHS->getAs<AutoType>()) {
11107 if (!AT->isDeduced() && AT->isGNUAutoType())
11121 llvm_unreachable("Non-canonical and dependent types shouldn't get here");
11140 QualType LHSPointee = LHS->castAs<PointerType>()->getPointeeType();
11141 QualType RHSPointee = RHS->castAs<PointerType>()->getPointeeType();
11159 QualType LHSPointee = LHS->castAs<BlockPointerType>()->getPointeeType();
11160 QualType RHSPointee = RHS->castAs<BlockPointerType>()->getPointeeType();
11192 QualType LHSValue = LHS->castAs<AtomicType>()->getValueType();
11193 QualType RHSValue = RHS->castAs<AtomicType>()->getValueType();
11212 if (LCAT && RCAT && RCAT->getZExtSize() != LCAT->getZExtSize())
11215 QualType LHSElem = getAsArrayType(LHS)->getElementType();
11216 QualType RHSElem = getAsArrayType(RHS)->getElementType();
11234 -> std::pair<bool,llvm::APInt> {
11237 Expr *E = VAT->getSizeExpr();
11238 if (E && (TheInt = E->getIntegerConstantExpr(*this)))
11243 return std::make_pair(true, CAT->getSize());
11260 return getConstantArrayType(ResultType, LCAT->getSize(),
11261 LCAT->getSizeExpr(), ArraySizeModifier(), 0);
11263 return getConstantArrayType(ResultType, RCAT->getSize(),
11264 RCAT->getSizeExpr(), ArraySizeModifier(), 0);
11299 if (areCompatVectorTypes(LHSCan->castAs<VectorType>(),
11300 RHSCan->castAs<VectorType>()))
11304 if (areCompatMatrixTypes(LHSCan->castAs<ConstantMatrixType>(),
11305 RHSCan->castAs<ConstantMatrixType>()))
11312 if (canAssignObjCInterfaces(LHS->castAs<ObjCObjectType>(),
11313 RHS->castAs<ObjCObjectType>()))
11320 LHS->castAs<ObjCObjectPointerType>(),
11321 RHS->castAs<ObjCObjectPointerType>(), BlockReturnType))
11325 if (canAssignObjCInterfaces(LHS->castAs<ObjCObjectPointerType>(),
11326 RHS->castAs<ObjCObjectPointerType>()))
11338 // Merge two bit-precise int types, while trying to preserve typedef info.
11339 bool LHSUnsigned = LHS->castAs<BitIntType>()->isUnsigned();
11340 bool RHSUnsigned = RHS->castAs<BitIntType>()->isUnsigned();
11341 unsigned LHSBits = LHS->castAs<BitIntType>()->getNumBits();
11342 unsigned RHSBits = RHS->castAs<BitIntType>()->getNumBits();
11363 bool FirstHasInfo = FirstFnType->hasExtParameterInfos();
11364 bool SecondHasInfo = SecondFnType->hasExtParameterInfos();
11372 size_t E = FirstHasInfo ? FirstFnType->getExtParameterInfos().size()
11373 : SecondFnType->getExtParameterInfos().size();
11378 FirstParam = FirstFnType->getExtParameterInfo(I);
11380 SecondParam = SecondFnType->getExtParameterInfo(I);
11408 /// mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and
11417 if (RHSCan->isFunctionType()) {
11418 if (!LHSCan->isFunctionType())
11421 cast<FunctionType>(RHSCan.getTypePtr())->getReturnType();
11423 cast<FunctionType>(LHSCan.getTypePtr())->getReturnType();
11431 const auto *F = LHS->castAs<FunctionType>();
11433 FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
11436 getFunctionType(OldReturnType, FPT->getParamTypes(), EPI);
11471 if (LHSCan->isObjCObjectPointerType() && RHSCan->isObjCObjectPointerType()) {
11472 QualType LHSBaseQT = LHS->castAs<ObjCObjectPointerType>()->getPointeeType();
11473 QualType RHSBaseQT = RHS->castAs<ObjCObjectPointerType>()->getPointeeType();
11483 //===----------------------------------------------------------------------===//
11485 //===----------------------------------------------------------------------===//
11488 if (const auto *ET = T->getAs<EnumType>())
11489 T = ET->getDecl()->getIntegerType();
11490 if (T->isBooleanType())
11492 if (const auto *EIT = T->getAs<BitIntType>())
11493 return EIT->getNumBits();
11499 assert((T->hasIntegerRepresentation() || T->isEnumeralType() ||
11500 T->isFixedPointType()) &&
11503 // Turn <4 x signed int> -> <4 x unsigned int>
11504 if (const auto *VTy = T->getAs<VectorType>())
11505 return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
11506 VTy->getNumElements(), VTy->getVectorKind());
11509 if (const auto *EITy = T->getAs<BitIntType>())
11510 return getBitIntType(/*Unsigned=*/true, EITy->getNumBits());
11514 if (const auto *ETy = T->getAs<EnumType>())
11515 T = ETy->getDecl()->getIntegerType();
11517 switch (T->castAs<BuiltinType>()->getKind()) {
11565 assert((T->hasUnsignedIntegerRepresentation() ||
11566 T->isUnsignedFixedPointType()) &&
11573 assert((T->hasIntegerRepresentation() || T->isEnumeralType() ||
11574 T->isFixedPointType()) &&
11577 // Turn <4 x unsigned int> -> <4 x signed int>
11578 if (const auto *VTy = T->getAs<VectorType>())
11579 return getVectorType(getCorrespondingSignedType(VTy->getElementType()),
11580 VTy->getNumElements(), VTy->getVectorKind());
11583 if (const auto *EITy = T->getAs<BitIntType>())
11584 return getBitIntType(/*Unsigned=*/false, EITy->getNumBits());
11588 if (const auto *ETy = T->getAs<EnumType>())
11589 T = ETy->getDecl()->getIntegerType();
11591 switch (T->castAs<BuiltinType>()->getKind()) {
11640 (T->hasSignedIntegerRepresentation() || T->isSignedFixedPointType()) &&
11651 //===----------------------------------------------------------------------===//
11653 //===----------------------------------------------------------------------===//
11655 /// DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the
11679 default: Done = true; --Str; break;
11859 // passed by reference. An example of a by-value va_list is
11860 // x86, where va_list is a char*. An example of by-ref va_list
11861 // is x86-64, where va_list is a __va_list_tag[1]. For x86,
11862 // we want this argument to be a char*&; for x86-64, we want
11866 if (Type->isArrayType())
11972 default: Done = true; --Str; break;
11976 // qualified with an address space.
11980 // Note AddrSpace == 0 is not the same as an unspecified address space.
11992 // FIXME: There's no way to have a built-in with an rvalue ref arg.
12005 assert((!RequiresICE || Type->isIntegralOrEnumerationType()) &&
12012 // type descriptors for target-dependent types. These descriptors are decoded in
12014 // descriptor decoding to define builtins mixing target-dependent and target-
12023 /// GetBuiltinType - Return the type for the specified builtin.
12054 // Do array -> pointer decay. The builtin should use the decayed type.
12055 if (Ty->isArrayType())
12074 // We really shouldn't be making a no-proto type here.
12090 if (!FD->isExternallyVisible())
12093 // Non-user-provided functions get emitted as weak definitions with every
12095 if (!FD->isUserProvided())
12099 switch (FD->getTemplateSpecializationKind()) {
12112 // inlining, but that no out-of-line copy of the inline function would be
12113 // generated in the translation unit. -- end note ]
12122 if (!FD->isInlined())
12127 !FD->hasAttr<DLLExportAttr>()) ||
12128 FD->hasAttr<GNUInlineAttr>()) {
12133 if (FD->isInlineDefinitionExternallyVisible())
12140 // Functions specified with extern and inline in -fms-compatibility mode
12143 if (FD->isMSExternInline())
12148 cast<CXXConstructorDecl>(FD)->isInheritingConstructor())
12159 // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
12161 if (D->hasAttr<DLLImportAttr>()) {
12164 } else if (D->hasAttr<DLLExportAttr>()) {
12168 // Device-side functions with __global__ attribute must always be
12170 if (D->hasAttr<CUDAGlobalAttr>() &&
12194 switch (Source->hasExternalDefinitions(D)) {
12223 VD->getType().isConstQualified() &&
12224 !VD->getType().isVolatileQualified() && !VD->isInline() &&
12225 !isa<VarTemplateSpecializationDecl>(VD) && !VD->getDescribedVarTemplate())
12228 if (!VD->isExternallyVisible())
12231 if (VD->isStaticLocal()) {
12232 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
12234 LexicalContext = LexicalContext->getLexicalParent();
12236 // ObjC Blocks can create local variables that don't have a FunctionDecl
12241 // Otherwise, let the static local variable inherit its linkage from the
12246 // Itanium ABI 5.2.2: "Each COMDAT group [for a static local variable] must
12248 // contains, whether inline or out-of-line."
12258 // MSVC treats in-class initialized static data members as definitions.
12259 // By giving them non-strong linkage, out-of-line definitions won't
12264 // Most non-template variables have strong linkage; inline variables are
12280 switch (VD->getTemplateSpecializationKind()) {
12286 VD->isStaticDataMember()
12311 if (!VD->isFileVarDecl())
12314 if (VD->getStorageClass() == SC_Register)
12316 if (VD->getDescribedVarTemplate() ||
12321 if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
12330 return !D->getDeclContext()->isDependentContext();
12332 return !D->getDeclContext()->isDependentContext();
12334 return !D->getDeclContext()->isDependentContext();
12341 if (D->getDeclContext()->isDependentContext())
12345 if (D->hasAttr<WeakRefAttr>())
12349 if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>())
12354 if (!FD->doesThisDeclarationHaveABody())
12355 return FD->doesDeclarationForceExternallyVisibleDefinition();
12358 if (FD->hasAttr<ConstructorAttr>() || FD->hasAttr<DestructorAttr>())
12365 const CXXRecordDecl *RD = MD->getParent();
12366 if (MD->isOutOfLine() && RD->isDynamicClass()) {
12368 if (KeyFunc && KeyFunc->getCanonicalDecl() == MD->getCanonicalDecl())
12383 assert(VD->isFileVarDecl() && "Expected file scoped var");
12391 if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly &&
12395 if (VD->shouldEmitInExternalSource())
12407 // Variables that have destruction with side-effects are required.
12408 if (VD->needsDestruction(*this))
12411 // Variables that have initialization with side-effects are required.
12412 if (VD->getInit() && VD->getInit()->HasSideEffects(*this) &&
12413 // We can get a value-dependent initializer during error recovery.
12414 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
12417 // Likewise, variables with tuple-like bindings are required if their
12418 // bindings have side-effects.
12420 for (const auto *BD : DD->bindings())
12421 if (const auto *BindingVD = BD->getHoldingVar())
12431 assert(FD->isMultiVersion() && "Only valid for multiversioned functions");
12433 FD = FD->getMostRecentDecl();
12435 // lookup results, which happens to be (mostly) oldest-to-newest, but we
12438 FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
12439 FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl();
12440 if (CurFD && hasSameType(CurFD->getType(), FD->getType()) &&
12453 return ABI->getDefaultMethodCallConv(IsVariadic);
12455 // Builtins ignore user-specified default calling convention and remain the
12487 return Target->getDefaultCallingConv();
12492 return ABI->isNearlyEmpty(RD);
12497 auto ABI = Target->getCXXABI();
12513 switch (T->getCXXABI().getKind()) {
12547 [](ASTContext &, const NamedDecl *ND) -> std::optional<unsigned> {
12549 return RD->getDeviceLambdaManglingNumber();
12578 /// getIntTypeForBitwidth -
12591 /// getRealTypeForBitwidth -
12625 Listener->AddedManglingNumber(ND, Number);
12631 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
12650 Listener->AddedStaticLocalNumbers(VD, Number);
12655 return I != StaticLocalNumbers.end() ? I->second : 1;
12679 return ABI->createMangleNumberingContext();
12684 return ABI->getCopyConstructorForExceptionObject(
12685 cast<CXXRecordDecl>(RD->getFirstDecl()));
12690 return ABI->addCopyConstructorForExceptionObject(
12691 cast<CXXRecordDecl>(RD->getFirstDecl()),
12692 cast<CXXConstructorDecl>(CD->getFirstDecl()));
12697 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
12702 return ABI->getTypedefNameForUnnamedTagDecl(TD);
12707 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
12711 return ABI->getDeclaratorForUnnamedTagDecl(TD);
12722 return I->second;
12727 // A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
12786 assert(T->isRecordType() && "template param object of unexpected type");
12814 QualType AtomicTy = E->getPtr()->getType()->getPointeeType();
12827 if (MethodDecl->hasAttr<UnavailableAttr>()
12828 || MethodDecl->hasAttr<DeprecatedAttr>())
12830 if (MethodDecl->getObjCDeclQualifier() !=
12831 MethodImpl->getObjCDeclQualifier())
12833 if (!hasSameType(MethodDecl->getReturnType(), MethodImpl->getReturnType()))
12836 if (MethodDecl->param_size() != MethodImpl->param_size())
12839 for (ObjCMethodDecl::param_const_iterator IM = MethodImpl->param_begin(),
12840 IF = MethodDecl->param_begin(), EM = MethodImpl->param_end(),
12841 EF = MethodDecl->param_end();
12845 if (ImplVar->getObjCDeclQualifier() != DeclVar->getObjCDeclQualifier())
12847 if (!hasSameType(DeclVar->getType(), ImplVar->getType()))
12851 return (MethodDecl->isVariadic() == MethodImpl->isVariadic());
12856 if (QT->getUnqualifiedDesugaredType()->isNullPtrType())
12859 AS = QT->getPointeeType().getAddressSpace();
12874 X->Profile(IDX, *this, /*Canonical=*/true);
12875 Y->Profile(IDY, *this, /*Canonical=*/true);
12883 // The getCommon*Checked variants are 'null inputs not-allowed' equivalents of
12889 for (const Decl *DX : X->redecls()) {
12894 if (DX->isFirstDecl())
12945 return X->getAttributeLoc() == Y->getAttributeLoc() ? X->getAttributeLoc()
12968 if (!Ctx.hasSameType(X.getAsExpr()->getType(), Y.getAsExpr()->getType()))
13022 return X->getKeyword() == Y->getKeyword() ? X->getKeyword()
13030 return X->getQualifier() == Y->getQualifier()
13031 ? X->getQualifier()
13032 : Ctx.getCanonicalNestedNameSpecifier(X->getQualifier());
13037 return Ctx.getCommonSugaredType(X->getElementType(), Y->getElementType());
13044 QualType EX = X->getElementType(), EY = Y->getElementType();
13048 QX += EX.getQualifiers() - RQ;
13049 QY += EY.getQualifiers() - RQ;
13055 return Ctx.getCommonSugaredType(X->getPointeeType(), Y->getPointeeType());
13059 assert(Ctx.hasSameExpr(X->getSizeExpr(), Y->getSizeExpr()));
13060 return X->getSizeExpr();
13064 assert(X->getSizeModifier() == Y->getSizeModifier());
13065 return X->getSizeModifier();
13070 assert(X->getIndexTypeCVRQualifiers() == Y->getIndexTypeCVRQualifiers());
13071 return X->getIndexTypeCVRQualifiers();
13085 QualType &U = Out[Res.first->second];
13109 // If either of them is non-throwing, the result is the other.
13118 // If we're left with value-dependent computed noexcept expressions, we're
13165 Type::TypeClass TC = X->getTypeClass();
13166 assert(TC == Y->getTypeClass());
13172 #define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
13176 #define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
13187 #define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
13198 assert(AX->getDeducedType().isNull());
13199 assert(AY->getDeducedType().isNull());
13200 assert(AX->getKeyword() == AY->getKeyword());
13201 assert(AX->isInstantiationDependentType() ==
13202 AY->isInstantiationDependentType());
13203 auto As = getCommonTemplateArguments(Ctx, AX->getTypeConstraintArguments(),
13204 AY->getTypeConstraintArguments());
13205 return Ctx.getAutoType(QualType(), AX->getKeyword(),
13206 AX->isInstantiationDependentType(),
13207 AX->containsUnexpandedParameterPack(),
13208 getCommonDeclChecked(AX->getTypeConstraintConcept(),
13209 AY->getTypeConstraintConcept()),
13226 AX->getBracketsRange() == AY->getBracketsRange()
13227 ? AX->getBracketsRange()
13233 assert(AX->getSize() == AY->getSize());
13234 const Expr *SizeExpr = Ctx.hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
13235 ? AX->getSizeExpr()
13238 getCommonArrayElementType(Ctx, AX, QX, AY, QY), AX->getSize(), SizeExpr,
13244 assert(AX->getSize() == AY->getSize());
13245 const Expr *SizeExpr = Ctx.hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
13246 ? AX->getSizeExpr()
13249 getCommonArrayElementType(Ctx, AX, QX, AY, QY), AX->getSize(), SizeExpr,
13256 Ctx.getCommonSugaredType(AX->getValueType(), AY->getValueType()));
13280 Ctx.getCommonSugaredType(QualType(PX->getClass(), 0),
13281 QualType(PY->getClass(), 0))
13289 PX->isSpelledAsLValue() ||
13290 PY->isSpelledAsLValue());
13301 assert(Ctx.hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
13303 PX->getAddrSpaceExpr(),
13309 assert(FX->getExtInfo() == FY->getExtInfo());
13311 Ctx.getCommonSugaredType(FX->getReturnType(), FY->getReturnType()),
13312 FX->getExtInfo());
13317 FunctionProtoType::ExtProtoInfo EPIX = FX->getExtProtoInfo(),
13318 EPIY = FY->getExtProtoInfo();
13331 Ctx.getCommonSugaredType(FX->getReturnType(), FY->getReturnType());
13332 auto P = getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
13343 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
13344 OY->getProtocols().begin(), OY->getProtocols().end(),
13346 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
13349 auto TAs = getCommonTypes(Ctx, OX->getTypeArgsAsWritten(),
13350 OY->getTypeArgsAsWritten());
13352 Ctx.getCommonSugaredType(OX->getBaseType(), OY->getBaseType()), TAs,
13353 OX->getProtocols(),
13354 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
13359 assert(MX->getNumRows() == MY->getNumRows());
13360 assert(MX->getNumColumns() == MY->getNumColumns());
13362 MX->getNumRows(), MX->getNumColumns());
13367 assert(Ctx.hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
13368 assert(Ctx.hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
13370 getCommonElementType(Ctx, MX, MY), MX->getRowExpr(),
13371 MX->getColumnExpr(), getCommonAttrLoc(MX, MY));
13375 assert(VX->getNumElements() == VY->getNumElements());
13376 assert(VX->getVectorKind() == VY->getVectorKind());
13378 VX->getNumElements(), VX->getVectorKind());
13382 assert(VX->getNumElements() == VY->getNumElements());
13384 VX->getNumElements());
13396 assert(VX->getVectorKind() == VY->getVectorKind());
13399 getCommonAttrLoc(VX, VY), VX->getVectorKind());
13405 getCommonDeclChecked(IX->getDecl(), IY->getDecl()),
13406 Ctx.getCommonSugaredType(IX->getInjectedSpecializationType(),
13407 IY->getInjectedSpecializationType()));
13412 auto As = getCommonTemplateArguments(Ctx, TX->template_arguments(),
13413 TY->template_arguments());
13415 ::getCommonTemplateNameChecked(Ctx, TX->getTemplateName(),
13416 TY->getTemplateName()),
13417 As, X->getCanonicalTypeInternal());
13422 assert(DX->isDependentType());
13423 assert(DY->isDependentType());
13424 assert(Ctx.hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
13431 assert(DX->isDependentType());
13432 assert(DY->isDependentType());
13433 assert(Ctx.hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
13439 assert(NX->getIdentifier() == NY->getIdentifier());
13442 NX->getIdentifier(), NX->getCanonicalTypeInternal());
13447 assert(TX->getIdentifier() == TY->getIdentifier());
13448 auto As = getCommonTemplateArguments(Ctx, TX->template_arguments(),
13449 TY->template_arguments());
13452 TX->getIdentifier(), As);
13457 assert(TX->getUTTKind() == TY->getUTTKind());
13459 Ctx.getCommonSugaredType(TX->getBaseType(), TY->getBaseType()),
13460 Ctx.getCommonSugaredType(TX->getUnderlyingType(),
13461 TY->getUnderlyingType()),
13462 TX->getUTTKind());
13467 assert(PX->getNumExpansions() == PY->getNumExpansions());
13469 Ctx.getCommonSugaredType(PX->getPattern(), PY->getPattern()),
13470 PX->getNumExpansions(), false);
13474 assert(PX->isReadOnly() == PY->isReadOnly());
13475 auto MP = PX->isReadOnly() ? &ASTContext::getReadPipeType
13482 assert(TX->getDepth() == TY->getDepth());
13483 assert(TX->getIndex() == TY->getIndex());
13484 assert(TX->isParameterPack() == TY->isParameterPack());
13486 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
13487 getCommonDecl(TX->getDecl(), TY->getDecl()));
13496 Type::TypeClass TC = X->getTypeClass();
13497 if (TC != Y->getTypeClass())
13538 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
13547 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
13556 AttributedType::Kind Kind = AX->getAttrKind();
13557 if (Kind != AY->getAttrKind())
13559 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
13568 const BTFTypeTagAttr *AX = BX->getAttr();
13570 if (AX->getBTFTypeTag() !=
13571 cast<BTFTagAttributedType>(Y)->getAttr()->getBTFTypeTag())
13578 AutoTypeKeyword KW = AX->getKeyword();
13579 if (KW != AY->getKeyword())
13582 ConceptDecl *CD = ::getCommonDecl(AX->getTypeConstraintConcept(),
13583 AY->getTypeConstraintConcept());
13586 getCommonTemplateArguments(Ctx, As, AX->getTypeConstraintArguments(),
13587 AY->getTypeConstraintArguments())) {
13594 return Ctx.getAutoType(Ctx.getQualifiedType(Underlying), AX->getKeyword(),
13609 ::getCommonDecl(EX->getOwnedTagDecl(), EY->getOwnedTagDecl()));
13614 const IdentifierInfo *IX = MX->getMacroIdentifier();
13615 if (IX != MY->getMacroIdentifier())
13623 ::getCommonDecl(SX->getAssociatedDecl(), SY->getAssociatedDecl());
13626 unsigned Index = SX->getIndex();
13627 if (Index != SY->getIndex())
13629 auto PackIndex = SX->getPackIndex();
13630 if (PackIndex != SY->getPackIndex())
13644 TemplateName CTN = ::getCommonTemplateName(Ctx, TX->getTemplateName(),
13645 TY->getTemplateName());
13649 if (getCommonTemplateArguments(Ctx, Args, TX->template_arguments(),
13650 TY->template_arguments()))
13657 const TypedefNameDecl *CD = ::getCommonDecl(TX->getDecl(), TY->getDecl());
13668 if (cast<TypeOfType>(X)->getKind() == cast<TypeOfType>(Y)->getKind() &&
13669 cast<TypeOfType>(X)->getKind() == TypeOfKind::Unqualified)
13679 UnaryTransformType::UTTKind KX = UX->getUTTKind();
13680 if (KX != UY->getUTTKind())
13682 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
13692 ::getCommonDecl(UX->getFoundDecl(), UY->getFoundDecl());
13700 if (DX->isCountInBytes() != DY->isCountInBytes())
13702 if (DX->isOrNull() != DY->isOrNull())
13704 Expr *CEX = DX->getCountExpr();
13705 Expr *CEY = DY->getCountExpr();
13706 llvm::ArrayRef<clang::TypeCoupledDeclRefInfo> CDX = DX->getCoupledDecls();
13709 DX->isCountInBytes(), DX->isOrNull(),
13711 if (!CEX->isIntegerConstantExpr(Ctx) || !CEY->isIntegerConstantExpr(Ctx))
13715 llvm::APSInt VX = *CEX->getIntegerConstantExpr(Ctx);
13716 llvm::APSInt VY = *CEY->getIntegerConstantExpr(Ctx);
13720 DX->isCountInBytes(), DX->isOrNull(),
13731 QualType NT = T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
13768 QX -= SX.Quals;
13769 QY -= SY.Quals;
13793 QX -= Underlying.Quals;
13804 assert(Ty->isFixedPointType());
13806 if (Ty->isUnsaturatedFixedPointType())
13809 switch (Ty->castAs<BuiltinType>()->getKind()) {
13840 assert(Ty->isFixedPointType());
13842 if (Ty->isSaturatedFixedPointType()) return Ty;
13844 switch (Ty->castAs<BuiltinType>()->getKind()) {
13894 assert(Ty->isFixedPointType());
13897 switch (Ty->castAs<BuiltinType>()->getKind()) {
13940 assert(Ty->isFixedPointType());
13943 switch (Ty->castAs<BuiltinType>()->getKind()) {
13982 assert((Ty->isFixedPointType() || Ty->isIntegerType()) &&
13985 if (Ty->isIntegerType())
13987 getIntWidth(Ty), Ty->isSignedIntegerType());
13989 bool isSigned = Ty->isSignedFixedPointType();
13992 Ty->isSaturatedFixedPointType(),
13997 assert(Ty->isFixedPointType());
14002 assert(Ty->isFixedPointType());
14007 assert(Ty->isUnsignedFixedPointType() &&
14010 switch (Ty->castAs<BuiltinType>()->getKind()) {
14047 for (StringRef F : FMVExt->getImpliedFeatures())
14055 ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(TD->getFeaturesStr());
14058 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
14068 Target->initFeatureMap(FeatureMap, getDiagnostics(),
14069 Target->getTargetOpts().CPU,
14070 Target->getTargetOpts().Features);
14077 StringRef TargetCPU = Target->getTargetOpts().CPU;
14078 const FunctionDecl *FD = GD.getDecl()->getAsFunction();
14079 if (const auto *TD = FD->getAttr<TargetAttr>()) {
14085 if (!Target->getTriple().isAArch64())
14088 Target->getTargetOpts().FeaturesAsWritten.begin(),
14089 Target->getTargetOpts().FeaturesAsWritten.end());
14091 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
14098 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU,
14100 } else if (const auto *SD = FD->getAttr<CPUSpecificAttr>()) {
14102 Target->getCPUSpecificCPUDispatchFeatures(
14103 SD->getCPUName(GD.getMultiVersionIndex())->getName(), FeaturesTmp);
14106 Target->getTargetOpts().FeaturesAsWritten.begin(),
14107 Target->getTargetOpts().FeaturesAsWritten.end());
14108 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
14109 } else if (const auto *TC = FD->getAttr<TargetClonesAttr>()) {
14110 if (Target->getTriple().isAArch64()) {
14112 TC->getFeatures(Feats, GD.getMultiVersionIndex());
14115 Target->getTargetOpts().FeaturesAsWritten.begin(),
14116 Target->getTargetOpts().FeaturesAsWritten.end());
14117 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
14120 StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
14122 TargetCPU = VersionStr.drop_front(sizeof("arch=") - 1);
14125 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
14127 } else if (const auto *TV = FD->getAttr<TargetVersionAttr>()) {
14129 TV->getFeatures(Feats);
14132 Target->getTargetOpts().FeaturesAsWritten.begin(),
14133 Target->getTargetOpts().FeaturesAsWritten.end());
14134 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
14136 FeatureMap = Target->getTargetOpts().FeatureMap;
14157 bool IsExplicitDeviceVar = (D->hasAttr<CUDADeviceAttr>() &&
14158 !D->getAttr<CUDADeviceAttr>()->isImplicit()) ||
14159 (D->hasAttr<CUDAConstantAttr>() &&
14160 !D->getAttr<CUDAConstantAttr>()->isImplicit());
14165 (D->hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
14166 (D->hasAttr<CUDAGlobalAttr>() &&
14173 (D->hasAttr<HIPManagedAttr>() || D->hasAttr<CUDAGlobalAttr>() ||
14189 assert(ThisClass->isPolymorphic());
14193 assert(PrimaryBase->isPolymorphic());
14196 if (!Base || Base == PrimaryBase || !Base->isPolymorphic())
14206 assert(Method->isVirtual());
14215 return Existing->second.contains(MangledName.str());
14220 if (const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
14226 Mangler->mangleCXXDtorThunk(Destructor, VirtualMethodDecl.getDtorType(),
14230 Mangler->mangleThunk(Method, Thunk, /* elideOverrideInfo */ true,
14235 Mangler->mangleCXXDtorThunk(Destructor, VirtualMethodDecl.getDtorType(),
14239 Mangler->mangleThunk(Method, Thunk, /* elideOverrideInfo */ false,