45#include "llvm/ADT/ArrayRef.h"
46#include "llvm/ADT/STLForwardCompat.h"
47#include "llvm/ADT/StringExtras.h"
48#include "llvm/IR/DerivedTypes.h"
49#include "llvm/Support/ErrorHandling.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;
347 llvm_unreachable(
"no Attr* for AttributedType*");
352 auto FoundLoc = LocsForMacros.find(MQT);
353 assert(FoundLoc != LocsForMacros.end() &&
354 "Unable to find macro expansion location for MacroQualifedType");
355 return FoundLoc->second;
360 LocsForMacros[MQT] = Loc;
363 void setParsedNoDeref(
bool parsed) { parsedNoDeref = parsed; }
365 bool didParseNoDeref()
const {
return parsedNoDeref; }
367 void setParsedHLSLParamMod(
bool Parsed) { ParsedHLSLParamMod = Parsed; }
369 bool didParseHLSLParamMod()
const {
return ParsedHLSLParamMod; }
371 ~TypeProcessingState() {
372 if (savedAttrs.empty())
375 getMutableDeclSpec().getAttributes().clearListOnly();
377 getMutableDeclSpec().getAttributes().addAtEnd(AL);
381 DeclSpec &getMutableDeclSpec()
const {
423 if (
attr.getKind() == ParsedAttr::AT_ObjCGC)
425 assert(
attr.getKind() == ParsedAttr::AT_ObjCOwnership);
440 bool onlyBlockPointers) {
446 for (; i != 0; --i) {
448 switch (fnChunk.
Kind) {
464 for (--i; i != 0; --i) {
466 switch (ptrChunk.
Kind) {
476 if (onlyBlockPointers)
485 llvm_unreachable(
"bad declarator chunk kind");
491 llvm_unreachable(
"bad declarator chunk kind");
508 Declarator &declarator = state.getDeclarator();
511 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
513 switch (chunk.
Kind) {
519 if (state.isProcessingDeclSpec() &&
520 attr.getKind() == ParsedAttr::AT_ObjCOwnership)
523 if (!destChunk) destChunk = &chunk;
536 if (state.isProcessingDeclSpec() &&
537 attr.getKind() == ParsedAttr::AT_ObjCOwnership) {
564 Declarator &declarator = state.getDeclarator();
568 unsigned innermost = -1U;
569 bool considerDeclSpec =
true;
572 switch (chunk.
Kind) {
586 considerDeclSpec =
false;
594 if (considerDeclSpec) {
599 state.saveDeclSpecAttrs();
608 if (innermost != -1U) {
616 state.addIgnoredTypeAttr(
attr);
625 Declarator &declarator = state.getDeclarator();
629 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
631 switch (chunk.
Kind) {
658 Declarator &declarator = state.getDeclarator();
678 state.saveDeclSpecAttrs();
682 state,
attr, state.getCurrentAttributes(), declSpecType, CFT))
687 state.addIgnoredTypeAttr(
attr);
698 Declarator &declarator = state.getDeclarator();
708 state.addIgnoredTypeAttr(
attr);
733 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute())
736 switch (
attr.getKind()) {
753 case ParsedAttr::AT_ObjCKindOf:
766 Declarator &declarator = state.getDeclarator();
812 {}, loc, loc, declarator));
827 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
832 if (!(RemoveTQs & Qual.first))
836 if (TypeQuals & Qual.first)
837 S.
Diag(Qual.second, DiagID)
842 TypeQuals &= ~Qual.first;
856 if (AL.isInvalid() || !AL.isTypeAttr())
859 diag::warn_block_literal_attributes_on_omitted_return_type)
861 ToBeRemoved.push_back(&AL);
871 diag::warn_block_literal_qualifiers_on_omitted_return_type);
877static OpenCLAccessAttr::Spelling
880 if (AL.getKind() == ParsedAttr::AT_OpenCLAccess)
881 return static_cast<OpenCLAccessAttr::Spelling
>(AL.getSemanticSpelling());
882 return OpenCLAccessAttr::Keyword_read_only;
885static UnaryTransformType::UTTKind
888#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
890 return UnaryTransformType::Enum;
891#include "clang/Basic/TransformTypeTraits.def"
893 llvm_unreachable(
"attempted to parse a non-unary transform builtin");
907 Sema &S = state.getSema();
908 Declarator &declarator = state.getDeclarator();
925 Result = Context.SignedCharTy;
928 "Unknown TSS value");
929 Result = Context.UnsignedCharTy;
938 Context.getPrintingPolicy());
939 Result = Context.getSignedWCharType();
942 "Unknown TSS value");
945 Context.getPrintingPolicy());
946 Result = Context.getUnsignedWCharType();
951 "Unknown TSS value");
956 "Unknown TSS value");
957 Result = Context.Char16Ty;
961 "Unknown TSS value");
962 Result = Context.Char32Ty;
972 Result = Context.getAutoDeductType();
976 Context.DependentTy)) {
977 Result = Context.DependentTy;
993 S.
Diag(DeclLoc, diag::warn_missing_type_specifier)
1004 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1015 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1021 "implicit int is disabled?");
1022 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1036 Result = Context.ShortTy;
1042 Result = Context.LongLongTy;
1052 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1061 Result = Context.UnsignedIntTy;
1064 Result = Context.UnsignedShortTy;
1067 Result = Context.UnsignedLongTy;
1070 Result = Context.UnsignedLongLongTy;
1080 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1104 Result = Context.ShortAccumTy;
1107 Result = Context.AccumTy;
1110 Result = Context.LongAccumTy;
1113 llvm_unreachable(
"Unable to specify long long as _Accum width");
1120 Result = Context.getCorrespondingSaturatedType(
Result);
1127 Result = Context.ShortFractTy;
1130 Result = Context.FractTy;
1133 Result = Context.LongFractTy;
1136 llvm_unreachable(
"Unable to specify long long as _Fract width");
1143 Result = Context.getCorrespondingSaturatedType(
Result);
1153 Result = Context.UnsignedInt128Ty;
1155 Result = Context.Int128Ty;
1165 Result = Context.Float16Ty;
1173 Result = Context.BFloat16Ty;
1178 Result = Context.LongDoubleTy;
1180 Result = Context.DoubleTy;
1185 << (S.
getLangOpts().getOpenCLCompatibleVersion() == 300
1186 ?
"cl_khr_fp64 and __opencl_c_fp64"
1197 Result = Context.Float128Ty;
1204 Result = Context.Ibm128Ty;
1235 "No qualifiers on tag names!");
1248 "Can't handle qualifiers on typedef names yet!");
1261 assert(!
Result.isNull() &&
"Didn't get a type for typeof?");
1262 if (!
Result->isDependentType())
1263 if (
const auto *TT =
Result->getAs<TagType>())
1266 Result = Context.getTypeOfType(
1274 assert(E &&
"Didn't get an expression for typeof?");
1288 assert(E &&
"Didn't get an expression for decltype?");
1299 assert(E &&
"Didn't get an expression for pack indexing");
1310#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
1311#include "clang/Basic/TransformTypeTraits.def"
1313 assert(!
Result.isNull() &&
"Didn't get a type for the transformation?");
1333 TypeConstraintConcept =
1339 TemplateId->NumArgs);
1341 for (
const auto &ArgLoc : TemplateArgsInfo.
arguments())
1342 TemplateArgs.push_back(ArgLoc.getArgument());
1348 TypeConstraintConcept, TemplateArgs);
1358 Result = Context.UnknownAnyTy;
1363 assert(!
Result.isNull() &&
"Didn't get a type for _Atomic?");
1371#define GENERIC_IMAGE_TYPE(ImgType, Id) \
1372 case DeclSpec::TST_##ImgType##_t: \
1373 switch (getImageAccess(DS.getAttributes())) { \
1374 case OpenCLAccessAttr::Keyword_write_only: \
1375 Result = Context.Id##WOTy; \
1377 case OpenCLAccessAttr::Keyword_read_write: \
1378 Result = Context.Id##RWTy; \
1380 case OpenCLAccessAttr::Keyword_read_only: \
1381 Result = Context.Id##ROTy; \
1383 case OpenCLAccessAttr::SpellingNotCalculated: \
1384 llvm_unreachable("Spelling not yet calculated"); \
1387#include "clang/Basic/OpenCLImageTypes.def"
1389#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1390 case DeclSpec::TST_##Name: \
1391 Result = Context.SingletonId; \
1393#include "clang/Basic/HLSLIntangibleTypes.def"
1404 if (
Result->containsErrors())
1409 bool IsOpenCLC30Compatible =
1419 (IsOpenCLC30Compatible &&
1422 << 0 <<
Result <<
"__opencl_c_images";
1424 }
else if (
Result->isOCLImage3dWOType() &&
1429 << (IsOpenCLC30Compatible
1430 ?
"cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
1431 :
"cl_khr_3d_image_writes");
1443 Context.getPrintingPolicy());
1451 unsigned typeSize =
static_cast<unsigned>(Context.getTypeSize(
Result));
1452 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1458 Result = Context.getVectorType(
Result, 128/typeSize, VecKind);
1483 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
1494 if (AL.isStandardAttributeSyntax() && AL.isClangScope() &&
1495 !(AL.getKind() == ParsedAttr::AT_MatrixType &&
1497 S.
Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl)
1525 if (
Result->isFunctionType()) {
1526 unsigned DiagId = diag::warn_typecheck_function_qualifiers_ignored;
1528 DiagId = diag::ext_typecheck_function_qualifiers_unspecified;
1544 if (TypeQuals &&
Result->isReferenceType()) {
1546 S, DS, TypeQuals,
Result,
1548 diag::warn_typecheck_reference_qualifiers);
1555 && TypeQuals &
Result.getCVRQualifiers()) {
1582 if (!
Result->isIntegerType()) {
1584 StringRef SpecifierName =
1586 S.
Diag(Loc, diag::err_overflow_behavior_non_integer_type)
1587 << SpecifierName <<
Result.getAsString() << 1;
1589 OverflowBehaviorType::OverflowBehaviorKind Kind =
1591 ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
1592 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
1600 assert(!
Result.isNull() &&
"This function should not return a null type");
1617 if (T->isReferenceType()) {
1625 unsigned DiagID = 0;
1639 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1644 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1650 Diag(Loc, DiagID) << EltTy;
1653 if (T->isArrayType())
1655 ? diag::warn_c23_compat_restrict_on_array_of_pointers
1656 : diag::ext_restrict_on_array_of_pointers_c23);
1660 return Context.getQualifiedType(T, Qs);
1664 unsigned CVRAU,
const DeclSpec *DS) {
1669 if (T->isReferenceType())
1698 Split.Quals.addCVRQualifiers(CVR);
1708 return Context.getParenType(T);
1716 if (!
type->isObjCLifetimeType() ||
1726 if (
type.isConstQualified()) {
1732 }
else if (
type->isObjCARCImplicitlyUnretainedType()) {
1750 diag::err_arc_indirect_no_ownership,
type, isReference));
1752 S.
Diag(loc, diag::err_arc_indirect_no_ownership) <<
type << isReference;
1756 assert(implicitLifetime &&
"didn't infer any lifetime!");
1797enum QualifiedFunctionKind { QFK_BlockPointer, QFK_Pointer, QFK_Reference };
1803 QualifiedFunctionKind QFK) {
1810 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1811 << QFK << isa<FunctionType>(T.IgnoreParens()) << T
1822 Diag(Loc, diag::err_qualified_function_typeid)
1839 if (T->isReferenceType()) {
1841 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1849 Diag(Loc, diag::err_opencl_function_pointer) << 0;
1854 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
1861 if (T->isObjCObjectType())
1862 return Context.getObjCObjectPointerType(T);
1874 if (T.isWebAssemblyReferenceType()) {
1875 Diag(Loc, diag::err_wasm_reference_pr) << 0;
1880 if (T->getUnqualifiedDesugaredType()->isWebAssemblyTableType()) {
1881 Diag(Loc, diag::err_wasm_table_pr) << 0;
1887 return Context.getPointerType(T);
1894 "Unresolved overloaded function type");
1921 if (T->isVoidType()) {
1922 Diag(Loc, diag::err_reference_to_void);
1927 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
1937 Diag(Loc, diag::err_opencl_function_pointer) << 1;
1950 T.isWebAssemblyReferenceType()) {
1951 Diag(Loc, diag::err_wasm_reference_pr) << 1;
1954 if (T->isWebAssemblyTableType()) {
1955 Diag(Loc, diag::err_wasm_table_pr) << 1;
1961 return Context.getLValueReferenceType(T, SpelledAsLValue);
1962 return Context.getRValueReferenceType(T);
1966 return Context.getReadPipeType(T);
1970 return Context.getWritePipeType(T);
1976 return Context.getDependentBitIntType(IsUnsigned, BitWidth);
1978 llvm::APSInt Bits(32);
1985 size_t NumBits = Bits.getZExtValue();
1986 if (!IsUnsigned && NumBits < 2) {
1987 Diag(Loc, diag::err_bit_int_bad_size) << 0;
1991 if (IsUnsigned && NumBits < 1) {
1992 Diag(Loc, diag::err_bit_int_bad_size) << 1;
1998 Diag(Loc, diag::err_bit_int_max_size)
2003 return Context.getBitIntType(IsUnsigned, NumBits);
2012 llvm::APSInt &SizeVal,
unsigned VLADiag,
2037 VLADiagnoser(
unsigned VLADiag,
bool VLAIsError)
2038 : VLADiag(VLADiag), VLAIsError(VLAIsError) {}
2042 return S.
Diag(Loc, diag::err_array_size_non_int) << T;
2047 IsVLA = !VLAIsError;
2048 return S.
Diag(Loc, VLADiag);
2053 return S.
Diag(Loc, diag::ext_vla_folded_to_constant);
2055 } Diagnoser(VLADiag, VLAIsError);
2059 if (Diagnoser.IsVLA)
2065 EltTy =
Context.getBaseElementType(EltTy);
2073 if (Size.isMultipleOf(Alignment))
2076 Diag(Loc, diag::err_array_element_alignment)
2077 << EltTy << Size.getQuantity() << Alignment.
getQuantity();
2082 Expr *ArraySize,
unsigned Quals,
2098 if (T->isReferenceType()) {
2099 Diag(Loc, diag::err_illegal_decl_array_of_references)
2104 if (T->isVoidType() || T->isIncompleteArrayType()) {
2105 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 << T;
2110 diag::err_array_of_abstract_type))
2115 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
2117 if (!MPTy->getQualifier().isDependent())
2123 if (!T.isWebAssemblyReferenceType() &&
2125 diag::err_array_incomplete_or_sizeless_type))
2130 if (
Context.getTargetInfo().getTriple().isWasm() && T->isArrayType()) {
2131 const auto *ATy = dyn_cast<ArrayType>(T);
2132 if (ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
2133 Diag(Loc, diag::err_wasm_reftype_multidimensional_array);
2138 if (T->isSizelessType() && !T.isWebAssemblyReferenceType()) {
2139 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 1 << T;
2143 if (T->isFunctionType()) {
2144 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2149 if (
const auto *RD = T->getAsRecordDecl()) {
2152 if (RD->hasFlexibleArrayMember())
2153 Diag(Loc, diag::ext_flexible_array_in_array) << T;
2154 }
else if (T->isObjCObjectType()) {
2155 Diag(Loc, diag::err_objc_array_of_interfaces) << T;
2166 ArraySize =
Result.get();
2170 if (ArraySize && !ArraySize->
isPRValue()) {
2175 ArraySize =
Result.get();
2198 if (
const auto *CondExpr = dyn_cast_if_present<ConditionalOperator>(
2200 std::optional<llvm::APSInt> LHS =
2201 CondExpr->getLHS()->getIntegerConstantExpr(
Context);
2202 std::optional<llvm::APSInt> RHS =
2203 CondExpr->getRHS()->getIntegerConstantExpr(
Context);
2204 return LHS && RHS && LHS->isNegative() != RHS->isNegative();
2214 VLADiag = diag::err_opencl_vla;
2217 VLADiag = diag::warn_vla_used;
2220 VLADiag = diag::err_vla_in_sfinae;
2223 VLADiag = diag::err_openmp_vla_in_task_untied;
2228 ? diag::ext_vla_cxx_in_gnu_mode_static_assert
2229 : diag::ext_vla_cxx_static_assert;
2231 VLADiag =
getLangOpts().GNUMode ? diag::ext_vla_cxx_in_gnu_mode
2232 : diag::ext_vla_cxx;
2235 VLADiag = diag::ext_vla;
2239 llvm::APSInt ConstVal(
Context.getTypeSize(
Context.getSizeType()));
2246 T =
Context.getVariableArrayType(T,
nullptr, ASM, Quals);
2248 T =
Context.getIncompleteArrayType(T, ASM, Quals);
2251 T =
Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals);
2258 if (!R.isUsable()) {
2262 T =
Context.getVariableArrayType(T, ArraySize, ASM, Quals);
2263 }
else if (!T->isDependentType() && !T->isIncompleteType() &&
2264 !T->isConstantSizeType()) {
2271 T =
Context.getVariableArrayType(T, ArraySize, ASM, Quals);
2276 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2283 diag::err_typecheck_negative_array_size)
2287 if (ConstVal == 0 && !T.isWebAssemblyReferenceType()) {
2298 : diag::ext_typecheck_zero_array_size)
2305 unsigned ActiveSizeBits =
2306 (!T->isDependentType() && !T->isVariablyModifiedType() &&
2307 !T->isIncompleteType() && !T->isUndeducedType())
2309 : ConstVal.getActiveBits();
2312 <<
toString(ConstVal, 10, ConstVal.isSigned(),
2319 T =
Context.getConstantArrayType(T, ConstVal, ArraySize, ASM, Quals);
2323 if (T->isVariableArrayType()) {
2324 if (!
Context.getTargetInfo().isVLASupported()) {
2328 IsCUDADevice ? diag::err_cuda_vla : diag::err_vla_unsupported)
2329 << (IsCUDADevice ? llvm::to_underlying(
CUDA().CurrentTarget()) : 0);
2333 FSI->setHasVLA(Loc);
2341 : diag::ext_c99_array_usage)
2352 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2362 bool ForMatrixType =
false) {
2365 if (!llvm::isPowerOf2_32(NumBits))
2366 return S.
Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
2380 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
2389 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2392 std::optional<llvm::APSInt> VecSize =
2395 Diag(AttrLoc, diag::err_attribute_argument_type)
2401 if (VecSize->isNegative()) {
2402 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2407 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2411 if (!VecSize->isIntN(61)) {
2413 Diag(AttrLoc, diag::err_attribute_size_too_large)
2417 uint64_t VectorSizeBits = VecSize->getZExtValue() * 8;
2418 unsigned TypeSize =
static_cast<unsigned>(
Context.getTypeSize(CurType));
2420 if (VectorSizeBits == 0) {
2421 Diag(AttrLoc, diag::err_attribute_zero_size)
2426 if (!TypeSize || VectorSizeBits % TypeSize) {
2427 Diag(AttrLoc, diag::err_attribute_invalid_size)
2432 if (VectorSizeBits / TypeSize > std::numeric_limits<uint32_t>::max()) {
2433 Diag(AttrLoc, diag::err_attribute_size_too_large)
2438 return Context.getVectorType(CurType, VectorSizeBits / TypeSize,
2454 if ((!T->isDependentType() && !T->isIntegerType() &&
2455 !T->isRealFloatingType()) ||
2456 (IsNoBoolVecLang && T->isBooleanType())) {
2457 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
2461 if (
const auto *BIT = T->getAs<
BitIntType>();
2466 std::optional<llvm::APSInt> VecSize =
2469 Diag(AttrLoc, diag::err_attribute_argument_type)
2475 if (VecSize->isNegative()) {
2476 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2480 if (!VecSize->isIntN(32)) {
2481 Diag(AttrLoc, diag::err_attribute_size_too_large)
2487 unsigned VectorSize =
static_cast<unsigned>(VecSize->getZExtValue());
2489 if (VectorSize == 0) {
2490 Diag(AttrLoc, diag::err_attribute_zero_size)
2495 return Context.getExtVectorType(T, VectorSize);
2498 return Context.getDependentSizedExtVectorType(T, SizeExpr, AttrLoc);
2503 assert(
Context.getLangOpts().MatrixTypes &&
2504 "Should never build a matrix type when it is disabled");
2509 Diag(AttrLoc, diag::err_attribute_invalid_matrix_type) << ElementTy;
2520 return Context.getDependentSizedMatrixType(ElementTy, NumRows, NumCols,
2523 std::optional<llvm::APSInt> ValueRows =
2525 std::optional<llvm::APSInt> ValueColumns =
2532 if (!ValueRows && !ValueColumns) {
2533 Diag(AttrLoc, diag::err_attribute_argument_type)
2541 Diag(AttrLoc, diag::err_attribute_argument_type)
2547 if (!ValueColumns) {
2548 Diag(AttrLoc, diag::err_attribute_argument_type)
2554 unsigned MatrixRows =
static_cast<unsigned>(ValueRows->getZExtValue());
2555 unsigned MatrixColumns =
static_cast<unsigned>(ValueColumns->getZExtValue());
2556 if (MatrixRows == 0 && MatrixColumns == 0) {
2557 Diag(AttrLoc, diag::err_attribute_zero_size)
2558 <<
"matrix" << RowRange << ColRange;
2561 if (MatrixRows == 0) {
2562 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << RowRange;
2565 if (MatrixColumns == 0) {
2566 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << ColRange;
2569 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension &&
2570 MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2571 Diag(AttrLoc, diag::err_attribute_size_too_large)
2572 << RowRange << ColRange <<
"matrix row and column";
2575 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension) {
2576 Diag(AttrLoc, diag::err_attribute_size_too_large)
2577 << RowRange <<
"matrix row";
2580 if (MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2581 Diag(AttrLoc, diag::err_attribute_size_too_large)
2582 << ColRange <<
"matrix column";
2585 return Context.getConstantMatrixType(ElementTy, MatrixRows, MatrixColumns);
2589 if ((T->isArrayType() && !
getLangOpts().allowArrayReturnTypes()) ||
2590 T->isFunctionType()) {
2591 Diag(Loc, diag::err_func_returning_array_function)
2592 << T->isFunctionType() << T;
2597 if (T->isHalfType() && !
getLangOpts().NativeHalfArgsAndReturns &&
2598 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2599 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2606 if (T->isObjCObjectType()) {
2607 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
2613 if (T.getPointerAuth()) {
2614 Diag(Loc, diag::err_ptrauth_qualifier_invalid) << T << 0;
2618 if (T.hasNonTrivialToPrimitiveDestructCUnion() ||
2619 T.hasNonTrivialToPrimitiveCopyCUnion())
2626 Diag(Loc, diag::warn_deprecated_volatile_return) << T;
2641 bool emittedError =
false;
2643 enum class RequiredCC { OnlySwift, SwiftOrSwiftAsync };
2644 auto checkCompatible = [&](
unsigned paramIndex, RequiredCC required) {
2646 (required == RequiredCC::OnlySwift)
2649 if (isCompatible || emittedError)
2651 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
2653 << (required == RequiredCC::OnlySwift);
2654 emittedError =
true;
2656 for (
size_t paramIndex = 0, numParams = paramTypes.size();
2657 paramIndex != numParams; ++paramIndex) {
2668 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2669 if (paramIndex != 0 &&
2672 S.
Diag(getParamLoc(paramIndex),
2673 diag::err_swift_indirect_result_not_first);
2678 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2687 checkCompatible(paramIndex, RequiredCC::OnlySwift);
2688 if (paramIndex == 0 ||
2691 S.
Diag(getParamLoc(paramIndex),
2692 diag::err_swift_error_result_not_after_swift_context);
2696 llvm_unreachable(
"bad ABI kind");
2708 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2710 QualType ParamType =
Context.getAdjustedParameterType(ParamTypes[Idx]);
2712 Diag(Loc, diag::err_param_with_void_type);
2715 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2717 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2721 Diag(Loc, diag::err_wasm_table_as_function_parameter);
2725 Diag(Loc, diag::err_ptrauth_qualifier_invalid) << T << 1;
2732 Diag(Loc, diag::warn_deprecated_volatile_param) << ParamType;
2734 ParamTypes[Idx] = ParamType;
2739 [=](
unsigned i) {
return Loc; });
2750 return Context.getFunctionType(T, ParamTypes, EPI);
2765 D <<
"member pointer";
2773 Diag(Loc, diag::err_distant_exception_spec);
2779 if (T->isReferenceType()) {
2780 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2785 if (T->isVoidType()) {
2786 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2794 Diag(Loc, diag::err_opencl_function_pointer) << 0;
2799 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
2808 if (T->isFunctionType())
2817 if (!T->isFunctionType()) {
2818 Diag(Loc, diag::err_nonfunction_block_type);
2828 return Context.getBlockPointerType(T);
2834 if (TInfo) *TInfo =
nullptr;
2839 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2840 QT = LIT->getType();
2841 TSI = LIT->getTypeSourceInfo();
2851 unsigned chunkIndex);
2858 Sema &S = state.getSema();
2859 Declarator &declarator = state.getDeclarator();
2865 unsigned outermostPointerIndex = 0;
2867 unsigned numPointers = 0;
2869 unsigned chunkIndex = i;
2871 switch (chunk.
Kind) {
2881 outermostPointerIndex = chunkIndex;
2889 if (numPointers != 1)
return;
2891 outermostPointerIndex = chunkIndex;
2909 if (numPointers == 1) {
2927 }
else if (numPointers == 2) {
2940 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership)
2944 outermostPointerIndex);
2966 }
const QualKinds[5] = {
2980 for (
auto &E : QualKinds) {
2981 if (Quals & E.Mask) {
2982 if (!QualStr.empty()) QualStr +=
' ';
2999 << QualStr <<
NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
3005 unsigned FunctionChunkIndex) {
3015 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
3017 OuterChunkIndex != End; ++OuterChunkIndex) {
3019 switch (OuterChunk.
Kind) {
3026 diag::warn_qual_return_type,
3052 llvm_unreachable(
"unknown declarator chunk kind");
3073static std::pair<QualType, TypeSourceInfo *>
3077 Sema &S = state.getSema();
3081 const unsigned AutoParameterPosition = Info.
TemplateParams.size();
3095 TemplateParameterDepth, AutoParameterPosition,
3098 IsParameterPack,
Auto->isConstrained());
3103 if (
Auto->isConstrained()) {
3110 for (
unsigned Idx = 0; Idx < AutoLoc.
getNumArgs(); ++Idx) {
3168 QualType NewT = state.ReplaceAutoType(T, Replacement);
3172 return {NewT, NewTSI};
3181 Sema &SemaRef = state.getSema();
3184 ReturnTypeInfo =
nullptr;
3187 TagDecl *OwnedTagDecl =
nullptr;
3237 DeducedType *
Deduced = T->getContainedDeducedType();
3238 bool DeducedIsTrailingReturnType =
false;
3242 DeducedIsTrailingReturnType =
true;
3252 bool IsCXXAutoType =
3254 bool IsDeducedReturnType =
false;
3304 assert(Info &&
"No LambdaScopeInfo on the stack!");
3310 if (!DeducedIsTrailingReturnType)
3323 llvm_unreachable(
"unhandled tag kind");
3325 Error = Cxx ? 1 : 2;
3328 Error = Cxx ? 3 : 4;
3373 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3375 IsDeducedReturnType =
true;
3378 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3380 IsDeducedReturnType =
true;
3385 if (SemaRef.
getLangOpts().CPlusPlus23 && IsCXXAutoType &&
3386 !
Auto->isDecltypeAuto())
3419 (!SemaRef.
getLangOpts().CPlusPlus11 || !IsCXXAutoType))
3425 switch (
Auto->getKeyword()) {
3432 "unknown auto type");
3436 auto *DTST = dyn_cast<DeducedTemplateSpecializationType>(
Deduced);
3439 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
3452 unsigned DiagId = 0;
3454 DiagId = diag::warn_cxx11_compat_generic_lambda;
3455 else if (IsDeducedReturnType)
3456 DiagId = diag::warn_cxx11_compat_deduced_return_type;
3458 DiagId = diag::warn_cxx98_compat_auto_type_specifier;
3461 SemaRef.
Diag(AutoRange.
getBegin(), DiagId) << AutoRange;
3469 unsigned DiagID = 0;
3475 llvm_unreachable(
"parser should not have allowed this");
3491 DiagID = diag::err_type_defined_in_alias_template;
3503 DiagID = diag::err_type_defined_in_type_specifier;
3513 DiagID = diag::err_type_defined_in_param_type;
3519 DiagID = diag::err_type_defined_in_condition;
3530 assert(!T.isNull() &&
"This function should not return a null type");
3539 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3569 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3570 : diag::warn_empty_parens_are_function_decl)
3581 if (Comma.getFileID() != Name.
getFileID() ||
3589 Result.suppressDiagnostics();
3602 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3617 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
3625 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
3636 "do not have redundant top-level parentheses");
3645 bool CouldBeTemporaryObject =
3649 (T->isRecordType() || T->isDependentType()) &&
3652 bool StartsWithDeclaratorId =
true;
3660 StartsWithDeclaratorId =
false;
3665 CouldBeTemporaryObject =
false;
3673 CouldBeTemporaryObject =
false;
3674 StartsWithDeclaratorId =
false;
3684 CouldBeTemporaryObject =
false;
3691 CouldBeTemporaryObject =
false;
3692 StartsWithDeclaratorId =
false;
3702 if (CouldBeTemporaryObject) {
3706 CouldBeTemporaryObject =
false;
3707 Result.suppressDiagnostics();
3712 if (!CouldBeTemporaryObject) {
3736 S.
Diag(
Paren.Loc, diag::warn_redundant_parens_around_declarator)
3742 S.
Diag(
Paren.Loc, diag::warn_parens_disambiguated_as_variable_declaration)
3744 auto *RD = T->getAsCXXRecordDecl();
3745 if (!RD || !RD->hasDefinition() || RD->hasNonTrivialDestructor())
3746 S.
Diag(
Paren.Loc, diag::note_raii_guard_add_name)
3751 S.
Diag(D.
getBeginLoc(), diag::note_function_style_cast_add_parentheses)
3754 S.
Diag(
Paren.Loc, diag::note_remove_parens_for_variable_declaration)
3770 switch (AL.getKind()) {
3789 bool IsCXXInstanceMethod =
false;
3795 unsigned I = ChunkIndex;
3796 bool FoundNonParen =
false;
3797 while (I && !FoundNonParen) {
3800 FoundNonParen =
true;
3803 if (FoundNonParen) {
3806 IsCXXInstanceMethod =
3811 IsCXXInstanceMethod =
3819 IsCXXInstanceMethod =
3827 IsCXXInstanceMethod);
3835 if (Triple.isSPIRV() && Triple.getVendor() != llvm::Triple::AMD) {
3837 if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
3845 for (
const ParsedAttr &AL : llvm::concat<ParsedAttr>(
3848 if (AL.getKind() == ParsedAttr::AT_DeviceKernel) {
3859 enum class SimplePointerKind {
3868 switch (nullability) {
3870 if (!Ident__Nonnull)
3871 Ident__Nonnull =
PP.getIdentifierInfo(
"_Nonnull");
3872 return Ident__Nonnull;
3875 if (!Ident__Nullable)
3876 Ident__Nullable =
PP.getIdentifierInfo(
"_Nullable");
3877 return Ident__Nullable;
3880 if (!Ident__Nullable_result)
3881 Ident__Nullable_result =
PP.getIdentifierInfo(
"_Nullable_result");
3882 return Ident__Nullable_result;
3885 if (!Ident__Null_unspecified)
3886 Ident__Null_unspecified =
PP.getIdentifierInfo(
"_Null_unspecified");
3887 return Ident__Null_unspecified;
3889 llvm_unreachable(
"Unknown nullability kind.");
3896 if (AL.getKind() == ParsedAttr::AT_TypeNonNull ||
3897 AL.getKind() == ParsedAttr::AT_TypeNullable ||
3898 AL.getKind() == ParsedAttr::AT_TypeNullableResult ||
3899 AL.getKind() == ParsedAttr::AT_TypeNullUnspecified)
3908 enum class PointerDeclaratorKind {
3916 MaybePointerToCFRef,
3920 NSErrorPointerPointer,
3926 enum class PointerWrappingDeclaratorKind {
3940static PointerDeclaratorKind
3942 PointerWrappingDeclaratorKind &wrappingKind) {
3943 unsigned numNormalPointers = 0;
3946 if (
type->isDependentType())
3947 return PointerDeclaratorKind::NonPointer;
3952 switch (chunk.
Kind) {
3954 if (numNormalPointers == 0)
3955 wrappingKind = PointerWrappingDeclaratorKind::Array;
3964 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3965 : PointerDeclaratorKind::SingleLevelPointer;
3971 if (numNormalPointers == 0)
3972 wrappingKind = PointerWrappingDeclaratorKind::Reference;
3976 ++numNormalPointers;
3977 if (numNormalPointers > 2)
3978 return PointerDeclaratorKind::MultiLevelPointer;
3984 unsigned numTypeSpecifierPointers = 0;
3988 ++numNormalPointers;
3990 if (numNormalPointers > 2)
3991 return PointerDeclaratorKind::MultiLevelPointer;
3993 type = ptrType->getPointeeType();
3994 ++numTypeSpecifierPointers;
4000 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4001 : PointerDeclaratorKind::SingleLevelPointer;
4006 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4007 : PointerDeclaratorKind::SingleLevelPointer;
4012 ++numNormalPointers;
4013 ++numTypeSpecifierPointers;
4016 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
4018 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
4019 return PointerDeclaratorKind::NSErrorPointerPointer;
4028 if (objcClass->getInterface()->getIdentifier() ==
4030 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
4031 return PointerDeclaratorKind::NSErrorPointerPointer;
4038 if (numNormalPointers == 0)
4039 return PointerDeclaratorKind::NonPointer;
4043 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2 &&
4045 return PointerDeclaratorKind::CFErrorRefPointer;
4053 switch (numNormalPointers) {
4055 return PointerDeclaratorKind::NonPointer;
4058 return PointerDeclaratorKind::SingleLevelPointer;
4061 return PointerDeclaratorKind::MaybePointerToCFRef;
4064 return PointerDeclaratorKind::MultiLevelPointer;
4073 if (ctx->isFunctionOrMethod())
4076 if (ctx->isFileContext())
4087 bool invalid =
false;
4089 if (invalid || !sloc.
isFile())
4107template <
typename DiagBuilderT>
4116 if (!FixItLoc.
isValid() || FixItLoc == PointerLoc)
4125 InsertionTextBuf +=
" ";
4126 StringRef InsertionText = InsertionTextBuf.str();
4129 InsertionText = InsertionText.drop_back();
4130 }
else if (NextChar[-1] ==
'[') {
4131 if (NextChar[0] ==
']')
4132 InsertionText = InsertionText.drop_back().drop_front();
4134 InsertionText = InsertionText.drop_front();
4137 InsertionText = InsertionText.drop_back().drop_front();
4144 SimplePointerKind PointerKind,
4149 if (PointerKind == SimplePointerKind::Array) {
4150 S.
Diag(PointerLoc, diag::warn_nullability_missing_array);
4152 S.
Diag(PointerLoc, diag::warn_nullability_missing)
4153 <<
static_cast<unsigned>(PointerKind);
4156 auto FixItLoc = PointerEndLoc.
isValid() ? PointerEndLoc : PointerLoc;
4157 if (FixItLoc.isMacroID())
4161 auto Diag = S.
Diag(FixItLoc, diag::note_nullability_fix_it);
4192 if (pointerKind == SimplePointerKind::Array)
4193 diagKind = diag::warn_nullability_missing_array;
4195 diagKind = diag::warn_nullability_missing;
4201 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
4233 auto kind =
static_cast<SimplePointerKind
>(fileNullability.
PointerKind);
4248 unsigned i = endIndex;
4276template<
typename AttrT>
4279 return ::new (Ctx) AttrT(Ctx, AL);
4297 llvm_unreachable(
"unknown NullabilityKind");
4308 if (ASOld != ASNew) {
4309 S.
Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
4314 diag::warn_attribute_address_multiple_identical_qualifiers);
4323 return T->canHaveNullability(
false) &&
4329 T->getCanonicalTypeInternal());
4339 Sema &S = state.getSema();
4349 bool IsTypedefName =
4355 bool IsQualifiedFunction = T->isFunctionProtoType() &&
4363 if (
auto *DT = T->getAs<DeducedType>()) {
4364 const AutoType *AT = T->getAs<AutoType>();
4366 if ((AT && AT->isDecltypeAuto()) || IsClassTemplateDeduction) {
4368 unsigned Index = E - I - 1;
4370 unsigned DiagId = IsClassTemplateDeduction
4371 ? diag::err_deduced_class_template_compound_type
4372 : diag::err_decltype_auto_compound_type;
4373 unsigned DiagKind = 0;
4374 switch (DeclChunk.
Kind) {
4378 if (IsClassTemplateDeduction) {
4386 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
4404 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
4413 bool inferNullabilityCS =
false;
4414 bool inferNullabilityInnerOnly =
false;
4415 bool inferNullabilityInnerOnlyComplete =
false;
4418 bool inAssumeNonNullRegion =
false;
4420 if (assumeNonNullLoc.
isValid()) {
4421 inAssumeNonNullRegion =
true;
4435 } complainAboutMissingNullability = CAMN_No;
4436 unsigned NumPointersRemaining = 0;
4437 auto complainAboutInferringWithinChunk = PointerWrappingDeclaratorKind::None;
4439 if (IsTypedefName) {
4443 complainAboutMissingNullability = CAMN_InnerPointers;
4447 ++NumPointersRemaining;
4452 switch (chunk.
Kind) {
4460 ++NumPointersRemaining;
4468 ++NumPointersRemaining;
4473 bool isFunctionOrMethod =
false;
4474 switch (
auto context = state.getDeclarator().getContext()) {
4480 isFunctionOrMethod =
true;
4484 if (state.getDeclarator().isObjCIvar() && !isFunctionOrMethod) {
4485 complainAboutMissingNullability = CAMN_No;
4490 if (state.getDeclarator().isObjCWeakProperty()) {
4493 complainAboutMissingNullability = CAMN_No;
4494 if (inAssumeNonNullRegion) {
4504 complainAboutMissingNullability = CAMN_Yes;
4507 auto wrappingKind = PointerWrappingDeclaratorKind::None;
4509 case PointerDeclaratorKind::NonPointer:
4510 case PointerDeclaratorKind::MultiLevelPointer:
4514 case PointerDeclaratorKind::SingleLevelPointer:
4516 if (inAssumeNonNullRegion) {
4517 complainAboutInferringWithinChunk = wrappingKind;
4524 case PointerDeclaratorKind::CFErrorRefPointer:
4525 case PointerDeclaratorKind::NSErrorPointerPointer:
4528 if (isFunctionOrMethod && inAssumeNonNullRegion)
4532 case PointerDeclaratorKind::MaybePointerToCFRef:
4533 if (isFunctionOrMethod) {
4537 auto hasCFReturnsAttr =
4539 return AttrList.hasAttribute(ParsedAttr::AT_CFReturnsRetained) ||
4540 AttrList.hasAttribute(ParsedAttr::AT_CFReturnsNotRetained);
4545 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
4548 inferNullabilityInnerOnly =
true;
4558 complainAboutMissingNullability = CAMN_Yes;
4586 auto isVaList = [&S](
QualType T) ->
bool {
4592 if (typedefTy->getDecl() == vaListTypedef)
4594 if (
auto *name = typedefTy->getDecl()->getIdentifier())
4595 if (name->isStr(
"va_list"))
4597 typedefTy = typedefTy->desugar()->getAs<
TypedefType>();
4598 }
while (typedefTy);
4604 auto inferPointerNullability =
4609 if (NumPointersRemaining > 0)
4610 --NumPointersRemaining;
4617 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
4620 ? ParsedAttr::Form::ContextSensitiveKeyword()
4621 : ParsedAttr::Form::Keyword(
false ,
4627 attrs.addAtEnd(nullabilityAttr);
4629 if (inferNullabilityCS) {
4630 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
4634 if (pointerLoc.isValid() &&
4635 complainAboutInferringWithinChunk !=
4636 PointerWrappingDeclaratorKind::None) {
4638 S.
Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
4643 if (inferNullabilityInnerOnly)
4644 inferNullabilityInnerOnlyComplete =
true;
4645 return nullabilityAttr;
4650 switch (complainAboutMissingNullability) {
4654 case CAMN_InnerPointers:
4655 if (NumPointersRemaining == 0)
4671 if (NumPointersRemaining > 0)
4672 --NumPointersRemaining;
4674 SimplePointerKind pointerKind = SimplePointerKind::Pointer;
4675 if (T->isBlockPointerType())
4676 pointerKind = SimplePointerKind::BlockPointer;
4677 else if (T->isMemberPointerType())
4678 pointerKind = SimplePointerKind::MemberPointer;
4680 if (
auto *
attr = inferPointerNullability(
4685 T = state.getAttributedType(
4691 if (complainAboutMissingNullability == CAMN_Yes && T->isArrayType() &&
4699 bool ExpectNoDerefChunk =
4700 state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
4710 bool AreDeclaratorChunksValid =
true;
4712 unsigned chunkIndex = e - i - 1;
4713 state.setCurrentChunkIndex(chunkIndex);
4716 switch (DeclType.
Kind) {
4724 if (!LangOpts.Blocks)
4725 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
4728 inferPointerNullability(SimplePointerKind::BlockPointer, DeclType.
Loc,
4730 state.getDeclarator().getAttributePool());
4736 if (LangOpts.OpenCL)
4751 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
4753 state.getDeclarator().getAttributePool());
4756 T = Context.getObjCObjectPointerType(T);
4765 if (LangOpts.OpenCL) {
4766 if (T->isImageType() || T->isSamplerT() || T->isPipeType() ||
4767 T->isBlockPointerType()) {
4781 diag::err_overflow_behavior_non_integer_type)
4815 if (chunkIndex != 0 && !ArraySize &&
4834 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
4845 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype)
4847 :
"type qualifier");
4858 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost)
4860 :
"type qualifier");
4870 if (complainAboutMissingNullability == CAMN_Yes &&
4886 IsQualifiedFunction =
4892 return SS.isInvalid() ||
4917 if (
First &&
First->isExplicitObjectParameter() &&
4931 diag::err_explicit_object_parameter_nonmember)
4932 << 2 << 0 <<
First->getSourceRange();
4935 diag::err_explicit_object_parameter_invalid)
4936 <<
First->getSourceRange();
4942 AreDeclaratorChunksValid =
false;
4955 ? diag::err_auto_missing_trailing_return
4956 : diag::err_deduced_return_type);
4959 AreDeclaratorChunksValid =
false;
4962 diag::warn_cxx11_compat_deduced_return_type);
4971 AreDeclaratorChunksValid =
false;
4974 if (T != Context.DependentTy) {
4976 diag::err_deduction_guide_with_complex_decl)
4980 AreDeclaratorChunksValid =
false;
4997 S.
Diag(Loc, diag::err_trailing_return_without_auto) << T << SR;
5000 AreDeclaratorChunksValid =
false;
5007 }
else if (AutoType *
Auto = T->getContainedAutoType()) {
5016 if (InventedParamInfo) {
5018 state, T, TInfo,
Auto, *InventedParamInfo);
5031 T->isFunctionType()) &&
5034 unsigned diagID = diag::err_func_returning_array_function;
5037 if (chunkIndex == 0 &&
5039 diagID = diag::err_block_returning_array_function;
5040 S.
Diag(DeclType.
Loc, diagID) << T->isFunctionType() << T;
5043 AreDeclaratorChunksValid =
false;
5048 if (T->isHalfType()) {
5056 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5059 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
5065 if (T.getPointerAuth()) {
5066 S.
Diag(DeclType.
Loc, diag::err_ptrauth_qualifier_invalid) << T << 0;
5069 if (LangOpts.OpenCL) {
5072 if (T->isBlockPointerType() || T->isImageType() || T->isSamplerT() ||
5083 "__cl_clang_variadic_functions", S.
getLangOpts()) &&
5095 if (T->isObjCObjectType()) {
5104 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
5108 T = Context.getObjCObjectPointerType(T);
5116 AreDeclaratorChunksValid =
false;
5124 if ((T.getCVRQualifiers() || T->isAtomicType()) &&
5128 (T->isRecordType() || T->isDependentType() ||
5129 T->isUndeducedAutoType()))) {
5130 if (T->isVoidType() && !S.
getLangOpts().CPlusPlus &&
5136 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) << T;
5143 if (T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20)
5144 S.
Diag(DeclType.
Loc, diag::warn_deprecated_volatile_return) << T;
5149 if (T.getQualifiers().hasObjCLifetime()) {
5154 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5155 AttrLoc = AL.getLoc();
5162 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5163 AttrLoc = AL.getLoc();
5177 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
5178 << T.getQualifiers().getObjCLifetime();
5186 S.
Diag(Tag->getLocation(), diag::err_type_defined_in_result_type)
5187 << Context.getCanonicalTagType(Tag);
5194 diag::err_exception_spec_in_typedef)
5212 T = Context.getFunctionNoProtoType(T, EI);
5220 diag::warn_c17_compat_ellipsis_only_parameter);
5222 ParsedAttr::AT_Overloadable) &&
5224 ParsedAttr::AT_Overloadable) &&
5226 ParsedAttr::AT_Overloadable))
5234 diag::err_ident_list_in_fn_declaration);
5238 ? Context.getFunctionNoProtoType(T, EI)
5240 AreDeclaratorChunksValid =
false;
5263 bool HasAnyInterestingExtParameterInfos =
false;
5265 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
5267 QualType ParamTy = Param->getType();
5268 assert(!ParamTy.
isNull() &&
"Couldn't parse type?");
5279 ParamTy = Context.IntTy;
5280 Param->setType(ParamTy);
5284 ParamTy = Context.IntTy;
5285 Param->setType(ParamTy);
5289 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
5291 for (
const auto *A : Param->attrs()) {
5292 S.
Diag(A->getLoc(), diag::warn_attribute_on_void_param)
5293 << A << A->getRange();
5298 if (Param->isExplicitObjectParameter()) {
5299 S.
Diag(Param->getLocation(),
5300 diag::err_void_explicit_object_param);
5313 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5316 Param->setInvalidDecl();
5318 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5320 S.
Diag(Param->getLocation(),
5321 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
5325 if (Context.isPromotableIntegerType(ParamTy)) {
5326 ParamTy = Context.getPromotedIntegerType(ParamTy);
5327 Param->setKNRPromoted(
true);
5329 if (BTy->getKind() == BuiltinType::Float) {
5330 ParamTy = Context.DoubleTy;
5331 Param->setKNRPromoted(
true);
5336 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5341 if (LangOpts.ObjCAutoRefCount && Param->hasAttr<NSConsumedAttr>()) {
5342 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
5343 HasAnyInterestingExtParameterInfos =
true;
5347 ExtParameterInfos[i] =
5348 ExtParameterInfos[i].withABI(
attr->getABI());
5349 HasAnyInterestingExtParameterInfos =
true;
5352 if (Param->hasAttr<PassObjectSizeAttr>()) {
5353 ExtParameterInfos[i] = ExtParameterInfos[i].withHasPassObjectSize();
5354 HasAnyInterestingExtParameterInfos =
true;
5357 if (Param->hasAttr<NoEscapeAttr>()) {
5358 ExtParameterInfos[i] = ExtParameterInfos[i].withIsNoEscape(
true);
5359 HasAnyInterestingExtParameterInfos =
true;
5362 ParamTys.push_back(ParamTy);
5365 if (HasAnyInterestingExtParameterInfos) {
5374 Expr *NoexceptExpr =
nullptr;
5380 DynamicExceptions.reserve(N);
5381 DynamicExceptionRanges.reserve(N);
5382 for (
unsigned I = 0; I != N; ++I) {
5393 DynamicExceptionRanges,
5400 auto IsClassMember = [&]() {
5401 return (!state.getDeclarator().getCXXScopeSpec().isEmpty() &&
5402 state.getDeclarator()
5406 state.getDeclarator().getContext() ==
5408 state.getDeclarator().getContext() ==
5412 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
5432 T = Context.getFunctionType(T, ParamTys, EPI);
5441 inferPointerNullability(SimplePointerKind::MemberPointer, DeclType.
Loc,
5443 state.getDeclarator().getAttributePool());
5448 AreDeclaratorChunksValid =
false;
5457 AreDeclaratorChunksValid =
false;
5475 AreDeclaratorChunksValid =
false;
5484 S.
Diag(DeclType.
Loc, diag::warn_noderef_on_non_pointer_or_array);
5486 ExpectNoDerefChunk = state.didParseNoDeref();
5490 if (ExpectNoDerefChunk)
5491 S.
Diag(state.getDeclarator().getBeginLoc(),
5492 diag::warn_noderef_on_non_pointer_or_array);
5505 bool IsBlock =
false;
5507 switch (DeclType.Kind) {
5519 S.
Diag(DeclType.Loc, diag::warn_strict_prototypes)
5531 assert(!T.isNull() &&
"T must not be null after this point");
5533 if (LangOpts.CPlusPlus && T->isFunctionType()) {
5535 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
5548 ExplicitObjectMember,
5552 Kind = DeductionGuide;
5569 auto *P = dyn_cast_or_null<ParmVarDecl>(Chunk.
Fun.
Params->
Param);
5570 if (P && P->isExplicitObjectParameter())
5571 Kind = ExplicitObjectMember;
5597 if (IsQualifiedFunction &&
5622 if (!RemovalLocs.empty()) {
5623 llvm::sort(RemovalLocs,
5625 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
5626 Loc = RemovalLocs.front();
5630 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
5654 if (!AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
5662 state.diagnoseIgnoredTypeAttrs(T);
5673 if (T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20 &&
5698 if (!T->containsUnexpandedParameterPack() &&
5699 (!LangOpts.CPlusPlus20 || !T->getContainedAutoType())) {
5701 diag::err_function_parameter_pack_without_parameter_packs)
5705 T = Context.getPackExpansionType(T, std::nullopt,
5718 if (T->containsUnexpandedParameterPack())
5719 T = Context.getPackExpansionType(T, std::nullopt);
5722 LangOpts.CPlusPlus11
5723 ? diag::warn_cxx98_compat_variadic_templates
5724 : diag::ext_variadic_templates);
5754 diag::err_ellipsis_in_declarator_not_parameter);
5760 assert(!T.isNull() &&
"T must not be null at the end of this function");
5761 if (!AreDeclaratorChunksValid)
5762 return Context.getTrivialTypeSourceInfo(T);
5764 if (state.didParseHLSLParamMod() && !T->isConstantArrayType())
5773 TypeProcessingState state(*
this, D);
5796 unsigned chunkIndex) {
5797 Sema &S = state.getSema();
5805 const char *attrStr =
nullptr;
5806 switch (ownership) {
5824 &Args, 1, ParsedAttr::Form::GNU());
5833 Sema &S = state.getSema();
5837 bool hasIndirection =
false;
5840 switch (chunk.
Kind) {
5849 hasIndirection =
true;
5882 TypeProcessingState state(*
this, D);
5897 TypeProcessingState &State) {
5902 TypeProcessingState &State) {
5904 State.getSema().HLSL().TakeLocForHLSLAttribute(TL.
getTypePtr());
5912 if (AL.getKind() == ParsedAttr::AT_MatrixType) {
5921 llvm_unreachable(
"no matrix_type attribute found at the expected location!");
5926 switch (Chunk.
Kind) {
5931 llvm_unreachable(
"cannot be _Atomic qualified");
5949 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
5951 ASTContext &Context;
5952 TypeProcessingState &State;
5956 TypeSpecLocFiller(Sema &S, ASTContext &Context, TypeProcessingState &State,
5958 : SemaRef(S), Context(Context), State(State), DS(DS) {}
5960 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
5964 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
5967 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
5970 void VisitHLSLAttributedResourceTypeLoc(HLSLAttributedResourceTypeLoc TL) {
5974 void VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {}
5975 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
5978 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
5980 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
5985 void VisitPointerTypeLoc(PointerTypeLoc TL) { Visit(TL.
getNextTypeLoc()); }
5986 void VisitTypedefTypeLoc(TypedefTypeLoc TL) {
5988 TypeSourceInfo *TInfo =
nullptr;
6001 void VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
6003 TypeSourceInfo *TInfo =
nullptr;
6016 void VisitUsingTypeLoc(UsingTypeLoc TL) {
6018 TypeSourceInfo *TInfo =
nullptr;
6031 void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
6038 void VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
6039 TypeSourceInfo *RepTInfo =
nullptr;
6043 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6044 TypeSourceInfo *RepTInfo =
nullptr;
6048 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
6049 TypeSourceInfo *TInfo =
nullptr;
6060 TL.
copy(OldTL.
castAs<TemplateSpecializationTypeLoc>());
6062 OldTL.
castAs<TemplateSpecializationTypeLoc>().getRAngleLoc());
6064 void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
6070 void VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
6076 TypeSourceInfo *TInfo =
nullptr;
6080 void VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
6085 void VisitPackIndexingTypeLoc(PackIndexingTypeLoc TL) {
6089 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
6094 TypeSourceInfo *TInfo =
nullptr;
6098 void VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
6111 void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
6113 TypeSourceInfo *TInfo =
nullptr;
6118 void VisitAutoTypeLoc(AutoTypeLoc TL) {
6132 NestedNameSpecifierLoc NNS =
6135 : NestedNameSpecifierLoc());
6136 TemplateArgumentListInfo TemplateArgsInfo(TemplateId->
LAngleLoc,
6138 if (TemplateId->
NumArgs > 0) {
6143 DeclarationNameInfo DNI = DeclarationNameInfo(
6144 TL.
getTypePtr()->getTypeConstraintConcept()->getDeclName(),
6147 NamedDecl *FoundDecl;
6152 FoundDecl = cast_if_present<NamedDecl>(TN.getAsTemplateDecl());
6160 void VisitDeducedTemplateSpecializationTypeLoc(
6161 DeducedTemplateSpecializationTypeLoc TL) {
6163 TypeSourceInfo *TInfo =
nullptr;
6169 void VisitTagTypeLoc(TagTypeLoc TL) {
6171 TypeSourceInfo *TInfo =
nullptr;
6179 ElaboratedTypeKeyword::None
6181 : SourceLocation());
6185 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6192 TypeSourceInfo *TInfo =
nullptr;
6204 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6207 TypeSourceInfo *TInfo =
nullptr;
6212 void VisitExtIntTypeLoc(BitIntTypeLoc TL) {
6216 void VisitDependentExtIntTypeLoc(DependentBitIntTypeLoc TL) {
6220 void VisitTypeLoc(TypeLoc TL) {
6226 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
6227 ASTContext &Context;
6228 TypeProcessingState &State;
6229 const DeclaratorChunk &Chunk;
6232 DeclaratorLocFiller(ASTContext &Context, TypeProcessingState &State,
6233 const DeclaratorChunk &Chunk)
6234 : Context(Context), State(State), Chunk(Chunk) {}
6236 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6237 llvm_unreachable(
"qualified type locs not expected here!");
6239 void VisitDecayedTypeLoc(DecayedTypeLoc TL) {
6240 llvm_unreachable(
"decayed type locs not expected here!");
6242 void VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
6243 llvm_unreachable(
"array parameter type locs not expected here!");
6246 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
6249 void VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
6252 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
6255 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
6258 void VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
6261 void VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
6265 void VisitPointerTypeLoc(PointerTypeLoc TL) {
6269 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6273 void VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
6278 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
6284 void VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
6289 void VisitArrayTypeLoc(ArrayTypeLoc TL) {
6295 void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
6300 const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.
Fun;
6303 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
6309 void VisitParenTypeLoc(ParenTypeLoc TL) {
6314 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6318 void VisitBitIntTypeLoc(BitIntTypeLoc TL) {
6321 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6324 void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.
setNameLoc(Chunk.
Loc); }
6325 void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
6328 void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
6331 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6335 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
6338 void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
6342 void VisitTypeLoc(TypeLoc TL) {
6343 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
6352 if (AL.getKind() == ParsedAttr::AT_AddressSpace) {
6361 "no address_space attribute found at the expected location!");
6375 Sema &S = State.getSema();
6401 bool HasDesugaredTypeLoc =
true;
6402 while (HasDesugaredTypeLoc) {
6404 case TypeLoc::MacroQualified: {
6407 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6412 case TypeLoc::Attributed: {
6419 case TypeLoc::Adjusted:
6420 case TypeLoc::BTFTagAttributed: {
6425 case TypeLoc::DependentAddressSpace: {
6433 HasDesugaredTypeLoc =
false;
6444 if (ReturnTypeInfo) {
6464 "LocInfoType's TypeClass conflicts with an existing Type class");
6470 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
6471 " was used directly instead of getting the QualType through"
6472 " GetTypeFromParser");
6479 "Type name should have no identifier!");
6516 const Expr *AddrSpace,
6519 std::optional<llvm::APSInt> OptAddrSpace =
6521 if (!OptAddrSpace) {
6522 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
6527 llvm::APSInt &addrSpace = *OptAddrSpace;
6530 if (addrSpace.isSigned()) {
6531 if (addrSpace.isNegative()) {
6532 S.
Diag(AttrLoc, diag::err_attribute_address_space_negative)
6536 addrSpace.setIsSigned(
false);
6539 llvm::APSInt
max(addrSpace.getBitWidth());
6543 if (addrSpace >
max) {
6544 S.
Diag(AttrLoc, diag::err_attribute_address_space_too_high)
6566 return Context.getAddrSpaceQualType(T, ASIdx);
6575 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
6579 return Context.getDependentAddressSpaceType(T, AddrSpace, AttrLoc);
6591 TypeProcessingState &State) {
6592 Sema &S = State.getSema();
6598 if (!
Attr.diagnoseLangOpts(S)) {
6604 if (
Attr.getNumArgs() != 1) {
6605 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6612 auto *StrLiteral = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6621 StringRef BTFTypeTag = StrLiteral->getString();
6622 Type = State.getBTFTagAttributedType(
6623 ::new (Ctx) BTFTypeTagAttr(Ctx,
Attr, BTFTypeTag),
Type);
6631 TypeProcessingState &State) {
6632 Sema &S = State.getSema();
6637 S.
Diag(
Attr.
getLoc(), diag::err_attribute_address_function_type);
6643 if (
Attr.
getKind() == ParsedAttr::AT_AddressSpace) {
6646 if (
Attr.getNumArgs() != 1) {
6653 Expr *ASArgExpr =
Attr.getArgAsExpr(0);
6662 ::new (Ctx) AddressSpaceAttr(Ctx,
Attr,
static_cast<unsigned>(ASIdx));
6674 if (EquivType.
isNull()) {
6678 T = State.getAttributedType(ASAttr,
Type, EquivType);
6680 T = State.getAttributedType(ASAttr,
Type,
Type);
6691 :
Attr.asOpenCLLangAS();
6693 ASIdx =
Attr.asHLSLLangAS();
6696 llvm_unreachable(
"Invalid address space");
6709 TypeProcessingState &State) {
6710 Sema &S = State.getSema();
6714 S.
Diag(
Attr.
getLoc(), diag::warn_overflow_behavior_attribute_disabled)
6721 if (
Attr.getNumArgs() != 1) {
6722 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6730 S.
Diag(
Attr.
getLoc(), diag::err_overflow_behavior_non_integer_type)
6731 <<
Attr <<
Type.getAsString() << 0;
6736 StringRef KindName =
"";
6739 if (
Attr.isArgIdent(0)) {
6740 Ident =
Attr.getArgAsIdent(0)->getIdentifierInfo();
6749 auto *Str = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6751 KindName = Str->getString();
6760 OverflowBehaviorType::OverflowBehaviorKind Kind;
6761 if (KindName ==
"wrap") {
6762 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
6763 }
else if (KindName ==
"trap") {
6764 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
6767 << KindName <<
Attr;
6773 const DeclSpec &DS = State.getDeclarator().getDeclSpec();
6777 OverflowBehaviorType::OverflowBehaviorKind SpecifierKind =
6778 DS.
isWrapSpecified() ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
6779 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
6781 if (SpecifierKind != Kind) {
6784 << 1 << SpecifierName << KindName;
6788 S.
Diag(
Attr.
getLoc(), diag::warn_redundant_overflow_behaviors_mixed)
6795 if (
const auto *ExistingOBT =
Type->
getAs<OverflowBehaviorType>()) {
6796 OverflowBehaviorType::OverflowBehaviorKind ExistingKind =
6797 ExistingOBT->getBehaviorKind();
6798 if (ExistingKind != Kind) {
6799 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_overflow_behaviors) << 0;
6800 if (Kind == OverflowBehaviorType::OverflowBehaviorKind::Trap) {
6801 Type = State.getOverflowBehaviorType(Kind,
6802 ExistingOBT->getUnderlyingType());
6807 Type = State.getOverflowBehaviorType(Kind,
Type);
6817 bool NonObjCPointer =
false;
6819 if (!
type->isDependentType() && !
type->isUndeducedType()) {
6827 NonObjCPointer =
true;
6828 }
else if (!
type->isObjCRetainableType()) {
6834 if (state.isProcessingDeclSpec()) {
6842 Sema &S = state.getSema();
6848 if (!
attr.isArgIdent(0)) {
6849 S.
Diag(AttrLoc, diag::err_attribute_argument_type) <<
attr
6857 if (II->
isStr(
"none"))
6859 else if (II->
isStr(
"strong"))
6861 else if (II->
isStr(
"weak"))
6863 else if (II->
isStr(
"autoreleasing"))
6866 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported) <<
attr << II;
6883 =
type.getQualifiers().getObjCLifetime()) {
6886 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
6893 if (previousLifetime != lifetime) {
6896 const Type *prevTy =
nullptr;
6897 while (!prevTy || prevTy != underlyingType.
Ty) {
6898 prevTy = underlyingType.
Ty;
6907 if (NonObjCPointer) {
6908 StringRef name =
attr.getAttrName()->getName();
6917 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
6934 type = state.getAttributedType(
6941 if (!NonObjCPointer)
6958 diagnostic,
type, 0));
6960 S.
Diag(loc, diagnostic);
6969 unsigned diagnostic =
6970 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
6971 : diag::err_arc_weak_no_runtime);
6974 diagnoseOrDelay(S, AttrLoc, diagnostic,
type);
6986 if (Class->isArcWeakrefUnavailable()) {
6987 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
6988 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
6989 diag::note_class_declared);
7004 Sema &S = state.getSema();
7007 if (!
type->isPointerType() &&
7008 !
type->isObjCObjectPointerType() &&
7009 !
type->isBlockPointerType())
7013 S.
Diag(
attr.getLoc(), diag::err_attribute_multiple_objc_gc);
7019 if (!
attr.isArgIdent(0)) {
7020 S.
Diag(
attr.getLoc(), diag::err_attribute_argument_type)
7026 if (
attr.getNumArgs() > 1) {
7027 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_number_arguments) <<
attr
7034 if (II->
isStr(
"weak"))
7036 else if (II->
isStr(
"strong"))
7039 S.
Diag(
attr.getLoc(), diag::warn_attribute_type_not_supported)
7049 if (
attr.getLoc().isValid())
7050 type = state.getAttributedType(
7067 struct FunctionTypeUnwrapper {
7081 const FunctionType *
Fn;
7082 SmallVector<
unsigned char , 8> Stack;
7084 FunctionTypeUnwrapper(Sema &S, QualType T) : Original(T) {
7096 Stack.push_back(
Array);
7102 Stack.push_back(BlockPointer);
7105 Stack.push_back(MemberPointer);
7111 Stack.push_back(Attributed);
7114 Stack.push_back(MacroQualified);
7122 T = QualType(DTy, 0);
7123 Stack.push_back(Desugar);
7128 bool isFunctionType()
const {
return (Fn !=
nullptr); }
7129 const FunctionType *get()
const {
return Fn; }
7131 QualType wrap(Sema &S,
const FunctionType *
New) {
7133 if (
New == get())
return Original;
7136 return wrap(S.
Context, Original, 0);
7140 QualType wrap(ASTContext &
C, QualType Old,
unsigned I) {
7141 if (I == Stack.size())
7146 SplitQualType SplitOld = Old.
split();
7150 return wrap(
C, SplitOld.
Ty, I);
7151 return C.getQualifiedType(wrap(
C, SplitOld.
Ty, I), SplitOld.
Quals);
7154 QualType wrap(ASTContext &
C,
const Type *Old,
unsigned I) {
7155 if (I == Stack.size())
return QualType(Fn, 0);
7157 switch (
static_cast<WrapKind
>(Stack[I++])) {
7168 return C.getParenType(
New);
7171 case MacroQualified:
7175 if (
const auto *CAT = dyn_cast<ConstantArrayType>(Old)) {
7176 QualType
New = wrap(
C, CAT->getElementType(), I);
7177 return C.getConstantArrayType(
New, CAT->getSize(), CAT->getSizeExpr(),
7178 CAT->getSizeModifier(),
7179 CAT->getIndexTypeCVRQualifiers());
7182 if (
const auto *VAT = dyn_cast<VariableArrayType>(Old)) {
7183 QualType
New = wrap(
C, VAT->getElementType(), I);
7184 return C.getVariableArrayType(
New, VAT->getSizeExpr(),
7185 VAT->getSizeModifier(),
7186 VAT->getIndexTypeCVRQualifiers());
7190 QualType
New = wrap(
C, IAT->getElementType(), I);
7191 return C.getIncompleteArrayType(
New, IAT->getSizeModifier(),
7192 IAT->getIndexTypeCVRQualifiers());
7197 return C.getPointerType(
New);
7200 case BlockPointer: {
7202 return C.getBlockPointerType(
New);
7205 case MemberPointer: {
7218 return C.getRValueReferenceType(
New);
7222 llvm_unreachable(
"unknown wrapping kind");
7229 Sema &S = State.getSema();
7233 default: llvm_unreachable(
"Unknown attribute kind");
7234 case ParsedAttr::AT_Ptr32:
7237 case ParsedAttr::AT_Ptr64:
7240 case ParsedAttr::AT_SPtr:
7243 case ParsedAttr::AT_UPtr:
7248 std::bitset<attr::LastAttr> Attrs;
7251 if (
const TypedefType *TT = dyn_cast<TypedefType>(Desugared)) {
7252 Desugared = TT->desugar();
7255 const AttributedType *AT = dyn_cast<AttributedType>(Desugared);
7258 Attrs[AT->getAttrKind()] =
true;
7259 Desugared = AT->getModifiedType();
7265 if (Attrs[NewAttrKind]) {
7266 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7269 Attrs[NewAttrKind] =
true;
7273 if (Attrs[attr::Ptr32] && Attrs[attr::Ptr64]) {
7274 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7276 <<
"'__ptr64'" << 0;
7278 }
else if (Attrs[attr::SPtr] && Attrs[attr::UPtr]) {
7279 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7291 S.
Diag(PAttr.
getLoc(), diag::err_attribute_no_member_pointers) << PAttr;
7293 S.
Diag(PAttr.
getLoc(), diag::err_attribute_pointers_only) << PAttr << 0;
7301 if (PtrWidth == 32) {
7302 if (Attrs[attr::Ptr64])
7304 else if (Attrs[attr::UPtr])
7306 }
else if (PtrWidth == 64 && Attrs[attr::Ptr32]) {
7323 assert(PAttr.
getKind() == ParsedAttr::AT_WebAssemblyFuncref);
7325 Sema &S = State.getSema();
7328 std::bitset<attr::LastAttr> Attrs;
7330 const auto *AT = dyn_cast<AttributedType>(QT);
7332 Attrs[AT->getAttrKind()] =
true;
7333 AT = dyn_cast<AttributedType>(AT->getModifiedType());
7338 if (Attrs[NewAttrKind]) {
7339 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7345 const auto *Ptr = dyn_cast<PointerType>(Desugared);
7346 if (!Ptr || !Ptr->getPointeeType()->isFunctionType()) {
7347 S.
Diag(PAttr.
getLoc(), diag::err_attribute_webassembly_funcref);
7365 Sema &S = State.getSema();
7366 auto &D = State.getDeclarator();
7372 if (State.isProcessingDeclSpec()) {
7373 if (!(D.isPrototypeContext() ||
7377 if (
auto *chunk = D.getInnermostNonParenChunk()) {
7400 auto chunkIdx = State.getCurrentChunkIndex();
7401 if (chunkIdx >= 1 &&
7404 D.getTypeObject(chunkIdx - 1).getAttrs());
7409 auto *A = ::new (S.
Context) SwiftAttrAttr(S.
Context, PAttr, Str);
7410 QT = State.getAttributedType(A, QT, QT);
7417 auto Attributed = dyn_cast<AttributedType>(
Type.getTypePtr());
7422 if (Attributed->getImmediateNullability())
7423 return Attributed->getModifiedType();
7427 Ctx, Attributed->getModifiedType());
7428 assert(Modified.
getTypePtr() != Attributed->getModifiedType().getTypePtr());
7430 Attributed->getEquivalentType(),
7431 Attributed->getAttr());
7437 case ParsedAttr::AT_TypeNonNull:
7440 case ParsedAttr::AT_TypeNullable:
7443 case ParsedAttr::AT_TypeNullableResult:
7446 case ParsedAttr::AT_TypeNullUnspecified:
7450 llvm_unreachable(
"not a nullability attribute kind");
7457 bool IsContextSensitive,
bool AllowOnArrayType,
bool OverrideExisting) {
7458 bool Implicit = (State ==
nullptr);
7464 while (
auto *Attributed = dyn_cast<AttributedType>(Desugared.
getTypePtr())) {
7466 if (
auto ExistingNullability = Attributed->getImmediateNullability()) {
7468 if (Nullability == *ExistingNullability) {
7472 S.
Diag(NullabilityLoc, diag::warn_nullability_duplicate)
7479 if (!OverrideExisting) {
7481 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7491 Desugared = Attributed->getModifiedType();
7499 if (Nullability != *ExistingNullability && !
Implicit) {
7500 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7508 if (
auto typedefNullability =
7509 AttributedType::stripOuterNullability(underlyingType)) {
7510 if (*typedefNullability == *ExistingNullability) {
7523 !(AllowOnArrayType && Desugared->
isArrayType())) {
7525 S.
Diag(NullabilityLoc, diag::err_nullability_nonpointer)
7533 if (IsContextSensitive) {
7535 const Type *pointeeType =
nullptr;
7544 S.
Diag(NullabilityLoc, diag::err_nullability_cs_multilevel)
7546 S.
Diag(NullabilityLoc, diag::note_nullability_type_specifier)
7558 QT = State->getAttributedType(A, QT, QT);
7567 bool AllowOnArrayType) {
7573 Nullability, NullabilityLoc,
7574 IsContextSensitive, AllowOnArrayType,
7581 bool AllowArrayTypes,
7582 bool OverrideExisting) {
7584 *
this,
nullptr,
nullptr,
Type, Nullability, DiagLoc,
7585 false, AllowArrayTypes, OverrideExisting);
7593 llvm::APInt MaxSizeForAddrSpace =
7594 llvm::APInt::getMaxValue(
Context.getTargetInfo().getPointerWidth(AS));
7595 std::optional<CharUnits> TSizeInChars =
Context.getTypeSizeInCharsIfKnown(T);
7596 if (TSizeInChars &&
static_cast<uint64_t
>(TSizeInChars->getQuantity()) >
7597 MaxSizeForAddrSpace.getZExtValue()) {
7599 << T << MaxSizeForAddrSpace;
7610 Sema &S = state.getSema();
7614 type = state.getAttributedType(
7627 S.
Diag(
attr.getLoc(), diag::err_objc_kindof_nonobject)
7636 objType->getBaseType(), objType->getTypeArgsAsWritten(),
7637 objType->getProtocols(),
7638 objType->isObjCUnqualifiedId() ?
false :
true);
7643 if (
auto nullability =
type->getNullability()) {
7646 assert(
attr.getAttributeSpellingListIndex() == 0 &&
7647 "multiple spellings for __kindof?");
7650 equivType = state.getAttributedType(A, equivType, equivType);
7655 type = state.getAttributedType(
7668 Declarator &declarator = state.getDeclarator();
7671 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
7684 PK_MemberFunctionPointer,
7689 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
7691 auto diag = state.getSema().Diag(
attr.getLoc(),
7692 diag::warn_nullability_declspec)
7694 attr.isContextSensitiveKeywordAttribute())
7696 <<
static_cast<unsigned>(pointerKind);
7702 state.getSema().getPreprocessor().getLocForEndOfToken(
7704 " " +
attr.getAttrName()->getName().str() +
" ");
7714 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
7716 switch (chunk.
Kind) {
7720 return moveToChunk(chunk,
false);
7732 return moveToChunk(*dest,
true);
7748 assert(!
Attr.isInvalid());
7751 llvm_unreachable(
"not a calling convention attribute");
7752 case ParsedAttr::AT_CDecl:
7754 case ParsedAttr::AT_FastCall:
7756 case ParsedAttr::AT_StdCall:
7758 case ParsedAttr::AT_ThisCall:
7760 case ParsedAttr::AT_RegCall:
7762 case ParsedAttr::AT_Pascal:
7764 case ParsedAttr::AT_SwiftCall:
7766 case ParsedAttr::AT_SwiftAsyncCall:
7768 case ParsedAttr::AT_VectorCall:
7770 case ParsedAttr::AT_AArch64VectorPcs:
7772 case ParsedAttr::AT_AArch64SVEPcs:
7774 case ParsedAttr::AT_ArmStreaming:
7776 case ParsedAttr::AT_Pcs: {
7781 if (
Attr.isArgExpr(0))
7784 Str =
Attr.getArgAsIdent(0)->getIdentifierInfo()->getName();
7785 PcsAttr::PCSType
Type;
7786 if (!PcsAttr::ConvertStrToPCSType(Str,
Type))
7787 llvm_unreachable(
"already validated the attribute");
7788 return ::new (Ctx) PcsAttr(Ctx,
Attr,
Type);
7790 case ParsedAttr::AT_IntelOclBicc:
7792 case ParsedAttr::AT_MSABI:
7794 case ParsedAttr::AT_SysVABI:
7796 case ParsedAttr::AT_PreserveMost:
7798 case ParsedAttr::AT_PreserveAll:
7800 case ParsedAttr::AT_M68kRTD:
7802 case ParsedAttr::AT_PreserveNone:
7804 case ParsedAttr::AT_RISCVVectorCC:
7806 case ParsedAttr::AT_RISCVVLSCC: {
7809 unsigned ABIVLen = 128;
7810 if (
Attr.getNumArgs()) {
7811 std::optional<llvm::APSInt> MaybeABIVLen =
7812 Attr.getArgAsExpr(0)->getIntegerConstantExpr(Ctx);
7814 llvm_unreachable(
"Invalid RISC-V ABI VLEN");
7815 ABIVLen = MaybeABIVLen->getZExtValue();
7818 return ::new (Ctx) RISCVVLSCCAttr(Ctx,
Attr, ABIVLen);
7821 llvm_unreachable(
"unexpected attribute kind!");
7824std::optional<FunctionEffectMode>
7829 std::optional<llvm::APSInt> ConditionValue =
7831 if (!ConditionValue) {
7837 return std::nullopt;
7846 FunctionTypeUnwrapper &Unwrapped) {
7848 if (!Unwrapped.isFunctionType())
7851 Sema &S = TPState.getSema();
7855 if (FPT ==
nullptr) {
7856 S.
Diag(PAttr.
getLoc(), diag::err_func_with_effects_no_prototype)
7863 bool IsNonBlocking = PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7864 PAttr.
getKind() == ParsedAttr::AT_Blocking;
7867 Expr *CondExpr =
nullptr;
7869 if (PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7870 PAttr.
getKind() == ParsedAttr::AT_NonAllocating) {
7879 std::optional<FunctionEffectMode> MaybeMode =
7885 NewMode = *MaybeMode;
7920 assert(
Success &&
"effect conflicts should have been diagnosed above");
7924 FPT->getParamTypes(), EPI);
7933 auto OtherAttr = llvm::find_if(
7934 state.getCurrentAttributes(),
7935 [OtherKind](
const ParsedAttr &A) { return A.getKind() == OtherKind; });
7936 if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
7939 Sema &S = state.getSema();
7941 << *OtherAttr <<
Attr
7942 << (OtherAttr->isRegularKeywordAttribute() ||
7944 S.
Diag(OtherAttr->getLoc(), diag::note_conflicting_attribute);
7952 if (!
Attr.getNumArgs()) {
7958 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
7959 StringRef StateName;
7964 if (StateName !=
"sme_za_state") {
7965 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
7972 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_attributes_arm_agnostic);
7987 if (!
Attr.getNumArgs()) {
7993 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
7994 StringRef StateName;
8001 if (StateName ==
"za") {
8004 }
else if (StateName ==
"zt0") {
8008 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8014 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_agnostic);
8023 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_state)
8039 Sema &S = state.getSema();
8041 FunctionTypeUnwrapper unwrapped(S,
type);
8043 if (
attr.getKind() == ParsedAttr::AT_NoReturn) {
8048 if (!unwrapped.isFunctionType())
8057 if (
attr.getKind() == ParsedAttr::AT_CFIUncheckedCallee) {
8059 if (!unwrapped.isFunctionType())
8062 if (!unwrapped.get()->isFunctionProtoType()) {
8063 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8064 <<
attr <<
attr.isRegularKeywordAttribute()
8072 FPT->getReturnType(), FPT->getParamTypes(),
8073 FPT->getExtProtoInfo().withCFIUncheckedCallee(
true));
8078 if (
attr.getKind() == ParsedAttr::AT_CmseNSCall) {
8080 if (!unwrapped.isFunctionType())
8085 S.
Diag(
attr.getLoc(), diag::warn_attribute_ignored) <<
attr;
8092 unwrapped.get()->getExtInfo().withCmseNSCall(
true);
8099 if (
attr.getKind() == ParsedAttr::AT_NSReturnsRetained) {
8100 if (
attr.getNumArgs())
return true;
8103 if (!unwrapped.isFunctionType())
8108 attr.getLoc(), unwrapped.get()->getReturnType()))
8113 if (state.getSema().getLangOpts().ObjCAutoRefCount) {
8115 = unwrapped.get()->getExtInfo().withProducesResult(
true);
8118 type = state.getAttributedType(
8124 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCallerSavedRegisters) {
8129 if (!unwrapped.isFunctionType())
8133 unwrapped.get()->getExtInfo().withNoCallerSavedRegs(
true);
8138 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCfCheck) {
8140 S.
Diag(
attr.getLoc(), diag::warn_nocf_check_attribute_ignored);
8150 if (!unwrapped.isFunctionType())
8154 unwrapped.get()->getExtInfo().withNoCfCheck(
true);
8159 if (
attr.getKind() == ParsedAttr::AT_Regparm) {
8165 if (!unwrapped.isFunctionType())
8172 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8174 <<
attr.isRegularKeywordAttribute();
8180 unwrapped.get()->getExtInfo().withRegParm(value);
8185 if (
attr.getKind() == ParsedAttr::AT_CFISalt) {
8186 if (
attr.getNumArgs() != 1)
8194 if (!unwrapped.isFunctionType())
8199 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_decl_type)
8200 <<
attr <<
attr.isRegularKeywordAttribute()
8210 FnTy->getParamTypes(), EPI);
8215 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8216 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible ||
8217 attr.getKind() == ParsedAttr::AT_ArmPreserves ||
8218 attr.getKind() == ParsedAttr::AT_ArmIn ||
8219 attr.getKind() == ParsedAttr::AT_ArmOut ||
8220 attr.getKind() == ParsedAttr::AT_ArmInOut ||
8221 attr.getKind() == ParsedAttr::AT_ArmAgnostic) {
8225 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8226 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible)
8230 if (!unwrapped.isFunctionType())
8237 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8238 <<
attr <<
attr.isRegularKeywordAttribute()
8245 switch (
attr.getKind()) {
8246 case ParsedAttr::AT_ArmStreaming:
8248 ParsedAttr::AT_ArmStreamingCompatible))
8252 case ParsedAttr::AT_ArmStreamingCompatible:
8257 case ParsedAttr::AT_ArmPreserves:
8261 case ParsedAttr::AT_ArmIn:
8265 case ParsedAttr::AT_ArmOut:
8269 case ParsedAttr::AT_ArmInOut:
8273 case ParsedAttr::AT_ArmAgnostic:
8278 llvm_unreachable(
"Unsupported attribute");
8282 FnTy->getParamTypes(), EPI);
8287 if (
attr.getKind() == ParsedAttr::AT_NoThrow) {
8289 if (!unwrapped.isFunctionType())
8302 if (Proto->hasExceptionSpec()) {
8303 switch (Proto->getExceptionSpecType()) {
8305 llvm_unreachable(
"This doesn't have an exception spec!");
8323 S.
Diag(
attr.getLoc(), diag::warn_nothrow_attribute_ignored);
8329 type = unwrapped.wrap(
8338 if (
attr.getKind() == ParsedAttr::AT_NonBlocking ||
8339 attr.getKind() == ParsedAttr::AT_NonAllocating ||
8340 attr.getKind() == ParsedAttr::AT_Blocking ||
8341 attr.getKind() == ParsedAttr::AT_Allocating) {
8346 if (!unwrapped.isFunctionType())
return false;
8361 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8364 <<
attr.isRegularKeywordAttribute();
8383 return S.
Diag(
attr.getLoc(), diag::warn_cconv_unsupported)
8388 return S.
Diag(
attr.getLoc(), diag::err_cconv_varargs)
8395 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8397 <<
attr.isRegularKeywordAttribute();
8409 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
8418 const AttributedType *AT;
8422 while ((AT = T->getAs<AttributedType>()) &&
8424 if (AT->isCallingConv())
8426 T = AT->getModifiedType();
8433 FunctionTypeUnwrapper Unwrapped(*
this, T);
8439 Context.getDefaultCallingConvention(IsVariadic, HasThisPointer);
8446 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() && IsCtorOrDtor) {
8450 Diag(Loc, diag::warn_cconv_unsupported)
8459 Context.getDefaultCallingConvention(IsVariadic, !HasThisPointer);
8461 if (CurCC != DefaultCC)
8469 QualType Wrapped = Unwrapped.wrap(*
this, FT);
8470 T =
Context.getAdjustedType(T, Wrapped);
8483 if (
Attr.getNumArgs() != 1) {
8490 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8503 if (
Attr.getNumArgs() != 1) {
8509 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8524 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
8525 Triple.getArch() == llvm::Triple::aarch64_32 ||
8526 Triple.getArch() == llvm::Triple::aarch64_be;
8528 if (IsPolyUnsigned) {
8530 return BTy->
getKind() == BuiltinType::UChar ||
8531 BTy->
getKind() == BuiltinType::UShort ||
8532 BTy->
getKind() == BuiltinType::ULong ||
8533 BTy->
getKind() == BuiltinType::ULongLong;
8536 return BTy->
getKind() == BuiltinType::SChar ||
8537 BTy->
getKind() == BuiltinType::Short ||
8538 BTy->
getKind() == BuiltinType::LongLong;
8544 if ((Triple.isArch64Bit() || Triple.getArch() == llvm::Triple::aarch64_32) &&
8545 BTy->
getKind() == BuiltinType::Double)
8548 return BTy->
getKind() == BuiltinType::SChar ||
8549 BTy->
getKind() == BuiltinType::UChar ||
8550 BTy->
getKind() == BuiltinType::Short ||
8551 BTy->
getKind() == BuiltinType::UShort ||
8552 BTy->
getKind() == BuiltinType::Int ||
8553 BTy->
getKind() == BuiltinType::UInt ||
8554 BTy->
getKind() == BuiltinType::Long ||
8555 BTy->
getKind() == BuiltinType::ULong ||
8556 BTy->
getKind() == BuiltinType::LongLong ||
8557 BTy->
getKind() == BuiltinType::ULongLong ||
8558 BTy->
getKind() == BuiltinType::Float ||
8559 BTy->
getKind() == BuiltinType::Half ||
8560 BTy->
getKind() == BuiltinType::BFloat16 ||
8561 BTy->
getKind() == BuiltinType::MFloat8;
8566 const auto *AttrExpr =
Attr.getArgAsExpr(0);
8567 if (!AttrExpr->isTypeDependent()) {
8568 if (std::optional<llvm::APSInt> Res =
8569 AttrExpr->getIntegerConstantExpr(S.
Context)) {
8611 if (
Attr.getNumArgs() != 1) {
8612 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8618 llvm::APSInt numEltsInt(32);
8624 S.
Diag(
Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
8631 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
8632 unsigned vecSize = typeSize * numElts;
8633 if (vecSize != 64 && vecSize != 128) {
8634 S.
Diag(
Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
8646 assert((
Attr.getNumArgs() > 0 &&
Attr.getNumArgs() <= 3) &&
8647 "__ptrauth qualifier takes between 1 and 3 arguments");
8648 Expr *KeyArg =
Attr.getArgAsExpr(0);
8649 Expr *IsAddressDiscriminatedArg =
8650 Attr.getNumArgs() >= 2 ?
Attr.getArgAsExpr(1) :
nullptr;
8651 Expr *ExtraDiscriminatorArg =
8652 Attr.getNumArgs() >= 3 ?
Attr.getArgAsExpr(2) :
nullptr;
8661 bool IsInvalid =
false;
8662 unsigned IsAddressDiscriminated, ExtraDiscriminator;
8665 IsAddressDiscriminated);
8674 if (!T->isSignableType(Ctx) && !T->isDependentType()) {
8675 S.
Diag(
Attr.
getLoc(), diag::err_ptrauth_qualifier_invalid_target) << T;
8680 if (T.getPointerAuth()) {
8681 S.
Diag(
Attr.
getLoc(), diag::err_ptrauth_qualifier_redundant) << T;
8692 assert((!IsAddressDiscriminatedArg || IsAddressDiscriminated <= 1) &&
8693 "address discriminator arg should be either 0 or 1");
8695 Key, IsAddressDiscriminated, ExtraDiscriminator,
8717 S.
Diag(
Attr.
getLoc(), diag::err_attribute_arm_feature_sve_bits_unsupported)
8724 if (
Attr.getNumArgs() != 1) {
8725 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8732 llvm::APSInt SveVectorSizeInBits(32);
8736 unsigned VecSize =
static_cast<unsigned>(SveVectorSizeInBits.getZExtValue());
8759 if (BT->getKind() == BuiltinType::SveBool) {
8764 VecSize /= TypeSize;
8771 const VectorType *VT = dyn_cast<VectorType>(CurType);
8774 diag::err_attribute_arm_mve_polymorphism);
8781 State.getSema().Context,
Attr),
8793 <<
Attr <<
"'zve32x'";
8800 if (!VScale || !VScale->first || VScale->first != VScale->second) {
8801 S.
Diag(
Attr.
getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
8808 if (
Attr.getNumArgs() != 1) {
8809 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8816 llvm::APSInt RVVVectorSizeInBits(32);
8828 unsigned VecSize =
static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue());
8832 unsigned MinElts = Info.
EC.getKnownMinValue();
8835 unsigned ExpectedSize = VScale->first * MinElts;
8857 ExpectedSize *= EltSize;
8858 NumElts = VecSize / EltSize;
8862 if (VecSize != ExpectedSize) {
8864 << VecSize << ExpectedSize;
8877 S.
Diag(
Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
8883 QualType BaseTy = TypedefTy->desugar();
8885 std::string PrevAccessQual;
8887 if (TypedefTy->getDecl()->hasAttr<OpenCLAccessAttr>()) {
8888 OpenCLAccessAttr *
Attr =
8889 TypedefTy->getDecl()->getAttr<OpenCLAccessAttr>();
8892 PrevAccessQual =
"read_only";
8896 switch (ImgType->getKind()) {
8897 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8898 case BuiltinType::Id: \
8899 PrevAccessQual = #Access; \
8901 #include "clang/Basic/OpenCLImageTypes.def"
8903 llvm_unreachable(
"Unable to find corresponding image type.");
8906 llvm_unreachable(
"unexpected type");
8909 if (PrevAccessQual == AttrName.ltrim(
"_")) {
8915 S.
Diag(
Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
8918 S.
Diag(TypedefTy->getDecl()->getBeginLoc(),
8919 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
8921 if (
Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
8936 if (
Attr.getNumArgs() != 2) {
8937 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8942 Expr *RowsExpr =
Attr.getArgAsExpr(0);
8943 Expr *ColsExpr =
Attr.getArgAsExpr(1);
8951 Sema &S = State.getSema();
8954 S.
Diag(PA.
getLoc(), diag::err_attribute_too_few_arguments) << PA << 1;
8966 for (
unsigned Idx = 1; Idx < PA.
getNumArgs(); Idx++) {
8972 auto *AnnotateTypeAttr =
8973 AnnotateTypeAttr::Create(S.
Context, Str, Args.data(), Args.size(), PA);
8974 CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType);
8980 if (State.getDeclarator().isDeclarationOfFunction()) {
8981 CurType = State.getAttributedType(
8986 State.getSema().Diag(
Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
8993 if (State.getDeclarator().isDeclarationOfFunction()) {
8994 auto *
Attr = State.getSema().ParseLifetimeCaptureByAttr(PA,
"this");
8996 CurType = State.getAttributedType(
Attr, CurType, CurType);
9008 if (
Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_inout ||
9009 Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_out) {
9010 State.setParsedHLSLParamMod(
true);
9019 state.setParsedNoDeref(
false);
9035 if (
attr.isInvalid())
9038 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute()) {
9043 if (
attr.isGNUScope()) {
9044 assert(
attr.isStandardAttributeSyntax());
9045 bool IsTypeAttr =
attr.isTypeAttr();
9047 state.getSema().Diag(
attr.getLoc(),
9049 ? diag::warn_gcc_ignores_type_attr
9050 : diag::warn_cxx11_gnu_attribute_on_type)
9056 !
attr.isTypeAttr()) {
9069 switch (
attr.getKind()) {
9072 if ((
attr.isStandardAttributeSyntax() ||
9073 attr.isRegularKeywordAttribute()) &&
9075 state.getSema().Diag(
attr.getLoc(), diag::err_attribute_not_type_attr)
9076 <<
attr <<
attr.isRegularKeywordAttribute();
9077 attr.setUsedAsTypeAttr();
9082 if (
attr.isStandardAttributeSyntax()) {
9083 state.getSema().DiagnoseUnknownAttribute(
attr);
9093 case ParsedAttr::AT_BTFTypeTag:
9095 attr.setUsedAsTypeAttr();
9098 case ParsedAttr::AT_MayAlias:
9101 attr.setUsedAsTypeAttr();
9103 case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
9104 case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
9105 state.getSema().Diag(
attr.getLoc(), diag::warn_deprecated_attribute)
9108 case ParsedAttr::AT_OpenCLPrivateAddressSpace:
9109 case ParsedAttr::AT_OpenCLGlobalAddressSpace:
9110 case ParsedAttr::AT_OpenCLLocalAddressSpace:
9111 case ParsedAttr::AT_OpenCLConstantAddressSpace:
9112 case ParsedAttr::AT_OpenCLGenericAddressSpace:
9113 case ParsedAttr::AT_AddressSpace:
9115 attr.setUsedAsTypeAttr();
9117 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
9120 if (state.getSema().getLangOpts().getHLSLVersion() <
9122 state.getSema().Diag(
attr.getLoc(), diag::warn_hlsl_groupshared_202x);
9129 attr.setUsedAsTypeAttr();
9131 case ParsedAttr::AT_HLSLRowMajor:
9132 case ParsedAttr::AT_HLSLColumnMajor:
9134 state.getSema().HLSL().buildMatrixLayoutTypeAttr(
type,
attr))
9136 attr.setUsedAsTypeAttr();
9141 attr.setUsedAsTypeAttr();
9143 case ParsedAttr::AT_VectorSize:
9145 attr.setUsedAsTypeAttr();
9147 case ParsedAttr::AT_ExtVectorType:
9149 attr.setUsedAsTypeAttr();
9151 case ParsedAttr::AT_NeonVectorType:
9153 attr.setUsedAsTypeAttr();
9155 case ParsedAttr::AT_NeonPolyVectorType:
9158 attr.setUsedAsTypeAttr();
9160 case ParsedAttr::AT_ArmSveVectorBits:
9162 attr.setUsedAsTypeAttr();
9164 case ParsedAttr::AT_ArmMveStrictPolymorphism: {
9166 attr.setUsedAsTypeAttr();
9169 case ParsedAttr::AT_RISCVRVVVectorBits:
9171 attr.setUsedAsTypeAttr();
9173 case ParsedAttr::AT_OpenCLAccess:
9175 attr.setUsedAsTypeAttr();
9177 case ParsedAttr::AT_PointerAuth:
9180 attr.setUsedAsTypeAttr();
9182 case ParsedAttr::AT_LifetimeBound:
9186 case ParsedAttr::AT_LifetimeCaptureBy:
9190 case ParsedAttr::AT_OverflowBehavior:
9192 attr.setUsedAsTypeAttr();
9195 case ParsedAttr::AT_NoDeref: {
9200 if (
attr.isStandardAttributeSyntax()) {
9201 state.getSema().Diag(
attr.getLoc(), diag::warn_attribute_ignored)
9208 attr.setUsedAsTypeAttr();
9209 state.setParsedNoDeref(
true);
9213 case ParsedAttr::AT_MatrixType:
9215 attr.setUsedAsTypeAttr();
9218 case ParsedAttr::AT_WebAssemblyFuncref: {
9220 attr.setUsedAsTypeAttr();
9224 case ParsedAttr::AT_HLSLParamModifier: {
9226 if (attrs.
hasAttribute(ParsedAttr::AT_HLSLGroupSharedAddressSpace)) {
9227 state.getSema().Diag(
attr.getLoc(), diag::err_hlsl_attr_incompatible)
9228 <<
attr <<
"'groupshared'";
9232 attr.setUsedAsTypeAttr();
9236 case ParsedAttr::AT_SwiftAttr: {
9243 attr.setUsedAsTypeAttr();
9251 if (
type->canHaveNullability() ||
type->isDependentType() ||
9252 type->isArrayType() ||
9256 endIndex = state.getCurrentChunkIndex();
9258 endIndex = state.getDeclarator().getNumTypeObjects();
9259 bool allowOnArrayType =
9260 state.getDeclarator().isPrototypeContext() &&
9263 allowOnArrayType)) {
9267 attr.setUsedAsTypeAttr();
9271 case ParsedAttr::AT_ObjCKindOf:
9279 state.getSema().Diag(
attr.getLoc(),
9280 diag::err_objc_kindof_wrong_position)
9283 state.getDeclarator().getDeclSpec().getBeginLoc(),
9293 case ParsedAttr::AT_NoThrow:
9296 if (!state.getSema().getLangOpts().CPlusPlus)
9301 attr.setUsedAsTypeAttr();
9305 if (
attr.isStandardAttributeSyntax() ||
9306 attr.isRegularKeywordAttribute()) {
9323 case ParsedAttr::AT_AcquireHandle: {
9324 if (!
type->isFunctionType())
9327 if (
attr.getNumArgs() != 1) {
9328 state.getSema().Diag(
attr.getLoc(),
9329 diag::err_attribute_wrong_number_arguments)
9335 StringRef HandleType;
9336 if (!state.getSema().checkStringLiteralArgumentAttr(
attr, 0, HandleType))
9338 type = state.getAttributedType(
9339 AcquireHandleAttr::Create(state.getSema().Context, HandleType,
attr),
9341 attr.setUsedAsTypeAttr();
9344 case ParsedAttr::AT_AnnotateType: {
9346 attr.setUsedAsTypeAttr();
9349 case ParsedAttr::AT_HLSLResourceClass:
9350 case ParsedAttr::AT_HLSLResourceDimension:
9351 case ParsedAttr::AT_HLSLROV:
9352 case ParsedAttr::AT_HLSLRawBuffer:
9353 case ParsedAttr::AT_HLSLIsArray:
9354 case ParsedAttr::AT_HLSLContainedType: {
9359 state.getSema().HLSL().handleResourceTypeAttr(
type,
attr))
9360 attr.setUsedAsTypeAttr();
9368 !
type.getQualifiers().hasObjCLifetime() &&
9369 !
type.getQualifiers().hasObjCGCAttr() &&
9370 attr.getKind() != ParsedAttr::AT_ObjCGC &&
9371 attr.getKind() != ParsedAttr::AT_ObjCOwnership) {
9373 type = state.getSema().Context.getMacroQualifiedType(
type, MacroII);
9374 state.setExpansionLocForMacroQualifiedType(
9376 attr.getMacroExpansionLoc());
9383 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
9385 auto *Def = Var->getDefinition();
9391 Def = Var->getDefinition();
9398 if (Var->getPointOfInstantiation().isInvalid() && Def) {
9399 assert(Var->getTemplateSpecializationKind() ==
9401 "explicit instantiation with no point of instantiation");
9402 Var->setTemplateSpecializationKind(
9403 Var->getTemplateSpecializationKind(), PointOfInstantiation);
9423 if (
const auto CastE = dyn_cast<ExplicitCastExpr>(E)) {
9424 QualType DestType = CastE->getTypeAsWritten();
9425 if (
const auto *IAT =
Context.getAsIncompleteArrayType(DestType)) {
9430 IAT->getElementType(),
9467 if (RequireCompleteTypeImpl(Loc, T, Kind, &Diagnoser))
9469 if (
auto *TD = T->getAsTagDecl(); TD && !TD->isCompleteDefinitionRequired()) {
9470 TD->setCompleteDefinitionRequired();
9471 Consumer.HandleTagDeclRequiredDefinition(TD);
9504 auto DefinitionIsAcceptable = [&](
NamedDecl *D) {
9524 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
9525 return RD->isThisDeclarationADefinition();
9526 if (
auto *ED = dyn_cast<EnumDecl>(D))
9527 return ED->isThisDeclarationADefinition();
9528 if (
auto *FD = dyn_cast<FunctionDecl>(D))
9529 return FD->isThisDeclarationADefinition();
9530 if (
auto *VD = dyn_cast<VarDecl>(D))
9532 llvm_unreachable(
"unexpected decl type");
9534 auto FoundAcceptableDefinition = [&](
NamedDecl *D) {
9536 return DefinitionIsAcceptable(D);
9544 return DefinitionIsAcceptable(D);
9546 for (
auto *RD : D->
redecls()) {
9548 if (!IsDefinition(ND))
9550 if (DefinitionIsAcceptable(ND)) {
9559 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9560 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
9562 D = RD->getDefinition();
9563 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
9564 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
9566 if (OnlyNeedComplete && (ED->isFixed() ||
getLangOpts().MSVCCompat)) {
9572 *Suggested =
nullptr;
9573 for (
auto *Redecl : ED->redecls()) {
9576 if (Redecl->isThisDeclarationADefinition() ||
9577 (Redecl->isCanonicalDecl() && !*Suggested))
9578 *Suggested = Redecl;
9583 D = ED->getDefinition();
9584 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
9585 if (
auto *Pattern = FD->getTemplateInstantiationPattern())
9587 D = FD->getDefinition();
9588 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
9589 if (
auto *Pattern = VD->getTemplateInstantiationPattern())
9591 D = VD->getDefinition();
9594 assert(D &&
"missing definition for pattern of instantiated definition");
9598 if (FoundAcceptableDefinition(D))
9603 if (
auto *Source =
Context.getExternalSource()) {
9604 Source->CompleteRedeclChain(D);
9605 return FoundAcceptableDefinition(D);
9621 bool OnlyNeedComplete) {
9638 bool OnlyNeedComplete) {
9646 if (!RD->
hasAttr<MSInheritanceAttr>()) {
9648 bool BestCase =
false;
9668 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
9669 S.
getASTContext(), BestCase, Loc, MSInheritanceAttr::Spelling(IM)));
9675 CompleteTypeKind Kind,
9676 TypeDiagnoser *Diagnoser) {
9685 if (
const auto *MPTy = dyn_cast<MemberPointerType>(T.
getCanonicalType())) {
9686 if (CXXRecordDecl *RD = MPTy->getMostRecentCXXRecordDecl();
9687 RD && !RD->isDependentType()) {
9689 if (
getLangOpts().CompleteMemberPointers && !RD->isBeingDefined() &&
9695 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
9702 NamedDecl *Def =
nullptr;
9704 bool Incomplete = (T->isIncompleteType(&Def) ||
9714 NamedDecl *Suggested =
nullptr;
9720 if (Diagnoser && Suggested)
9723 return !TreatAsComplete;
9727 TempInst.Template = Def;
9728 TempInst.Entity = Def;
9729 TempInst.PointOfInstantiation = Loc;
9737 TagDecl *
Tag = dyn_cast_or_null<TagDecl>(Def);
9738 ObjCInterfaceDecl *IFace = dyn_cast_or_null<ObjCInterfaceDecl>(Def);
9750 if (
auto *Source =
Context.getExternalSource()) {
9751 if (Tag &&
Tag->hasExternalLexicalStorage())
9752 Source->CompleteType(Tag);
9754 Source->CompleteType(IFace);
9757 if (!T->isIncompleteType())
9758 return RequireCompleteTypeImpl(Loc, T, Kind, Diagnoser);
9765 if (
auto *RD = dyn_cast_or_null<CXXRecordDecl>(Tag)) {
9766 bool Instantiated =
false;
9767 bool Diagnosed =
false;
9768 if (RD->isDependentContext()) {
9772 }
else if (
auto *ClassTemplateSpec =
9773 dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
9774 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
9778 Diagnoser, ClassTemplateSpec->hasStrictPackMatch());
9780 Instantiated =
true;
9783 CXXRecordDecl *Pattern = RD->getInstantiatedFromMemberClass();
9784 if (!RD->isBeingDefined() && Pattern) {
9785 MemberSpecializationInfo *MSI = RD->getMemberSpecializationInfo();
9786 assert(MSI &&
"Missing member specialization information?");
9796 Instantiated =
true;
9804 if (Diagnoser && Diagnosed)
9809 if (!T->isIncompleteType())
9810 return RequireCompleteTypeImpl(Loc, T, Kind, Diagnoser);
9820 Diagnoser->diagnose(*
this, Loc, T);
9824 if (Tag && !
Tag->isInvalidDecl() && !
Tag->getLocation().isInvalid())
9825 Diag(
Tag->getLocation(),
Tag->isBeingDefined()
9826 ? diag::note_type_being_defined
9827 : diag::note_forward_declaration)
9828 <<
Context.getCanonicalTagType(Tag);
9861 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
9867 assert(!T->isDependentType() &&
"type should not be dependent");
9876 if (T->isVariableArrayType())
9892 Diag(RD->getLocation(), diag::note_non_literal_lambda);
9900 if (RD->getNumVBases()) {
9901 Diag(RD->getLocation(), diag::note_non_literal_virtual_base)
9903 for (
const auto &I : RD->vbases())
9904 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
9905 << I.getSourceRange();
9906 }
else if (!RD->isAggregate() && !RD->hasConstexprNonCopyMoveConstructor() &&
9907 !RD->hasTrivialDefaultConstructor()) {
9908 Diag(RD->getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
9909 }
else if (RD->hasNonLiteralTypeFieldsOrBases()) {
9910 for (
const auto &I : RD->bases()) {
9911 if (!I.getType()->isLiteralType(
Context)) {
9912 Diag(I.getBeginLoc(), diag::note_non_literal_base_class)
9913 << RD << I.getType() << I.getSourceRange();
9917 for (
const auto *I : RD->fields()) {
9918 if (!I->getType()->isLiteralType(
Context) ||
9919 I->getType().isVolatileQualified()) {
9920 Diag(I->getLocation(), diag::note_non_literal_field)
9921 << RD << I << I->getType()
9922 << I->getType().isVolatileQualified();
9927 : !RD->hasTrivialDestructor()) {
9932 assert(Dtor &&
"class has literal fields and bases but no dtor?");
9937 Diag(Dtor->getLocation(), diag::note_non_literal_non_constexpr_dtor)
9940 Diag(Dtor->getLocation(), Dtor->isUserProvided()
9941 ? diag::note_non_literal_user_provided_dtor
9942 : diag::note_non_literal_nontrivial_dtor)
9944 if (!Dtor->isUserProvided())
9968 if (
const TagType *TT = T->getAs<TagType>())
9971 return Context.getTypeOfExprType(E, Kind);
9992 return Context.getCountAttributedType(WrappedTy, CountExpr, CountInBytes,
10002 if (
auto *ImplCastExpr = dyn_cast<ImplicitCastExpr>(E))
10003 IDExpr = ImplCastExpr->getSubExpr();
10005 if (
auto *PackExpr = dyn_cast<PackIndexingExpr>(E)) {
10007 IDExpr = PackExpr->getPackIdExpression();
10009 IDExpr = PackExpr->getSelectedExpr();
10025 if (
const auto *SNTTPE = dyn_cast<SubstNonTypeTemplateParmExpr>(IDExpr))
10026 IDExpr = SNTTPE->getReplacement();
10034 if (
const auto *DRE = dyn_cast<DeclRefExpr>(IDExpr)) {
10039 if (
const auto *ME = dyn_cast<MemberExpr>(IDExpr)) {
10040 if (
const auto *VD = ME->getMemberDecl())
10042 return VD->getType();
10043 }
else if (
const auto *IR = dyn_cast<ObjCIvarRefExpr>(IDExpr)) {
10044 return IR->getDecl()->getType();
10045 }
else if (
const auto *PR = dyn_cast<ObjCPropertyRefExpr>(IDExpr)) {
10046 if (PR->isExplicitProperty())
10047 return PR->getExplicitProperty()->getType();
10048 }
else if (
const auto *PE = dyn_cast<PredefinedExpr>(IDExpr)) {
10049 return PE->getType();
10060 if (
auto *DRE = dyn_cast<DeclRefExpr>(IDExpr->
IgnoreParens())) {
10061 if (
auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
10064 return Context.getLValueReferenceType(T);
10069 return Context.getReferenceQualifiedType(E);
10081 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
10094 Diag(Loc, diag::err_expected_name_of_pack) << Pattern;
10098 if (!
Type.isNull())
10100 : diag::ext_pack_indexing);
10107 bool FullySubstituted,
10112 llvm::APSInt
Value;
10119 IndexExpr = Res.
get();
10120 uint64_t
V =
Value.getZExtValue();
10121 if (FullySubstituted &&
V >= Expansions.size()) {
10123 <<
V << Pattern << Expansions.size();
10126 Index =
static_cast<unsigned>(
V);
10129 return Context.getPackIndexingType(Pattern, IndexExpr, FullySubstituted,
10130 Expansions, Index);
10135 assert(BaseType->isEnumeralType());
10136 EnumDecl *ED = BaseType->castAs<EnumType>()->getDecl();
10141 if (Underlying.
isNull()) {
10143 assert(!Underlying.
isNull());
10151 if (!BaseType->isEnumeralType()) {
10152 Diag(Loc, diag::err_only_enums_have_underlying_types);
10159 if (BaseType->isIncompleteType(&FwdDecl)) {
10160 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
10161 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
10169 QualType Pointer = BaseType.isReferenceable() || BaseType->isVoidType()
10178 if (!BaseType->isAnyPointerType())
10187 return Context.getDecayedType(Underlying);
10196 Split.Quals.removeCVRQualifiers();
10197 return Context.getQualifiedType(Split);
10204 BaseType.isReferenceable()
10206 UKind == UnaryTransformType::AddLvalueReference,
10214 if (UKind == UnaryTransformType::RemoveAllExtents)
10215 return Context.getBaseElementType(BaseType);
10217 if (
const auto *AT =
Context.getAsArrayType(BaseType))
10218 return AT->getElementType();
10227 if (UKind == UTTKind::RemoveCVRef &&
10228 (T.isConstQualified() || T.isVolatileQualified())) {
10233 T =
Context.getQualifiedType(Unqual, Quals);
10240 if ((BaseType->isReferenceType() && UKind != UTTKind::RemoveRestrict) ||
10241 BaseType->isFunctionType())
10247 if (UKind == UTTKind::RemoveConst || UKind == UTTKind::RemoveCV)
10249 if (UKind == UTTKind::RemoveVolatile || UKind == UTTKind::RemoveCV)
10251 if (UKind == UTTKind::RemoveRestrict)
10254 return Context.getQualifiedType(Unqual, Quals);
10260 if (BaseType->isEnumeralType()) {
10262 if (
auto *
BitInt = dyn_cast<BitIntType>(Underlying)) {
10263 unsigned int Bits =
BitInt->getNumBits();
10267 S.
Diag(Loc, diag::err_make_signed_integral_only)
10268 << IsMakeSigned <<
true << BaseType << 1 << Underlying;
10272 S.
Diag(Loc, diag::err_make_signed_integral_only)
10273 << IsMakeSigned <<
false << BaseType << 1
10280 std::array<CanQualType *, 6> AllSignedIntegers = {
10284 AllSignedIntegers.data(), AllSignedIntegers.size() - Int128Unsupported);
10285 std::array<CanQualType *, 6> AllUnsignedIntegers = {
10290 AllUnsignedIntegers.size() -
10291 Int128Unsupported);
10293 IsMakeSigned ? &AvailableSignedIntegers : &AvailableUnsignedIntegers;
10297 llvm::find_if(*Consider, [&S, BaseSize](
const CanQual<Type> *T) {
10301 assert(
Result != Consider->end());
10302 return QualType((*Result)->getTypePtr(), 0);
10307 bool IsMakeSigned = UKind == UnaryTransformType::MakeSigned;
10308 if ((!BaseType->isIntegerType() && !BaseType->isEnumeralType()) ||
10309 BaseType->isBooleanType() ||
10310 (BaseType->isBitIntType() &&
10312 Diag(Loc, diag::err_make_signed_integral_only)
10313 << IsMakeSigned << BaseType->isBitIntType() << BaseType << 0;
10317 bool IsNonIntIntegral =
10318 BaseType->
isChar16Type() || BaseType->isChar32Type() ||
10319 BaseType->isWideCharType() || BaseType->isEnumeralType();
10324 : IsMakeSigned ?
Context.getCorrespondingSignedType(BaseType)
10325 :
Context.getCorrespondingUnsignedType(BaseType);
10326 if (Underlying.
isNull())
10333 if (BaseType->isDependentType())
10334 return Context.getUnaryTransformType(BaseType, BaseType, UKind);
10337 case UnaryTransformType::EnumUnderlyingType: {
10341 case UnaryTransformType::AddPointer: {
10345 case UnaryTransformType::RemovePointer: {
10349 case UnaryTransformType::Decay: {
10353 case UnaryTransformType::AddLvalueReference:
10354 case UnaryTransformType::AddRvalueReference: {
10358 case UnaryTransformType::RemoveAllExtents:
10359 case UnaryTransformType::RemoveExtent: {
10363 case UnaryTransformType::RemoveCVRef:
10364 case UnaryTransformType::RemoveReference: {
10368 case UnaryTransformType::RemoveConst:
10369 case UnaryTransformType::RemoveCV:
10370 case UnaryTransformType::RemoveRestrict:
10371 case UnaryTransformType::RemoveVolatile: {
10375 case UnaryTransformType::MakeSigned:
10376 case UnaryTransformType::MakeUnsigned: {
10394 int DisallowedKind = -1;
10395 if (T->isArrayType())
10396 DisallowedKind = 1;
10397 else if (T->isFunctionType())
10398 DisallowedKind = 2;
10399 else if (T->isReferenceType())
10400 DisallowedKind = 3;
10401 else if (T->isAtomicType())
10402 DisallowedKind = 4;
10403 else if (T.hasQualifiers())
10404 DisallowedKind = 5;
10405 else if (T->isSizelessType())
10406 DisallowedKind = 6;
10409 DisallowedKind = 7;
10410 else if (T->isBitIntType())
10411 DisallowedKind = 8;
10414 DisallowedKind = 9;
10416 if (DisallowedKind != -1) {
10417 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;
10425 return Context.getAtomicType(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 QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType)
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 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 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)
static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, const ParsedAttributesView &Attrs)
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 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 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...
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
CanQualType UnsignedLongTy
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>.
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
SourceLocation getLAngleLoc() const
void setConceptReference(ConceptReference *CR)
NamedDecl * getFoundDecl() const
TemplateArgumentLoc getArgLoc(unsigned i) const
unsigned getNumArgs() const
TemplateDecl * getNamedConcept() 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)
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
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *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...
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
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
Expr * getPackIndexingExpr() const
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()
SourceLocation getEllipsisLoc() const
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
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 setNameLoc(SourceLocation Loc)
void setNameLoc(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...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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.
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.
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
void setEllipsisLoc(SourceLocation Loc)
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...
QualType getCanonicalType() 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.
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 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.
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.
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.
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
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 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.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const Decl *D, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, UnsignedOrNone NumLevels=std::nullopt, bool SkipInnerNonInstantiated=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
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 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)
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
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 AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
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 ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
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.
virtual size_t getMaxBitIntWidth() const
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
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 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 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.
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 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 isObjCObjectPointerType() 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.
void setNameLoc(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.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
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
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ 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)
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.
@ 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
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.
@ Type
The name was classified as a type.
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
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ NeonPoly
is ARM Neon polynomial vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ None
The alignment was not explicit in code.
@ 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
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.
NestedNameSpecifier Prefix
Describes how types, statements, expressions, and declarations should be printed.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ Memoization
Added for Template instantiation observation.
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.