44#include "llvm/ADT/ArrayRef.h"
45#include "llvm/ADT/STLForwardCompat.h"
46#include "llvm/ADT/StringExtras.h"
47#include "llvm/IR/DerivedTypes.h"
48#include "llvm/Support/ErrorHandling.h"
49#include "llvm/TargetParser/RISCVTargetParser.h"
83 bool useExpansionLoc =
true;
84 switch (
attr.getKind()) {
85 case ParsedAttr::AT_ObjCGC:
88 case ParsedAttr::AT_ObjCOwnership:
94 useExpansionLoc =
false;
99 StringRef name =
attr.getAttrName()->getName();
103 attr.isArgIdent(0) ?
attr.getArgAsIdent(0)->getIdentifierInfo() :
nullptr;
104 if (useExpansionLoc && loc.
isMacroID() && II) {
105 if (II->
isStr(
"strong")) {
107 }
else if (II->
isStr(
"weak")) {
112 S.
Diag(loc,
attr.isRegularKeywordAttribute()
113 ? diag::err_type_attribute_wrong_type
114 : diag::warn_type_attribute_wrong_type)
115 << name << WhichType <<
type;
120#define OBJC_POINTER_TYPE_ATTRS_CASELIST \
121 case ParsedAttr::AT_ObjCGC: \
122 case ParsedAttr::AT_ObjCOwnership
125#define CALLING_CONV_ATTRS_CASELIST \
126 case ParsedAttr::AT_CDecl: \
127 case ParsedAttr::AT_FastCall: \
128 case ParsedAttr::AT_StdCall: \
129 case ParsedAttr::AT_ThisCall: \
130 case ParsedAttr::AT_RegCall: \
131 case ParsedAttr::AT_Pascal: \
132 case ParsedAttr::AT_SwiftCall: \
133 case ParsedAttr::AT_SwiftAsyncCall: \
134 case ParsedAttr::AT_VectorCall: \
135 case ParsedAttr::AT_AArch64VectorPcs: \
136 case ParsedAttr::AT_AArch64SVEPcs: \
137 case ParsedAttr::AT_MSABI: \
138 case ParsedAttr::AT_SysVABI: \
139 case ParsedAttr::AT_Pcs: \
140 case ParsedAttr::AT_IntelOclBicc: \
141 case ParsedAttr::AT_PreserveMost: \
142 case ParsedAttr::AT_PreserveAll: \
143 case ParsedAttr::AT_M68kRTD: \
144 case ParsedAttr::AT_PreserveNone: \
145 case ParsedAttr::AT_RISCVVectorCC: \
146 case ParsedAttr::AT_RISCVVLSCC
149#define FUNCTION_TYPE_ATTRS_CASELIST \
150 case ParsedAttr::AT_NSReturnsRetained: \
151 case ParsedAttr::AT_NoReturn: \
152 case ParsedAttr::AT_NonBlocking: \
153 case ParsedAttr::AT_NonAllocating: \
154 case ParsedAttr::AT_Blocking: \
155 case ParsedAttr::AT_Allocating: \
156 case ParsedAttr::AT_Regparm: \
157 case ParsedAttr::AT_CFIUncheckedCallee: \
158 case ParsedAttr::AT_CFISalt: \
159 case ParsedAttr::AT_CmseNSCall: \
160 case ParsedAttr::AT_ArmStreaming: \
161 case ParsedAttr::AT_ArmStreamingCompatible: \
162 case ParsedAttr::AT_ArmPreserves: \
163 case ParsedAttr::AT_ArmIn: \
164 case ParsedAttr::AT_ArmOut: \
165 case ParsedAttr::AT_ArmInOut: \
166 case ParsedAttr::AT_ArmAgnostic: \
167 case ParsedAttr::AT_AnyX86NoCallerSavedRegisters: \
168 case ParsedAttr::AT_AnyX86NoCfCheck: \
169 CALLING_CONV_ATTRS_CASELIST
172#define MS_TYPE_ATTRS_CASELIST \
173 case ParsedAttr::AT_Ptr32: \
174 case ParsedAttr::AT_Ptr64: \
175 case ParsedAttr::AT_SPtr: \
176 case ParsedAttr::AT_UPtr
179#define NULLABILITY_TYPE_ATTRS_CASELIST \
180 case ParsedAttr::AT_TypeNonNull: \
181 case ParsedAttr::AT_TypeNullable: \
182 case ParsedAttr::AT_TypeNullableResult: \
183 case ParsedAttr::AT_TypeNullUnspecified
188 class TypeProcessingState {
212 using TypeAttrPair = std::pair<const AttributedType*, const Attr*>;
214 bool AttrsForTypesSorted =
true;
218 llvm::DenseMap<const MacroQualifiedType *, SourceLocation> LocsForMacros;
226 bool ParsedHLSLParamMod;
230 :
sema(
sema), declarator(declarator),
232 ParsedHLSLParamMod(
false) {}
234 Sema &getSema()
const {
242 bool isProcessingDeclSpec()
const {
246 unsigned getCurrentChunkIndex()
const {
250 void setCurrentChunkIndex(
unsigned idx) {
256 if (isProcessingDeclSpec())
257 return getMutableDeclSpec().getAttributes();
262 void saveDeclSpecAttrs() {
264 if (!savedAttrs.empty())
267 DeclSpec &spec = getMutableDeclSpec();
268 llvm::append_range(savedAttrs,
275 ignoredTypeAttrs.push_back(&
attr);
281 for (
auto *
Attr : ignoredTypeAttrs)
290 sema.Context.getAttributedType(A, ModifiedType, EquivType);
292 AttrsForTypesSorted =
false;
297 QualType getBTFTagAttributedType(
const BTFTypeTagAttr *BTFAttr,
299 return sema.Context.getBTFTagAttributedType(BTFAttr, WrappedType);
305 getOverflowBehaviorType(OverflowBehaviorType::OverflowBehaviorKind Kind,
307 return sema.Context.getOverflowBehaviorType(Kind, UnderlyingType);
314 QualType T =
sema.ReplaceAutoType(TypeWithAuto, Replacement);
315 if (
auto *AttrTy = TypeWithAuto->
getAs<AttributedType>()) {
318 for (TypeAttrPair &A : AttrsForTypes) {
319 if (A.first == AttrTy)
322 AttrsForTypesSorted =
false;
328 const Attr *takeAttrForAttributedType(
const AttributedType *AT) {
329 if (!AttrsForTypesSorted) {
330 llvm::stable_sort(AttrsForTypes, llvm::less_first());
331 AttrsForTypesSorted =
true;
336 for (
auto It = llvm::partition_point(
338 [=](
const TypeAttrPair &A) {
return A.first < AT; });
339 It != AttrsForTypes.end() && It->first == AT; ++It) {
342 It->second =
nullptr;
356 auto FoundLoc = LocsForMacros.find(MQT);
357 assert(FoundLoc != LocsForMacros.end() &&
358 "Unable to find macro expansion location for MacroQualifedType");
359 return FoundLoc->second;
364 LocsForMacros[MQT] = Loc;
367 void setParsedNoDeref(
bool parsed) { parsedNoDeref = parsed; }
369 bool didParseNoDeref()
const {
return parsedNoDeref; }
371 void setParsedHLSLParamMod(
bool Parsed) { ParsedHLSLParamMod = Parsed; }
373 bool didParseHLSLParamMod()
const {
return ParsedHLSLParamMod; }
375 ~TypeProcessingState() {
376 if (savedAttrs.empty())
379 getMutableDeclSpec().getAttributes().clearListOnly();
381 getMutableDeclSpec().getAttributes().addAtEnd(AL);
385 DeclSpec &getMutableDeclSpec()
const {
427 if (
attr.getKind() == ParsedAttr::AT_ObjCGC)
429 assert(
attr.getKind() == ParsedAttr::AT_ObjCOwnership);
444 bool onlyBlockPointers) {
450 for (; i != 0; --i) {
452 switch (fnChunk.
Kind) {
468 for (--i; i != 0; --i) {
470 switch (ptrChunk.
Kind) {
480 if (onlyBlockPointers)
489 llvm_unreachable(
"bad declarator chunk kind");
495 llvm_unreachable(
"bad declarator chunk kind");
512 Declarator &declarator = state.getDeclarator();
515 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
517 switch (chunk.
Kind) {
523 if (state.isProcessingDeclSpec() &&
524 attr.getKind() == ParsedAttr::AT_ObjCOwnership)
527 if (!destChunk) destChunk = &chunk;
540 if (state.isProcessingDeclSpec() &&
541 attr.getKind() == ParsedAttr::AT_ObjCOwnership) {
568 Declarator &declarator = state.getDeclarator();
572 unsigned innermost = -1U;
573 bool considerDeclSpec =
true;
576 switch (chunk.
Kind) {
590 considerDeclSpec =
false;
598 if (considerDeclSpec) {
603 state.saveDeclSpecAttrs();
612 if (innermost != -1U) {
620 state.addIgnoredTypeAttr(
attr);
629 Declarator &declarator = state.getDeclarator();
633 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
635 switch (chunk.
Kind) {
662 Declarator &declarator = state.getDeclarator();
682 state.saveDeclSpecAttrs();
686 state,
attr, state.getCurrentAttributes(), declSpecType, CFT))
691 state.addIgnoredTypeAttr(
attr);
702 Declarator &declarator = state.getDeclarator();
712 state.addIgnoredTypeAttr(
attr);
737 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute())
740 switch (
attr.getKind()) {
757 case ParsedAttr::AT_ObjCKindOf:
770 Declarator &declarator = state.getDeclarator();
816 {}, loc, loc, declarator));
831 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
836 if (!(RemoveTQs & Qual.first))
840 if (TypeQuals & Qual.first)
841 S.
Diag(Qual.second, DiagID)
846 TypeQuals &= ~Qual.first;
860 if (AL.isInvalid() || !AL.isTypeAttr())
863 diag::warn_block_literal_attributes_on_omitted_return_type)
865 ToBeRemoved.push_back(&AL);
875 diag::warn_block_literal_qualifiers_on_omitted_return_type);
881static OpenCLAccessAttr::Spelling
884 if (AL.getKind() == ParsedAttr::AT_OpenCLAccess)
885 return static_cast<OpenCLAccessAttr::Spelling
>(AL.getSemanticSpelling());
886 return OpenCLAccessAttr::Keyword_read_only;
889static UnaryTransformType::UTTKind
892#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
894 return UnaryTransformType::Enum;
895#include "clang/Basic/BuiltinTraits.inc"
897 llvm_unreachable(
"attempted to parse a non-unary transform builtin");
911 Sema &S = state.getSema();
912 Declarator &declarator = state.getDeclarator();
929 Result = Context.SignedCharTy;
932 "Unknown TSS value");
933 Result = Context.UnsignedCharTy;
942 Context.getPrintingPolicy());
943 Result = Context.getSignedWCharType();
946 "Unknown TSS value");
949 Context.getPrintingPolicy());
950 Result = Context.getUnsignedWCharType();
955 "Unknown TSS value");
960 "Unknown TSS value");
961 Result = Context.Char16Ty;
965 "Unknown TSS value");
966 Result = Context.Char32Ty;
976 Result = Context.getAutoDeductType();
980 Context.DependentTy)) {
981 Result = Context.DependentTy;
997 S.
Diag(DeclLoc, diag::warn_missing_type_specifier)
1008 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1019 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1025 "implicit int is disabled?");
1026 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1040 Result = Context.ShortTy;
1046 Result = Context.LongLongTy;
1056 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1065 Result = Context.UnsignedIntTy;
1068 Result = Context.UnsignedShortTy;
1071 Result = Context.UnsignedLongTy;
1074 Result = Context.UnsignedLongLongTy;
1084 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1108 Result = Context.ShortAccumTy;
1111 Result = Context.AccumTy;
1114 Result = Context.LongAccumTy;
1117 llvm_unreachable(
"Unable to specify long long as _Accum width");
1124 Result = Context.getCorrespondingSaturatedType(
Result);
1131 Result = Context.ShortFractTy;
1134 Result = Context.FractTy;
1137 Result = Context.LongFractTy;
1140 llvm_unreachable(
"Unable to specify long long as _Fract width");
1147 Result = Context.getCorrespondingSaturatedType(
Result);
1157 Result = Context.UnsignedInt128Ty;
1159 Result = Context.Int128Ty;
1169 Result = Context.Float16Ty;
1177 Result = Context.BFloat16Ty;
1182 Result = Context.LongDoubleTy;
1184 Result = Context.DoubleTy;
1189 << (S.
getLangOpts().getOpenCLCompatibleVersion() >= 300
1190 ?
"cl_khr_fp64 and __opencl_c_fp64"
1201 Result = Context.Float128Ty;
1208 Result = Context.Ibm128Ty;
1239 "No qualifiers on tag names!");
1252 "Can't handle qualifiers on typedef names yet!");
1265 assert(!
Result.isNull() &&
"Didn't get a type for typeof?");
1266 if (!
Result->isDependentType())
1267 if (
const auto *TT =
Result->getAs<TagType>())
1270 Result = Context.getTypeOfType(
1278 assert(E &&
"Didn't get an expression for typeof?");
1292 assert(E &&
"Didn't get an expression for decltype?");
1310#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
1311#include "clang/Basic/BuiltinTraits.inc"
1313 assert(!
Result.isNull() &&
"Didn't get a type for the transformation?");
1333 TypeConstraintConcept = TemplateId->
Template.get();
1338 TemplateId->NumArgs);
1340 for (
const auto &ArgLoc : TemplateArgsInfo.
arguments())
1341 TemplateArgs.push_back(ArgLoc.getArgument());
1347 TypeConstraintConcept, TemplateArgs);
1357 Result = Context.UnknownAnyTy;
1362 assert(!
Result.isNull() &&
"Didn't get a type for _Atomic?");
1370#define GENERIC_IMAGE_TYPE(ImgType, Id) \
1371 case DeclSpec::TST_##ImgType##_t: \
1372 switch (getImageAccess(DS.getAttributes())) { \
1373 case OpenCLAccessAttr::Keyword_write_only: \
1374 Result = Context.Id##WOTy; \
1376 case OpenCLAccessAttr::Keyword_read_write: \
1377 Result = Context.Id##RWTy; \
1379 case OpenCLAccessAttr::Keyword_read_only: \
1380 Result = Context.Id##ROTy; \
1382 case OpenCLAccessAttr::SpellingNotCalculated: \
1383 llvm_unreachable("Spelling not yet calculated"); \
1386#include "clang/Basic/OpenCLImageTypes.def"
1388#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1389 case DeclSpec::TST_##Name: \
1390 Result = Context.SingletonId; \
1392#include "clang/Basic/HLSLIntangibleTypes.def"
1394#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1395 case DeclSpec::TST_##Name: \
1396 Result = Context.SingletonId; \
1398#include "clang/Basic/HLSLPackedTypes.def"
1409 if (
Result->containsErrors())
1414 bool IsOpenCLC30Compatible =
1424 (IsOpenCLC30Compatible &&
1427 << 0 <<
Result <<
"__opencl_c_images";
1429 }
else if (
Result->isOCLImage3dWOType() &&
1434 << (IsOpenCLC30Compatible
1435 ?
"cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
1436 :
"cl_khr_3d_image_writes");
1448 Context.getPrintingPolicy());
1456 unsigned typeSize =
static_cast<unsigned>(Context.getTypeSize(
Result));
1457 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1463 Result = Context.getVectorType(
Result, 128/typeSize, VecKind);
1488 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
1499 if (AL.isStandardAttributeSyntax() && AL.isClangScope() &&
1500 !(AL.getKind() == ParsedAttr::AT_MatrixType &&
1502 S.
Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl)
1530 if (
Result->isFunctionType()) {
1531 unsigned DiagId = diag::warn_typecheck_function_qualifiers_ignored;
1533 DiagId = diag::ext_typecheck_function_qualifiers_unspecified;
1549 if (TypeQuals &&
Result->isReferenceType()) {
1551 S, DS, TypeQuals,
Result,
1553 diag::warn_typecheck_reference_qualifiers);
1560 && TypeQuals &
Result.getCVRQualifiers()) {
1587 if (
Result->isAtomicType()) {
1589 StringRef SpecifierName =
1591 S.
Diag(Loc, diag::err_overflow_behavior_atomic_type)
1592 << SpecifierName <<
Result.getAsString() << 1;
1593 }
else if (!
Result->isIntegerType()) {
1595 StringRef SpecifierName =
1597 S.
Diag(Loc, diag::err_overflow_behavior_non_integer_type)
1598 << SpecifierName <<
Result.getAsString() << 1;
1600 OverflowBehaviorType::OverflowBehaviorKind Kind =
1602 ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
1603 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
1611 assert(!
Result.isNull() &&
"This function should not return a null type");
1628 if (
T->isReferenceType()) {
1636 unsigned DiagID = 0;
1650 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1655 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1661 Diag(Loc, DiagID) << EltTy;
1664 if (
T->isArrayType())
1665 DiagCompat(Loc, diag_compat::restrict_on_array_of_pointers);
1669 return Context.getQualifiedType(
T, Qs);
1673 unsigned CVRAU,
const DeclSpec *DS) {
1678 if (
T->isReferenceType())
1707 Split.Quals.addCVRQualifiers(CVR);
1725 if (!
type->isObjCLifetimeType() ||
1735 if (
type.isConstQualified()) {
1741 }
else if (
type->isObjCARCImplicitlyUnretainedType()) {
1759 diag::err_arc_indirect_no_ownership,
type, isReference));
1761 S.
Diag(loc, diag::err_arc_indirect_no_ownership) <<
type << isReference;
1765 assert(implicitLifetime &&
"didn't infer any lifetime!");
1806enum QualifiedFunctionKind { QFK_BlockPointer, QFK_Pointer, QFK_Reference };
1812 QualifiedFunctionKind QFK) {
1819 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1820 << QFK << isa<FunctionType>(
T.IgnoreParens()) <<
T
1831 Diag(Loc, diag::err_qualified_function_typeid)
1848 if (
T->isReferenceType()) {
1850 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1858 Diag(Loc, diag::err_opencl_function_pointer) << 0;
1863 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
1870 if (
T->isObjCObjectType())
1871 return Context.getObjCObjectPointerType(
T);
1883 if (
T.isWebAssemblyReferenceType()) {
1884 Diag(Loc, diag::err_wasm_reference_pr) << 0;
1889 if (
T->getUnqualifiedDesugaredType()->isWebAssemblyTableType()) {
1890 Diag(Loc, diag::err_wasm_table_pr) << 0;
1903 "Unresolved overloaded function type");
1930 if (
T->isVoidType()) {
1931 Diag(Loc, diag::err_reference_to_void);
1936 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
1946 Diag(Loc, diag::err_opencl_function_pointer) << 1;
1959 T.isWebAssemblyReferenceType()) {
1960 Diag(Loc, diag::err_wasm_reference_pr) << 1;
1963 if (
T->isWebAssemblyTableType()) {
1964 Diag(Loc, diag::err_wasm_table_pr) << 1;
1970 return Context.getLValueReferenceType(
T, SpelledAsLValue);
1971 return Context.getRValueReferenceType(
T);
1975 if (
T->isPointerType())
1976 return S.
Diag(Loc, diag::err_invalid_pipe_packet_type)
1978 if (
T->isReferenceType())
1979 return S.
Diag(Loc, diag::err_invalid_pipe_packet_type)
1981 if (
T->isBlockPointerType())
1982 return S.
Diag(Loc, diag::err_invalid_pipe_packet_type)
1984 if (!
T->isObjectType())
1985 return S.
Diag(Loc, diag::err_invalid_pipe_packet_type)
1988 return S.
Diag(Loc, diag::err_invalid_pipe_packet_type)
2003 return Context.getWritePipeType(
T);
2009 return Context.getDependentBitIntType(IsUnsigned, BitWidth);
2011 llvm::APSInt Bits(32);
2018 size_t NumBits = Bits.getZExtValue();
2019 if (!IsUnsigned && NumBits < 2) {
2020 Diag(Loc, diag::err_bit_int_bad_size) << 0;
2024 if (IsUnsigned && NumBits < 1) {
2025 Diag(Loc, diag::err_bit_int_bad_size) << 1;
2031 Diag(Loc, diag::err_bit_int_max_size)
2036 return Context.getBitIntType(IsUnsigned, NumBits);
2045 llvm::APSInt &SizeVal,
unsigned VLADiag,
2070 VLADiagnoser(
unsigned VLADiag,
bool VLAIsError)
2071 : VLADiag(VLADiag), VLAIsError(VLAIsError) {}
2075 return S.
Diag(Loc, diag::err_array_size_non_int) <<
T;
2080 IsVLA = !VLAIsError;
2081 return S.
Diag(Loc, VLADiag);
2086 return S.
Diag(Loc, diag::ext_vla_folded_to_constant);
2088 } Diagnoser(VLADiag, VLAIsError);
2092 if (Diagnoser.IsVLA)
2098 EltTy =
Context.getBaseElementType(EltTy);
2106 if (Size.isMultipleOf(Alignment))
2109 Diag(Loc, diag::err_array_element_alignment)
2110 << EltTy << Size.getQuantity() << Alignment.
getQuantity();
2115 const llvm::APSInt &NumElements,
2117 unsigned ActiveSizeBits = NumElements.getActiveBits();
2118 if (!ElementType->isDependentType() && !ElementType->isIncompleteType() &&
2119 !ElementType->isUndeducedType() && ElementType->isConstantSizeType())
2122 Context, ElementType, NumElements));
2126 Diag(Loc, diag::err_array_too_large)
2127 <<
toString(NumElements, 10, NumElements.isSigned(),
2135 Expr *ArraySize,
unsigned Quals,
2154 if (
T->isReferenceType()) {
2155 Diag(Loc, diag::err_illegal_decl_array_of_references)
2160 if (
T->isVoidType() ||
T->isIncompleteArrayType()) {
2161 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 <<
T;
2166 diag::err_array_of_abstract_type))
2171 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
2173 if (!MPTy->getQualifier().isDependent())
2179 if (!
T.isWebAssemblyReferenceType() &&
2181 diag::err_array_incomplete_or_sizeless_type))
2186 if (
Context.getTargetInfo().getTriple().isWasm() &&
T->isArrayType()) {
2187 const auto *ATy = dyn_cast<ArrayType>(
T);
2188 if (ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
2189 Diag(Loc, diag::err_wasm_reftype_multidimensional_array);
2194 if (
T->isSizelessType() && !
T.isWebAssemblyReferenceType()) {
2195 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 1 <<
T;
2199 if (
T->isFunctionType()) {
2200 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2205 if (
const auto *RD =
T->getAsRecordDecl()) {
2208 if (RD->hasFlexibleArrayMember())
2209 Diag(Loc, diag::ext_flexible_array_in_array) <<
T;
2210 }
else if (
T->isObjCObjectType()) {
2211 Diag(Loc, diag::err_objc_array_of_interfaces) <<
T;
2222 ArraySize =
Result.get();
2226 if (ArraySize && !ArraySize->
isPRValue()) {
2231 ArraySize =
Result.get();
2254 if (
const auto *CondExpr = dyn_cast_if_present<ConditionalOperator>(
2256 std::optional<llvm::APSInt> LHS =
2257 CondExpr->getLHS()->getIntegerConstantExpr(
Context);
2258 std::optional<llvm::APSInt> RHS =
2259 CondExpr->getRHS()->getIntegerConstantExpr(
Context);
2260 return LHS && RHS && LHS->isNegative() != RHS->isNegative();
2270 VLADiag = diag::err_opencl_vla;
2273 VLADiag = diag::warn_vla_used;
2276 VLADiag = diag::err_vla_in_sfinae;
2279 VLADiag = diag::err_openmp_vla_in_task_untied;
2284 ? diag::ext_vla_cxx_in_gnu_mode_static_assert
2285 : diag::ext_vla_cxx_static_assert;
2287 VLADiag =
getLangOpts().GNUMode ? diag::ext_vla_cxx_in_gnu_mode
2288 : diag::ext_vla_cxx;
2291 VLADiag = diag::ext_vla;
2295 llvm::APSInt ConstVal(
Context.getTypeSize(
Context.getSizeType()));
2302 T =
Context.getVariableArrayType(
T,
nullptr, ASM, IndexTypeQuals);
2304 T =
Context.getIncompleteArrayType(
T, ASM, IndexTypeQuals);
2307 T =
Context.getDependentSizedArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2314 if (!R.isUsable()) {
2318 T =
Context.getVariableArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2319 }
else if (!
T->isDependentType() && !
T->isIncompleteType() &&
2320 !
T->isConstantSizeType()) {
2327 T =
Context.getVariableArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2332 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2339 diag::err_typecheck_negative_array_size)
2343 if (ConstVal == 0 && !
T.isWebAssemblyReferenceType()) {
2354 : diag::ext_typecheck_zero_array_size)
2364 T =
Context.getConstantArrayType(
T, ConstVal, ArraySize, ASM,
2369 if (
T->isVariableArrayType()) {
2370 if (!
Context.getTargetInfo().isVLASupported()) {
2374 IsCUDADevice ? diag::err_cuda_vla : diag::err_vla_unsupported)
2375 << (IsCUDADevice ? llvm::to_underlying(
CUDA().CurrentTarget()) : 0);
2379 FSI->setHasVLA(Loc);
2387 : diag::ext_c99_array_usage)
2398 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2409 if (
const Expr *Size = VAT->getSizeExpr())
2410 VLASizeExprOwners.try_emplace(Size,
CurContext);
2417 bool ForMatrixType =
false) {
2420 if (!llvm::isPowerOf2_32(NumBits))
2421 return S.
Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
2441 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
2450 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2453 std::optional<llvm::APSInt> VecSize =
2456 Diag(AttrLoc, diag::err_attribute_argument_type)
2462 if (VecSize->isNegative()) {
2463 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2468 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2473 Diag(AttrLoc, diag::err_attribute_size_too_large)
2477 uint64_t VectorSizeBits = VecSize->getZExtValue() * 8;
2478 unsigned TypeSize =
static_cast<unsigned>(
Context.getTypeSize(CurType));
2480 if (VectorSizeBits == 0) {
2481 Diag(AttrLoc, diag::err_attribute_zero_size)
2486 if (!TypeSize || VectorSizeBits % TypeSize) {
2487 Diag(AttrLoc, diag::err_attribute_invalid_size)
2493 Diag(AttrLoc, diag::err_attribute_size_too_large)
2498 return Context.getVectorType(CurType, VectorSizeBits / TypeSize,
2514 if ((!
T->isDependentType() && !
T->isIntegerType() &&
2515 !
T->isRealFloatingType()) ||
2516 T->isEnumeralType() || (IsNoBoolVecLang &&
T->isBooleanType())) {
2517 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) <<
T;
2526 std::optional<llvm::APSInt> VecSize =
2529 Diag(AttrLoc, diag::err_attribute_argument_type)
2535 if (VecSize->isNegative()) {
2536 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2543 Diag(AttrLoc, diag::err_attribute_size_too_large)
2547 unsigned VectorSize =
static_cast<unsigned>(VecSize->getZExtValue());
2549 if (VectorSize == 0) {
2550 Diag(AttrLoc, diag::err_attribute_zero_size)
2555 if (!
T->isDependentType() &&
2557 Diag(AttrLoc, diag::err_attribute_size_too_large)
2562 return Context.getExtVectorType(
T, VectorSize);
2565 return Context.getDependentSizedExtVectorType(
T, SizeExpr, AttrLoc);
2570 assert(
Context.getLangOpts().MatrixTypes &&
2571 "Should never build a matrix type when it is disabled");
2576 Diag(AttrLoc, diag::err_attribute_invalid_matrix_type) << ElementTy;
2587 return Context.getDependentSizedMatrixType(ElementTy, NumRows, NumCols,
2590 std::optional<llvm::APSInt> ValueRows =
2592 std::optional<llvm::APSInt> ValueColumns =
2599 if (!ValueRows && !ValueColumns) {
2600 Diag(AttrLoc, diag::err_attribute_argument_type)
2608 Diag(AttrLoc, diag::err_attribute_argument_type)
2614 if (!ValueColumns) {
2615 Diag(AttrLoc, diag::err_attribute_argument_type)
2621 unsigned MatrixRows =
static_cast<unsigned>(ValueRows->getZExtValue());
2622 unsigned MatrixColumns =
static_cast<unsigned>(ValueColumns->getZExtValue());
2623 if (MatrixRows == 0 && MatrixColumns == 0) {
2624 Diag(AttrLoc, diag::err_attribute_zero_size)
2625 <<
"matrix" << RowRange << ColRange;
2628 if (MatrixRows == 0) {
2629 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << RowRange;
2632 if (MatrixColumns == 0) {
2633 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << ColRange;
2636 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension &&
2637 MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2638 Diag(AttrLoc, diag::err_attribute_size_too_large)
2639 << RowRange << ColRange <<
"matrix row and column";
2642 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension) {
2643 Diag(AttrLoc, diag::err_attribute_size_too_large)
2644 << RowRange <<
"matrix row";
2647 if (MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2648 Diag(AttrLoc, diag::err_attribute_size_too_large)
2649 << ColRange <<
"matrix column";
2652 return Context.getConstantMatrixType(ElementTy, MatrixRows, MatrixColumns);
2656 if ((
T->isArrayType() && !
getLangOpts().allowArrayReturnTypes()) ||
2657 T->isFunctionType()) {
2658 Diag(Loc, diag::err_func_returning_array_function)
2659 <<
T->isFunctionType() <<
T;
2664 if (
T->isHalfType() && !
getLangOpts().NativeHalfArgsAndReturns &&
2665 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2666 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2673 if (
T->isObjCObjectType()) {
2674 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
2680 if (
T.getPointerAuth()) {
2681 Diag(Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 0;
2685 if (
T.hasNonTrivialToPrimitiveDestructCUnion() ||
2686 T.hasNonTrivialToPrimitiveCopyCUnion())
2693 Diag(Loc, diag::warn_deprecated_volatile_return) <<
T;
2708 bool emittedError =
false;
2710 enum class RequiredCC { OnlySwift, SwiftOrSwiftAsync };
2711 auto checkCompatible = [&](
unsigned paramIndex, RequiredCC required) {
2713 (required == RequiredCC::OnlySwift)
2716 if (isCompatible || emittedError)
2718 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
2720 << (required == RequiredCC::OnlySwift);
2721 emittedError =
true;
2723 for (
size_t paramIndex = 0, numParams = paramTypes.size();
2724 paramIndex != numParams; ++paramIndex) {
2735 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2736 if (paramIndex != 0 &&
2739 S.
Diag(getParamLoc(paramIndex),
2740 diag::err_swift_indirect_result_not_first);
2745 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2754 checkCompatible(paramIndex, RequiredCC::OnlySwift);
2755 if (paramIndex == 0 ||
2758 S.
Diag(getParamLoc(paramIndex),
2759 diag::err_swift_error_result_not_after_swift_context);
2763 llvm_unreachable(
"bad ABI kind");
2775 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2777 QualType ParamType =
Context.getAdjustedParameterType(ParamTypes[Idx]);
2779 Diag(Loc, diag::err_param_with_void_type);
2782 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2784 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2788 Diag(Loc, diag::err_wasm_table_as_function_parameter);
2792 Diag(Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 1;
2799 Diag(Loc, diag::warn_deprecated_volatile_param) << ParamType;
2801 ParamTypes[Idx] = ParamType;
2806 [=](
unsigned i) {
return Loc; });
2817 return Context.getFunctionType(
T, ParamTypes, EPI);
2832 D <<
"member pointer";
2840 Diag(Loc, diag::err_distant_exception_spec);
2846 if (
T->isReferenceType()) {
2847 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2852 if (
T->isVoidType()) {
2853 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2861 Diag(Loc, diag::err_opencl_function_pointer) << 0;
2866 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
2875 if (
T->isFunctionType())
2884 if (!
T->isFunctionType()) {
2885 Diag(Loc, diag::err_nonfunction_block_type);
2895 return Context.getBlockPointerType(
T);
2901 if (TInfo) *TInfo =
nullptr;
2906 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2907 QT = LIT->getType();
2908 TSI = LIT->getTypeSourceInfo();
2918 unsigned chunkIndex);
2925 Sema &S = state.getSema();
2926 Declarator &declarator = state.getDeclarator();
2932 unsigned outermostPointerIndex = 0;
2934 unsigned numPointers = 0;
2936 unsigned chunkIndex = i;
2938 switch (chunk.
Kind) {
2948 outermostPointerIndex = chunkIndex;
2956 if (numPointers != 1)
return;
2958 outermostPointerIndex = chunkIndex;
2976 if (numPointers == 1) {
2994 }
else if (numPointers == 2) {
3007 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership)
3011 outermostPointerIndex);
3033 }
const QualKinds[5] = {
3047 for (
auto &E : QualKinds) {
3048 if (Quals & E.Mask) {
3049 if (!QualStr.empty()) QualStr +=
' ';
3066 << QualStr <<
NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
3072 unsigned FunctionChunkIndex) {
3082 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
3084 OuterChunkIndex != End; ++OuterChunkIndex) {
3086 switch (OuterChunk.
Kind) {
3093 diag::warn_qual_return_type,
3119 llvm_unreachable(
"unknown declarator chunk kind");
3140static std::pair<QualType, TypeSourceInfo *>
3144 Sema &S = state.getSema();
3148 const unsigned AutoParameterPosition = Info.
TemplateParams.size();
3161 AutoParameterPosition,
3163 AutoParameterPosition),
3164 false, IsParameterPack,
3165 Auto->isConstrained());
3170 if (
Auto->isConstrained()) {
3177 for (
unsigned Idx = 0; Idx < AutoLoc.
getNumArgs(); ++Idx) {
3237 QualType NewT = state.ReplaceAutoType(
T, Replacement);
3241 return {NewT, NewTSI};
3250 Sema &SemaRef = state.getSema();
3253 ReturnTypeInfo =
nullptr;
3256 TagDecl *OwnedTagDecl =
nullptr;
3306 DeducedType *
Deduced =
T->getContainedDeducedType();
3307 bool DeducedIsTrailingReturnType =
false;
3311 DeducedIsTrailingReturnType =
true;
3321 bool IsCXXAutoType =
3323 bool IsDeducedReturnType =
false;
3373 assert(Info &&
"No LambdaScopeInfo on the stack!");
3379 if (!DeducedIsTrailingReturnType)
3392 llvm_unreachable(
"unhandled tag kind");
3394 Error = Cxx ? 1 : 2;
3397 Error = Cxx ? 3 : 4;
3442 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3444 IsDeducedReturnType =
true;
3447 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3449 IsDeducedReturnType =
true;
3454 if (IsCXXAutoType && !
Auto->isDecltypeAuto())
3487 (!SemaRef.
getLangOpts().CPlusPlus11 || !IsCXXAutoType))
3493 switch (
Auto->getKeyword()) {
3500 "unknown auto type");
3504 auto *DTST = dyn_cast<DeducedTemplateSpecializationType>(
Deduced);
3507 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
3520 unsigned DiagId = 0;
3522 DiagId = diag::warn_cxx11_compat_generic_lambda;
3523 else if (IsDeducedReturnType)
3524 DiagId = diag::warn_cxx11_compat_deduced_return_type;
3526 DiagId = diag::warn_cxx98_compat_auto_type_specifier;
3529 SemaRef.
Diag(AutoRange.
getBegin(), DiagId) << AutoRange;
3537 unsigned DiagID = 0;
3543 llvm_unreachable(
"parser should not have allowed this");
3559 DiagID = diag::err_type_defined_in_alias_template;
3571 DiagID = diag::err_type_defined_in_type_specifier;
3581 DiagID = diag::err_type_defined_in_param_type;
3587 DiagID = diag::err_type_defined_in_condition;
3598 assert(!
T.isNull() &&
"This function should not return a null type");
3607 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3637 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3638 : diag::warn_empty_parens_are_function_decl)
3649 if (Comma.getFileID() != Name.
getFileID() ||
3657 Result.suppressDiagnostics();
3670 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3685 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
3693 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
3704 "do not have redundant top-level parentheses");
3713 bool CouldBeTemporaryObject =
3717 (
T->isRecordType() ||
T->isDependentType()) &&
3720 bool StartsWithDeclaratorId =
true;
3728 StartsWithDeclaratorId =
false;
3733 CouldBeTemporaryObject =
false;
3741 CouldBeTemporaryObject =
false;
3742 StartsWithDeclaratorId =
false;
3752 CouldBeTemporaryObject =
false;
3759 CouldBeTemporaryObject =
false;
3760 StartsWithDeclaratorId =
false;
3770 if (CouldBeTemporaryObject) {
3774 CouldBeTemporaryObject =
false;
3775 Result.suppressDiagnostics();
3780 if (!CouldBeTemporaryObject) {
3804 S.
Diag(
Paren.Loc, diag::warn_redundant_parens_around_declarator)
3810 S.
Diag(
Paren.Loc, diag::warn_parens_disambiguated_as_variable_declaration)
3812 auto *RD =
T->getAsCXXRecordDecl();
3813 if (!RD || !RD->hasDefinition() || RD->hasNonTrivialDestructor())
3814 S.
Diag(
Paren.Loc, diag::note_raii_guard_add_name)
3819 S.
Diag(D.
getBeginLoc(), diag::note_function_style_cast_add_parentheses)
3822 S.
Diag(
Paren.Loc, diag::note_remove_parens_for_variable_declaration)
3838 switch (AL.getKind()) {
3857 bool IsCXXInstanceMethod =
false;
3863 unsigned I = ChunkIndex;
3864 bool FoundNonParen =
false;
3865 while (I && !FoundNonParen) {
3868 FoundNonParen =
true;
3871 if (FoundNonParen) {
3874 IsCXXInstanceMethod =
3879 IsCXXInstanceMethod =
3887 IsCXXInstanceMethod =
3895 IsCXXInstanceMethod);
3903 if (Triple.isSPIRV() && Triple.getVendor() != llvm::Triple::AMD) {
3905 if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
3913 for (
const ParsedAttr &AL : llvm::concat<ParsedAttr>(
3916 if (AL.getKind() == ParsedAttr::AT_DeviceKernel) {
3927 enum class SimplePointerKind {
3936 switch (nullability) {
3938 if (!Ident__Nonnull)
3939 Ident__Nonnull =
PP.getIdentifierInfo(
"_Nonnull");
3940 return Ident__Nonnull;
3943 if (!Ident__Nullable)
3944 Ident__Nullable =
PP.getIdentifierInfo(
"_Nullable");
3945 return Ident__Nullable;
3948 if (!Ident__Nullable_result)
3949 Ident__Nullable_result =
PP.getIdentifierInfo(
"_Nullable_result");
3950 return Ident__Nullable_result;
3953 if (!Ident__Null_unspecified)
3954 Ident__Null_unspecified =
PP.getIdentifierInfo(
"_Null_unspecified");
3955 return Ident__Null_unspecified;
3957 llvm_unreachable(
"Unknown nullability kind.");
3964 if (AL.getKind() == ParsedAttr::AT_TypeNonNull ||
3965 AL.getKind() == ParsedAttr::AT_TypeNullable ||
3966 AL.getKind() == ParsedAttr::AT_TypeNullableResult ||
3967 AL.getKind() == ParsedAttr::AT_TypeNullUnspecified)
3976 enum class PointerDeclaratorKind {
3984 MaybePointerToCFRef,
3988 NSErrorPointerPointer,
3994 enum class PointerWrappingDeclaratorKind {
4008static PointerDeclaratorKind
4010 PointerWrappingDeclaratorKind &wrappingKind) {
4011 unsigned numNormalPointers = 0;
4014 if (
type->isDependentType())
4015 return PointerDeclaratorKind::NonPointer;
4020 switch (chunk.
Kind) {
4022 if (numNormalPointers == 0)
4023 wrappingKind = PointerWrappingDeclaratorKind::Array;
4032 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4033 : PointerDeclaratorKind::SingleLevelPointer;
4039 if (numNormalPointers == 0)
4040 wrappingKind = PointerWrappingDeclaratorKind::Reference;
4044 ++numNormalPointers;
4045 if (numNormalPointers > 2)
4046 return PointerDeclaratorKind::MultiLevelPointer;
4052 unsigned numTypeSpecifierPointers = 0;
4056 ++numNormalPointers;
4058 if (numNormalPointers > 2)
4059 return PointerDeclaratorKind::MultiLevelPointer;
4061 type = ptrType->getPointeeType();
4062 ++numTypeSpecifierPointers;
4068 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4069 : PointerDeclaratorKind::SingleLevelPointer;
4074 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4075 : PointerDeclaratorKind::SingleLevelPointer;
4080 ++numNormalPointers;
4081 ++numTypeSpecifierPointers;
4084 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
4086 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
4087 return PointerDeclaratorKind::NSErrorPointerPointer;
4096 if (objcClass->getInterface()->getIdentifier() ==
4098 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
4099 return PointerDeclaratorKind::NSErrorPointerPointer;
4106 if (numNormalPointers == 0)
4107 return PointerDeclaratorKind::NonPointer;
4111 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2 &&
4113 return PointerDeclaratorKind::CFErrorRefPointer;
4121 switch (numNormalPointers) {
4123 return PointerDeclaratorKind::NonPointer;
4126 return PointerDeclaratorKind::SingleLevelPointer;
4129 return PointerDeclaratorKind::MaybePointerToCFRef;
4132 return PointerDeclaratorKind::MultiLevelPointer;
4141 if (ctx->isFunctionOrMethod())
4144 if (ctx->isFileContext())
4155 bool invalid =
false;
4157 if (invalid || !sloc.
isFile())
4175template <
typename DiagBuilderT>
4184 if (!FixItLoc.
isValid() || FixItLoc == PointerLoc)
4193 InsertionTextBuf +=
" ";
4194 StringRef InsertionText = InsertionTextBuf.str();
4197 InsertionText = InsertionText.drop_back();
4198 }
else if (NextChar[-1] ==
'[') {
4199 if (NextChar[0] ==
']')
4200 InsertionText = InsertionText.drop_back().drop_front();
4202 InsertionText = InsertionText.drop_front();
4205 InsertionText = InsertionText.drop_back().drop_front();
4212 SimplePointerKind PointerKind,
4217 if (PointerKind == SimplePointerKind::Array) {
4218 S.
Diag(PointerLoc, diag::warn_nullability_missing_array);
4220 S.
Diag(PointerLoc, diag::warn_nullability_missing)
4221 <<
static_cast<unsigned>(PointerKind);
4224 auto FixItLoc = PointerEndLoc.
isValid() ? PointerEndLoc : PointerLoc;
4225 if (FixItLoc.isMacroID())
4229 auto Diag = S.
Diag(FixItLoc, diag::note_nullability_fix_it);
4260 if (pointerKind == SimplePointerKind::Array)
4261 diagKind = diag::warn_nullability_missing_array;
4263 diagKind = diag::warn_nullability_missing;
4269 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
4301 auto kind =
static_cast<SimplePointerKind
>(fileNullability.
PointerKind);
4316 unsigned i = endIndex;
4344template<
typename AttrT>
4347 return ::new (Ctx) AttrT(Ctx, AL);
4365 llvm_unreachable(
"unknown NullabilityKind");
4376 if (ASOld != ASNew) {
4377 S.
Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
4382 diag::warn_attribute_address_multiple_identical_qualifiers);
4391 return T->canHaveNullability(
false) &&
4397 T->getCanonicalTypeInternal());
4407 Sema &S = state.getSema();
4417 bool IsTypedefName =
4423 bool IsQualifiedFunction =
T->isFunctionProtoType() &&
4431 if (
auto *DT =
T->getAs<DeducedType>(); DT && !
T->containsErrors()) {
4432 const AutoType *AT =
T->getAs<AutoType>();
4434 if ((AT && AT->isDecltypeAuto()) || IsClassTemplateDeduction) {
4436 unsigned Index = E - I - 1;
4438 unsigned DiagId = IsClassTemplateDeduction
4439 ? diag::err_deduced_class_template_compound_type
4440 : diag::err_decltype_auto_compound_type;
4441 unsigned DiagKind = 0;
4442 switch (DeclChunk.
Kind) {
4446 if (IsClassTemplateDeduction) {
4454 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
4472 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
4481 bool inferNullabilityCS =
false;
4482 bool inferNullabilityInnerOnly =
false;
4483 bool inferNullabilityInnerOnlyComplete =
false;
4486 bool inAssumeNonNullRegion =
false;
4488 if (assumeNonNullLoc.
isValid()) {
4489 inAssumeNonNullRegion =
true;
4503 } complainAboutMissingNullability = CAMN_No;
4504 unsigned NumPointersRemaining = 0;
4505 auto complainAboutInferringWithinChunk = PointerWrappingDeclaratorKind::None;
4507 if (IsTypedefName) {
4511 complainAboutMissingNullability = CAMN_InnerPointers;
4515 ++NumPointersRemaining;
4520 switch (chunk.
Kind) {
4528 ++NumPointersRemaining;
4536 ++NumPointersRemaining;
4541 bool isFunctionOrMethod =
false;
4542 switch (
auto context = state.getDeclarator().getContext()) {
4548 isFunctionOrMethod =
true;
4552 if (state.getDeclarator().isObjCIvar() && !isFunctionOrMethod) {
4553 complainAboutMissingNullability = CAMN_No;
4558 if (state.getDeclarator().isObjCWeakProperty()) {
4561 complainAboutMissingNullability = CAMN_No;
4562 if (inAssumeNonNullRegion) {
4572 complainAboutMissingNullability = CAMN_Yes;
4575 auto wrappingKind = PointerWrappingDeclaratorKind::None;
4577 case PointerDeclaratorKind::NonPointer:
4578 case PointerDeclaratorKind::MultiLevelPointer:
4582 case PointerDeclaratorKind::SingleLevelPointer:
4584 if (inAssumeNonNullRegion) {
4585 complainAboutInferringWithinChunk = wrappingKind;
4592 case PointerDeclaratorKind::CFErrorRefPointer:
4593 case PointerDeclaratorKind::NSErrorPointerPointer:
4596 if (isFunctionOrMethod && inAssumeNonNullRegion)
4600 case PointerDeclaratorKind::MaybePointerToCFRef:
4601 if (isFunctionOrMethod) {
4605 auto hasCFReturnsAttr =
4607 return AttrList.hasAttribute(ParsedAttr::AT_CFReturnsRetained) ||
4608 AttrList.hasAttribute(ParsedAttr::AT_CFReturnsNotRetained);
4613 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
4616 inferNullabilityInnerOnly =
true;
4626 complainAboutMissingNullability = CAMN_Yes;
4654 auto isVaList = [&S](
QualType T) ->
bool {
4660 if (typedefTy->getDecl() == vaListTypedef)
4662 if (
auto *name = typedefTy->getDecl()->getIdentifier())
4663 if (name->isStr(
"va_list"))
4665 typedefTy = typedefTy->desugar()->getAs<
TypedefType>();
4666 }
while (typedefTy);
4672 auto inferPointerNullability =
4677 if (NumPointersRemaining > 0)
4678 --NumPointersRemaining;
4685 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
4688 ? ParsedAttr::Form::ContextSensitiveKeyword()
4689 : ParsedAttr::Form::Keyword(
false ,
4695 attrs.addAtEnd(nullabilityAttr);
4697 if (inferNullabilityCS) {
4698 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
4702 if (pointerLoc.isValid() &&
4703 complainAboutInferringWithinChunk !=
4704 PointerWrappingDeclaratorKind::None) {
4706 S.
Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
4711 if (inferNullabilityInnerOnly)
4712 inferNullabilityInnerOnlyComplete =
true;
4713 return nullabilityAttr;
4718 switch (complainAboutMissingNullability) {
4722 case CAMN_InnerPointers:
4723 if (NumPointersRemaining == 0)
4739 if (NumPointersRemaining > 0)
4740 --NumPointersRemaining;
4742 SimplePointerKind pointerKind = SimplePointerKind::Pointer;
4743 if (
T->isBlockPointerType())
4744 pointerKind = SimplePointerKind::BlockPointer;
4745 else if (
T->isMemberPointerType())
4746 pointerKind = SimplePointerKind::MemberPointer;
4748 if (
auto *
attr = inferPointerNullability(
4753 T = state.getAttributedType(
4759 if (complainAboutMissingNullability == CAMN_Yes &&
T->isArrayType() &&
4767 bool ExpectNoDerefChunk =
4768 state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
4778 bool AreDeclaratorChunksValid =
true;
4780 unsigned chunkIndex = e - i - 1;
4781 state.setCurrentChunkIndex(chunkIndex);
4784 switch (DeclType.
Kind) {
4792 if (!LangOpts.Blocks)
4793 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
4796 inferPointerNullability(SimplePointerKind::BlockPointer, DeclType.
Loc,
4798 state.getDeclarator().getAttributePool());
4804 if (LangOpts.OpenCL)
4819 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
4821 state.getDeclarator().getAttributePool());
4824 T = Context.getObjCObjectPointerType(
T);
4833 if (LangOpts.OpenCL) {
4834 if (
T->isImageType() ||
T->isSamplerT() ||
T->isPipeType() ||
4835 T->isBlockPointerType()) {
4849 diag::err_overflow_behavior_non_integer_type)
4883 if (chunkIndex != 0 && !ArraySize &&
4902 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
4913 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype)
4915 :
"type qualifier");
4926 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost)
4928 :
"type qualifier");
4938 if (complainAboutMissingNullability == CAMN_Yes &&
4954 IsQualifiedFunction =
4960 return SS.isInvalid() ||
4961 isa_and_present<CXXRecordDecl>(
4986 if (
First &&
First->isExplicitObjectParameter() &&
5000 diag::err_explicit_object_parameter_nonmember)
5001 << 2 << 0 <<
First->getSourceRange();
5004 diag::err_explicit_object_parameter_invalid)
5005 <<
First->getSourceRange();
5011 AreDeclaratorChunksValid =
false;
5024 ? diag::err_auto_missing_trailing_return
5025 : diag::err_deduced_return_type);
5028 AreDeclaratorChunksValid =
false;
5031 diag::warn_cxx11_compat_deduced_return_type);
5040 AreDeclaratorChunksValid =
false;
5043 if (
T != Context.DependentTy) {
5045 diag::err_deduction_guide_with_complex_decl)
5049 AreDeclaratorChunksValid =
false;
5066 S.
Diag(Loc, diag::err_trailing_return_without_auto) <<
T << SR;
5069 AreDeclaratorChunksValid =
false;
5076 }
else if (AutoType *
Auto =
T->getContainedAutoType()) {
5085 if (InventedParamInfo) {
5087 state,
T, TInfo,
Auto, *InventedParamInfo);
5100 T->isFunctionType()) &&
5103 unsigned diagID = diag::err_func_returning_array_function;
5106 if (chunkIndex == 0 &&
5108 diagID = diag::err_block_returning_array_function;
5109 S.
Diag(DeclType.
Loc, diagID) <<
T->isFunctionType() <<
T;
5112 AreDeclaratorChunksValid =
false;
5117 if (
T->isHalfType()) {
5125 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5128 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
5134 if (
T.getPointerAuth()) {
5135 S.
Diag(DeclType.
Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 0;
5138 if (LangOpts.OpenCL) {
5141 if (
T->isBlockPointerType() ||
T->isImageType() ||
T->isSamplerT() ||
5152 "__cl_clang_variadic_functions", S.
getLangOpts()) &&
5164 if (
T->isObjCObjectType()) {
5173 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
5177 T = Context.getObjCObjectPointerType(
T);
5185 AreDeclaratorChunksValid =
false;
5193 if ((
T.getCVRQualifiers() ||
T->isAtomicType()) &&
5197 (
T->isRecordType() ||
T->isDependentType() ||
5198 T->isUndeducedAutoType()))) {
5205 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) <<
T;
5212 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20)
5213 S.
Diag(DeclType.
Loc, diag::warn_deprecated_volatile_return) <<
T;
5218 if (
T.getQualifiers().hasObjCLifetime()) {
5223 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5224 AttrLoc = AL.getLoc();
5231 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5232 AttrLoc = AL.getLoc();
5246 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
5247 <<
T.getQualifiers().getObjCLifetime();
5255 S.
Diag(Tag->getLocation(), diag::err_type_defined_in_result_type)
5256 << Context.getCanonicalTagType(Tag);
5263 diag::err_exception_spec_in_typedef)
5281 T = Context.getFunctionNoProtoType(
T, EI);
5289 diag::warn_c17_compat_ellipsis_only_parameter);
5291 ParsedAttr::AT_Overloadable) &&
5293 ParsedAttr::AT_Overloadable) &&
5295 ParsedAttr::AT_Overloadable))
5303 diag::err_ident_list_in_fn_declaration);
5307 ? Context.getFunctionNoProtoType(
T, EI)
5309 AreDeclaratorChunksValid =
false;
5332 bool HasAnyInterestingExtParameterInfos =
false;
5334 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
5336 QualType ParamTy = Param->getType();
5337 assert(!ParamTy.
isNull() &&
"Couldn't parse type?");
5348 ParamTy = Context.IntTy;
5349 Param->setType(ParamTy);
5353 ParamTy = Context.IntTy;
5354 Param->setType(ParamTy);
5358 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
5360 for (
const auto *A : Param->attrs()) {
5361 S.
Diag(A->getLoc(), diag::warn_attribute_on_void_param)
5362 << A << A->getRange();
5367 if (Param->isExplicitObjectParameter()) {
5368 S.
Diag(Param->getLocation(),
5369 diag::err_void_explicit_object_param);
5382 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5385 Param->setInvalidDecl();
5387 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5389 S.
Diag(Param->getLocation(),
5390 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
5394 if (Context.isPromotableIntegerType(ParamTy)) {
5395 ParamTy = Context.getPromotedIntegerType(ParamTy);
5396 Param->setKNRPromoted(
true);
5398 if (BTy->getKind() == BuiltinType::Float) {
5399 ParamTy = Context.DoubleTy;
5400 Param->setKNRPromoted(
true);
5405 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5410 if (LangOpts.ObjCAutoRefCount && Param->hasAttr<NSConsumedAttr>()) {
5411 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
5412 HasAnyInterestingExtParameterInfos =
true;
5416 ExtParameterInfos[i] =
5417 ExtParameterInfos[i].withABI(
attr->getABI());
5418 HasAnyInterestingExtParameterInfos =
true;
5421 if (Param->hasAttr<PassObjectSizeAttr>()) {
5422 ExtParameterInfos[i] = ExtParameterInfos[i].withHasPassObjectSize();
5423 HasAnyInterestingExtParameterInfos =
true;
5426 if (Param->hasAttr<NoEscapeAttr>()) {
5427 ExtParameterInfos[i] = ExtParameterInfos[i].withIsNoEscape(
true);
5428 HasAnyInterestingExtParameterInfos =
true;
5431 ParamTys.push_back(ParamTy);
5434 if (HasAnyInterestingExtParameterInfos) {
5443 Expr *NoexceptExpr =
nullptr;
5449 DynamicExceptions.reserve(N);
5450 DynamicExceptionRanges.reserve(N);
5451 for (
unsigned I = 0; I != N; ++I) {
5462 DynamicExceptionRanges,
5469 auto IsClassMember = [&]() {
5470 return (!state.getDeclarator().getCXXScopeSpec().isEmpty() &&
5471 state.getDeclarator()
5475 state.getDeclarator().getContext() ==
5477 state.getDeclarator().getContext() ==
5481 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
5501 T = Context.getFunctionType(
T, ParamTys, EPI);
5510 inferPointerNullability(SimplePointerKind::MemberPointer, DeclType.
Loc,
5512 state.getDeclarator().getAttributePool());
5517 AreDeclaratorChunksValid =
false;
5526 AreDeclaratorChunksValid =
false;
5545 AreDeclaratorChunksValid =
false;
5554 S.
Diag(DeclType.
Loc, diag::warn_noderef_on_non_pointer_or_array);
5556 ExpectNoDerefChunk = state.didParseNoDeref();
5560 if (ExpectNoDerefChunk)
5561 S.
Diag(state.getDeclarator().getBeginLoc(),
5562 diag::warn_noderef_on_non_pointer_or_array);
5575 bool IsBlock =
false;
5577 switch (DeclType.Kind) {
5589 S.
Diag(DeclType.Loc, diag::warn_strict_prototypes)
5601 assert(!
T.isNull() &&
"T must not be null after this point");
5603 if (LangOpts.CPlusPlus &&
T->isFunctionType()) {
5605 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
5618 ExplicitObjectMember,
5622 Kind = DeductionGuide;
5639 auto *P = dyn_cast_or_null<ParmVarDecl>(Chunk.
Fun.
Params->
Param);
5640 if (P && P->isExplicitObjectParameter())
5641 Kind = ExplicitObjectMember;
5667 if (IsQualifiedFunction &&
5693 if (!RemovalLocs.empty()) {
5694 llvm::sort(RemovalLocs,
5696 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
5697 Loc = RemovalLocs.front();
5701 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
5725 if (!AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
5733 state.diagnoseIgnoredTypeAttrs(
T);
5744 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20 &&
5769 if (!
T->containsUnexpandedParameterPack() &&
5770 (!LangOpts.CPlusPlus20 || !
T->getContainedAutoType())) {
5772 diag::err_function_parameter_pack_without_parameter_packs)
5776 T = Context.getPackExpansionType(
T, std::nullopt,
5789 if (
T->containsUnexpandedParameterPack())
5790 T = Context.getPackExpansionType(
T, std::nullopt);
5822 diag::err_ellipsis_in_declarator_not_parameter);
5828 assert(!
T.isNull() &&
"T must not be null at the end of this function");
5829 if (!AreDeclaratorChunksValid)
5830 return Context.getTrivialTypeSourceInfo(
T);
5832 if (state.didParseHLSLParamMod() && !
T->isConstantArrayType())
5841 TypeProcessingState state(*
this, D);
5864 unsigned chunkIndex) {
5865 Sema &S = state.getSema();
5873 const char *attrStr =
nullptr;
5874 switch (ownership) {
5892 &Args, 1, ParsedAttr::Form::GNU());
5901 Sema &S = state.getSema();
5905 bool hasIndirection =
false;
5908 switch (chunk.
Kind) {
5917 hasIndirection =
true;
5950 TypeProcessingState state(*
this, D);
5965 TypeProcessingState &State) {
5970 TypeProcessingState &State) {
5972 State.getSema().HLSL().TakeLocForHLSLAttribute(TL.
getTypePtr());
5980 if (AL.getKind() == ParsedAttr::AT_MatrixType) {
5989 llvm_unreachable(
"no matrix_type attribute found at the expected location!");
5997 ? ParsedAttr::AT_ExtVectorType
5998 : ParsedAttr::AT_VectorSize;
6000 if (AL.getKind() == Kind && !AL.isInvalid() && AL.getNumArgs() == 1) {
6014 switch (Chunk.
Kind) {
6019 llvm_unreachable(
"cannot be _Atomic qualified");
6037 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
6039 ASTContext &Context;
6040 TypeProcessingState &State;
6044 TypeSpecLocFiller(Sema &S, ASTContext &Context, TypeProcessingState &State,
6046 : SemaRef(S), Context(Context), State(State), DS(DS) {}
6048 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
6052 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
6055 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
6058 void VisitHLSLAttributedResourceTypeLoc(HLSLAttributedResourceTypeLoc TL) {
6062 void VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {}
6063 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6066 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6068 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6073 void VisitPointerTypeLoc(PointerTypeLoc TL) { Visit(TL.
getNextTypeLoc()); }
6074 void VisitTypedefTypeLoc(TypedefTypeLoc TL) {
6076 TypeSourceInfo *TInfo =
nullptr;
6089 void VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
6091 TypeSourceInfo *TInfo =
nullptr;
6104 void VisitUsingTypeLoc(UsingTypeLoc TL) {
6106 TypeSourceInfo *TInfo =
nullptr;
6119 void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
6126 void VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
6127 TypeSourceInfo *RepTInfo =
nullptr;
6131 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6132 TypeSourceInfo *RepTInfo =
nullptr;
6136 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
6137 TypeSourceInfo *TInfo =
nullptr;
6148 TL.
copy(OldTL.
castAs<TemplateSpecializationTypeLoc>());
6150 OldTL.
castAs<TemplateSpecializationTypeLoc>().getRAngleLoc());
6152 void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
6158 void VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
6164 TypeSourceInfo *TInfo =
nullptr;
6168 void VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
6173 void VisitPackIndexingTypeLoc(PackIndexingTypeLoc TL) {
6175 TypeSourceInfo *TInfo =
nullptr;
6179 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
6184 TypeSourceInfo *TInfo =
nullptr;
6188 void VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
6201 void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
6203 TypeSourceInfo *TInfo =
nullptr;
6208 void VisitAutoTypeLoc(AutoTypeLoc TL) {
6222 NestedNameSpecifierLoc NNS =
6225 : NestedNameSpecifierLoc());
6226 TemplateArgumentListInfo TemplateArgsInfo(TemplateId->
LAngleLoc,
6228 if (TemplateId->
NumArgs > 0) {
6237 NamedDecl *FoundDecl;
6242 FoundDecl = cast_if_present<NamedDecl>(TN.getAsTemplateDecl());
6250 void VisitDeducedTemplateSpecializationTypeLoc(
6251 DeducedTemplateSpecializationTypeLoc TL) {
6253 TypeSourceInfo *TInfo =
nullptr;
6259 void VisitTagTypeLoc(TagTypeLoc TL) {
6261 TypeSourceInfo *TInfo =
nullptr;
6269 ElaboratedTypeKeyword::None
6271 : SourceLocation());
6275 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6282 TypeSourceInfo *TInfo =
nullptr;
6294 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6297 TypeSourceInfo *TInfo =
nullptr;
6302 void VisitExtIntTypeLoc(BitIntTypeLoc TL) {
6306 void VisitDependentExtIntTypeLoc(DependentBitIntTypeLoc TL) {
6310 void VisitTypeLoc(TypeLoc TL) {
6316 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
6317 ASTContext &Context;
6318 TypeProcessingState &State;
6319 const DeclaratorChunk &Chunk;
6322 DeclaratorLocFiller(ASTContext &Context, TypeProcessingState &State,
6323 const DeclaratorChunk &Chunk)
6324 : Context(Context), State(State), Chunk(Chunk) {}
6326 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6327 llvm_unreachable(
"qualified type locs not expected here!");
6329 void VisitDecayedTypeLoc(DecayedTypeLoc TL) {
6330 llvm_unreachable(
"decayed type locs not expected here!");
6332 void VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
6333 llvm_unreachable(
"array parameter type locs not expected here!");
6336 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
6339 void VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
6342 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
6345 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
6348 void VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
6351 void VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
6355 void VisitPointerTypeLoc(PointerTypeLoc TL) {
6359 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6363 void VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
6368 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
6374 void VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
6379 void VisitArrayTypeLoc(ArrayTypeLoc TL) {
6385 void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
6390 const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.
Fun;
6393 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
6399 void VisitParenTypeLoc(ParenTypeLoc TL) {
6404 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6408 void VisitBitIntTypeLoc(BitIntTypeLoc TL) {
6411 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6414 void VisitVectorTypeLoc(VectorTypeLoc TL) {
6418 void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
6421 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6425 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
6428 void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
6432 void VisitTypeLoc(TypeLoc TL) {
6433 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
6444 if (AL.getKind() != ParsedAttr::AT_AddressSpace || AL.isInvalid() ||
6445 AL.getNumArgs() != 1 || !AL.isArgExpr(0))
6455 "no address_space attribute found at the expected location!");
6469 Sema &S = State.getSema();
6495 bool HasDesugaredTypeLoc =
true;
6496 while (HasDesugaredTypeLoc) {
6498 case TypeLoc::MacroQualified: {
6501 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6506 case TypeLoc::Attributed: {
6513 case TypeLoc::Adjusted:
6514 case TypeLoc::BTFTagAttributed: {
6519 case TypeLoc::DependentAddressSpace: {
6533 HasDesugaredTypeLoc =
false;
6544 if (ReturnTypeInfo) {
6564 "LocInfoType's TypeClass conflicts with an existing Type class");
6570 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
6571 " was used directly instead of getting the QualType through"
6572 " GetTypeFromParser");
6579 "Type name should have no identifier!");
6616 const Expr *AddrSpace,
6619 std::optional<llvm::APSInt> OptAddrSpace =
6621 if (!OptAddrSpace) {
6622 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
6627 llvm::APSInt &addrSpace = *OptAddrSpace;
6630 if (addrSpace.isSigned()) {
6631 if (addrSpace.isNegative()) {
6632 S.
Diag(AttrLoc, diag::err_attribute_address_space_negative)
6636 addrSpace.setIsSigned(
false);
6639 llvm::APSInt
max(addrSpace.getBitWidth());
6643 if (addrSpace >
max) {
6644 S.
Diag(AttrLoc, diag::err_attribute_address_space_too_high)
6666 return Context.getAddrSpaceQualType(
T, ASIdx);
6675 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
6679 return Context.getDependentAddressSpaceType(
T, AddrSpace, AttrLoc);
6691 TypeProcessingState &State) {
6692 Sema &S = State.getSema();
6695 auto *StrLiteral = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6704 StringRef BTFTypeTag = StrLiteral->getString();
6705 Type = State.getBTFTagAttributedType(
6706 ::new (Ctx) BTFTypeTagAttr(Ctx,
Attr, BTFTypeTag),
Type);
6714 TypeProcessingState &State) {
6715 Sema &S = State.getSema();
6720 S.
Diag(
Attr.
getLoc(), diag::err_attribute_address_function_type);
6726 if (
Attr.
getKind() == ParsedAttr::AT_AddressSpace) {
6729 if (
Attr.getNumArgs() != 1) {
6736 Expr *ASArgExpr =
Attr.getArgAsExpr(0);
6745 ::new (Ctx) AddressSpaceAttr(Ctx,
Attr,
static_cast<unsigned>(ASIdx));
6757 if (EquivType.
isNull()) {
6761 T = State.getAttributedType(ASAttr,
Type, EquivType);
6763 T = State.getAttributedType(ASAttr,
Type,
Type);
6778 ASIdx =
Attr.asHLSLLangAS();
6781 llvm_unreachable(
"Invalid address space");
6794 TypeProcessingState &State) {
6795 Sema &S = State.getSema();
6799 S.
Diag(
Attr.
getLoc(), diag::warn_overflow_behavior_attribute_disabled)
6806 if (
Attr.getNumArgs() != 1) {
6807 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6816 <<
Attr <<
Type.getAsString() << 0;
6823 S.
Diag(
Attr.
getLoc(), diag::err_overflow_behavior_non_integer_type)
6824 <<
Attr <<
Type.getAsString() << 0;
6829 StringRef KindName =
"";
6832 if (
Attr.isArgIdent(0)) {
6833 Ident =
Attr.getArgAsIdent(0)->getIdentifierInfo();
6842 auto *Str = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6844 KindName = Str->getString();
6853 OverflowBehaviorType::OverflowBehaviorKind Kind;
6854 if (KindName ==
"wrap") {
6855 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
6856 }
else if (KindName ==
"trap") {
6857 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
6860 << KindName <<
Attr;
6866 const DeclSpec &DS = State.getDeclarator().getDeclSpec();
6870 OverflowBehaviorType::OverflowBehaviorKind SpecifierKind =
6871 DS.
isWrapSpecified() ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
6872 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
6874 if (SpecifierKind != Kind) {
6877 << 1 << SpecifierName << KindName;
6881 S.
Diag(
Attr.
getLoc(), diag::warn_redundant_overflow_behaviors_mixed)
6888 if (
const auto *ExistingOBT =
Type->
getAs<OverflowBehaviorType>()) {
6889 OverflowBehaviorType::OverflowBehaviorKind ExistingKind =
6890 ExistingOBT->getBehaviorKind();
6891 if (ExistingKind != Kind) {
6892 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_overflow_behaviors) << 0;
6893 if (Kind == OverflowBehaviorType::OverflowBehaviorKind::Trap) {
6894 Type = State.getOverflowBehaviorType(Kind,
6895 ExistingOBT->getUnderlyingType());
6900 Type = State.getOverflowBehaviorType(Kind,
Type);
6910 bool NonObjCPointer =
false;
6912 if (!
type->isDependentType() && !
type->isUndeducedType()) {
6920 NonObjCPointer =
true;
6921 }
else if (!
type->isObjCRetainableType()) {
6927 if (state.isProcessingDeclSpec()) {
6935 Sema &S = state.getSema();
6941 if (!
attr.isArgIdent(0)) {
6942 S.
Diag(AttrLoc, diag::err_attribute_argument_type) <<
attr
6950 if (II->
isStr(
"none"))
6952 else if (II->
isStr(
"strong"))
6954 else if (II->
isStr(
"weak"))
6956 else if (II->
isStr(
"autoreleasing"))
6959 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported) <<
attr << II;
6976 =
type.getQualifiers().getObjCLifetime()) {
6979 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
6986 if (previousLifetime != lifetime) {
6989 const Type *prevTy =
nullptr;
6990 while (!prevTy || prevTy != underlyingType.
Ty) {
6991 prevTy = underlyingType.
Ty;
7000 if (NonObjCPointer) {
7001 StringRef name =
attr.getAttrName()->getName();
7010 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
7027 type = state.getAttributedType(
7034 if (!NonObjCPointer)
7051 diagnostic,
type, 0));
7053 S.
Diag(loc, diagnostic);
7062 unsigned diagnostic =
7063 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
7064 : diag::err_arc_weak_no_runtime);
7067 diagnoseOrDelay(S, AttrLoc, diagnostic,
type);
7079 if (Class->isArcWeakrefUnavailable()) {
7080 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
7081 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
7082 diag::note_class_declared);
7097 Sema &S = state.getSema();
7100 if (!
type->isPointerType() &&
7101 !
type->isObjCObjectPointerType() &&
7102 !
type->isBlockPointerType())
7106 S.
Diag(
attr.getLoc(), diag::err_attribute_multiple_objc_gc);
7112 if (!
attr.isArgIdent(0)) {
7113 S.
Diag(
attr.getLoc(), diag::err_attribute_argument_type)
7119 if (
attr.getNumArgs() > 1) {
7120 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_number_arguments) <<
attr
7127 if (II->
isStr(
"weak"))
7129 else if (II->
isStr(
"strong"))
7132 S.
Diag(
attr.getLoc(), diag::warn_attribute_type_not_supported)
7142 if (
attr.getLoc().isValid())
7143 type = state.getAttributedType(
7160 struct FunctionTypeUnwrapper {
7174 const FunctionType *
Fn;
7175 SmallVector<
unsigned char , 8> Stack;
7177 FunctionTypeUnwrapper(Sema &S, QualType
T) : Original(
T) {
7179 const Type *Ty =
T.getTypePtr();
7189 Stack.push_back(
Array);
7195 Stack.push_back(BlockPointer);
7198 Stack.push_back(MemberPointer);
7204 Stack.push_back(Attributed);
7207 Stack.push_back(MacroQualified);
7215 T = QualType(DTy, 0);
7216 Stack.push_back(Desugar);
7221 bool isFunctionType()
const {
return (Fn !=
nullptr); }
7222 const FunctionType *get()
const {
return Fn; }
7224 QualType wrap(Sema &S,
const FunctionType *
New) {
7226 if (
New == get())
return Original;
7229 return wrap(S.
Context, Original, 0);
7233 QualType wrap(ASTContext &
C, QualType Old,
unsigned I) {
7234 if (I == Stack.size())
7239 SplitQualType SplitOld = Old.
split();
7243 return wrap(
C, SplitOld.
Ty, I);
7244 return C.getQualifiedType(wrap(
C, SplitOld.
Ty, I), SplitOld.
Quals);
7247 QualType wrap(ASTContext &
C,
const Type *Old,
unsigned I) {
7248 if (I == Stack.size())
return QualType(Fn, 0);
7250 switch (
static_cast<WrapKind
>(Stack[I++])) {
7261 return C.getParenType(
New);
7264 case MacroQualified:
7268 if (
const auto *CAT = dyn_cast<ConstantArrayType>(Old)) {
7269 QualType
New = wrap(
C, CAT->getElementType(), I);
7270 return C.getConstantArrayType(
New, CAT->getSize(), CAT->getSizeExpr(),
7271 CAT->getSizeModifier(),
7272 CAT->getIndexTypeCVRQualifiers());
7275 if (
const auto *VAT = dyn_cast<VariableArrayType>(Old)) {
7276 QualType
New = wrap(
C, VAT->getElementType(), I);
7277 return C.getVariableArrayType(
New, VAT->getSizeExpr(),
7278 VAT->getSizeModifier(),
7279 VAT->getIndexTypeCVRQualifiers());
7283 QualType
New = wrap(
C, IAT->getElementType(), I);
7284 return C.getIncompleteArrayType(
New, IAT->getSizeModifier(),
7285 IAT->getIndexTypeCVRQualifiers());
7290 return C.getPointerType(
New);
7293 case BlockPointer: {
7295 return C.getBlockPointerType(
New);
7298 case MemberPointer: {
7311 return C.getRValueReferenceType(
New);
7315 llvm_unreachable(
"unknown wrapping kind");
7322 Sema &S = State.getSema();
7326 default: llvm_unreachable(
"Unknown attribute kind");
7327 case ParsedAttr::AT_Ptr32:
7330 case ParsedAttr::AT_Ptr64:
7333 case ParsedAttr::AT_SPtr:
7336 case ParsedAttr::AT_UPtr:
7341 std::bitset<attr::LastAttr> Attrs;
7344 if (
const TypedefType *TT = dyn_cast<TypedefType>(Desugared)) {
7345 Desugared = TT->desugar();
7348 const AttributedType *AT = dyn_cast<AttributedType>(Desugared);
7351 Attrs[AT->getAttrKind()] =
true;
7352 Desugared = AT->getModifiedType();
7358 if (Attrs[NewAttrKind]) {
7359 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7362 Attrs[NewAttrKind] =
true;
7366 if (Attrs[attr::Ptr32] && Attrs[attr::Ptr64]) {
7367 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7369 <<
"'__ptr64'" << 0;
7371 }
else if (Attrs[attr::SPtr] && Attrs[attr::UPtr]) {
7372 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7384 S.
Diag(PAttr.
getLoc(), diag::err_attribute_no_member_pointers) << PAttr;
7386 S.
Diag(PAttr.
getLoc(), diag::err_attribute_pointers_only) << PAttr << 0;
7394 if (PtrWidth == 32) {
7395 if (Attrs[attr::Ptr64])
7397 else if (Attrs[attr::UPtr])
7399 }
else if (PtrWidth == 64 && Attrs[attr::Ptr32]) {
7419 assert(PAttr.
getKind() == ParsedAttr::AT_WebAssemblyFuncref);
7421 Sema &S = State.getSema();
7424 std::bitset<attr::LastAttr> Attrs;
7426 const auto *AT = dyn_cast<AttributedType>(QT);
7428 Attrs[AT->getAttrKind()] =
true;
7429 AT = dyn_cast<AttributedType>(AT->getModifiedType());
7434 if (Attrs[NewAttrKind]) {
7435 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7441 const auto *Ptr = dyn_cast<PointerType>(Desugared);
7442 if (!Ptr || !Ptr->getPointeeType()->isFunctionType()) {
7443 S.
Diag(PAttr.
getLoc(), diag::err_attribute_webassembly_funcref);
7455 QT = State.getAttributedType(A, QT,
Equivalent);
7464 Sema &S = State.getSema();
7465 auto &D = State.getDeclarator();
7471 if (State.isProcessingDeclSpec()) {
7472 if (!(D.isPrototypeContext() ||
7476 if (
auto *chunk = D.getInnermostNonParenChunk()) {
7499 auto chunkIdx = State.getCurrentChunkIndex();
7500 if (chunkIdx >= 1 &&
7503 D.getTypeObject(chunkIdx - 1).getAttrs());
7508 auto *A = ::new (S.
Context) SwiftAttrAttr(S.
Context, PAttr, Str);
7509 QT = State.getAttributedType(A, QT, QT);
7516 auto Attributed = dyn_cast<AttributedType>(
Type.getTypePtr());
7521 if (Attributed->getImmediateNullability())
7522 return Attributed->getModifiedType();
7526 Ctx, Attributed->getModifiedType());
7527 assert(Modified.
getTypePtr() != Attributed->getModifiedType().getTypePtr());
7529 Attributed->getEquivalentType(),
7530 Attributed->getAttr());
7536 case ParsedAttr::AT_TypeNonNull:
7539 case ParsedAttr::AT_TypeNullable:
7542 case ParsedAttr::AT_TypeNullableResult:
7545 case ParsedAttr::AT_TypeNullUnspecified:
7549 llvm_unreachable(
"not a nullability attribute kind");
7556 bool IsContextSensitive,
bool AllowOnArrayType,
bool OverrideExisting) {
7557 bool Implicit = (State ==
nullptr);
7563 while (
auto *Attributed = dyn_cast<AttributedType>(Desugared.
getTypePtr())) {
7565 if (
auto ExistingNullability = Attributed->getImmediateNullability()) {
7567 if (Nullability == *ExistingNullability) {
7571 S.
Diag(NullabilityLoc, diag::warn_nullability_duplicate)
7578 if (!OverrideExisting) {
7580 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7590 Desugared = Attributed->getModifiedType();
7598 if (Nullability != *ExistingNullability && !
Implicit) {
7599 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7607 if (
auto typedefNullability =
7608 AttributedType::stripOuterNullability(underlyingType)) {
7609 if (*typedefNullability == *ExistingNullability) {
7622 !(AllowOnArrayType && Desugared->
isArrayType())) {
7624 S.
Diag(NullabilityLoc, diag::err_nullability_nonpointer)
7632 if (IsContextSensitive) {
7643 S.
Diag(NullabilityLoc, diag::err_nullability_cs_multilevel)
7645 S.
Diag(NullabilityLoc, diag::note_nullability_type_specifier)
7657 QT = State->getAttributedType(A, QT, QT);
7666 bool AllowOnArrayType) {
7672 Nullability, NullabilityLoc,
7673 IsContextSensitive, AllowOnArrayType,
7680 bool AllowArrayTypes,
7681 bool OverrideExisting) {
7683 *
this,
nullptr,
nullptr,
Type, Nullability, DiagLoc,
7684 false, AllowArrayTypes, OverrideExisting);
7692 llvm::APInt MaxSizeForAddrSpace =
7693 llvm::APInt::getMaxValue(
Context.getTargetInfo().getPointerWidth(AS));
7694 std::optional<CharUnits> TSizeInChars =
Context.getTypeSizeInCharsIfKnown(
T);
7695 if (TSizeInChars &&
static_cast<uint64_t
>(TSizeInChars->getQuantity()) >
7696 MaxSizeForAddrSpace.getZExtValue()) {
7698 <<
T << MaxSizeForAddrSpace;
7709 Sema &S = state.getSema();
7713 type = state.getAttributedType(
7726 S.
Diag(
attr.getLoc(), diag::err_objc_kindof_nonobject)
7735 objType->getBaseType(), objType->getTypeArgsAsWritten(),
7736 objType->getProtocols(),
7737 objType->isObjCUnqualifiedId() ?
false :
true);
7742 if (
auto nullability =
type->getNullability()) {
7745 assert(
attr.getAttributeSpellingListIndex() == 0 &&
7746 "multiple spellings for __kindof?");
7749 equivType = state.getAttributedType(A, equivType, equivType);
7754 type = state.getAttributedType(
7767 Declarator &declarator = state.getDeclarator();
7770 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
7783 PK_MemberFunctionPointer,
7788 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
7790 auto diag = state.getSema().Diag(
attr.getLoc(),
7791 diag::warn_nullability_declspec)
7793 attr.isContextSensitiveKeywordAttribute())
7795 <<
static_cast<unsigned>(pointerKind);
7801 state.getSema().getPreprocessor().getLocForEndOfToken(
7803 " " +
attr.getAttrName()->getName().str() +
" ");
7813 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
7815 switch (chunk.
Kind) {
7819 return moveToChunk(chunk,
false);
7831 return moveToChunk(*dest,
true);
7847 assert(!
Attr.isInvalid());
7850 llvm_unreachable(
"not a calling convention attribute");
7851 case ParsedAttr::AT_CDecl:
7853 case ParsedAttr::AT_FastCall:
7855 case ParsedAttr::AT_StdCall:
7857 case ParsedAttr::AT_ThisCall:
7859 case ParsedAttr::AT_RegCall:
7861 case ParsedAttr::AT_Pascal:
7863 case ParsedAttr::AT_SwiftCall:
7865 case ParsedAttr::AT_SwiftAsyncCall:
7867 case ParsedAttr::AT_VectorCall:
7869 case ParsedAttr::AT_AArch64VectorPcs:
7871 case ParsedAttr::AT_AArch64SVEPcs:
7873 case ParsedAttr::AT_ArmStreaming:
7875 case ParsedAttr::AT_Pcs: {
7880 if (
Attr.isArgExpr(0))
7883 Str =
Attr.getArgAsIdent(0)->getIdentifierInfo()->getName();
7884 PcsAttr::PCSType
Type;
7885 if (!PcsAttr::ConvertStrToPCSType(Str,
Type))
7886 llvm_unreachable(
"already validated the attribute");
7887 return ::new (Ctx) PcsAttr(Ctx,
Attr,
Type);
7889 case ParsedAttr::AT_IntelOclBicc:
7891 case ParsedAttr::AT_MSABI:
7893 case ParsedAttr::AT_SysVABI:
7895 case ParsedAttr::AT_PreserveMost:
7897 case ParsedAttr::AT_PreserveAll:
7899 case ParsedAttr::AT_M68kRTD:
7901 case ParsedAttr::AT_PreserveNone:
7903 case ParsedAttr::AT_RISCVVectorCC:
7905 case ParsedAttr::AT_RISCVVLSCC: {
7908 unsigned ABIVLen = 128;
7909 if (
Attr.getNumArgs()) {
7910 std::optional<llvm::APSInt> MaybeABIVLen =
7911 Attr.getArgAsExpr(0)->getIntegerConstantExpr(Ctx);
7913 llvm_unreachable(
"Invalid RISC-V ABI VLEN");
7914 ABIVLen = MaybeABIVLen->getZExtValue();
7917 return ::new (Ctx) RISCVVLSCCAttr(Ctx,
Attr, ABIVLen);
7920 llvm_unreachable(
"unexpected attribute kind!");
7923std::optional<FunctionEffectMode>
7928 std::optional<llvm::APSInt> ConditionValue =
7930 if (!ConditionValue) {
7936 return std::nullopt;
7945 FunctionTypeUnwrapper &Unwrapped) {
7947 if (!Unwrapped.isFunctionType())
7950 Sema &S = TPState.getSema();
7954 if (FPT ==
nullptr) {
7955 S.
Diag(PAttr.
getLoc(), diag::err_func_with_effects_no_prototype)
7962 bool IsNonBlocking = PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7963 PAttr.
getKind() == ParsedAttr::AT_Blocking;
7966 Expr *CondExpr =
nullptr;
7968 if (PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7969 PAttr.
getKind() == ParsedAttr::AT_NonAllocating) {
7978 std::optional<FunctionEffectMode> MaybeMode =
7984 NewMode = *MaybeMode;
8019 assert(
Success &&
"effect conflicts should have been diagnosed above");
8023 FPT->getParamTypes(), EPI);
8032 auto OtherAttr = llvm::find_if(
8033 state.getCurrentAttributes(),
8034 [OtherKind](
const ParsedAttr &A) { return A.getKind() == OtherKind; });
8035 if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
8038 Sema &S = state.getSema();
8040 << *OtherAttr <<
Attr
8041 << (OtherAttr->isRegularKeywordAttribute() ||
8043 S.
Diag(OtherAttr->getLoc(), diag::note_conflicting_attribute);
8051 if (!
Attr.getNumArgs()) {
8057 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
8058 StringRef StateName;
8063 if (StateName !=
"sme_za_state") {
8064 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8071 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_attributes_arm_agnostic);
8086 if (!
Attr.getNumArgs()) {
8092 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
8093 StringRef StateName;
8100 if (StateName ==
"za") {
8103 }
else if (StateName ==
"zt0") {
8107 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8113 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_agnostic);
8122 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_state)
8138 Sema &S = state.getSema();
8140 FunctionTypeUnwrapper unwrapped(S,
type);
8142 if (
attr.getKind() == ParsedAttr::AT_NoReturn) {
8147 if (!unwrapped.isFunctionType())
8156 if (
attr.getKind() == ParsedAttr::AT_CFIUncheckedCallee) {
8158 if (!unwrapped.isFunctionType())
8161 if (!unwrapped.get()->isFunctionProtoType()) {
8162 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8163 <<
attr <<
attr.isRegularKeywordAttribute()
8171 FPT->getReturnType(), FPT->getParamTypes(),
8172 FPT->getExtProtoInfo().withCFIUncheckedCallee(
true));
8177 if (
attr.getKind() == ParsedAttr::AT_CmseNSCall) {
8179 if (!unwrapped.isFunctionType())
8184 S.
Diag(
attr.getLoc(), diag::warn_attribute_ignored) <<
attr;
8191 unwrapped.get()->getExtInfo().withCmseNSCall(
true);
8198 if (
attr.getKind() == ParsedAttr::AT_NSReturnsRetained) {
8199 if (
attr.getNumArgs())
return true;
8202 if (!unwrapped.isFunctionType())
8207 attr.getLoc(), unwrapped.get()->getReturnType()))
8212 if (state.getSema().getLangOpts().ObjCAutoRefCount) {
8214 = unwrapped.get()->getExtInfo().withProducesResult(
true);
8217 type = state.getAttributedType(
8223 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCallerSavedRegisters) {
8228 if (!unwrapped.isFunctionType())
8232 unwrapped.get()->getExtInfo().withNoCallerSavedRegs(
true);
8237 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCfCheck) {
8239 S.
Diag(
attr.getLoc(), diag::warn_nocf_check_attribute_ignored);
8249 if (!unwrapped.isFunctionType())
8253 unwrapped.get()->getExtInfo().withNoCfCheck(
true);
8258 if (
attr.getKind() == ParsedAttr::AT_Regparm) {
8264 if (!unwrapped.isFunctionType())
8271 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8273 <<
attr.isRegularKeywordAttribute();
8279 unwrapped.get()->getExtInfo().withRegParm(value);
8284 if (
attr.getKind() == ParsedAttr::AT_CFISalt) {
8285 if (
attr.getNumArgs() != 1)
8293 if (!unwrapped.isFunctionType())
8298 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_decl_type)
8299 <<
attr <<
attr.isRegularKeywordAttribute()
8309 FnTy->getParamTypes(), EPI);
8314 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8315 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible ||
8316 attr.getKind() == ParsedAttr::AT_ArmPreserves ||
8317 attr.getKind() == ParsedAttr::AT_ArmIn ||
8318 attr.getKind() == ParsedAttr::AT_ArmOut ||
8319 attr.getKind() == ParsedAttr::AT_ArmInOut ||
8320 attr.getKind() == ParsedAttr::AT_ArmAgnostic) {
8324 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8325 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible)
8329 if (!unwrapped.isFunctionType())
8336 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8337 <<
attr <<
attr.isRegularKeywordAttribute()
8344 switch (
attr.getKind()) {
8345 case ParsedAttr::AT_ArmStreaming:
8347 ParsedAttr::AT_ArmStreamingCompatible))
8351 case ParsedAttr::AT_ArmStreamingCompatible:
8356 case ParsedAttr::AT_ArmPreserves:
8360 case ParsedAttr::AT_ArmIn:
8364 case ParsedAttr::AT_ArmOut:
8368 case ParsedAttr::AT_ArmInOut:
8372 case ParsedAttr::AT_ArmAgnostic:
8377 llvm_unreachable(
"Unsupported attribute");
8381 FnTy->getParamTypes(), EPI);
8386 if (
attr.getKind() == ParsedAttr::AT_NoThrow) {
8388 if (!unwrapped.isFunctionType())
8401 if (Proto->hasExceptionSpec()) {
8402 switch (Proto->getExceptionSpecType()) {
8404 llvm_unreachable(
"This doesn't have an exception spec!");
8422 S.
Diag(
attr.getLoc(), diag::warn_nothrow_attribute_ignored);
8428 type = unwrapped.wrap(
8437 if (
attr.getKind() == ParsedAttr::AT_NonBlocking ||
8438 attr.getKind() == ParsedAttr::AT_NonAllocating ||
8439 attr.getKind() == ParsedAttr::AT_Blocking ||
8440 attr.getKind() == ParsedAttr::AT_Allocating) {
8445 if (!unwrapped.isFunctionType())
return false;
8460 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8463 <<
attr.isRegularKeywordAttribute();
8482 return S.
Diag(
attr.getLoc(), diag::warn_cconv_unsupported)
8487 return S.
Diag(
attr.getLoc(), diag::err_cconv_varargs)
8494 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8496 <<
attr.isRegularKeywordAttribute();
8508 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
8517 const AttributedType *AT;
8521 while ((AT =
T->getAs<AttributedType>()) &&
8523 if (AT->isCallingConv())
8525 T = AT->getModifiedType();
8532 FunctionTypeUnwrapper Unwrapped(*
this,
T);
8538 Context.getDefaultCallingConvention(IsVariadic, HasThisPointer);
8545 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() && IsCtorOrDtor) {
8549 Diag(Loc, diag::warn_cconv_unsupported)
8558 Context.getDefaultCallingConvention(IsVariadic, !HasThisPointer);
8560 if (CurCC != DefaultCC)
8568 QualType Wrapped = Unwrapped.wrap(*
this, FT);
8569 T =
Context.getAdjustedType(
T, Wrapped);
8582 if (
Attr.getNumArgs() != 1) {
8589 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8601 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8616 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
8617 Triple.getArch() == llvm::Triple::aarch64_32 ||
8618 Triple.getArch() == llvm::Triple::aarch64_be;
8620 if (IsPolyUnsigned) {
8622 return BTy->
getKind() == BuiltinType::UChar ||
8623 BTy->
getKind() == BuiltinType::UShort ||
8624 BTy->
getKind() == BuiltinType::ULong ||
8625 BTy->
getKind() == BuiltinType::ULongLong;
8628 return BTy->
getKind() == BuiltinType::SChar ||
8629 BTy->
getKind() == BuiltinType::Short ||
8630 BTy->
getKind() == BuiltinType::LongLong;
8636 if ((Triple.isArch64Bit() || Triple.getArch() == llvm::Triple::aarch64_32) &&
8637 BTy->
getKind() == BuiltinType::Double)
8640 return BTy->
getKind() == BuiltinType::SChar ||
8641 BTy->
getKind() == BuiltinType::UChar ||
8642 BTy->
getKind() == BuiltinType::Short ||
8643 BTy->
getKind() == BuiltinType::UShort ||
8644 BTy->
getKind() == BuiltinType::Int ||
8645 BTy->
getKind() == BuiltinType::UInt ||
8646 BTy->
getKind() == BuiltinType::Long ||
8647 BTy->
getKind() == BuiltinType::ULong ||
8648 BTy->
getKind() == BuiltinType::LongLong ||
8649 BTy->
getKind() == BuiltinType::ULongLong ||
8650 BTy->
getKind() == BuiltinType::Float ||
8651 BTy->
getKind() == BuiltinType::Half ||
8652 BTy->
getKind() == BuiltinType::BFloat16 ||
8653 BTy->
getKind() == BuiltinType::MFloat8;
8658 const auto *AttrExpr =
Attr.getArgAsExpr(0);
8659 if (!AttrExpr->isTypeDependent()) {
8660 if (std::optional<llvm::APSInt> Res =
8661 AttrExpr->getIntegerConstantExpr(S.
Context)) {
8703 llvm::APSInt numEltsInt(32);
8709 S.
Diag(
Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
8716 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
8717 unsigned vecSize = typeSize * numElts;
8718 if (vecSize != 64 && vecSize != 128) {
8719 S.
Diag(
Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
8731 assert((
Attr.getNumArgs() > 0 &&
Attr.getNumArgs() <= 3) &&
8732 "__ptrauth qualifier takes between 1 and 3 arguments");
8733 Expr *KeyArg =
Attr.getArgAsExpr(0);
8734 Expr *IsAddressDiscriminatedArg =
8735 Attr.getNumArgs() >= 2 ?
Attr.getArgAsExpr(1) :
nullptr;
8736 Expr *ExtraDiscriminatorArg =
8737 Attr.getNumArgs() >= 3 ?
Attr.getArgAsExpr(2) :
nullptr;
8746 bool IsInvalid =
false;
8747 unsigned IsAddressDiscriminated, ExtraDiscriminator;
8750 IsAddressDiscriminated);
8759 if (!
T->isSignableType(Ctx) && !
T->isDependentType()) {
8760 S.
Diag(
Attr.
getLoc(), diag::err_ptrauth_qualifier_invalid_target) <<
T;
8765 if (
T.getPointerAuth()) {
8777 assert((!IsAddressDiscriminatedArg || IsAddressDiscriminated <= 1) &&
8778 "address discriminator arg should be either 0 or 1");
8780 Key, IsAddressDiscriminated, ExtraDiscriminator,
8802 S.
Diag(
Attr.
getLoc(), diag::err_attribute_arm_feature_sve_bits_unsupported)
8809 llvm::APSInt SveVectorSizeInBits(32);
8813 unsigned VecSize =
static_cast<unsigned>(SveVectorSizeInBits.getZExtValue());
8836 if (BT->getKind() == BuiltinType::SveBool) {
8841 VecSize /= TypeSize;
8848 const VectorType *VT = dyn_cast<VectorType>(CurType);
8851 diag::err_attribute_arm_mve_polymorphism);
8858 State.getSema().Context,
Attr),
8870 <<
Attr <<
"'zve32x'";
8877 if (!VScale || !VScale->first || VScale->first != VScale->second) {
8878 S.
Diag(
Attr.
getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
8885 llvm::APSInt RVVVectorSizeInBits(32);
8897 unsigned VecSize =
static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue());
8901 unsigned MinElts = Info.
EC.getKnownMinValue();
8904 unsigned ExpectedSize = VScale->first * MinElts;
8912 unsigned SubByteLanes = 0;
8915 if (VecSize == 1 || VecSize == 2 || VecSize == 4)
8916 SubByteLanes = VecSize;
8922 llvm::Log2_32(llvm::RISCV::RVVBitsPerBlock / MinElts), SubByteLanes);
8924 ExpectedSize *= EltSize;
8925 NumElts = VecSize / EltSize;
8931 int(llvm::Log2_32(MinElts * EltSize)) -
8932 int(llvm::Log2_32(llvm::RISCV::RVVBitsPerBlock)));
8936 if (VecSize != ExpectedSize) {
8938 << VecSize << ExpectedSize;
8951 S.
Diag(
Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
8957 QualType BaseTy = TypedefTy->desugar();
8959 std::string PrevAccessQual;
8961 if (TypedefTy->getDecl()->hasAttr<OpenCLAccessAttr>()) {
8962 OpenCLAccessAttr *
Attr =
8963 TypedefTy->getDecl()->getAttr<OpenCLAccessAttr>();
8966 PrevAccessQual =
"read_only";
8970 switch (ImgType->getKind()) {
8971 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8972 case BuiltinType::Id: \
8973 PrevAccessQual = #Access; \
8975 #include "clang/Basic/OpenCLImageTypes.def"
8977 llvm_unreachable(
"Unable to find corresponding image type.");
8980 llvm_unreachable(
"unexpected type");
8983 if (PrevAccessQual == AttrName.ltrim(
"_")) {
8989 S.
Diag(
Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
8992 S.
Diag(TypedefTy->getDecl()->getBeginLoc(),
8993 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
8995 if (
Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
9010 Expr *RowsExpr =
Attr.getArgAsExpr(0);
9011 Expr *ColsExpr =
Attr.getArgAsExpr(1);
9019 Sema &S = State.getSema();
9022 S.
Diag(PA.
getLoc(), diag::err_attribute_too_few_arguments) << PA << 1;
9034 for (
unsigned Idx = 1; Idx < PA.
getNumArgs(); Idx++) {
9040 auto *AnnotateTypeAttr =
9041 AnnotateTypeAttr::Create(S.
Context, Str, Args.data(), Args.size(), PA);
9042 CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType);
9048 if (State.getDeclarator().isDeclarationOfFunction()) {
9049 CurType = State.getAttributedType(
9054 State.getSema().Diag(
Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
9061 if (State.getDeclarator().isDeclarationOfFunction()) {
9062 auto *
Attr = State.getSema().ParseLifetimeCaptureByAttr(PA,
"this");
9064 CurType = State.getAttributedType(
Attr, CurType, CurType);
9076 if (
Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_inout ||
9077 Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_out) {
9078 State.setParsedHLSLParamMod(
true);
9111 state.setParsedNoDeref(
false);
9127 if (
attr.isInvalid())
9130 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute()) {
9135 if (
attr.isGNUScope()) {
9136 assert(
attr.isStandardAttributeSyntax());
9137 bool IsTypeAttr =
attr.isTypeAttr();
9139 state.getSema().Diag(
attr.getLoc(),
9141 ? diag::warn_gcc_ignores_type_attr
9142 : diag::warn_cxx11_gnu_attribute_on_type)
9148 !
attr.isTypeAttr()) {
9159 if (
attr.isTypeAttr() &&
9160 state.getSema().checkCommonAttributeFeatures(
type,
attr)) {
9167 switch (
attr.getKind()) {
9170 if ((
attr.isStandardAttributeSyntax() ||
9171 attr.isRegularKeywordAttribute()) &&
9173 state.getSema().Diag(
attr.getLoc(), diag::err_attribute_not_type_attr)
9174 <<
attr <<
attr.isRegularKeywordAttribute();
9175 attr.setUsedAsTypeAttr();
9180 if (
attr.isStandardAttributeSyntax()) {
9181 state.getSema().DiagnoseUnknownAttribute(
attr);
9191 case ParsedAttr::AT_BTFTypeTag:
9193 attr.setUsedAsTypeAttr();
9196 case ParsedAttr::AT_MayAlias:
9199 attr.setUsedAsTypeAttr();
9201 case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
9202 case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
9203 state.getSema().Diag(
attr.getLoc(), diag::warn_deprecated_attribute)
9206 case ParsedAttr::AT_OpenCLPrivateAddressSpace:
9207 case ParsedAttr::AT_OpenCLGlobalAddressSpace:
9208 case ParsedAttr::AT_OpenCLLocalAddressSpace:
9209 case ParsedAttr::AT_OpenCLConstantAddressSpace:
9210 case ParsedAttr::AT_OpenCLGenericAddressSpace:
9211 case ParsedAttr::AT_AddressSpace:
9212 case ParsedAttr::AT_SYCLPrivateAddressSpace:
9213 case ParsedAttr::AT_SYCLGlobalAddressSpace:
9214 case ParsedAttr::AT_SYCLLocalAddressSpace:
9215 case ParsedAttr::AT_SYCLConstantAddressSpace:
9216 case ParsedAttr::AT_SYCLGenericAddressSpace:
9218 attr.setUsedAsTypeAttr();
9220 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
9223 if (state.getSema().getLangOpts().getHLSLVersion() <
9225 state.getSema().Diag(
attr.getLoc(), diag::warn_hlsl_groupshared_202x);
9232 attr.setUsedAsTypeAttr();
9234 case ParsedAttr::AT_HLSLRowMajor:
9235 case ParsedAttr::AT_HLSLColumnMajor:
9237 state.getSema().HLSL().buildMatrixLayoutTypeAttr(
type,
attr)) {
9239 attr.getKind() == ParsedAttr::AT_HLSLRowMajor
9243 state.getSema().Context.getMatrixTypeWithLayout(
type, Layout);
9246 attr.setUsedAsTypeAttr();
9251 attr.setUsedAsTypeAttr();
9253 case ParsedAttr::AT_VectorSize:
9255 attr.setUsedAsTypeAttr();
9257 case ParsedAttr::AT_ExtVectorType:
9259 attr.setUsedAsTypeAttr();
9261 case ParsedAttr::AT_NeonVectorType:
9263 attr.setUsedAsTypeAttr();
9265 case ParsedAttr::AT_NeonPolyVectorType:
9268 attr.setUsedAsTypeAttr();
9270 case ParsedAttr::AT_ArmSveVectorBits:
9272 attr.setUsedAsTypeAttr();
9274 case ParsedAttr::AT_ArmMveStrictPolymorphism: {
9276 attr.setUsedAsTypeAttr();
9279 case ParsedAttr::AT_RISCVRVVVectorBits:
9281 attr.setUsedAsTypeAttr();
9283 case ParsedAttr::AT_OpenCLAccess:
9285 attr.setUsedAsTypeAttr();
9287 case ParsedAttr::AT_PointerAuth:
9290 attr.setUsedAsTypeAttr();
9292 case ParsedAttr::AT_LifetimeBound:
9296 case ParsedAttr::AT_LifetimeCaptureBy:
9300 case ParsedAttr::AT_OverflowBehavior:
9302 attr.setUsedAsTypeAttr();
9305 case ParsedAttr::AT_NoDeref: {
9310 if (
attr.isStandardAttributeSyntax()) {
9311 state.getSema().Diag(
attr.getLoc(), diag::warn_attribute_ignored)
9318 attr.setUsedAsTypeAttr();
9319 state.setParsedNoDeref(
true);
9323 case ParsedAttr::AT_MatrixType:
9325 attr.setUsedAsTypeAttr();
9328 case ParsedAttr::AT_WebAssemblyFuncref: {
9330 attr.setUsedAsTypeAttr();
9334 case ParsedAttr::AT_HLSLParamModifier: {
9336 if (attrs.
hasAttribute(ParsedAttr::AT_HLSLGroupSharedAddressSpace)) {
9337 state.getSema().Diag(
attr.getLoc(), diag::err_hlsl_attr_incompatible)
9338 <<
attr <<
"'groupshared'";
9342 attr.setUsedAsTypeAttr();
9346 case ParsedAttr::AT_SwiftAttr: {
9353 attr.setUsedAsTypeAttr();
9361 if (
type->canHaveNullability() ||
type->isDependentType() ||
9362 type->isArrayType() ||
9366 endIndex = state.getCurrentChunkIndex();
9368 endIndex = state.getDeclarator().getNumTypeObjects();
9369 bool allowOnArrayType =
9370 state.getDeclarator().isPrototypeContext() &&
9373 allowOnArrayType)) {
9377 attr.setUsedAsTypeAttr();
9381 case ParsedAttr::AT_ObjCKindOf:
9389 state.getSema().Diag(
attr.getLoc(),
9390 diag::err_objc_kindof_wrong_position)
9393 state.getDeclarator().getDeclSpec().getBeginLoc(),
9403 case ParsedAttr::AT_NoThrow:
9406 if (!state.getSema().getLangOpts().CPlusPlus)
9411 attr.setUsedAsTypeAttr();
9415 if (
attr.isStandardAttributeSyntax() ||
9416 attr.isRegularKeywordAttribute()) {
9433 case ParsedAttr::AT_AcquireHandle: {
9434 if (!
type->isFunctionType())
9437 if (
attr.getNumArgs() != 1) {
9438 state.getSema().Diag(
attr.getLoc(),
9439 diag::err_attribute_wrong_number_arguments)
9445 StringRef HandleType;
9446 if (!state.getSema().checkStringLiteralArgumentAttr(
attr, 0, HandleType))
9448 type = state.getAttributedType(
9449 AcquireHandleAttr::Create(state.getSema().Context, HandleType,
attr),
9451 attr.setUsedAsTypeAttr();
9454 case ParsedAttr::AT_AnnotateType: {
9456 attr.setUsedAsTypeAttr();
9459 case ParsedAttr::AT_HLSLResourceClass:
9460 case ParsedAttr::AT_HLSLResourceDimension:
9461 case ParsedAttr::AT_HLSLIsROV:
9462 case ParsedAttr::AT_HLSLRawBuffer:
9463 case ParsedAttr::AT_HLSLIsArray:
9464 case ParsedAttr::AT_HLSLIsMultiSampled:
9465 case ParsedAttr::AT_HLSLContainedType: {
9470 state.getSema().HLSL().handleResourceTypeAttr(
type,
attr))
9471 attr.setUsedAsTypeAttr();
9479 !
type.getQualifiers().hasObjCLifetime() &&
9480 !
type.getQualifiers().hasObjCGCAttr() &&
9481 attr.getKind() != ParsedAttr::AT_ObjCGC &&
9482 attr.getKind() != ParsedAttr::AT_ObjCOwnership) {
9484 type = state.getSema().Context.getMacroQualifiedType(
type, MacroII);
9485 state.setExpansionLocForMacroQualifiedType(
9487 attr.getMacroExpansionLoc());
9494 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
9496 auto *Def = Var->getDefinition();
9502 Def = Var->getDefinition();
9509 if (Var->getPointOfInstantiation().isInvalid() && Def) {
9510 assert(Var->getTemplateSpecializationKind() ==
9512 "explicit instantiation with no point of instantiation");
9513 Var->setTemplateSpecializationKind(
9514 Var->getTemplateSpecializationKind(), PointOfInstantiation);
9534 if (
const auto CastE = dyn_cast<ExplicitCastExpr>(E)) {
9535 QualType DestType = CastE->getTypeAsWritten();
9536 if (
const auto *IAT =
Context.getAsIncompleteArrayType(DestType)) {
9541 IAT->getElementType(),
9578 if (RequireCompleteTypeImpl(Loc,
T, Kind, &Diagnoser))
9580 if (
auto *TD =
T->getAsTagDecl(); TD && !TD->isCompleteDefinitionRequired()) {
9581 TD->setCompleteDefinitionRequired();
9582 Consumer.HandleTagDeclRequiredDefinition(TD);
9615 auto DefinitionIsAcceptable = [&](
NamedDecl *D) {
9635 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
9636 return RD->isThisDeclarationADefinition();
9637 if (
auto *ED = dyn_cast<EnumDecl>(D))
9638 return ED->isThisDeclarationADefinition();
9639 if (
auto *FD = dyn_cast<FunctionDecl>(D))
9640 return FD->isThisDeclarationADefinition();
9641 if (
auto *VD = dyn_cast<VarDecl>(D))
9643 llvm_unreachable(
"unexpected decl type");
9645 auto FoundAcceptableDefinition = [&](
NamedDecl *D) {
9647 return DefinitionIsAcceptable(D);
9655 return DefinitionIsAcceptable(D);
9657 for (
auto *RD : D->
redecls()) {
9659 if (!IsDefinition(ND))
9661 if (DefinitionIsAcceptable(ND)) {
9670 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9671 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
9673 D = RD->getDefinition();
9674 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
9675 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
9677 if (OnlyNeedComplete && (ED->isFixed() ||
getLangOpts().MSVCCompat)) {
9683 *Suggested =
nullptr;
9684 for (
auto *Redecl : ED->redecls()) {
9687 if (Redecl->isThisDeclarationADefinition() ||
9688 (Redecl->isCanonicalDecl() && !*Suggested))
9689 *Suggested = Redecl;
9694 D = ED->getDefinition();
9695 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
9696 if (
auto *Pattern = FD->getTemplateInstantiationPattern())
9698 D = FD->getDefinition();
9699 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
9700 if (
auto *Pattern = VD->getTemplateInstantiationPattern())
9702 D = VD->getDefinition();
9705 assert(D &&
"missing definition for pattern of instantiated definition");
9709 if (FoundAcceptableDefinition(D))
9714 if (
auto *Source =
Context.getExternalSource()) {
9715 Source->CompleteRedeclChain(D);
9716 return FoundAcceptableDefinition(D);
9732 bool OnlyNeedComplete) {
9749 bool OnlyNeedComplete) {
9757 if (!RD->
hasAttr<MSInheritanceAttr>()) {
9759 bool BestCase =
false;
9779 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
9780 S.
getASTContext(), BestCase, Loc, MSInheritanceAttr::Spelling(IM)));
9786 CompleteTypeKind Kind,
9787 TypeDiagnoser *Diagnoser) {
9796 if (
const auto *MPTy = dyn_cast<MemberPointerType>(
T.getCanonicalType())) {
9797 if (CXXRecordDecl *RD = MPTy->getMostRecentCXXRecordDecl();
9798 RD && !RD->isDependentType()) {
9800 if (
getLangOpts().CompleteMemberPointers && !RD->isBeingDefined() &&
9806 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
9813 NamedDecl *Def =
nullptr;
9825 NamedDecl *Suggested =
nullptr;
9831 if (Diagnoser && Suggested)
9834 return !TreatAsComplete;
9839 TagDecl *
Tag = dyn_cast_or_null<TagDecl>(Def);
9840 ObjCInterfaceDecl *IFace = dyn_cast_or_null<ObjCInterfaceDecl>(Def);
9852 if (
auto *Source =
Context.getExternalSource()) {
9853 if (Tag &&
Tag->hasExternalLexicalStorage())
9854 Source->CompleteType(Tag);
9856 Source->CompleteType(IFace);
9860 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9867 if (
auto *RD = dyn_cast_or_null<CXXRecordDecl>(Tag)) {
9868 bool Instantiated =
false;
9869 bool Diagnosed =
false;
9870 if (RD->isDependentContext()) {
9874 }
else if (
auto *ClassTemplateSpec =
9875 dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
9876 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
9880 Diagnoser, ClassTemplateSpec->hasStrictPackMatch());
9882 Instantiated =
true;
9885 CXXRecordDecl *Pattern = RD->getInstantiatedFromMemberClass();
9886 if (!RD->isBeingDefined() && Pattern) {
9887 MemberSpecializationInfo *MSI = RD->getMemberSpecializationInfo();
9888 assert(MSI &&
"Missing member specialization information?");
9898 Instantiated =
true;
9906 if (Diagnoser && Diagnosed)
9912 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9922 Diagnoser->diagnose(*
this, Loc,
T);
9926 if (Tag && !
Tag->isInvalidDecl() && !
Tag->getLocation().isInvalid())
9927 Diag(
Tag->getLocation(),
Tag->isBeingDefined()
9928 ? diag::note_type_being_defined
9929 : diag::note_forward_declaration)
9930 <<
Context.getCanonicalTagType(Tag);
9963 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
9969 assert(!
T->isDependentType() &&
"type should not be dependent");
9978 if (
T->isVariableArrayType())
9994 Diag(RD->getLocation(), diag::note_non_literal_lambda);
10003 Diag(RD->getLocation(), diag::note_non_literal_virtual_base)
10005 for (
const auto &I : RD->vbases())
10006 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
10007 << I.getSourceRange();
10008 }
else if (!RD->isAggregate() && !RD->hasConstexprNonCopyMoveConstructor() &&
10009 !RD->hasTrivialDefaultConstructor()) {
10010 Diag(RD->getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
10011 }
else if (RD->hasNonLiteralTypeFieldsOrBases()) {
10012 for (
const auto &I : RD->bases()) {
10013 if (!I.getType()->isLiteralType(
Context)) {
10014 Diag(I.getBeginLoc(), diag::note_non_literal_base_class)
10015 << RD << I.getType() << I.getSourceRange();
10019 for (
const auto *I : RD->fields()) {
10020 if (!I->getType()->isLiteralType(
Context) ||
10021 I->getType().isVolatileQualified()) {
10022 Diag(I->getLocation(), diag::note_non_literal_field)
10023 << RD << I << I->getType()
10024 << I->getType().isVolatileQualified();
10029 : !RD->hasTrivialDestructor()) {
10034 assert(Dtor &&
"class has literal fields and bases but no dtor?");
10039 Diag(Dtor->getLocation(), diag::note_non_literal_non_constexpr_dtor)
10042 Diag(Dtor->getLocation(), Dtor->isUserProvided()
10043 ? diag::note_non_literal_user_provided_dtor
10044 : diag::note_non_literal_nontrivial_dtor)
10046 if (!Dtor->isUserProvided())
10070 if (
const TagType *TT =
T->getAs<TagType>())
10073 return Context.getTypeOfExprType(E, Kind);
10091 auto Reject = [&]() ->
bool {
10094 if (!CATy->getCountExpr())
10095 Context.completeCountAttributedType(CATy, Arg, {});
10112 if (!CATy->getCountExpr())
10113 Context.completeCountAttributedType(CATy, Arg, Decls);
10128 return Context.getCountAttributedType(WrappedTy, CountExpr, CountInBytes,
10138 if (
auto *ImplCastExpr = dyn_cast<ImplicitCastExpr>(E))
10139 IDExpr = ImplCastExpr->getSubExpr();
10141 if (
auto *PackExpr = dyn_cast<PackIndexingExpr>(E)) {
10143 IDExpr = PackExpr->getPackIdExpression();
10145 IDExpr = PackExpr->getSelectedExpr();
10161 if (
const auto *SNTTPE = dyn_cast<SubstNonTypeTemplateParmExpr>(IDExpr))
10162 IDExpr = SNTTPE->getReplacement();
10170 if (
const auto *DRE = dyn_cast<DeclRefExpr>(IDExpr)) {
10175 if (
const auto *ME = dyn_cast<MemberExpr>(IDExpr)) {
10176 if (
const auto *VD = ME->getMemberDecl())
10178 return VD->getType();
10179 }
else if (
const auto *IR = dyn_cast<ObjCIvarRefExpr>(IDExpr)) {
10180 return IR->getDecl()->getType();
10181 }
else if (
const auto *PR = dyn_cast<ObjCPropertyRefExpr>(IDExpr)) {
10182 if (PR->isExplicitProperty())
10183 return PR->getExplicitProperty()->getType();
10184 }
else if (
const auto *PE = dyn_cast<PredefinedExpr>(IDExpr)) {
10185 return PE->getType();
10196 if (
auto *DRE = dyn_cast<DeclRefExpr>(IDExpr->
IgnoreParens())) {
10197 if (
auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
10200 return Context.getLValueReferenceType(
T);
10205 return Context.getReferenceQualifiedType(E);
10217 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
10229 Diag(Loc, diag::err_expected_name_of_pack) << Pattern;
10233 if (!
Type.isNull())
10234 DiagCompat(Loc, diag_compat::pack_indexing);
10244 llvm::APSInt
Value;
10251 IndexExpr = Res.
get();
10252 uint64_t
V =
Value.getZExtValue();
10253 if (FullySubstituted &&
V >= Expansions.size()) {
10255 <<
V << Pattern << Expansions.size();
10258 Index =
static_cast<unsigned>(
V);
10261 return Context.getPackIndexingType(Pattern, IndexExpr, FullySubstituted,
10262 Expansions, Index);
10267 assert(BaseType->isEnumeralType());
10268 EnumDecl *ED = BaseType->castAs<EnumType>()->getDecl();
10273 if (Underlying.
isNull()) {
10275 assert(!Underlying.
isNull());
10283 if (!BaseType->isEnumeralType()) {
10284 Diag(Loc, diag::err_only_enums_have_underlying_types);
10291 if (BaseType->isIncompleteType(&FwdDecl)) {
10292 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
10293 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
10301 QualType Pointer = BaseType.isReferenceable() || BaseType->isVoidType()
10310 if (!BaseType->isAnyPointerType())
10319 return Context.getDecayedType(Underlying);
10328 Split.Quals.removeCVRQualifiers();
10329 return Context.getQualifiedType(Split);
10336 BaseType.isReferenceable()
10338 UKind == UnaryTransformType::AddLvalueReference,
10346 if (UKind == UnaryTransformType::RemoveAllExtents)
10347 return Context.getBaseElementType(BaseType);
10349 if (
const auto *AT =
Context.getAsArrayType(BaseType))
10350 return AT->getElementType();
10358 QualType T = BaseType.getNonReferenceType();
10359 if (UKind == UTTKind::RemoveCVRef &&
10360 (
T.isConstQualified() ||
T.isVolatileQualified())) {
10365 T =
Context.getQualifiedType(Unqual, Quals);
10372 if ((BaseType->isReferenceType() && UKind != UTTKind::RemoveRestrict) ||
10373 BaseType->isFunctionType())
10379 if (UKind == UTTKind::RemoveConst || UKind == UTTKind::RemoveCV)
10381 if (UKind == UTTKind::RemoveVolatile || UKind == UTTKind::RemoveCV)
10383 if (UKind == UTTKind::RemoveRestrict)
10386 return Context.getQualifiedType(Unqual, Quals);
10392 if (BaseType->isEnumeralType()) {
10394 if (
auto *
BitInt = dyn_cast<BitIntType>(Underlying)) {
10395 unsigned int Bits =
BitInt->getNumBits();
10399 S.
Diag(Loc, diag::err_make_signed_integral_only)
10400 << IsMakeSigned <<
true << BaseType << 1 << Underlying;
10404 S.
Diag(Loc, diag::err_make_signed_integral_only)
10405 << IsMakeSigned <<
false << BaseType << 1
10412 std::array<CanQualType *, 6> AllSignedIntegers = {
10416 AllSignedIntegers.data(), AllSignedIntegers.size() - Int128Unsupported);
10417 std::array<CanQualType *, 6> AllUnsignedIntegers = {
10422 AllUnsignedIntegers.size() -
10423 Int128Unsupported);
10425 IsMakeSigned ? &AvailableSignedIntegers : &AvailableUnsignedIntegers;
10429 llvm::find_if(*Consider, [&S, BaseSize](
const CanQual<Type> *
T) {
10433 assert(
Result != Consider->end());
10434 return QualType((*Result)->getTypePtr(), 0);
10439 bool IsMakeSigned = UKind == UnaryTransformType::MakeSigned;
10440 if ((!BaseType->isIntegerType() && !BaseType->isEnumeralType()) ||
10441 BaseType->isBooleanType() ||
10442 (BaseType->isBitIntType() &&
10444 Diag(Loc, diag::err_make_signed_integral_only)
10445 << IsMakeSigned << BaseType->isBitIntType() << BaseType << 0;
10449 bool IsNonIntIntegral =
10450 BaseType->
isChar16Type() || BaseType->isChar32Type() ||
10451 BaseType->isWideCharType() || BaseType->isEnumeralType();
10456 : IsMakeSigned ?
Context.getCorrespondingSignedType(BaseType)
10457 :
Context.getCorrespondingUnsignedType(BaseType);
10458 if (Underlying.
isNull())
10465 if (BaseType->isDependentType())
10466 return Context.getUnaryTransformType(BaseType, BaseType, UKind);
10469 case UnaryTransformType::EnumUnderlyingType: {
10473 case UnaryTransformType::AddPointer: {
10477 case UnaryTransformType::RemovePointer: {
10481 case UnaryTransformType::Decay: {
10485 case UnaryTransformType::AddLvalueReference:
10486 case UnaryTransformType::AddRvalueReference: {
10490 case UnaryTransformType::RemoveAllExtents:
10491 case UnaryTransformType::RemoveExtent: {
10495 case UnaryTransformType::RemoveCVRef:
10496 case UnaryTransformType::RemoveReference: {
10500 case UnaryTransformType::RemoveConst:
10501 case UnaryTransformType::RemoveCV:
10502 case UnaryTransformType::RemoveRestrict:
10503 case UnaryTransformType::RemoveVolatile: {
10507 case UnaryTransformType::MakeSigned:
10508 case UnaryTransformType::MakeUnsigned: {
10526 int DisallowedKind = -1;
10527 if (
T->isArrayType())
10528 DisallowedKind = 1;
10529 else if (
T->isFunctionType())
10530 DisallowedKind = 2;
10531 else if (
T->isReferenceType())
10532 DisallowedKind = 3;
10533 else if (
T->isAtomicType())
10534 DisallowedKind = 4;
10535 else if (
T.hasQualifiers())
10536 DisallowedKind = 5;
10537 else if (
T->isSizelessType())
10538 DisallowedKind = 6;
10541 DisallowedKind = 7;
10542 else if (
T->isBitIntType())
10543 DisallowedKind = 8;
10546 DisallowedKind = 9;
10547 else if (
T->isOverflowBehaviorType())
10549 DisallowedKind = 10;
10551 if (DisallowedKind != -1) {
10552 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind <<
T;
Defines the clang::ASTContext interface.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Result
Implement __builtin_bit_cast and related operations.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static StringRef getTriple(const Command &Job)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Defines the clang::Preprocessor interface.
static QualType getUnderlyingType(const SubRegion *R)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S, VectorKind VecKind)
HandleNeonVectorTypeAttr - The "neon_vector_type" and "neon_polyvector_type" attributes are used to c...
static constexpr uint64_t MaxVectorSizeInBits
static QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType)
static bool checkOpenCLPipePacketType(Sema &S, QualType T, SourceLocation Loc)
static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S)
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType type)
Given that an objc_gc attribute was written somewhere on a declaration other than on the declarator i...
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type.
#define MS_TYPE_ATTRS_CASELIST
#define CALLING_CONV_ATTRS_CASELIST
static void emitNullabilityConsistencyWarning(Sema &S, SimplePointerKind PointerKind, SourceLocation PointerLoc, SourceLocation PointerEndLoc)
static void fixItNullability(Sema &S, DiagBuilderT &Diag, SourceLocation PointerLoc, NullabilityKind Nullability)
Creates a fix-it to insert a C-style nullability keyword at pointerLoc, taking into account whitespac...
static ExprResult checkArraySize(Sema &S, Expr *&ArraySize, llvm::APSInt &SizeVal, unsigned VLADiag, bool VLAIsError)
Check whether the specified array bound can be evaluated using the relevant language rules.
static Attr * createNullabilityAttr(ASTContext &Ctx, ParsedAttr &Attr, NullabilityKind NK)
static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
HandleVectorSizeAttribute - this attribute is only applicable to integral and float scalars,...
static void inferARCWriteback(TypeProcessingState &state, QualType &declSpecType)
Given that this is the declaration of a parameter under ARC, attempt to infer attributes and such for...
static TypeSourceInfo * GetTypeSourceInfoForDeclarator(TypeProcessingState &State, QualType T, TypeSourceInfo *ReturnTypeInfo)
Create and instantiate a TypeSourceInfo with type source information.
static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx, const Expr *AddrSpace, SourceLocation AttrLoc)
Build an AddressSpace index from a constant expression and diagnose any errors related to invalid add...
static void HandleBTFTypeTagAttribute(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type.
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk)
static void HandleExtVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
static void HandleHLSLParamModifierAttr(TypeProcessingState &State, QualType &CurType, const ParsedAttr &Attr, Sema &S)
static void HandleLifetimeBoundAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &Attr)
static bool handleArmStateAttribute(Sema &S, FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, FunctionType::ArmStateValue State)
static bool handleArmAgnosticAttribute(Sema &S, FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr)
static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType, CUDAFunctionTarget CFT)
A function type attribute was written in the decl spec.
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
static constexpr uint64_t MaxVectorElements
static QualType inferARCLifetimeForPointee(Sema &S, QualType type, SourceLocation loc, bool isReference)
Given that we're building a pointer or reference to the given.
static bool handleNonBlockingNonAllocatingTypeAttr(TypeProcessingState &TPState, ParsedAttr &PAttr, QualType &QT, FunctionTypeUnwrapper &Unwrapped)
static QualType ChangeIntegralSignedness(Sema &S, QualType BaseType, bool IsMakeSigned, SourceLocation Loc)
static bool CheckNullabilityTypeSpecifier(Sema &S, TypeProcessingState *State, ParsedAttr *PAttr, QualType &QT, NullabilityKind Nullability, SourceLocation NullabilityLoc, bool IsContextSensitive, bool AllowOnArrayType, bool OverrideExisting)
#define OBJC_POINTER_TYPE_ATTRS_CASELIST
static void diagnoseBadTypeAttribute(Sema &S, const ParsedAttr &attr, QualType type)
diagnoseBadTypeAttribute - Diagnoses a type attribute which doesn't apply to the given type.
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator, PointerWrappingDeclaratorKind &wrappingKind)
Classify the given declarator, whose type-specified is type, based on what kind of pointer it refers ...
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr, llvm::APSInt &Result)
static void HandleSwiftAttr(TypeProcessingState &State, TypeAttrLocation TAL, QualType &QT, ParsedAttr &PAttr)
static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
static bool shouldHaveNullability(QualType T)
static void HandleArmMveStrictPolymorphismAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &Attr)
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, DeclaratorChunk &DeclType, QualType RT)
Produce an appropriate diagnostic for an ambiguity between a function declarator and a C++ direct-ini...
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType)
Distribute an objc_gc type attribute that was written on the declarator.
static FileID getNullabilityCompletenessCheckFileID(Sema &S, SourceLocation loc)
static void HandleOverflowBehaviorAttr(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
static void HandleArmSveVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr, Sema &S)
HandleArmSveVectorBitsTypeAttr - The "arm_sve_vector_bits" attribute is used to create fixed-length v...
#define FUNCTION_TYPE_ATTRS_CASELIST
static void HandleLifetimeCaptureByAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &PA)
static bool distributeNullabilityTypeAttr(TypeProcessingState &state, QualType type, ParsedAttr &attr)
Distribute a nullability type attribute that cannot be applied to the type specifier to a pointer,...
static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, QualType &declSpecType, CUDAFunctionTarget CFT)
Given that there are attributes written on the declarator or declaration itself, try to distribute an...
static void fillHLSLAttributedResourceTypeLoc(HLSLAttributedResourceTypeLoc TL, TypeProcessingState &State)
static void distributeFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType type)
A function type attribute was written somewhere in a declaration other than on the declarator itself ...
static void HandleMatrixTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
HandleMatrixTypeAttr - "matrix_type" attribute, like ext_vector_type.
static bool HandleWebAssemblyFuncrefAttr(TypeProcessingState &State, QualType &QT, ParsedAttr &PAttr)
static bool hasOuterPointerLikeChunk(const Declarator &D, unsigned endIndex)
Returns true if any of the declarator chunks before endIndex include a level of indirection: array,...
static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
Handle OpenCL Access Qualifier Attribute.
static NullabilityKind mapNullabilityAttrKind(ParsedAttr::Kind kind)
Map a nullability attribute kind to a nullability kind.
static bool distributeFunctionTypeAttrToInnermost(TypeProcessingState &state, ParsedAttr &attr, ParsedAttributesView &attrList, QualType &declSpecType, CUDAFunctionTarget CFT)
Try to distribute a function type attribute to the innermost function chunk or type.
#define NULLABILITY_TYPE_ATTRS_CASELIST
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TypeSourceInfo *&ReturnTypeInfo)
static void checkNullabilityConsistency(Sema &S, SimplePointerKind pointerKind, SourceLocation pointerLoc, SourceLocation pointerEndLoc=SourceLocation())
Complains about missing nullability if the file containing pointerLoc has other uses of nullability (...
static void transferARCOwnership(TypeProcessingState &state, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Used for transferring ownership in casts resulting in l-values.
static std::string getPrintableNameForEntity(DeclarationName Entity)
static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy)
static QualType rebuildAttributedTypeWithoutNullability(ASTContext &Ctx, QualType Type)
Rebuild an attributed type without the nullability attribute on it.
static DeclaratorChunk * maybeMovePastReturnType(Declarator &declarator, unsigned i, bool onlyBlockPointers)
Given the index of a declarator chunk, check whether that chunk directly specifies the return type of...
static OpenCLAccessAttr::Spelling getImageAccess(const ParsedAttributesView &Attrs)
static void fillMatrixTypeLoc(MatrixTypeLoc MTL, const ParsedAttributesView &Attrs)
static UnaryTransformType::UTTKind TSTToUnaryTransformType(DeclSpec::TST SwitchTST)
static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr, Sema &S)
HandleRISCVRVVVectorBitsTypeAttr - The "riscv_rvv_vector_bits" attribute is used to create fixed-leng...
static void HandleAddressSpaceTypeAttribute(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
HandleAddressSpaceTypeAttribute - Process an address_space attribute on the specified type.
static bool checkQualifiedFunction(Sema &S, QualType T, SourceLocation Loc, QualifiedFunctionKind QFK)
Check whether the type T is a qualified function type, and if it is, diagnose that it cannot be conta...
static bool checkOmittedBlockReturnType(Sema &S, Declarator &declarator, QualType Result)
Return true if this is omitted block return type.
static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, const ParsedAttr &Attr, Sema &S)
Handle the __ptrauth qualifier.
static bool DiagnoseMultipleAddrSpaceAttributes(Sema &S, LangAS ASOld, LangAS ASNew, SourceLocation AttrLoc)
static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T)
Produce an appropriate diagnostic for a declarator with top-level parentheses.
static QualType ConvertDeclSpecToType(TypeProcessingState &state)
Convert the specified declspec to the appropriate type object.
static std::pair< QualType, TypeSourceInfo * > InventTemplateParameter(TypeProcessingState &state, QualType T, TypeSourceInfo *TrailingTSI, AutoType *Auto, InventedTemplateParameterInfo &Info)
static void distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType, CUDAFunctionTarget CFT)
A function type attribute was written on the declarator or declaration.
static void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS, unsigned &TypeQuals, QualType TypeSoFar, unsigned RemoveTQs, unsigned DiagID)
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const ParsedAttributesView &AttrList, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
Helper for figuring out the default CC for a function declarator type.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for literal type diagnostic message.
static void recordNullabilitySeen(Sema &S, SourceLocation loc)
Marks that a nullability feature has been used in the file containing loc.
static bool CheckBitIntElementType(Sema &S, SourceLocation AttrLoc, const BitIntType *BIT, bool ForMatrixType=false)
static void checkExtParameterInfos(Sema &S, ArrayRef< QualType > paramTypes, const FunctionProtoType::ExtProtoInfo &EPI, llvm::function_ref< SourceLocation(unsigned)> getParamLoc)
Check the extended parameter information.
static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type, CUDAFunctionTarget CFT)
Process an individual function attribute.
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
static void BuildTypeCoupledDecls(Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
static void assignInheritanceModel(Sema &S, CXXRecordDecl *RD)
Locks in the inheritance model for the given class and all of its bases.
static void fillVectorTypeLoc(VectorTypeLoc VTL, const ParsedAttributesView &Attrs)
static bool checkObjCKindOfType(TypeProcessingState &state, QualType &type, ParsedAttr &attr)
Check the application of the Objective-C '__kindof' qualifier to the given type.
static bool hasNullabilityAttr(const ParsedAttributesView &attrs)
Check whether there is a nullability attribute of any kind in the given attribute list.
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type.
static void moveAttrFromListToList(ParsedAttr &attr, ParsedAttributesView &fromList, ParsedAttributesView &toList)
static void HandleAnnotateTypeAttr(TypeProcessingState &State, QualType &CurType, const ParsedAttr &PA)
static void fillAttributedTypeLoc(AttributedTypeLoc TL, TypeProcessingState &State)
TypeAttrLocation
The location of a type attribute.
@ TAL_DeclChunk
The attribute is part of a DeclaratorChunk.
@ TAL_DeclSpec
The attribute is in the decl-specifier-seq.
@ TAL_DeclName
The attribute is immediately after the declaration's name.
static bool isOmittedBlockReturnType(const Declarator &D)
isOmittedBlockReturnType - Return true if this declarator is missing a return type because this is a ...
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
static QualType GetEnumUnderlyingType(Sema &S, QualType BaseType, SourceLocation Loc)
static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, ArrayRef< const ParsedAttributesView * > AttrLists)
static bool IsNoDerefableChunk(const DeclaratorChunk &Chunk)
static AttrT * createSimpleAttr(ASTContext &Ctx, ParsedAttr &AL)
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, const ParsedAttributesView &attrs, CUDAFunctionTarget CFT=CUDAFunctionTarget::HostDevice)
static bool checkMutualExclusion(TypeProcessingState &state, const FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, AttributeCommonInfo::Kind OtherKind)
static Attr * getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr)
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ int max(int __a, int __b)
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
TranslationUnitDecl * getTranslationUnitDecl() const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
CanQualType UnsignedLongTy
CountAttributedType * getIncompleteCountAttributedType(QualType WrappedTy, bool CountInBytes, bool OrNull) const
Return a CountAttributedType whose count expression has not been parsed yet, for use by a late-parsed...
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
CanQualType UnsignedLongLongTy
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
DiagnosticsEngine & getDiagnostics() const
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getPointerAuthType(QualType Ty, PointerAuthQualifier PointerAuth)
Return a type with the given __ptrauth qualifier.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
void setLBracketLoc(SourceLocation Loc)
void setRBracketLoc(SourceLocation Loc)
void setSizeExpr(Expr *Size)
TypeLoc getValueLoc() const
void setKWLoc(SourceLocation Loc)
void setParensRange(SourceRange Range)
Attr - This represents one attribute.
attr::Kind getKind() const
const char * getSpelling() const
SourceRange getRange() const
bool isContextSensitiveKeywordAttribute() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() const
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
void setAttr(const Attr *A)
bool hasExplicitTemplateArgs() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
TemplateName getNamedConcept() const
SourceLocation getLAngleLoc() const
void setConceptReference(ConceptReference *CR)
NamedDecl * getFoundDecl() const
TemplateArgumentLoc getArgLoc(unsigned i) const
unsigned getNumArgs() const
DeclarationNameInfo getConceptNameInfo() const
void setRParenLoc(SourceLocation Loc)
TypeLoc getWrappedLoc() const
Comparison function object.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
void setCaretLoc(SourceLocation Loc)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
TypeSpecifierWidth getWrittenWidthSpec() const
bool needsExtraLocalData() const
void setBuiltinLoc(SourceLocation Loc)
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
TypeSpecifierSign getWrittenSignSpec() const
void expandBuiltinRange(SourceRange Range)
This class is used for builtin types like 'int'.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
bool hasDefinition() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Represents a canonical, potentially-qualified type.
SourceLocation getBegin() const
This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const TypeClass * getTypePtr() const
TypeLoc getNextTypeLoc() const
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
A reference to a declared variable, function, enum, etc.
Captures information about "declaration specifiers".
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
bool isTypeSpecPipe() const
static const TST TST_typeof_unqualType
SourceLocation getTypeSpecSignLoc() const
bool hasAutoTypeSpec() const
static const TST TST_typename
SourceLocation getEndLoc() const LLVM_READONLY
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
static const TST TST_char8
static const TST TST_BFloat16
TST getTypeSpecType() const
SCS getStorageClassSpec() const
SourceLocation getOverflowBehaviorLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isTypeSpecSat() const
SourceRange getSourceRange() const LLVM_READONLY
static const TST TST_auto_type
static const TST TST_interface
static const TST TST_double
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
TemplateIdAnnotation * getRepAsTemplateId() const
static const TST TST_union
static const TST TST_typename_pack_indexing
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
static const TST TST_unknown_anytype
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_accum
static const TST TST_half
ParsedAttributes & getAttributes()
bool isTypeAltiVecPixel() const
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
static const TST TST_ibm128
Expr * getRepAsExpr() const
static const TST TST_enum
AttributePool & getAttributePool() const
bool isWrapSpecified() const
static const TST TST_float128
static const TST TST_decltype
SourceRange getTypeSpecWidthRange() const
SourceLocation getTypeSpecTypeNameLoc() const
SourceLocation getTypeSpecWidthLoc() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_typeof_unqualExpr
static const TST TST_class
bool isOverflowBehaviorSpecified() const
bool hasTagDefinition() const
static const TST TST_decimal64
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isTypeAltiVecBool() const
bool isConstrainedAuto() const
static const TST TST_wchar
SourceLocation getTypeSpecComplexLoc() const
static const TST TST_void
bool isTypeAltiVecVector() const
static const TST TST_bitint
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_float
static const TST TST_atomic
bool isTrapSpecified() const
static const TST TST_fract
Decl * getRepAsDecl() const
static const TST TST_float16
static bool isTransformTypeTrait(TST T)
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
TypeSpecifierSign getTypeSpecSign() const
CXXScopeSpec & getTypeSpecScope()
SourceLocation getTypeSpecTypeLoc() const
OverflowBehaviorState getOverflowBehaviorState() const
static const TST TST_decltype_auto
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
static const TST TST_decimal32
TypeSpecifierWidth getTypeSpecWidth() const
static const TST TST_char32
static const TST TST_decimal128
bool isTypeSpecOwned() const
SourceLocation getTypeSpecSatLoc() const
SourceRange getTypeofParensRange() const
SourceLocation getUnalignedSpecLoc() const
static const TST TST_int128
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
static const TST TST_typeofType
static const TST TST_auto
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool isInvalidDecl() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
NameKind getNameKind() const
Determine what kind of name this is.
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk,...
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
FunctionDefinitionKind getFunctionDefinitionKind() const
const ParsedAttributes & getAttributes() const
SourceLocation getIdentifierLoc() const
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
SourceLocation getEndLoc() const LLVM_READONLY
bool isExpressionContext() const
Determine whether this declaration appears in a context where an expression could appear.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
SourceLocation getEllipsisLoc() const
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isFirstDeclarator() const
SourceLocation getCommaLoc() const
AttributePool & getAttributePool() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ParsedType getTrailingReturnType() const
Get the trailing return type appearing (at any level) within this declarator.
bool isInvalidType() const
bool isExplicitObjectMemberFunction()
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
bool isPrototypeContext() const
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
void setEllipsisLoc(SourceLocation EL)
const IdentifierInfo * getIdentifier() const
void setRParenLoc(SourceLocation Loc)
void setDecltypeLoc(SourceLocation Loc)
void setAttrNameLoc(SourceLocation loc)
void setAttrOperandParensRange(SourceRange range)
void setAttrExprOperand(Expr *e)
Represents an extended address space qualifier where the input address space value is dependent.
void copy(DependentNameTypeLoc Loc)
void initializeLocal(ASTContext &Context, SourceLocation Loc)
void initializeLocal(ASTContext &Context, SourceLocation Loc)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Represents a member of a struct/union/class.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
A SourceLocation and its associated SourceManager.
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
A mutable set of FunctionEffects and possibly conditions attached to them.
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
SmallVector< Conflict > Conflicts
Represents an abstract function effect, using just an enumeration describing its kind.
Kind
Identifies the particular effect.
An immutable set of FunctionEffects and possibly conditions attached to them.
Represents a prototype with parameter type info, e.g.
Qualifiers getMethodQuals() const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
unsigned getNumParams() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
void setParam(unsigned i, ParmVarDecl *VD)
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
CallingConv getCC() const
bool getProducesResult() const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
AArch64SMETypeAttributes
The AArch64 SME ACLE (Arm C/C++ Language Extensions) define a number of function type attributes that...
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_AgnosticZAStateMask
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
CallingConv getCallConv() const
QualType getReturnType() const
bool getHasRegParm() const
Type source information for HLSL attributed resource type.
TypeLoc getWrappedLoc() const
void setContainedTypeSourceInfo(TypeSourceInfo *TSI) const
void setSourceRange(const SourceRange &R)
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
A simple pair of identifier info and location.
void setIdentifierInfo(IdentifierInfo *Ident)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ElaboratedTypeKeyword getKeyword() const
void setAmpLoc(SourceLocation Loc)
An lvalue reference type, per C++11 [dcl.ref].
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
bool isImplicitIntAllowed() const
Returns true if implicit int is supported at all.
bool allowArrayReturnTypes() const
bool isTargetDevice() const
True when compiling for an offloading target device.
bool isImplicitIntRequired() const
Returns true if implicit int is part of the language requirements.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
Represents the results of name lookup.
TypeLoc getInnerLoc() const
void setExpansionLoc(SourceLocation Loc)
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
void setAttrRowOperand(Expr *e)
void setAttrColumnOperand(Expr *e)
void setAttrOperandParensRange(SourceRange range)
void setAttrNameLoc(SourceLocation loc)
static bool isValidElementType(QualType T, const LangOptions &LangOpts)
Valid elements types are the following:
void setStarLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
This represents a decl that may have a name.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents an ObjC class declaration.
void setNameLoc(SourceLocation Loc)
void setNameEndLoc(SourceLocation Loc)
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Wraps an ObjCPointerType with source location information.
void setStarLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
static OpaquePtr make(QualType P)
OpenCL supported extensions and optional core features.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
TypeLoc getWrappedLoc() const
A parameter attribute which changes the argument-passing ABI rule for the parameter.
void setRParenLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
void setInvalid(bool b=true) const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
AttributeCommonInfo::Kind getKind() const
void setUsedAsTypeAttr(bool Used=true)
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
bool hasMSPropertyAttr() const
void addAtEnd(ParsedAttr *newAttr)
bool hasAttribute(ParsedAttr::Kind K) const
void remove(ParsedAttr *ToBeRemoved)
void takeOneFrom(ParsedAttributes &Other, ParsedAttr *PA)
TypeLoc getValueLoc() const
void setKWLoc(SourceLocation Loc)
Pointer-authentication qualifiers.
static PointerAuthQualifier Create(unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues)
@ MaxKey
The maximum supported pointer-authentication key.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
PointerAuthQualifier getPointerAuth() const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
SplitQualType getSplitUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
UnqualTypeLoc getUnqualifiedLoc() const
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
void addCVRUQualifiers(unsigned mask)
static Qualifiers fromCVRMask(unsigned CVR)
void setUnaligned(bool flag)
std::string getAsString() const
@ MaxAddressSpace
The maximum supported address space number.
void addObjCLifetime(ObjCLifetime type)
void setAmpAmpLoc(SourceLocation Loc)
QualType getPointeeType() const
bool isSpelledAsLValue() const
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
QualType ProcessResourceTypeAttributes(QualType Wrapped)
QualType getInoutParameterType(QualType Ty)
bool isCFError(RecordDecl *D)
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
QualType BuildParenType(QualType T)
Build a paren type including T.
bool ActOnLateParsedTypeAttrArgument(BoundsAttributedType *BATy, FieldDecl *FD, Expr *Arg)
Supply the parsed argument of a late-parsed bounds attribute to the type built for it by ProcessLateP...
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Scope * getCurScope() const
Retrieve the parser's current scope.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
UnaryTransformType::UTTKind UTTKind
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
bool checkPointerAuthDiscriminatorArg(Expr *Arg, PointerAuthDiscArgKind Kind, unsigned &IntVal)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
std::optional< FunctionEffectMode > ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName)
Try to parse the conditional expression attached to an effect attribute (e.g.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain, bool PrimaryStrictPackMatch)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TrivialABIHandling::IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_TypeConstraint
A type constraint.
const LangOptions & getLangOpts() const
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc)
bool ProcessLateParsedTypeAttr(LateParsedTypeAttrInfo &LA, QualType &QT)
Validate the late-parsed type attribute LA and wrap QT in a CountAttributedType with no count yet,...
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
const LangOptions & LangOpts
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
void completeExprArrayBound(Expr *E)
bool hasExplicitCallingConv(QualType T)
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
sema::FunctionScopeInfo * getCurFunction() const
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements, SourceLocation Loc, SourceRange Range=SourceRange())
Diagnose an array of NumElements elements of type ElementType that is too large.
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
QualType BuildMemberPointerType(QualType T, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
ExprResult DefaultLvalueConversion(Expr *E)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
bool ValidateBoundsAttrTypeForTypePosition(QualType Ty, AttributeCommonInfo::Kind AttrKind, SourceLocation AttrLoc, SourceRange AttrRange, unsigned PointerNestLevel, BoundsAttrFlags &Flags)
Check a counted_by-family attribute in type position and initialize Flags from AttrKind.
bool isAcceptable(const NamedDecl *D, AcceptableKind Kind)
Determine whether a declaration is acceptable (visible/reachable).
QualType getDecltypeForExpr(Expr *E)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool hasVisibleMergedDefinition(const NamedDecl *Def)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType BuildAtomicType(QualType T, SourceLocation Loc)
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool diagnoseConflictingFunctionEffect(const FunctionEffectsRef &FX, const FunctionEffectWithCondition &EC, SourceLocation NewAttrLoc)
Warn and return true if adding a function effect to a set would create a conflict.
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
TypeResult ActOnTypeName(Declarator &D)
bool isSFINAEContext() const
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
bool CheckImplicitNullabilityTypeSpecifier(QualType &Type, NullabilityKind Nullability, SourceLocation DiagLoc, bool AllowArrayTypes, bool OverrideExisting)
Check whether a nullability type specifier can be added to the given type through some means not writ...
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::BumpPtrAllocator BumpAlloc
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Information about a FileID, basically just the logical file that it represents and include stack info...
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
Exposes information about the current target.
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual bool allowHalfArgsAndReturns() const
Whether half args and returns are supported.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, const llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
virtual size_t getMaxBitIntWidth() const
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SourceLocation getRAngleLoc() const
void copy(TemplateSpecializationTypeLoc Loc)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
const Type * getTypeForDecl() const
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
void * getOpaqueData() const
Get the pointer where source information is stored.
void copy(TypeLoc other)
Copies the other type loc into this one.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
bool isIncompleteArrayType() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isUndeducedAutoType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXRecordDecl * castAsCXXRecordDecl() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isSizelessBuiltinType() const
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isChar16Type() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool isMemberPointerType() const
bool isAtomicType() const
bool isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isObjCRetainableType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Base class for declarations which introduce a typedef-name.
void setParensRange(SourceRange range)
void setTypeofLoc(SourceLocation Loc)
Wrapper of type source information for a type with no direct qualifiers.
TypeLocClass getTypeLocClass() const
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
@ Definition
This declaration is definitely a definition.
Represents a C array with a specified size that is not an integer-constant-expression.
void initializeLocal(ASTContext &Context, SourceLocation Loc)
void setSizeExpr(Expr *E)
void setAttrNameLoc(SourceLocation Loc)
Represents a GCC generic vector type.
VectorKind getVectorKind() const
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Retains information about a function, method, or block that is currently being parsed.
Defines the clang::TargetInfo interface.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
VectorKind getRVVFixedLengthDataVectorKind(int LMulLog2)
Inverse of getRVVFixedLengthDataLMulLog2().
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ ExpectedParameterOrImplicitObjectParameter
@ ExpectedFunctionWithProtoType
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
decltype(auto)
llvm::StringRef getParameterABISpelling(ParameterABI kind)
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
LLVM_READONLY bool isAsciiIdentifierContinue(unsigned char c)
QualType pointeeType(QualType T)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ Success
Annotation was successful.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
VectorKind getRVVFixedLengthMaskVectorKind(unsigned RatioLog2, unsigned SubByteLanes)
Inverse of getRVVFixedLengthMaskRatioLog2() and getRVVFixedLengthMaskSubByteLanes().
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
TypeOfKind
The kind of 'typeof' expression we're after.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
@ AANT_ArgumentIntegerConstant
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
ArraySizeModifier
Capture whether this is a normal array (e.g.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static bool isBlockPointer(Expr *Arg)
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ FirstTargetAddressSpace
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ NeonPoly
is ARM Neon polynomial vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ ArrayBound
Array bound in array declarator or new-expression.
@ PackIndex
Index of a pack indexing expression or specifier.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
@ Implicit
An implicit conversion.
OptionalUnsigned< NullabilityKind > NullabilityKindOrNone
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
unsigned hasStatic
True if this dimension included the 'static' keyword.
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
unsigned TypeQuals
For now, sema will catch these as invalid.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
SourceLocation getTrailingReturnTypeLoc() const
Get the trailing-return-type location for this function declarator.
SourceLocation getLParenLoc() const
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
SourceLocation getExceptionSpecLocBeg() const
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
SourceRange getExceptionSpecRange() const
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
SourceLocation StarLoc
Location of the '*' token.
const IdentifierInfo * Ident
SourceLocation OverflowBehaviorLoc
The location of an __ob_wrap or __ob_trap qualifier, if any.
SourceLocation RestrictQualLoc
The location of the restrict-qualifier, if any.
SourceLocation ConstQualLoc
The location of the const-qualifier, if any.
SourceLocation VolatileQualLoc
The location of the volatile-qualifier, if any.
SourceLocation UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
SourceLocation AtomicQualLoc
The location of the _Atomic-qualifier, if any.
unsigned OverflowBehaviorIsWrap
Whether the overflow behavior qualifier is wrap (true) or trap (false).
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
One instance of this struct is used for each type in a declarator that is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
MemberPointerTypeInfo Mem
SourceLocation Loc
Loc - The place where this type was defined.
enum clang::DeclaratorChunk::@340323374315200305336204205154073066142310370142 Kind
Describes whether we've seen any nullability information for the given file.
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
uint8_t PointerKind
Which kind of pointer declarator we saw.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Holds information about the various types of exception specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionTypeExtraAttributeInfo ExtraAttributeInfo
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
void setArmSMEAttribute(AArch64SMETypeAttributes Kind, bool Enable=true)
FunctionType::ExtInfo ExtInfo
TypeSourceInfo * ContainedTyInfo
SmallVector< NamedDecl *, 4 > TemplateParams
Store the list of the template parameters for a generic lambda or an abbreviated function template.
unsigned AutoTemplateParameterDepth
If this is a generic lambda or abbreviated function template, use this as the depth of each 'auto' pa...
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
The part of a late-parsed type attribute that Sema reads and fills in during type construction.
BoundsAttributedType * TypeToComplete
The type built for this attribute during type construction, still missing the argument that hasn't be...
NestedNameSpecifier Prefix
Describes how types, statements, expressions, and declarations should be printed.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
SplitQualType getSingleStepDesugaredType() const
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.