44#include "llvm/ADT/ArrayRef.h"
45#include "llvm/ADT/STLForwardCompat.h"
46#include "llvm/ADT/StringExtras.h"
47#include "llvm/IR/DerivedTypes.h"
48#include "llvm/Support/ErrorHandling.h"
82 bool useExpansionLoc =
true;
83 switch (
attr.getKind()) {
84 case ParsedAttr::AT_ObjCGC:
87 case ParsedAttr::AT_ObjCOwnership:
93 useExpansionLoc =
false;
98 StringRef name =
attr.getAttrName()->getName();
102 attr.isArgIdent(0) ?
attr.getArgAsIdent(0)->getIdentifierInfo() :
nullptr;
103 if (useExpansionLoc && loc.
isMacroID() && II) {
104 if (II->
isStr(
"strong")) {
106 }
else if (II->
isStr(
"weak")) {
111 S.
Diag(loc,
attr.isRegularKeywordAttribute()
112 ? diag::err_type_attribute_wrong_type
113 : diag::warn_type_attribute_wrong_type)
114 << name << WhichType <<
type;
119#define OBJC_POINTER_TYPE_ATTRS_CASELIST \
120 case ParsedAttr::AT_ObjCGC: \
121 case ParsedAttr::AT_ObjCOwnership
124#define CALLING_CONV_ATTRS_CASELIST \
125 case ParsedAttr::AT_CDecl: \
126 case ParsedAttr::AT_FastCall: \
127 case ParsedAttr::AT_StdCall: \
128 case ParsedAttr::AT_ThisCall: \
129 case ParsedAttr::AT_RegCall: \
130 case ParsedAttr::AT_Pascal: \
131 case ParsedAttr::AT_SwiftCall: \
132 case ParsedAttr::AT_SwiftAsyncCall: \
133 case ParsedAttr::AT_VectorCall: \
134 case ParsedAttr::AT_AArch64VectorPcs: \
135 case ParsedAttr::AT_AArch64SVEPcs: \
136 case ParsedAttr::AT_MSABI: \
137 case ParsedAttr::AT_SysVABI: \
138 case ParsedAttr::AT_Pcs: \
139 case ParsedAttr::AT_IntelOclBicc: \
140 case ParsedAttr::AT_PreserveMost: \
141 case ParsedAttr::AT_PreserveAll: \
142 case ParsedAttr::AT_M68kRTD: \
143 case ParsedAttr::AT_PreserveNone: \
144 case ParsedAttr::AT_RISCVVectorCC: \
145 case ParsedAttr::AT_RISCVVLSCC
148#define FUNCTION_TYPE_ATTRS_CASELIST \
149 case ParsedAttr::AT_NSReturnsRetained: \
150 case ParsedAttr::AT_NoReturn: \
151 case ParsedAttr::AT_NonBlocking: \
152 case ParsedAttr::AT_NonAllocating: \
153 case ParsedAttr::AT_Blocking: \
154 case ParsedAttr::AT_Allocating: \
155 case ParsedAttr::AT_Regparm: \
156 case ParsedAttr::AT_CFIUncheckedCallee: \
157 case ParsedAttr::AT_CFISalt: \
158 case ParsedAttr::AT_CmseNSCall: \
159 case ParsedAttr::AT_ArmStreaming: \
160 case ParsedAttr::AT_ArmStreamingCompatible: \
161 case ParsedAttr::AT_ArmPreserves: \
162 case ParsedAttr::AT_ArmIn: \
163 case ParsedAttr::AT_ArmOut: \
164 case ParsedAttr::AT_ArmInOut: \
165 case ParsedAttr::AT_ArmAgnostic: \
166 case ParsedAttr::AT_AnyX86NoCallerSavedRegisters: \
167 case ParsedAttr::AT_AnyX86NoCfCheck: \
168 CALLING_CONV_ATTRS_CASELIST
171#define MS_TYPE_ATTRS_CASELIST \
172 case ParsedAttr::AT_Ptr32: \
173 case ParsedAttr::AT_Ptr64: \
174 case ParsedAttr::AT_SPtr: \
175 case ParsedAttr::AT_UPtr
178#define NULLABILITY_TYPE_ATTRS_CASELIST \
179 case ParsedAttr::AT_TypeNonNull: \
180 case ParsedAttr::AT_TypeNullable: \
181 case ParsedAttr::AT_TypeNullableResult: \
182 case ParsedAttr::AT_TypeNullUnspecified
187 class TypeProcessingState {
211 using TypeAttrPair = std::pair<const AttributedType*, const Attr*>;
213 bool AttrsForTypesSorted =
true;
217 llvm::DenseMap<const MacroQualifiedType *, SourceLocation> LocsForMacros;
225 bool ParsedHLSLParamMod;
229 :
sema(
sema), declarator(declarator),
231 ParsedHLSLParamMod(
false) {}
233 Sema &getSema()
const {
241 bool isProcessingDeclSpec()
const {
245 unsigned getCurrentChunkIndex()
const {
249 void setCurrentChunkIndex(
unsigned idx) {
255 if (isProcessingDeclSpec())
256 return getMutableDeclSpec().getAttributes();
261 void saveDeclSpecAttrs() {
263 if (!savedAttrs.empty())
266 DeclSpec &spec = getMutableDeclSpec();
267 llvm::append_range(savedAttrs,
274 ignoredTypeAttrs.push_back(&
attr);
280 for (
auto *
Attr : ignoredTypeAttrs)
289 sema.Context.getAttributedType(A, ModifiedType, EquivType);
291 AttrsForTypesSorted =
false;
296 QualType getBTFTagAttributedType(
const BTFTypeTagAttr *BTFAttr,
298 return sema.Context.getBTFTagAttributedType(BTFAttr, WrappedType);
304 getOverflowBehaviorType(OverflowBehaviorType::OverflowBehaviorKind Kind,
306 return sema.Context.getOverflowBehaviorType(Kind, UnderlyingType);
313 QualType T =
sema.ReplaceAutoType(TypeWithAuto, Replacement);
314 if (
auto *AttrTy = TypeWithAuto->
getAs<AttributedType>()) {
317 for (TypeAttrPair &A : AttrsForTypes) {
318 if (A.first == AttrTy)
321 AttrsForTypesSorted =
false;
327 const Attr *takeAttrForAttributedType(
const AttributedType *AT) {
328 if (!AttrsForTypesSorted) {
329 llvm::stable_sort(AttrsForTypes, llvm::less_first());
330 AttrsForTypesSorted =
true;
335 for (
auto It = llvm::partition_point(
337 [=](
const TypeAttrPair &A) {
return A.first < AT; });
338 It != AttrsForTypes.end() && It->first == AT; ++It) {
341 It->second =
nullptr;
355 auto FoundLoc = LocsForMacros.find(MQT);
356 assert(FoundLoc != LocsForMacros.end() &&
357 "Unable to find macro expansion location for MacroQualifedType");
358 return FoundLoc->second;
363 LocsForMacros[MQT] = Loc;
366 void setParsedNoDeref(
bool parsed) { parsedNoDeref = parsed; }
368 bool didParseNoDeref()
const {
return parsedNoDeref; }
370 void setParsedHLSLParamMod(
bool Parsed) { ParsedHLSLParamMod = Parsed; }
372 bool didParseHLSLParamMod()
const {
return ParsedHLSLParamMod; }
374 ~TypeProcessingState() {
375 if (savedAttrs.empty())
378 getMutableDeclSpec().getAttributes().clearListOnly();
380 getMutableDeclSpec().getAttributes().addAtEnd(AL);
384 DeclSpec &getMutableDeclSpec()
const {
426 if (
attr.getKind() == ParsedAttr::AT_ObjCGC)
428 assert(
attr.getKind() == ParsedAttr::AT_ObjCOwnership);
443 bool onlyBlockPointers) {
449 for (; i != 0; --i) {
451 switch (fnChunk.
Kind) {
467 for (--i; i != 0; --i) {
469 switch (ptrChunk.
Kind) {
479 if (onlyBlockPointers)
488 llvm_unreachable(
"bad declarator chunk kind");
494 llvm_unreachable(
"bad declarator chunk kind");
511 Declarator &declarator = state.getDeclarator();
514 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
516 switch (chunk.
Kind) {
522 if (state.isProcessingDeclSpec() &&
523 attr.getKind() == ParsedAttr::AT_ObjCOwnership)
526 if (!destChunk) destChunk = &chunk;
539 if (state.isProcessingDeclSpec() &&
540 attr.getKind() == ParsedAttr::AT_ObjCOwnership) {
567 Declarator &declarator = state.getDeclarator();
571 unsigned innermost = -1U;
572 bool considerDeclSpec =
true;
575 switch (chunk.
Kind) {
589 considerDeclSpec =
false;
597 if (considerDeclSpec) {
602 state.saveDeclSpecAttrs();
611 if (innermost != -1U) {
619 state.addIgnoredTypeAttr(
attr);
628 Declarator &declarator = state.getDeclarator();
632 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
634 switch (chunk.
Kind) {
661 Declarator &declarator = state.getDeclarator();
681 state.saveDeclSpecAttrs();
685 state,
attr, state.getCurrentAttributes(), declSpecType, CFT))
690 state.addIgnoredTypeAttr(
attr);
701 Declarator &declarator = state.getDeclarator();
711 state.addIgnoredTypeAttr(
attr);
736 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute())
739 switch (
attr.getKind()) {
756 case ParsedAttr::AT_ObjCKindOf:
769 Declarator &declarator = state.getDeclarator();
815 {}, loc, loc, declarator));
830 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
835 if (!(RemoveTQs & Qual.first))
839 if (TypeQuals & Qual.first)
840 S.
Diag(Qual.second, DiagID)
845 TypeQuals &= ~Qual.first;
859 if (AL.isInvalid() || !AL.isTypeAttr())
862 diag::warn_block_literal_attributes_on_omitted_return_type)
864 ToBeRemoved.push_back(&AL);
874 diag::warn_block_literal_qualifiers_on_omitted_return_type);
880static OpenCLAccessAttr::Spelling
883 if (AL.getKind() == ParsedAttr::AT_OpenCLAccess)
884 return static_cast<OpenCLAccessAttr::Spelling
>(AL.getSemanticSpelling());
885 return OpenCLAccessAttr::Keyword_read_only;
888static UnaryTransformType::UTTKind
891#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
893 return UnaryTransformType::Enum;
894#include "clang/Basic/BuiltinTraits.inc"
896 llvm_unreachable(
"attempted to parse a non-unary transform builtin");
910 Sema &S = state.getSema();
911 Declarator &declarator = state.getDeclarator();
928 Result = Context.SignedCharTy;
931 "Unknown TSS value");
932 Result = Context.UnsignedCharTy;
941 Context.getPrintingPolicy());
942 Result = Context.getSignedWCharType();
945 "Unknown TSS value");
948 Context.getPrintingPolicy());
949 Result = Context.getUnsignedWCharType();
954 "Unknown TSS value");
959 "Unknown TSS value");
960 Result = Context.Char16Ty;
964 "Unknown TSS value");
965 Result = Context.Char32Ty;
975 Result = Context.getAutoDeductType();
979 Context.DependentTy)) {
980 Result = Context.DependentTy;
996 S.
Diag(DeclLoc, diag::warn_missing_type_specifier)
1007 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1018 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1024 "implicit int is disabled?");
1025 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1039 Result = Context.ShortTy;
1045 Result = Context.LongLongTy;
1055 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1064 Result = Context.UnsignedIntTy;
1067 Result = Context.UnsignedShortTy;
1070 Result = Context.UnsignedLongTy;
1073 Result = Context.UnsignedLongLongTy;
1083 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1107 Result = Context.ShortAccumTy;
1110 Result = Context.AccumTy;
1113 Result = Context.LongAccumTy;
1116 llvm_unreachable(
"Unable to specify long long as _Accum width");
1123 Result = Context.getCorrespondingSaturatedType(
Result);
1130 Result = Context.ShortFractTy;
1133 Result = Context.FractTy;
1136 Result = Context.LongFractTy;
1139 llvm_unreachable(
"Unable to specify long long as _Fract width");
1146 Result = Context.getCorrespondingSaturatedType(
Result);
1156 Result = Context.UnsignedInt128Ty;
1158 Result = Context.Int128Ty;
1168 Result = Context.Float16Ty;
1176 Result = Context.BFloat16Ty;
1181 Result = Context.LongDoubleTy;
1183 Result = Context.DoubleTy;
1188 << (S.
getLangOpts().getOpenCLCompatibleVersion() >= 300
1189 ?
"cl_khr_fp64 and __opencl_c_fp64"
1200 Result = Context.Float128Ty;
1207 Result = Context.Ibm128Ty;
1238 "No qualifiers on tag names!");
1251 "Can't handle qualifiers on typedef names yet!");
1264 assert(!
Result.isNull() &&
"Didn't get a type for typeof?");
1265 if (!
Result->isDependentType())
1266 if (
const auto *TT =
Result->getAs<TagType>())
1269 Result = Context.getTypeOfType(
1277 assert(E &&
"Didn't get an expression for typeof?");
1291 assert(E &&
"Didn't get an expression for decltype?");
1309#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
1310#include "clang/Basic/BuiltinTraits.inc"
1312 assert(!
Result.isNull() &&
"Didn't get a type for the transformation?");
1332 TypeConstraintConcept = TemplateId->
Template.get();
1337 TemplateId->NumArgs);
1339 for (
const auto &ArgLoc : TemplateArgsInfo.
arguments())
1340 TemplateArgs.push_back(ArgLoc.getArgument());
1346 TypeConstraintConcept, TemplateArgs);
1356 Result = Context.UnknownAnyTy;
1361 assert(!
Result.isNull() &&
"Didn't get a type for _Atomic?");
1369#define GENERIC_IMAGE_TYPE(ImgType, Id) \
1370 case DeclSpec::TST_##ImgType##_t: \
1371 switch (getImageAccess(DS.getAttributes())) { \
1372 case OpenCLAccessAttr::Keyword_write_only: \
1373 Result = Context.Id##WOTy; \
1375 case OpenCLAccessAttr::Keyword_read_write: \
1376 Result = Context.Id##RWTy; \
1378 case OpenCLAccessAttr::Keyword_read_only: \
1379 Result = Context.Id##ROTy; \
1381 case OpenCLAccessAttr::SpellingNotCalculated: \
1382 llvm_unreachable("Spelling not yet calculated"); \
1385#include "clang/Basic/OpenCLImageTypes.def"
1387#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1388 case DeclSpec::TST_##Name: \
1389 Result = Context.SingletonId; \
1391#include "clang/Basic/HLSLIntangibleTypes.def"
1393#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1394 case DeclSpec::TST_##Name: \
1395 Result = Context.SingletonId; \
1397#include "clang/Basic/HLSLPackedTypes.def"
1408 if (
Result->containsErrors())
1413 bool IsOpenCLC30Compatible =
1423 (IsOpenCLC30Compatible &&
1426 << 0 <<
Result <<
"__opencl_c_images";
1428 }
else if (
Result->isOCLImage3dWOType() &&
1433 << (IsOpenCLC30Compatible
1434 ?
"cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
1435 :
"cl_khr_3d_image_writes");
1447 Context.getPrintingPolicy());
1455 unsigned typeSize =
static_cast<unsigned>(Context.getTypeSize(
Result));
1456 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1462 Result = Context.getVectorType(
Result, 128/typeSize, VecKind);
1487 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
1498 if (AL.isStandardAttributeSyntax() && AL.isClangScope() &&
1499 !(AL.getKind() == ParsedAttr::AT_MatrixType &&
1501 S.
Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl)
1529 if (
Result->isFunctionType()) {
1530 unsigned DiagId = diag::warn_typecheck_function_qualifiers_ignored;
1532 DiagId = diag::ext_typecheck_function_qualifiers_unspecified;
1548 if (TypeQuals &&
Result->isReferenceType()) {
1550 S, DS, TypeQuals,
Result,
1552 diag::warn_typecheck_reference_qualifiers);
1559 && TypeQuals &
Result.getCVRQualifiers()) {
1586 if (
Result->isAtomicType()) {
1588 StringRef SpecifierName =
1590 S.
Diag(Loc, diag::err_overflow_behavior_atomic_type)
1591 << SpecifierName <<
Result.getAsString() << 1;
1592 }
else if (!
Result->isIntegerType()) {
1594 StringRef SpecifierName =
1596 S.
Diag(Loc, diag::err_overflow_behavior_non_integer_type)
1597 << SpecifierName <<
Result.getAsString() << 1;
1599 OverflowBehaviorType::OverflowBehaviorKind Kind =
1601 ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
1602 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
1610 assert(!
Result.isNull() &&
"This function should not return a null type");
1627 if (
T->isReferenceType()) {
1635 unsigned DiagID = 0;
1649 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1654 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1660 Diag(Loc, DiagID) << EltTy;
1663 if (
T->isArrayType())
1664 DiagCompat(Loc, diag_compat::restrict_on_array_of_pointers);
1668 return Context.getQualifiedType(
T, Qs);
1672 unsigned CVRAU,
const DeclSpec *DS) {
1677 if (
T->isReferenceType())
1706 Split.Quals.addCVRQualifiers(CVR);
1724 if (!
type->isObjCLifetimeType() ||
1734 if (
type.isConstQualified()) {
1740 }
else if (
type->isObjCARCImplicitlyUnretainedType()) {
1758 diag::err_arc_indirect_no_ownership,
type, isReference));
1760 S.
Diag(loc, diag::err_arc_indirect_no_ownership) <<
type << isReference;
1764 assert(implicitLifetime &&
"didn't infer any lifetime!");
1805enum QualifiedFunctionKind { QFK_BlockPointer, QFK_Pointer, QFK_Reference };
1811 QualifiedFunctionKind QFK) {
1818 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1819 << QFK << isa<FunctionType>(
T.IgnoreParens()) <<
T
1830 Diag(Loc, diag::err_qualified_function_typeid)
1847 if (
T->isReferenceType()) {
1849 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1857 Diag(Loc, diag::err_opencl_function_pointer) << 0;
1862 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
1869 if (
T->isObjCObjectType())
1870 return Context.getObjCObjectPointerType(
T);
1882 if (
T.isWebAssemblyReferenceType()) {
1883 Diag(Loc, diag::err_wasm_reference_pr) << 0;
1888 if (
T->getUnqualifiedDesugaredType()->isWebAssemblyTableType()) {
1889 Diag(Loc, diag::err_wasm_table_pr) << 0;
1902 "Unresolved overloaded function type");
1929 if (
T->isVoidType()) {
1930 Diag(Loc, diag::err_reference_to_void);
1935 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
1945 Diag(Loc, diag::err_opencl_function_pointer) << 1;
1958 T.isWebAssemblyReferenceType()) {
1959 Diag(Loc, diag::err_wasm_reference_pr) << 1;
1962 if (
T->isWebAssemblyTableType()) {
1963 Diag(Loc, diag::err_wasm_table_pr) << 1;
1969 return Context.getLValueReferenceType(
T, SpelledAsLValue);
1970 return Context.getRValueReferenceType(
T);
1978 return Context.getWritePipeType(
T);
1984 return Context.getDependentBitIntType(IsUnsigned, BitWidth);
1986 llvm::APSInt Bits(32);
1993 size_t NumBits = Bits.getZExtValue();
1994 if (!IsUnsigned && NumBits < 2) {
1995 Diag(Loc, diag::err_bit_int_bad_size) << 0;
1999 if (IsUnsigned && NumBits < 1) {
2000 Diag(Loc, diag::err_bit_int_bad_size) << 1;
2006 Diag(Loc, diag::err_bit_int_max_size)
2011 return Context.getBitIntType(IsUnsigned, NumBits);
2020 llvm::APSInt &SizeVal,
unsigned VLADiag,
2045 VLADiagnoser(
unsigned VLADiag,
bool VLAIsError)
2046 : VLADiag(VLADiag), VLAIsError(VLAIsError) {}
2050 return S.
Diag(Loc, diag::err_array_size_non_int) <<
T;
2055 IsVLA = !VLAIsError;
2056 return S.
Diag(Loc, VLADiag);
2061 return S.
Diag(Loc, diag::ext_vla_folded_to_constant);
2063 } Diagnoser(VLADiag, VLAIsError);
2067 if (Diagnoser.IsVLA)
2073 EltTy =
Context.getBaseElementType(EltTy);
2081 if (Size.isMultipleOf(Alignment))
2084 Diag(Loc, diag::err_array_element_alignment)
2085 << EltTy << Size.getQuantity() << Alignment.
getQuantity();
2090 const llvm::APSInt &NumElements,
2092 unsigned ActiveSizeBits = NumElements.getActiveBits();
2093 if (!ElementType->isDependentType() && !ElementType->isIncompleteType() &&
2094 !ElementType->isUndeducedType() && ElementType->isConstantSizeType())
2097 Context, ElementType, NumElements));
2101 Diag(Loc, diag::err_array_too_large)
2102 <<
toString(NumElements, 10, NumElements.isSigned(),
2110 Expr *ArraySize,
unsigned Quals,
2129 if (
T->isReferenceType()) {
2130 Diag(Loc, diag::err_illegal_decl_array_of_references)
2135 if (
T->isVoidType() ||
T->isIncompleteArrayType()) {
2136 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 <<
T;
2141 diag::err_array_of_abstract_type))
2146 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
2148 if (!MPTy->getQualifier().isDependent())
2154 if (!
T.isWebAssemblyReferenceType() &&
2156 diag::err_array_incomplete_or_sizeless_type))
2161 if (
Context.getTargetInfo().getTriple().isWasm() &&
T->isArrayType()) {
2162 const auto *ATy = dyn_cast<ArrayType>(
T);
2163 if (ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
2164 Diag(Loc, diag::err_wasm_reftype_multidimensional_array);
2169 if (
T->isSizelessType() && !
T.isWebAssemblyReferenceType()) {
2170 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 1 <<
T;
2174 if (
T->isFunctionType()) {
2175 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2180 if (
const auto *RD =
T->getAsRecordDecl()) {
2183 if (RD->hasFlexibleArrayMember())
2184 Diag(Loc, diag::ext_flexible_array_in_array) <<
T;
2185 }
else if (
T->isObjCObjectType()) {
2186 Diag(Loc, diag::err_objc_array_of_interfaces) <<
T;
2197 ArraySize =
Result.get();
2201 if (ArraySize && !ArraySize->
isPRValue()) {
2206 ArraySize =
Result.get();
2229 if (
const auto *CondExpr = dyn_cast_if_present<ConditionalOperator>(
2231 std::optional<llvm::APSInt> LHS =
2232 CondExpr->getLHS()->getIntegerConstantExpr(
Context);
2233 std::optional<llvm::APSInt> RHS =
2234 CondExpr->getRHS()->getIntegerConstantExpr(
Context);
2235 return LHS && RHS && LHS->isNegative() != RHS->isNegative();
2245 VLADiag = diag::err_opencl_vla;
2248 VLADiag = diag::warn_vla_used;
2251 VLADiag = diag::err_vla_in_sfinae;
2254 VLADiag = diag::err_openmp_vla_in_task_untied;
2259 ? diag::ext_vla_cxx_in_gnu_mode_static_assert
2260 : diag::ext_vla_cxx_static_assert;
2262 VLADiag =
getLangOpts().GNUMode ? diag::ext_vla_cxx_in_gnu_mode
2263 : diag::ext_vla_cxx;
2266 VLADiag = diag::ext_vla;
2270 llvm::APSInt ConstVal(
Context.getTypeSize(
Context.getSizeType()));
2277 T =
Context.getVariableArrayType(
T,
nullptr, ASM, IndexTypeQuals);
2279 T =
Context.getIncompleteArrayType(
T, ASM, IndexTypeQuals);
2282 T =
Context.getDependentSizedArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2289 if (!R.isUsable()) {
2293 T =
Context.getVariableArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2294 }
else if (!
T->isDependentType() && !
T->isIncompleteType() &&
2295 !
T->isConstantSizeType()) {
2302 T =
Context.getVariableArrayType(
T, ArraySize, ASM, IndexTypeQuals);
2307 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2314 diag::err_typecheck_negative_array_size)
2318 if (ConstVal == 0 && !
T.isWebAssemblyReferenceType()) {
2329 : diag::ext_typecheck_zero_array_size)
2339 T =
Context.getConstantArrayType(
T, ConstVal, ArraySize, ASM,
2344 if (
T->isVariableArrayType()) {
2345 if (!
Context.getTargetInfo().isVLASupported()) {
2349 IsCUDADevice ? diag::err_cuda_vla : diag::err_vla_unsupported)
2350 << (IsCUDADevice ? llvm::to_underlying(
CUDA().CurrentTarget()) : 0);
2354 FSI->setHasVLA(Loc);
2362 : diag::ext_c99_array_usage)
2373 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2383 bool ForMatrixType =
false) {
2386 if (!llvm::isPowerOf2_32(NumBits))
2387 return S.
Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
2407 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
2416 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2419 std::optional<llvm::APSInt> VecSize =
2422 Diag(AttrLoc, diag::err_attribute_argument_type)
2428 if (VecSize->isNegative()) {
2429 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2434 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
2439 Diag(AttrLoc, diag::err_attribute_size_too_large)
2443 uint64_t VectorSizeBits = VecSize->getZExtValue() * 8;
2444 unsigned TypeSize =
static_cast<unsigned>(
Context.getTypeSize(CurType));
2446 if (VectorSizeBits == 0) {
2447 Diag(AttrLoc, diag::err_attribute_zero_size)
2452 if (!TypeSize || VectorSizeBits % TypeSize) {
2453 Diag(AttrLoc, diag::err_attribute_invalid_size)
2459 Diag(AttrLoc, diag::err_attribute_size_too_large)
2464 return Context.getVectorType(CurType, VectorSizeBits / TypeSize,
2480 if ((!
T->isDependentType() && !
T->isIntegerType() &&
2481 !
T->isRealFloatingType()) ||
2482 T->isEnumeralType() || (IsNoBoolVecLang &&
T->isBooleanType())) {
2483 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) <<
T;
2492 std::optional<llvm::APSInt> VecSize =
2495 Diag(AttrLoc, diag::err_attribute_argument_type)
2501 if (VecSize->isNegative()) {
2502 Diag(SizeExpr->
getExprLoc(), diag::err_attribute_vec_negative_size);
2509 Diag(AttrLoc, diag::err_attribute_size_too_large)
2513 unsigned VectorSize =
static_cast<unsigned>(VecSize->getZExtValue());
2515 if (VectorSize == 0) {
2516 Diag(AttrLoc, diag::err_attribute_zero_size)
2521 if (!
T->isDependentType() &&
2523 Diag(AttrLoc, diag::err_attribute_size_too_large)
2528 return Context.getExtVectorType(
T, VectorSize);
2531 return Context.getDependentSizedExtVectorType(
T, SizeExpr, AttrLoc);
2536 assert(
Context.getLangOpts().MatrixTypes &&
2537 "Should never build a matrix type when it is disabled");
2542 Diag(AttrLoc, diag::err_attribute_invalid_matrix_type) << ElementTy;
2553 return Context.getDependentSizedMatrixType(ElementTy, NumRows, NumCols,
2556 std::optional<llvm::APSInt> ValueRows =
2558 std::optional<llvm::APSInt> ValueColumns =
2565 if (!ValueRows && !ValueColumns) {
2566 Diag(AttrLoc, diag::err_attribute_argument_type)
2574 Diag(AttrLoc, diag::err_attribute_argument_type)
2580 if (!ValueColumns) {
2581 Diag(AttrLoc, diag::err_attribute_argument_type)
2587 unsigned MatrixRows =
static_cast<unsigned>(ValueRows->getZExtValue());
2588 unsigned MatrixColumns =
static_cast<unsigned>(ValueColumns->getZExtValue());
2589 if (MatrixRows == 0 && MatrixColumns == 0) {
2590 Diag(AttrLoc, diag::err_attribute_zero_size)
2591 <<
"matrix" << RowRange << ColRange;
2594 if (MatrixRows == 0) {
2595 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << RowRange;
2598 if (MatrixColumns == 0) {
2599 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << ColRange;
2602 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension &&
2603 MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2604 Diag(AttrLoc, diag::err_attribute_size_too_large)
2605 << RowRange << ColRange <<
"matrix row and column";
2608 if (MatrixRows >
Context.getLangOpts().MaxMatrixDimension) {
2609 Diag(AttrLoc, diag::err_attribute_size_too_large)
2610 << RowRange <<
"matrix row";
2613 if (MatrixColumns >
Context.getLangOpts().MaxMatrixDimension) {
2614 Diag(AttrLoc, diag::err_attribute_size_too_large)
2615 << ColRange <<
"matrix column";
2618 return Context.getConstantMatrixType(ElementTy, MatrixRows, MatrixColumns);
2622 if ((
T->isArrayType() && !
getLangOpts().allowArrayReturnTypes()) ||
2623 T->isFunctionType()) {
2624 Diag(Loc, diag::err_func_returning_array_function)
2625 <<
T->isFunctionType() <<
T;
2630 if (
T->isHalfType() && !
getLangOpts().NativeHalfArgsAndReturns &&
2631 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2632 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2639 if (
T->isObjCObjectType()) {
2640 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
2646 if (
T.getPointerAuth()) {
2647 Diag(Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 0;
2651 if (
T.hasNonTrivialToPrimitiveDestructCUnion() ||
2652 T.hasNonTrivialToPrimitiveCopyCUnion())
2659 Diag(Loc, diag::warn_deprecated_volatile_return) <<
T;
2674 bool emittedError =
false;
2676 enum class RequiredCC { OnlySwift, SwiftOrSwiftAsync };
2677 auto checkCompatible = [&](
unsigned paramIndex, RequiredCC required) {
2679 (required == RequiredCC::OnlySwift)
2682 if (isCompatible || emittedError)
2684 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
2686 << (required == RequiredCC::OnlySwift);
2687 emittedError =
true;
2689 for (
size_t paramIndex = 0, numParams = paramTypes.size();
2690 paramIndex != numParams; ++paramIndex) {
2701 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2702 if (paramIndex != 0 &&
2705 S.
Diag(getParamLoc(paramIndex),
2706 diag::err_swift_indirect_result_not_first);
2711 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
2720 checkCompatible(paramIndex, RequiredCC::OnlySwift);
2721 if (paramIndex == 0 ||
2724 S.
Diag(getParamLoc(paramIndex),
2725 diag::err_swift_error_result_not_after_swift_context);
2729 llvm_unreachable(
"bad ABI kind");
2741 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2743 QualType ParamType =
Context.getAdjustedParameterType(ParamTypes[Idx]);
2745 Diag(Loc, diag::err_param_with_void_type);
2748 !
Context.getTargetInfo().allowHalfArgsAndReturns()) {
2750 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2754 Diag(Loc, diag::err_wasm_table_as_function_parameter);
2758 Diag(Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 1;
2765 Diag(Loc, diag::warn_deprecated_volatile_param) << ParamType;
2767 ParamTypes[Idx] = ParamType;
2772 [=](
unsigned i) {
return Loc; });
2783 return Context.getFunctionType(
T, ParamTypes, EPI);
2798 D <<
"member pointer";
2806 Diag(Loc, diag::err_distant_exception_spec);
2812 if (
T->isReferenceType()) {
2813 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2818 if (
T->isVoidType()) {
2819 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2827 Diag(Loc, diag::err_opencl_function_pointer) << 0;
2832 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
2841 if (
T->isFunctionType())
2850 if (!
T->isFunctionType()) {
2851 Diag(Loc, diag::err_nonfunction_block_type);
2861 return Context.getBlockPointerType(
T);
2867 if (TInfo) *TInfo =
nullptr;
2872 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2873 QT = LIT->getType();
2874 TSI = LIT->getTypeSourceInfo();
2884 unsigned chunkIndex);
2891 Sema &S = state.getSema();
2892 Declarator &declarator = state.getDeclarator();
2898 unsigned outermostPointerIndex = 0;
2900 unsigned numPointers = 0;
2902 unsigned chunkIndex = i;
2904 switch (chunk.
Kind) {
2914 outermostPointerIndex = chunkIndex;
2922 if (numPointers != 1)
return;
2924 outermostPointerIndex = chunkIndex;
2942 if (numPointers == 1) {
2960 }
else if (numPointers == 2) {
2973 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership)
2977 outermostPointerIndex);
2999 }
const QualKinds[5] = {
3013 for (
auto &E : QualKinds) {
3014 if (Quals & E.Mask) {
3015 if (!QualStr.empty()) QualStr +=
' ';
3032 << QualStr <<
NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
3038 unsigned FunctionChunkIndex) {
3048 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
3050 OuterChunkIndex != End; ++OuterChunkIndex) {
3052 switch (OuterChunk.
Kind) {
3059 diag::warn_qual_return_type,
3085 llvm_unreachable(
"unknown declarator chunk kind");
3106static std::pair<QualType, TypeSourceInfo *>
3110 Sema &S = state.getSema();
3114 const unsigned AutoParameterPosition = Info.
TemplateParams.size();
3127 AutoParameterPosition,
3129 AutoParameterPosition),
3130 false, IsParameterPack,
3131 Auto->isConstrained());
3136 if (
Auto->isConstrained()) {
3143 for (
unsigned Idx = 0; Idx < AutoLoc.
getNumArgs(); ++Idx) {
3203 QualType NewT = state.ReplaceAutoType(
T, Replacement);
3207 return {NewT, NewTSI};
3216 Sema &SemaRef = state.getSema();
3219 ReturnTypeInfo =
nullptr;
3222 TagDecl *OwnedTagDecl =
nullptr;
3272 DeducedType *
Deduced =
T->getContainedDeducedType();
3273 bool DeducedIsTrailingReturnType =
false;
3277 DeducedIsTrailingReturnType =
true;
3287 bool IsCXXAutoType =
3289 bool IsDeducedReturnType =
false;
3339 assert(Info &&
"No LambdaScopeInfo on the stack!");
3345 if (!DeducedIsTrailingReturnType)
3358 llvm_unreachable(
"unhandled tag kind");
3360 Error = Cxx ? 1 : 2;
3363 Error = Cxx ? 3 : 4;
3408 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3410 IsDeducedReturnType =
true;
3413 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3415 IsDeducedReturnType =
true;
3420 if (IsCXXAutoType && !
Auto->isDecltypeAuto())
3453 (!SemaRef.
getLangOpts().CPlusPlus11 || !IsCXXAutoType))
3459 switch (
Auto->getKeyword()) {
3466 "unknown auto type");
3470 auto *DTST = dyn_cast<DeducedTemplateSpecializationType>(
Deduced);
3473 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
3486 unsigned DiagId = 0;
3488 DiagId = diag::warn_cxx11_compat_generic_lambda;
3489 else if (IsDeducedReturnType)
3490 DiagId = diag::warn_cxx11_compat_deduced_return_type;
3492 DiagId = diag::warn_cxx98_compat_auto_type_specifier;
3495 SemaRef.
Diag(AutoRange.
getBegin(), DiagId) << AutoRange;
3503 unsigned DiagID = 0;
3509 llvm_unreachable(
"parser should not have allowed this");
3525 DiagID = diag::err_type_defined_in_alias_template;
3537 DiagID = diag::err_type_defined_in_type_specifier;
3547 DiagID = diag::err_type_defined_in_param_type;
3553 DiagID = diag::err_type_defined_in_condition;
3564 assert(!
T.isNull() &&
"This function should not return a null type");
3573 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3603 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3604 : diag::warn_empty_parens_are_function_decl)
3615 if (Comma.getFileID() != Name.
getFileID() ||
3623 Result.suppressDiagnostics();
3636 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3651 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
3659 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
3670 "do not have redundant top-level parentheses");
3679 bool CouldBeTemporaryObject =
3683 (
T->isRecordType() ||
T->isDependentType()) &&
3686 bool StartsWithDeclaratorId =
true;
3694 StartsWithDeclaratorId =
false;
3699 CouldBeTemporaryObject =
false;
3707 CouldBeTemporaryObject =
false;
3708 StartsWithDeclaratorId =
false;
3718 CouldBeTemporaryObject =
false;
3725 CouldBeTemporaryObject =
false;
3726 StartsWithDeclaratorId =
false;
3736 if (CouldBeTemporaryObject) {
3740 CouldBeTemporaryObject =
false;
3741 Result.suppressDiagnostics();
3746 if (!CouldBeTemporaryObject) {
3770 S.
Diag(
Paren.Loc, diag::warn_redundant_parens_around_declarator)
3776 S.
Diag(
Paren.Loc, diag::warn_parens_disambiguated_as_variable_declaration)
3778 auto *RD =
T->getAsCXXRecordDecl();
3779 if (!RD || !RD->hasDefinition() || RD->hasNonTrivialDestructor())
3780 S.
Diag(
Paren.Loc, diag::note_raii_guard_add_name)
3785 S.
Diag(D.
getBeginLoc(), diag::note_function_style_cast_add_parentheses)
3788 S.
Diag(
Paren.Loc, diag::note_remove_parens_for_variable_declaration)
3804 switch (AL.getKind()) {
3823 bool IsCXXInstanceMethod =
false;
3829 unsigned I = ChunkIndex;
3830 bool FoundNonParen =
false;
3831 while (I && !FoundNonParen) {
3834 FoundNonParen =
true;
3837 if (FoundNonParen) {
3840 IsCXXInstanceMethod =
3845 IsCXXInstanceMethod =
3853 IsCXXInstanceMethod =
3861 IsCXXInstanceMethod);
3869 if (Triple.isSPIRV() && Triple.getVendor() != llvm::Triple::AMD) {
3871 if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
3879 for (
const ParsedAttr &AL : llvm::concat<ParsedAttr>(
3882 if (AL.getKind() == ParsedAttr::AT_DeviceKernel) {
3893 enum class SimplePointerKind {
3902 switch (nullability) {
3904 if (!Ident__Nonnull)
3905 Ident__Nonnull =
PP.getIdentifierInfo(
"_Nonnull");
3906 return Ident__Nonnull;
3909 if (!Ident__Nullable)
3910 Ident__Nullable =
PP.getIdentifierInfo(
"_Nullable");
3911 return Ident__Nullable;
3914 if (!Ident__Nullable_result)
3915 Ident__Nullable_result =
PP.getIdentifierInfo(
"_Nullable_result");
3916 return Ident__Nullable_result;
3919 if (!Ident__Null_unspecified)
3920 Ident__Null_unspecified =
PP.getIdentifierInfo(
"_Null_unspecified");
3921 return Ident__Null_unspecified;
3923 llvm_unreachable(
"Unknown nullability kind.");
3930 if (AL.getKind() == ParsedAttr::AT_TypeNonNull ||
3931 AL.getKind() == ParsedAttr::AT_TypeNullable ||
3932 AL.getKind() == ParsedAttr::AT_TypeNullableResult ||
3933 AL.getKind() == ParsedAttr::AT_TypeNullUnspecified)
3942 enum class PointerDeclaratorKind {
3950 MaybePointerToCFRef,
3954 NSErrorPointerPointer,
3960 enum class PointerWrappingDeclaratorKind {
3974static PointerDeclaratorKind
3976 PointerWrappingDeclaratorKind &wrappingKind) {
3977 unsigned numNormalPointers = 0;
3980 if (
type->isDependentType())
3981 return PointerDeclaratorKind::NonPointer;
3986 switch (chunk.
Kind) {
3988 if (numNormalPointers == 0)
3989 wrappingKind = PointerWrappingDeclaratorKind::Array;
3998 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3999 : PointerDeclaratorKind::SingleLevelPointer;
4005 if (numNormalPointers == 0)
4006 wrappingKind = PointerWrappingDeclaratorKind::Reference;
4010 ++numNormalPointers;
4011 if (numNormalPointers > 2)
4012 return PointerDeclaratorKind::MultiLevelPointer;
4018 unsigned numTypeSpecifierPointers = 0;
4022 ++numNormalPointers;
4024 if (numNormalPointers > 2)
4025 return PointerDeclaratorKind::MultiLevelPointer;
4027 type = ptrType->getPointeeType();
4028 ++numTypeSpecifierPointers;
4034 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4035 : PointerDeclaratorKind::SingleLevelPointer;
4040 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4041 : PointerDeclaratorKind::SingleLevelPointer;
4046 ++numNormalPointers;
4047 ++numTypeSpecifierPointers;
4050 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
4052 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
4053 return PointerDeclaratorKind::NSErrorPointerPointer;
4062 if (objcClass->getInterface()->getIdentifier() ==
4064 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
4065 return PointerDeclaratorKind::NSErrorPointerPointer;
4072 if (numNormalPointers == 0)
4073 return PointerDeclaratorKind::NonPointer;
4077 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2 &&
4079 return PointerDeclaratorKind::CFErrorRefPointer;
4087 switch (numNormalPointers) {
4089 return PointerDeclaratorKind::NonPointer;
4092 return PointerDeclaratorKind::SingleLevelPointer;
4095 return PointerDeclaratorKind::MaybePointerToCFRef;
4098 return PointerDeclaratorKind::MultiLevelPointer;
4107 if (ctx->isFunctionOrMethod())
4110 if (ctx->isFileContext())
4121 bool invalid =
false;
4123 if (invalid || !sloc.
isFile())
4141template <
typename DiagBuilderT>
4150 if (!FixItLoc.
isValid() || FixItLoc == PointerLoc)
4159 InsertionTextBuf +=
" ";
4160 StringRef InsertionText = InsertionTextBuf.str();
4163 InsertionText = InsertionText.drop_back();
4164 }
else if (NextChar[-1] ==
'[') {
4165 if (NextChar[0] ==
']')
4166 InsertionText = InsertionText.drop_back().drop_front();
4168 InsertionText = InsertionText.drop_front();
4171 InsertionText = InsertionText.drop_back().drop_front();
4178 SimplePointerKind PointerKind,
4183 if (PointerKind == SimplePointerKind::Array) {
4184 S.
Diag(PointerLoc, diag::warn_nullability_missing_array);
4186 S.
Diag(PointerLoc, diag::warn_nullability_missing)
4187 <<
static_cast<unsigned>(PointerKind);
4190 auto FixItLoc = PointerEndLoc.
isValid() ? PointerEndLoc : PointerLoc;
4191 if (FixItLoc.isMacroID())
4195 auto Diag = S.
Diag(FixItLoc, diag::note_nullability_fix_it);
4226 if (pointerKind == SimplePointerKind::Array)
4227 diagKind = diag::warn_nullability_missing_array;
4229 diagKind = diag::warn_nullability_missing;
4235 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
4267 auto kind =
static_cast<SimplePointerKind
>(fileNullability.
PointerKind);
4282 unsigned i = endIndex;
4310template<
typename AttrT>
4313 return ::new (Ctx) AttrT(Ctx, AL);
4331 llvm_unreachable(
"unknown NullabilityKind");
4342 if (ASOld != ASNew) {
4343 S.
Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
4348 diag::warn_attribute_address_multiple_identical_qualifiers);
4357 return T->canHaveNullability(
false) &&
4363 T->getCanonicalTypeInternal());
4373 Sema &S = state.getSema();
4383 bool IsTypedefName =
4389 bool IsQualifiedFunction =
T->isFunctionProtoType() &&
4397 if (
auto *DT =
T->getAs<DeducedType>(); DT && !
T->containsErrors()) {
4398 const AutoType *AT =
T->getAs<AutoType>();
4400 if ((AT && AT->isDecltypeAuto()) || IsClassTemplateDeduction) {
4402 unsigned Index = E - I - 1;
4404 unsigned DiagId = IsClassTemplateDeduction
4405 ? diag::err_deduced_class_template_compound_type
4406 : diag::err_decltype_auto_compound_type;
4407 unsigned DiagKind = 0;
4408 switch (DeclChunk.
Kind) {
4412 if (IsClassTemplateDeduction) {
4420 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
4438 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
4447 bool inferNullabilityCS =
false;
4448 bool inferNullabilityInnerOnly =
false;
4449 bool inferNullabilityInnerOnlyComplete =
false;
4452 bool inAssumeNonNullRegion =
false;
4454 if (assumeNonNullLoc.
isValid()) {
4455 inAssumeNonNullRegion =
true;
4469 } complainAboutMissingNullability = CAMN_No;
4470 unsigned NumPointersRemaining = 0;
4471 auto complainAboutInferringWithinChunk = PointerWrappingDeclaratorKind::None;
4473 if (IsTypedefName) {
4477 complainAboutMissingNullability = CAMN_InnerPointers;
4481 ++NumPointersRemaining;
4486 switch (chunk.
Kind) {
4494 ++NumPointersRemaining;
4502 ++NumPointersRemaining;
4507 bool isFunctionOrMethod =
false;
4508 switch (
auto context = state.getDeclarator().getContext()) {
4514 isFunctionOrMethod =
true;
4518 if (state.getDeclarator().isObjCIvar() && !isFunctionOrMethod) {
4519 complainAboutMissingNullability = CAMN_No;
4524 if (state.getDeclarator().isObjCWeakProperty()) {
4527 complainAboutMissingNullability = CAMN_No;
4528 if (inAssumeNonNullRegion) {
4538 complainAboutMissingNullability = CAMN_Yes;
4541 auto wrappingKind = PointerWrappingDeclaratorKind::None;
4543 case PointerDeclaratorKind::NonPointer:
4544 case PointerDeclaratorKind::MultiLevelPointer:
4548 case PointerDeclaratorKind::SingleLevelPointer:
4550 if (inAssumeNonNullRegion) {
4551 complainAboutInferringWithinChunk = wrappingKind;
4558 case PointerDeclaratorKind::CFErrorRefPointer:
4559 case PointerDeclaratorKind::NSErrorPointerPointer:
4562 if (isFunctionOrMethod && inAssumeNonNullRegion)
4566 case PointerDeclaratorKind::MaybePointerToCFRef:
4567 if (isFunctionOrMethod) {
4571 auto hasCFReturnsAttr =
4573 return AttrList.hasAttribute(ParsedAttr::AT_CFReturnsRetained) ||
4574 AttrList.hasAttribute(ParsedAttr::AT_CFReturnsNotRetained);
4579 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
4582 inferNullabilityInnerOnly =
true;
4592 complainAboutMissingNullability = CAMN_Yes;
4620 auto isVaList = [&S](
QualType T) ->
bool {
4626 if (typedefTy->getDecl() == vaListTypedef)
4628 if (
auto *name = typedefTy->getDecl()->getIdentifier())
4629 if (name->isStr(
"va_list"))
4631 typedefTy = typedefTy->desugar()->getAs<
TypedefType>();
4632 }
while (typedefTy);
4638 auto inferPointerNullability =
4643 if (NumPointersRemaining > 0)
4644 --NumPointersRemaining;
4651 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
4654 ? ParsedAttr::Form::ContextSensitiveKeyword()
4655 : ParsedAttr::Form::Keyword(
false ,
4661 attrs.addAtEnd(nullabilityAttr);
4663 if (inferNullabilityCS) {
4664 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
4668 if (pointerLoc.isValid() &&
4669 complainAboutInferringWithinChunk !=
4670 PointerWrappingDeclaratorKind::None) {
4672 S.
Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
4677 if (inferNullabilityInnerOnly)
4678 inferNullabilityInnerOnlyComplete =
true;
4679 return nullabilityAttr;
4684 switch (complainAboutMissingNullability) {
4688 case CAMN_InnerPointers:
4689 if (NumPointersRemaining == 0)
4705 if (NumPointersRemaining > 0)
4706 --NumPointersRemaining;
4708 SimplePointerKind pointerKind = SimplePointerKind::Pointer;
4709 if (
T->isBlockPointerType())
4710 pointerKind = SimplePointerKind::BlockPointer;
4711 else if (
T->isMemberPointerType())
4712 pointerKind = SimplePointerKind::MemberPointer;
4714 if (
auto *
attr = inferPointerNullability(
4719 T = state.getAttributedType(
4725 if (complainAboutMissingNullability == CAMN_Yes &&
T->isArrayType() &&
4733 bool ExpectNoDerefChunk =
4734 state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
4744 bool AreDeclaratorChunksValid =
true;
4746 unsigned chunkIndex = e - i - 1;
4747 state.setCurrentChunkIndex(chunkIndex);
4750 switch (DeclType.
Kind) {
4758 if (!LangOpts.Blocks)
4759 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
4762 inferPointerNullability(SimplePointerKind::BlockPointer, DeclType.
Loc,
4764 state.getDeclarator().getAttributePool());
4770 if (LangOpts.OpenCL)
4785 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
4787 state.getDeclarator().getAttributePool());
4790 T = Context.getObjCObjectPointerType(
T);
4799 if (LangOpts.OpenCL) {
4800 if (
T->isImageType() ||
T->isSamplerT() ||
T->isPipeType() ||
4801 T->isBlockPointerType()) {
4815 diag::err_overflow_behavior_non_integer_type)
4849 if (chunkIndex != 0 && !ArraySize &&
4868 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
4879 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype)
4881 :
"type qualifier");
4892 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost)
4894 :
"type qualifier");
4904 if (complainAboutMissingNullability == CAMN_Yes &&
4920 IsQualifiedFunction =
4926 return SS.isInvalid() ||
4927 isa_and_present<CXXRecordDecl>(
4952 if (
First &&
First->isExplicitObjectParameter() &&
4966 diag::err_explicit_object_parameter_nonmember)
4967 << 2 << 0 <<
First->getSourceRange();
4970 diag::err_explicit_object_parameter_invalid)
4971 <<
First->getSourceRange();
4977 AreDeclaratorChunksValid =
false;
4990 ? diag::err_auto_missing_trailing_return
4991 : diag::err_deduced_return_type);
4994 AreDeclaratorChunksValid =
false;
4997 diag::warn_cxx11_compat_deduced_return_type);
5006 AreDeclaratorChunksValid =
false;
5009 if (
T != Context.DependentTy) {
5011 diag::err_deduction_guide_with_complex_decl)
5015 AreDeclaratorChunksValid =
false;
5032 S.
Diag(Loc, diag::err_trailing_return_without_auto) <<
T << SR;
5035 AreDeclaratorChunksValid =
false;
5042 }
else if (AutoType *
Auto =
T->getContainedAutoType()) {
5051 if (InventedParamInfo) {
5053 state,
T, TInfo,
Auto, *InventedParamInfo);
5066 T->isFunctionType()) &&
5069 unsigned diagID = diag::err_func_returning_array_function;
5072 if (chunkIndex == 0 &&
5074 diagID = diag::err_block_returning_array_function;
5075 S.
Diag(DeclType.
Loc, diagID) <<
T->isFunctionType() <<
T;
5078 AreDeclaratorChunksValid =
false;
5083 if (
T->isHalfType()) {
5091 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5094 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
5100 if (
T.getPointerAuth()) {
5101 S.
Diag(DeclType.
Loc, diag::err_ptrauth_qualifier_invalid) <<
T << 0;
5104 if (LangOpts.OpenCL) {
5107 if (
T->isBlockPointerType() ||
T->isImageType() ||
T->isSamplerT() ||
5118 "__cl_clang_variadic_functions", S.
getLangOpts()) &&
5130 if (
T->isObjCObjectType()) {
5139 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
5143 T = Context.getObjCObjectPointerType(
T);
5151 AreDeclaratorChunksValid =
false;
5159 if ((
T.getCVRQualifiers() ||
T->isAtomicType()) &&
5163 (
T->isRecordType() ||
T->isDependentType() ||
5164 T->isUndeducedAutoType()))) {
5171 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) <<
T;
5178 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20)
5179 S.
Diag(DeclType.
Loc, diag::warn_deprecated_volatile_return) <<
T;
5184 if (
T.getQualifiers().hasObjCLifetime()) {
5189 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5190 AttrLoc = AL.getLoc();
5197 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5198 AttrLoc = AL.getLoc();
5212 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
5213 <<
T.getQualifiers().getObjCLifetime();
5221 S.
Diag(Tag->getLocation(), diag::err_type_defined_in_result_type)
5222 << Context.getCanonicalTagType(Tag);
5229 diag::err_exception_spec_in_typedef)
5247 T = Context.getFunctionNoProtoType(
T, EI);
5255 diag::warn_c17_compat_ellipsis_only_parameter);
5257 ParsedAttr::AT_Overloadable) &&
5259 ParsedAttr::AT_Overloadable) &&
5261 ParsedAttr::AT_Overloadable))
5269 diag::err_ident_list_in_fn_declaration);
5273 ? Context.getFunctionNoProtoType(
T, EI)
5275 AreDeclaratorChunksValid =
false;
5298 bool HasAnyInterestingExtParameterInfos =
false;
5300 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
5302 QualType ParamTy = Param->getType();
5303 assert(!ParamTy.
isNull() &&
"Couldn't parse type?");
5314 ParamTy = Context.IntTy;
5315 Param->setType(ParamTy);
5319 ParamTy = Context.IntTy;
5320 Param->setType(ParamTy);
5324 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
5326 for (
const auto *A : Param->attrs()) {
5327 S.
Diag(A->getLoc(), diag::warn_attribute_on_void_param)
5328 << A << A->getRange();
5333 if (Param->isExplicitObjectParameter()) {
5334 S.
Diag(Param->getLocation(),
5335 diag::err_void_explicit_object_param);
5348 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5351 Param->setInvalidDecl();
5353 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5355 S.
Diag(Param->getLocation(),
5356 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
5360 if (Context.isPromotableIntegerType(ParamTy)) {
5361 ParamTy = Context.getPromotedIntegerType(ParamTy);
5362 Param->setKNRPromoted(
true);
5364 if (BTy->getKind() == BuiltinType::Float) {
5365 ParamTy = Context.DoubleTy;
5366 Param->setKNRPromoted(
true);
5371 S.
Diag(Param->getLocation(), diag::err_opencl_invalid_param)
5376 if (LangOpts.ObjCAutoRefCount && Param->hasAttr<NSConsumedAttr>()) {
5377 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
5378 HasAnyInterestingExtParameterInfos =
true;
5382 ExtParameterInfos[i] =
5383 ExtParameterInfos[i].withABI(
attr->getABI());
5384 HasAnyInterestingExtParameterInfos =
true;
5387 if (Param->hasAttr<PassObjectSizeAttr>()) {
5388 ExtParameterInfos[i] = ExtParameterInfos[i].withHasPassObjectSize();
5389 HasAnyInterestingExtParameterInfos =
true;
5392 if (Param->hasAttr<NoEscapeAttr>()) {
5393 ExtParameterInfos[i] = ExtParameterInfos[i].withIsNoEscape(
true);
5394 HasAnyInterestingExtParameterInfos =
true;
5397 ParamTys.push_back(ParamTy);
5400 if (HasAnyInterestingExtParameterInfos) {
5409 Expr *NoexceptExpr =
nullptr;
5415 DynamicExceptions.reserve(N);
5416 DynamicExceptionRanges.reserve(N);
5417 for (
unsigned I = 0; I != N; ++I) {
5428 DynamicExceptionRanges,
5435 auto IsClassMember = [&]() {
5436 return (!state.getDeclarator().getCXXScopeSpec().isEmpty() &&
5437 state.getDeclarator()
5441 state.getDeclarator().getContext() ==
5443 state.getDeclarator().getContext() ==
5447 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
5467 T = Context.getFunctionType(
T, ParamTys, EPI);
5476 inferPointerNullability(SimplePointerKind::MemberPointer, DeclType.
Loc,
5478 state.getDeclarator().getAttributePool());
5483 AreDeclaratorChunksValid =
false;
5492 AreDeclaratorChunksValid =
false;
5510 AreDeclaratorChunksValid =
false;
5519 S.
Diag(DeclType.
Loc, diag::warn_noderef_on_non_pointer_or_array);
5521 ExpectNoDerefChunk = state.didParseNoDeref();
5525 if (ExpectNoDerefChunk)
5526 S.
Diag(state.getDeclarator().getBeginLoc(),
5527 diag::warn_noderef_on_non_pointer_or_array);
5540 bool IsBlock =
false;
5542 switch (DeclType.Kind) {
5554 S.
Diag(DeclType.Loc, diag::warn_strict_prototypes)
5566 assert(!
T.isNull() &&
"T must not be null after this point");
5568 if (LangOpts.CPlusPlus &&
T->isFunctionType()) {
5570 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
5583 ExplicitObjectMember,
5587 Kind = DeductionGuide;
5604 auto *P = dyn_cast_or_null<ParmVarDecl>(Chunk.
Fun.
Params->
Param);
5605 if (P && P->isExplicitObjectParameter())
5606 Kind = ExplicitObjectMember;
5632 if (IsQualifiedFunction &&
5658 if (!RemovalLocs.empty()) {
5659 llvm::sort(RemovalLocs,
5661 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
5662 Loc = RemovalLocs.front();
5666 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
5690 if (!AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
5698 state.diagnoseIgnoredTypeAttrs(
T);
5709 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20 &&
5734 if (!
T->containsUnexpandedParameterPack() &&
5735 (!LangOpts.CPlusPlus20 || !
T->getContainedAutoType())) {
5737 diag::err_function_parameter_pack_without_parameter_packs)
5741 T = Context.getPackExpansionType(
T, std::nullopt,
5754 if (
T->containsUnexpandedParameterPack())
5755 T = Context.getPackExpansionType(
T, std::nullopt);
5787 diag::err_ellipsis_in_declarator_not_parameter);
5793 assert(!
T.isNull() &&
"T must not be null at the end of this function");
5794 if (!AreDeclaratorChunksValid)
5795 return Context.getTrivialTypeSourceInfo(
T);
5797 if (state.didParseHLSLParamMod() && !
T->isConstantArrayType())
5806 TypeProcessingState state(*
this, D);
5829 unsigned chunkIndex) {
5830 Sema &S = state.getSema();
5838 const char *attrStr =
nullptr;
5839 switch (ownership) {
5857 &Args, 1, ParsedAttr::Form::GNU());
5866 Sema &S = state.getSema();
5870 bool hasIndirection =
false;
5873 switch (chunk.
Kind) {
5882 hasIndirection =
true;
5915 TypeProcessingState state(*
this, D);
5930 TypeProcessingState &State) {
5935 TypeProcessingState &State) {
5937 State.getSema().HLSL().TakeLocForHLSLAttribute(TL.
getTypePtr());
5945 if (AL.getKind() == ParsedAttr::AT_MatrixType) {
5954 llvm_unreachable(
"no matrix_type attribute found at the expected location!");
5959 switch (Chunk.
Kind) {
5964 llvm_unreachable(
"cannot be _Atomic qualified");
5982 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
5984 ASTContext &Context;
5985 TypeProcessingState &State;
5989 TypeSpecLocFiller(Sema &S, ASTContext &Context, TypeProcessingState &State,
5991 : SemaRef(S), Context(Context), State(State), DS(DS) {}
5993 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
5997 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
6000 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
6003 void VisitHLSLAttributedResourceTypeLoc(HLSLAttributedResourceTypeLoc TL) {
6007 void VisitHLSLInlineSpirvTypeLoc(HLSLInlineSpirvTypeLoc TL) {}
6008 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6011 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6013 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6018 void VisitPointerTypeLoc(PointerTypeLoc TL) { Visit(TL.
getNextTypeLoc()); }
6019 void VisitTypedefTypeLoc(TypedefTypeLoc TL) {
6021 TypeSourceInfo *TInfo =
nullptr;
6034 void VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
6036 TypeSourceInfo *TInfo =
nullptr;
6049 void VisitUsingTypeLoc(UsingTypeLoc TL) {
6051 TypeSourceInfo *TInfo =
nullptr;
6064 void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
6071 void VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
6072 TypeSourceInfo *RepTInfo =
nullptr;
6076 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6077 TypeSourceInfo *RepTInfo =
nullptr;
6081 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
6082 TypeSourceInfo *TInfo =
nullptr;
6093 TL.
copy(OldTL.
castAs<TemplateSpecializationTypeLoc>());
6095 OldTL.
castAs<TemplateSpecializationTypeLoc>().getRAngleLoc());
6097 void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
6103 void VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
6109 TypeSourceInfo *TInfo =
nullptr;
6113 void VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
6118 void VisitPackIndexingTypeLoc(PackIndexingTypeLoc TL) {
6120 TypeSourceInfo *TInfo =
nullptr;
6124 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
6129 TypeSourceInfo *TInfo =
nullptr;
6133 void VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
6146 void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
6148 TypeSourceInfo *TInfo =
nullptr;
6153 void VisitAutoTypeLoc(AutoTypeLoc TL) {
6167 NestedNameSpecifierLoc NNS =
6170 : NestedNameSpecifierLoc());
6171 TemplateArgumentListInfo TemplateArgsInfo(TemplateId->
LAngleLoc,
6173 if (TemplateId->
NumArgs > 0) {
6182 NamedDecl *FoundDecl;
6187 FoundDecl = cast_if_present<NamedDecl>(TN.getAsTemplateDecl());
6195 void VisitDeducedTemplateSpecializationTypeLoc(
6196 DeducedTemplateSpecializationTypeLoc TL) {
6198 TypeSourceInfo *TInfo =
nullptr;
6204 void VisitTagTypeLoc(TagTypeLoc TL) {
6206 TypeSourceInfo *TInfo =
nullptr;
6214 ElaboratedTypeKeyword::None
6216 : SourceLocation());
6220 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6227 TypeSourceInfo *TInfo =
nullptr;
6239 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6242 TypeSourceInfo *TInfo =
nullptr;
6247 void VisitExtIntTypeLoc(BitIntTypeLoc TL) {
6251 void VisitDependentExtIntTypeLoc(DependentBitIntTypeLoc TL) {
6255 void VisitTypeLoc(TypeLoc TL) {
6261 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
6262 ASTContext &Context;
6263 TypeProcessingState &State;
6264 const DeclaratorChunk &Chunk;
6267 DeclaratorLocFiller(ASTContext &Context, TypeProcessingState &State,
6268 const DeclaratorChunk &Chunk)
6269 : Context(Context), State(State), Chunk(Chunk) {}
6271 void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6272 llvm_unreachable(
"qualified type locs not expected here!");
6274 void VisitDecayedTypeLoc(DecayedTypeLoc TL) {
6275 llvm_unreachable(
"decayed type locs not expected here!");
6277 void VisitArrayParameterTypeLoc(ArrayParameterTypeLoc TL) {
6278 llvm_unreachable(
"array parameter type locs not expected here!");
6281 void VisitAttributedTypeLoc(AttributedTypeLoc TL) {
6284 void VisitCountAttributedTypeLoc(CountAttributedTypeLoc TL) {
6287 void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
6290 void VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
6293 void VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
6296 void VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
6300 void VisitPointerTypeLoc(PointerTypeLoc TL) {
6304 void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6308 void VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
6313 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
6319 void VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
6324 void VisitArrayTypeLoc(ArrayTypeLoc TL) {
6330 void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
6335 const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.
Fun;
6338 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
6344 void VisitParenTypeLoc(ParenTypeLoc TL) {
6349 void VisitPipeTypeLoc(PipeTypeLoc TL) {
6353 void VisitBitIntTypeLoc(BitIntTypeLoc TL) {
6356 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6359 void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.
setNameLoc(Chunk.
Loc); }
6360 void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
6363 void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
6366 void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6370 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
6373 void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
6377 void VisitTypeLoc(TypeLoc TL) {
6378 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
6389 if (AL.getKind() != ParsedAttr::AT_AddressSpace || AL.isInvalid() ||
6390 AL.getNumArgs() != 1 || !AL.isArgExpr(0))
6400 "no address_space attribute found at the expected location!");
6414 Sema &S = State.getSema();
6440 bool HasDesugaredTypeLoc =
true;
6441 while (HasDesugaredTypeLoc) {
6443 case TypeLoc::MacroQualified: {
6446 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6451 case TypeLoc::Attributed: {
6458 case TypeLoc::Adjusted:
6459 case TypeLoc::BTFTagAttributed: {
6464 case TypeLoc::DependentAddressSpace: {
6478 HasDesugaredTypeLoc =
false;
6489 if (ReturnTypeInfo) {
6509 "LocInfoType's TypeClass conflicts with an existing Type class");
6515 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
6516 " was used directly instead of getting the QualType through"
6517 " GetTypeFromParser");
6524 "Type name should have no identifier!");
6561 const Expr *AddrSpace,
6564 std::optional<llvm::APSInt> OptAddrSpace =
6566 if (!OptAddrSpace) {
6567 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
6572 llvm::APSInt &addrSpace = *OptAddrSpace;
6575 if (addrSpace.isSigned()) {
6576 if (addrSpace.isNegative()) {
6577 S.
Diag(AttrLoc, diag::err_attribute_address_space_negative)
6581 addrSpace.setIsSigned(
false);
6584 llvm::APSInt
max(addrSpace.getBitWidth());
6588 if (addrSpace >
max) {
6589 S.
Diag(AttrLoc, diag::err_attribute_address_space_too_high)
6611 return Context.getAddrSpaceQualType(
T, ASIdx);
6620 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
6624 return Context.getDependentAddressSpaceType(
T, AddrSpace, AttrLoc);
6636 TypeProcessingState &State) {
6637 Sema &S = State.getSema();
6643 if (!
Attr.diagnoseLangOpts(S)) {
6649 if (
Attr.getNumArgs() != 1) {
6650 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6657 auto *StrLiteral = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6666 StringRef BTFTypeTag = StrLiteral->getString();
6667 Type = State.getBTFTagAttributedType(
6668 ::new (Ctx) BTFTypeTagAttr(Ctx,
Attr, BTFTypeTag),
Type);
6676 TypeProcessingState &State) {
6677 Sema &S = State.getSema();
6682 S.
Diag(
Attr.
getLoc(), diag::err_attribute_address_function_type);
6688 if (
Attr.
getKind() == ParsedAttr::AT_AddressSpace) {
6691 if (
Attr.getNumArgs() != 1) {
6698 Expr *ASArgExpr =
Attr.getArgAsExpr(0);
6707 ::new (Ctx) AddressSpaceAttr(Ctx,
Attr,
static_cast<unsigned>(ASIdx));
6719 if (EquivType.
isNull()) {
6723 T = State.getAttributedType(ASAttr,
Type, EquivType);
6725 T = State.getAttributedType(ASAttr,
Type,
Type);
6740 ASIdx =
Attr.asHLSLLangAS();
6743 llvm_unreachable(
"Invalid address space");
6756 TypeProcessingState &State) {
6757 Sema &S = State.getSema();
6761 S.
Diag(
Attr.
getLoc(), diag::warn_overflow_behavior_attribute_disabled)
6768 if (
Attr.getNumArgs() != 1) {
6769 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6778 <<
Attr <<
Type.getAsString() << 0;
6785 S.
Diag(
Attr.
getLoc(), diag::err_overflow_behavior_non_integer_type)
6786 <<
Attr <<
Type.getAsString() << 0;
6791 StringRef KindName =
"";
6794 if (
Attr.isArgIdent(0)) {
6795 Ident =
Attr.getArgAsIdent(0)->getIdentifierInfo();
6804 auto *Str = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6806 KindName = Str->getString();
6815 OverflowBehaviorType::OverflowBehaviorKind Kind;
6816 if (KindName ==
"wrap") {
6817 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
6818 }
else if (KindName ==
"trap") {
6819 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
6822 << KindName <<
Attr;
6828 const DeclSpec &DS = State.getDeclarator().getDeclSpec();
6832 OverflowBehaviorType::OverflowBehaviorKind SpecifierKind =
6833 DS.
isWrapSpecified() ? OverflowBehaviorType::OverflowBehaviorKind::Wrap
6834 : OverflowBehaviorType::OverflowBehaviorKind::Trap;
6836 if (SpecifierKind != Kind) {
6839 << 1 << SpecifierName << KindName;
6843 S.
Diag(
Attr.
getLoc(), diag::warn_redundant_overflow_behaviors_mixed)
6850 if (
const auto *ExistingOBT =
Type->
getAs<OverflowBehaviorType>()) {
6851 OverflowBehaviorType::OverflowBehaviorKind ExistingKind =
6852 ExistingOBT->getBehaviorKind();
6853 if (ExistingKind != Kind) {
6854 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_overflow_behaviors) << 0;
6855 if (Kind == OverflowBehaviorType::OverflowBehaviorKind::Trap) {
6856 Type = State.getOverflowBehaviorType(Kind,
6857 ExistingOBT->getUnderlyingType());
6862 Type = State.getOverflowBehaviorType(Kind,
Type);
6872 bool NonObjCPointer =
false;
6874 if (!
type->isDependentType() && !
type->isUndeducedType()) {
6882 NonObjCPointer =
true;
6883 }
else if (!
type->isObjCRetainableType()) {
6889 if (state.isProcessingDeclSpec()) {
6897 Sema &S = state.getSema();
6903 if (!
attr.isArgIdent(0)) {
6904 S.
Diag(AttrLoc, diag::err_attribute_argument_type) <<
attr
6912 if (II->
isStr(
"none"))
6914 else if (II->
isStr(
"strong"))
6916 else if (II->
isStr(
"weak"))
6918 else if (II->
isStr(
"autoreleasing"))
6921 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported) <<
attr << II;
6938 =
type.getQualifiers().getObjCLifetime()) {
6941 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
6948 if (previousLifetime != lifetime) {
6951 const Type *prevTy =
nullptr;
6952 while (!prevTy || prevTy != underlyingType.
Ty) {
6953 prevTy = underlyingType.
Ty;
6962 if (NonObjCPointer) {
6963 StringRef name =
attr.getAttrName()->getName();
6972 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
6989 type = state.getAttributedType(
6996 if (!NonObjCPointer)
7013 diagnostic,
type, 0));
7015 S.
Diag(loc, diagnostic);
7024 unsigned diagnostic =
7025 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
7026 : diag::err_arc_weak_no_runtime);
7029 diagnoseOrDelay(S, AttrLoc, diagnostic,
type);
7041 if (Class->isArcWeakrefUnavailable()) {
7042 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
7043 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
7044 diag::note_class_declared);
7059 Sema &S = state.getSema();
7062 if (!
type->isPointerType() &&
7063 !
type->isObjCObjectPointerType() &&
7064 !
type->isBlockPointerType())
7068 S.
Diag(
attr.getLoc(), diag::err_attribute_multiple_objc_gc);
7074 if (!
attr.isArgIdent(0)) {
7075 S.
Diag(
attr.getLoc(), diag::err_attribute_argument_type)
7081 if (
attr.getNumArgs() > 1) {
7082 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_number_arguments) <<
attr
7089 if (II->
isStr(
"weak"))
7091 else if (II->
isStr(
"strong"))
7094 S.
Diag(
attr.getLoc(), diag::warn_attribute_type_not_supported)
7104 if (
attr.getLoc().isValid())
7105 type = state.getAttributedType(
7122 struct FunctionTypeUnwrapper {
7136 const FunctionType *
Fn;
7137 SmallVector<
unsigned char , 8> Stack;
7139 FunctionTypeUnwrapper(Sema &S, QualType
T) : Original(
T) {
7141 const Type *Ty =
T.getTypePtr();
7151 Stack.push_back(
Array);
7157 Stack.push_back(BlockPointer);
7160 Stack.push_back(MemberPointer);
7166 Stack.push_back(Attributed);
7169 Stack.push_back(MacroQualified);
7177 T = QualType(DTy, 0);
7178 Stack.push_back(Desugar);
7183 bool isFunctionType()
const {
return (Fn !=
nullptr); }
7184 const FunctionType *get()
const {
return Fn; }
7186 QualType wrap(Sema &S,
const FunctionType *
New) {
7188 if (
New == get())
return Original;
7191 return wrap(S.
Context, Original, 0);
7195 QualType wrap(ASTContext &
C, QualType Old,
unsigned I) {
7196 if (I == Stack.size())
7201 SplitQualType SplitOld = Old.
split();
7205 return wrap(
C, SplitOld.
Ty, I);
7206 return C.getQualifiedType(wrap(
C, SplitOld.
Ty, I), SplitOld.
Quals);
7209 QualType wrap(ASTContext &
C,
const Type *Old,
unsigned I) {
7210 if (I == Stack.size())
return QualType(Fn, 0);
7212 switch (
static_cast<WrapKind
>(Stack[I++])) {
7223 return C.getParenType(
New);
7226 case MacroQualified:
7230 if (
const auto *CAT = dyn_cast<ConstantArrayType>(Old)) {
7231 QualType
New = wrap(
C, CAT->getElementType(), I);
7232 return C.getConstantArrayType(
New, CAT->getSize(), CAT->getSizeExpr(),
7233 CAT->getSizeModifier(),
7234 CAT->getIndexTypeCVRQualifiers());
7237 if (
const auto *VAT = dyn_cast<VariableArrayType>(Old)) {
7238 QualType
New = wrap(
C, VAT->getElementType(), I);
7239 return C.getVariableArrayType(
New, VAT->getSizeExpr(),
7240 VAT->getSizeModifier(),
7241 VAT->getIndexTypeCVRQualifiers());
7245 QualType
New = wrap(
C, IAT->getElementType(), I);
7246 return C.getIncompleteArrayType(
New, IAT->getSizeModifier(),
7247 IAT->getIndexTypeCVRQualifiers());
7252 return C.getPointerType(
New);
7255 case BlockPointer: {
7257 return C.getBlockPointerType(
New);
7260 case MemberPointer: {
7273 return C.getRValueReferenceType(
New);
7277 llvm_unreachable(
"unknown wrapping kind");
7284 Sema &S = State.getSema();
7288 default: llvm_unreachable(
"Unknown attribute kind");
7289 case ParsedAttr::AT_Ptr32:
7292 case ParsedAttr::AT_Ptr64:
7295 case ParsedAttr::AT_SPtr:
7298 case ParsedAttr::AT_UPtr:
7303 std::bitset<attr::LastAttr> Attrs;
7306 if (
const TypedefType *TT = dyn_cast<TypedefType>(Desugared)) {
7307 Desugared = TT->desugar();
7310 const AttributedType *AT = dyn_cast<AttributedType>(Desugared);
7313 Attrs[AT->getAttrKind()] =
true;
7314 Desugared = AT->getModifiedType();
7320 if (Attrs[NewAttrKind]) {
7321 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7324 Attrs[NewAttrKind] =
true;
7328 if (Attrs[attr::Ptr32] && Attrs[attr::Ptr64]) {
7329 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7331 <<
"'__ptr64'" << 0;
7333 }
else if (Attrs[attr::SPtr] && Attrs[attr::UPtr]) {
7334 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7346 S.
Diag(PAttr.
getLoc(), diag::err_attribute_no_member_pointers) << PAttr;
7348 S.
Diag(PAttr.
getLoc(), diag::err_attribute_pointers_only) << PAttr << 0;
7356 if (PtrWidth == 32) {
7357 if (Attrs[attr::Ptr64])
7359 else if (Attrs[attr::UPtr])
7361 }
else if (PtrWidth == 64 && Attrs[attr::Ptr32]) {
7381 assert(PAttr.
getKind() == ParsedAttr::AT_WebAssemblyFuncref);
7383 Sema &S = State.getSema();
7386 std::bitset<attr::LastAttr> Attrs;
7388 const auto *AT = dyn_cast<AttributedType>(QT);
7390 Attrs[AT->getAttrKind()] =
true;
7391 AT = dyn_cast<AttributedType>(AT->getModifiedType());
7396 if (Attrs[NewAttrKind]) {
7397 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7403 const auto *Ptr = dyn_cast<PointerType>(Desugared);
7404 if (!Ptr || !Ptr->getPointeeType()->isFunctionType()) {
7405 S.
Diag(PAttr.
getLoc(), diag::err_attribute_webassembly_funcref);
7417 QT = State.getAttributedType(A, QT,
Equivalent);
7426 Sema &S = State.getSema();
7427 auto &D = State.getDeclarator();
7433 if (State.isProcessingDeclSpec()) {
7434 if (!(D.isPrototypeContext() ||
7438 if (
auto *chunk = D.getInnermostNonParenChunk()) {
7461 auto chunkIdx = State.getCurrentChunkIndex();
7462 if (chunkIdx >= 1 &&
7465 D.getTypeObject(chunkIdx - 1).getAttrs());
7470 auto *A = ::new (S.
Context) SwiftAttrAttr(S.
Context, PAttr, Str);
7471 QT = State.getAttributedType(A, QT, QT);
7478 auto Attributed = dyn_cast<AttributedType>(
Type.getTypePtr());
7483 if (Attributed->getImmediateNullability())
7484 return Attributed->getModifiedType();
7488 Ctx, Attributed->getModifiedType());
7489 assert(Modified.
getTypePtr() != Attributed->getModifiedType().getTypePtr());
7491 Attributed->getEquivalentType(),
7492 Attributed->getAttr());
7498 case ParsedAttr::AT_TypeNonNull:
7501 case ParsedAttr::AT_TypeNullable:
7504 case ParsedAttr::AT_TypeNullableResult:
7507 case ParsedAttr::AT_TypeNullUnspecified:
7511 llvm_unreachable(
"not a nullability attribute kind");
7518 bool IsContextSensitive,
bool AllowOnArrayType,
bool OverrideExisting) {
7519 bool Implicit = (State ==
nullptr);
7525 while (
auto *Attributed = dyn_cast<AttributedType>(Desugared.
getTypePtr())) {
7527 if (
auto ExistingNullability = Attributed->getImmediateNullability()) {
7529 if (Nullability == *ExistingNullability) {
7533 S.
Diag(NullabilityLoc, diag::warn_nullability_duplicate)
7540 if (!OverrideExisting) {
7542 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7552 Desugared = Attributed->getModifiedType();
7560 if (Nullability != *ExistingNullability && !
Implicit) {
7561 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7569 if (
auto typedefNullability =
7570 AttributedType::stripOuterNullability(underlyingType)) {
7571 if (*typedefNullability == *ExistingNullability) {
7584 !(AllowOnArrayType && Desugared->
isArrayType())) {
7586 S.
Diag(NullabilityLoc, diag::err_nullability_nonpointer)
7594 if (IsContextSensitive) {
7605 S.
Diag(NullabilityLoc, diag::err_nullability_cs_multilevel)
7607 S.
Diag(NullabilityLoc, diag::note_nullability_type_specifier)
7619 QT = State->getAttributedType(A, QT, QT);
7628 bool AllowOnArrayType) {
7634 Nullability, NullabilityLoc,
7635 IsContextSensitive, AllowOnArrayType,
7642 bool AllowArrayTypes,
7643 bool OverrideExisting) {
7645 *
this,
nullptr,
nullptr,
Type, Nullability, DiagLoc,
7646 false, AllowArrayTypes, OverrideExisting);
7654 llvm::APInt MaxSizeForAddrSpace =
7655 llvm::APInt::getMaxValue(
Context.getTargetInfo().getPointerWidth(AS));
7656 std::optional<CharUnits> TSizeInChars =
Context.getTypeSizeInCharsIfKnown(
T);
7657 if (TSizeInChars &&
static_cast<uint64_t
>(TSizeInChars->getQuantity()) >
7658 MaxSizeForAddrSpace.getZExtValue()) {
7660 <<
T << MaxSizeForAddrSpace;
7671 Sema &S = state.getSema();
7675 type = state.getAttributedType(
7688 S.
Diag(
attr.getLoc(), diag::err_objc_kindof_nonobject)
7697 objType->getBaseType(), objType->getTypeArgsAsWritten(),
7698 objType->getProtocols(),
7699 objType->isObjCUnqualifiedId() ?
false :
true);
7704 if (
auto nullability =
type->getNullability()) {
7707 assert(
attr.getAttributeSpellingListIndex() == 0 &&
7708 "multiple spellings for __kindof?");
7711 equivType = state.getAttributedType(A, equivType, equivType);
7716 type = state.getAttributedType(
7729 Declarator &declarator = state.getDeclarator();
7732 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
7745 PK_MemberFunctionPointer,
7750 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
7752 auto diag = state.getSema().Diag(
attr.getLoc(),
7753 diag::warn_nullability_declspec)
7755 attr.isContextSensitiveKeywordAttribute())
7757 <<
static_cast<unsigned>(pointerKind);
7763 state.getSema().getPreprocessor().getLocForEndOfToken(
7765 " " +
attr.getAttrName()->getName().str() +
" ");
7775 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
7777 switch (chunk.
Kind) {
7781 return moveToChunk(chunk,
false);
7793 return moveToChunk(*dest,
true);
7809 assert(!
Attr.isInvalid());
7812 llvm_unreachable(
"not a calling convention attribute");
7813 case ParsedAttr::AT_CDecl:
7815 case ParsedAttr::AT_FastCall:
7817 case ParsedAttr::AT_StdCall:
7819 case ParsedAttr::AT_ThisCall:
7821 case ParsedAttr::AT_RegCall:
7823 case ParsedAttr::AT_Pascal:
7825 case ParsedAttr::AT_SwiftCall:
7827 case ParsedAttr::AT_SwiftAsyncCall:
7829 case ParsedAttr::AT_VectorCall:
7831 case ParsedAttr::AT_AArch64VectorPcs:
7833 case ParsedAttr::AT_AArch64SVEPcs:
7835 case ParsedAttr::AT_ArmStreaming:
7837 case ParsedAttr::AT_Pcs: {
7842 if (
Attr.isArgExpr(0))
7845 Str =
Attr.getArgAsIdent(0)->getIdentifierInfo()->getName();
7846 PcsAttr::PCSType
Type;
7847 if (!PcsAttr::ConvertStrToPCSType(Str,
Type))
7848 llvm_unreachable(
"already validated the attribute");
7849 return ::new (Ctx) PcsAttr(Ctx,
Attr,
Type);
7851 case ParsedAttr::AT_IntelOclBicc:
7853 case ParsedAttr::AT_MSABI:
7855 case ParsedAttr::AT_SysVABI:
7857 case ParsedAttr::AT_PreserveMost:
7859 case ParsedAttr::AT_PreserveAll:
7861 case ParsedAttr::AT_M68kRTD:
7863 case ParsedAttr::AT_PreserveNone:
7865 case ParsedAttr::AT_RISCVVectorCC:
7867 case ParsedAttr::AT_RISCVVLSCC: {
7870 unsigned ABIVLen = 128;
7871 if (
Attr.getNumArgs()) {
7872 std::optional<llvm::APSInt> MaybeABIVLen =
7873 Attr.getArgAsExpr(0)->getIntegerConstantExpr(Ctx);
7875 llvm_unreachable(
"Invalid RISC-V ABI VLEN");
7876 ABIVLen = MaybeABIVLen->getZExtValue();
7879 return ::new (Ctx) RISCVVLSCCAttr(Ctx,
Attr, ABIVLen);
7882 llvm_unreachable(
"unexpected attribute kind!");
7885std::optional<FunctionEffectMode>
7890 std::optional<llvm::APSInt> ConditionValue =
7892 if (!ConditionValue) {
7898 return std::nullopt;
7907 FunctionTypeUnwrapper &Unwrapped) {
7909 if (!Unwrapped.isFunctionType())
7912 Sema &S = TPState.getSema();
7916 if (FPT ==
nullptr) {
7917 S.
Diag(PAttr.
getLoc(), diag::err_func_with_effects_no_prototype)
7924 bool IsNonBlocking = PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7925 PAttr.
getKind() == ParsedAttr::AT_Blocking;
7928 Expr *CondExpr =
nullptr;
7930 if (PAttr.
getKind() == ParsedAttr::AT_NonBlocking ||
7931 PAttr.
getKind() == ParsedAttr::AT_NonAllocating) {
7940 std::optional<FunctionEffectMode> MaybeMode =
7946 NewMode = *MaybeMode;
7981 assert(
Success &&
"effect conflicts should have been diagnosed above");
7985 FPT->getParamTypes(), EPI);
7994 auto OtherAttr = llvm::find_if(
7995 state.getCurrentAttributes(),
7996 [OtherKind](
const ParsedAttr &A) { return A.getKind() == OtherKind; });
7997 if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
8000 Sema &S = state.getSema();
8002 << *OtherAttr <<
Attr
8003 << (OtherAttr->isRegularKeywordAttribute() ||
8005 S.
Diag(OtherAttr->getLoc(), diag::note_conflicting_attribute);
8013 if (!
Attr.getNumArgs()) {
8019 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
8020 StringRef StateName;
8025 if (StateName !=
"sme_za_state") {
8026 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8033 S.
Diag(
Attr.
getLoc(), diag::err_conflicting_attributes_arm_agnostic);
8048 if (!
Attr.getNumArgs()) {
8054 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
8055 StringRef StateName;
8062 if (StateName ==
"za") {
8065 }
else if (StateName ==
"zt0") {
8069 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8075 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_agnostic);
8084 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_state)
8100 Sema &S = state.getSema();
8102 FunctionTypeUnwrapper unwrapped(S,
type);
8104 if (
attr.getKind() == ParsedAttr::AT_NoReturn) {
8109 if (!unwrapped.isFunctionType())
8118 if (
attr.getKind() == ParsedAttr::AT_CFIUncheckedCallee) {
8120 if (!unwrapped.isFunctionType())
8123 if (!unwrapped.get()->isFunctionProtoType()) {
8124 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8125 <<
attr <<
attr.isRegularKeywordAttribute()
8133 FPT->getReturnType(), FPT->getParamTypes(),
8134 FPT->getExtProtoInfo().withCFIUncheckedCallee(
true));
8139 if (
attr.getKind() == ParsedAttr::AT_CmseNSCall) {
8141 if (!unwrapped.isFunctionType())
8146 S.
Diag(
attr.getLoc(), diag::warn_attribute_ignored) <<
attr;
8153 unwrapped.get()->getExtInfo().withCmseNSCall(
true);
8160 if (
attr.getKind() == ParsedAttr::AT_NSReturnsRetained) {
8161 if (
attr.getNumArgs())
return true;
8164 if (!unwrapped.isFunctionType())
8169 attr.getLoc(), unwrapped.get()->getReturnType()))
8174 if (state.getSema().getLangOpts().ObjCAutoRefCount) {
8176 = unwrapped.get()->getExtInfo().withProducesResult(
true);
8179 type = state.getAttributedType(
8185 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCallerSavedRegisters) {
8190 if (!unwrapped.isFunctionType())
8194 unwrapped.get()->getExtInfo().withNoCallerSavedRegs(
true);
8199 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCfCheck) {
8201 S.
Diag(
attr.getLoc(), diag::warn_nocf_check_attribute_ignored);
8211 if (!unwrapped.isFunctionType())
8215 unwrapped.get()->getExtInfo().withNoCfCheck(
true);
8220 if (
attr.getKind() == ParsedAttr::AT_Regparm) {
8226 if (!unwrapped.isFunctionType())
8233 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8235 <<
attr.isRegularKeywordAttribute();
8241 unwrapped.get()->getExtInfo().withRegParm(value);
8246 if (
attr.getKind() == ParsedAttr::AT_CFISalt) {
8247 if (
attr.getNumArgs() != 1)
8255 if (!unwrapped.isFunctionType())
8260 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_decl_type)
8261 <<
attr <<
attr.isRegularKeywordAttribute()
8271 FnTy->getParamTypes(), EPI);
8276 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8277 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible ||
8278 attr.getKind() == ParsedAttr::AT_ArmPreserves ||
8279 attr.getKind() == ParsedAttr::AT_ArmIn ||
8280 attr.getKind() == ParsedAttr::AT_ArmOut ||
8281 attr.getKind() == ParsedAttr::AT_ArmInOut ||
8282 attr.getKind() == ParsedAttr::AT_ArmAgnostic) {
8286 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8287 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible)
8291 if (!unwrapped.isFunctionType())
8298 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type)
8299 <<
attr <<
attr.isRegularKeywordAttribute()
8306 switch (
attr.getKind()) {
8307 case ParsedAttr::AT_ArmStreaming:
8309 ParsedAttr::AT_ArmStreamingCompatible))
8313 case ParsedAttr::AT_ArmStreamingCompatible:
8318 case ParsedAttr::AT_ArmPreserves:
8322 case ParsedAttr::AT_ArmIn:
8326 case ParsedAttr::AT_ArmOut:
8330 case ParsedAttr::AT_ArmInOut:
8334 case ParsedAttr::AT_ArmAgnostic:
8339 llvm_unreachable(
"Unsupported attribute");
8343 FnTy->getParamTypes(), EPI);
8348 if (
attr.getKind() == ParsedAttr::AT_NoThrow) {
8350 if (!unwrapped.isFunctionType())
8363 if (Proto->hasExceptionSpec()) {
8364 switch (Proto->getExceptionSpecType()) {
8366 llvm_unreachable(
"This doesn't have an exception spec!");
8384 S.
Diag(
attr.getLoc(), diag::warn_nothrow_attribute_ignored);
8390 type = unwrapped.wrap(
8399 if (
attr.getKind() == ParsedAttr::AT_NonBlocking ||
8400 attr.getKind() == ParsedAttr::AT_NonAllocating ||
8401 attr.getKind() == ParsedAttr::AT_Blocking ||
8402 attr.getKind() == ParsedAttr::AT_Allocating) {
8407 if (!unwrapped.isFunctionType())
return false;
8422 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8425 <<
attr.isRegularKeywordAttribute();
8444 return S.
Diag(
attr.getLoc(), diag::warn_cconv_unsupported)
8449 return S.
Diag(
attr.getLoc(), diag::err_cconv_varargs)
8456 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8458 <<
attr.isRegularKeywordAttribute();
8470 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
8479 const AttributedType *AT;
8483 while ((AT =
T->getAs<AttributedType>()) &&
8485 if (AT->isCallingConv())
8487 T = AT->getModifiedType();
8494 FunctionTypeUnwrapper Unwrapped(*
this,
T);
8500 Context.getDefaultCallingConvention(IsVariadic, HasThisPointer);
8507 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() && IsCtorOrDtor) {
8511 Diag(Loc, diag::warn_cconv_unsupported)
8520 Context.getDefaultCallingConvention(IsVariadic, !HasThisPointer);
8522 if (CurCC != DefaultCC)
8530 QualType Wrapped = Unwrapped.wrap(*
this, FT);
8531 T =
Context.getAdjustedType(
T, Wrapped);
8544 if (
Attr.getNumArgs() != 1) {
8551 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8564 if (
Attr.getNumArgs() != 1) {
8570 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8585 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
8586 Triple.getArch() == llvm::Triple::aarch64_32 ||
8587 Triple.getArch() == llvm::Triple::aarch64_be;
8589 if (IsPolyUnsigned) {
8591 return BTy->
getKind() == BuiltinType::UChar ||
8592 BTy->
getKind() == BuiltinType::UShort ||
8593 BTy->
getKind() == BuiltinType::ULong ||
8594 BTy->
getKind() == BuiltinType::ULongLong;
8597 return BTy->
getKind() == BuiltinType::SChar ||
8598 BTy->
getKind() == BuiltinType::Short ||
8599 BTy->
getKind() == BuiltinType::LongLong;
8605 if ((Triple.isArch64Bit() || Triple.getArch() == llvm::Triple::aarch64_32) &&
8606 BTy->
getKind() == BuiltinType::Double)
8609 return BTy->
getKind() == BuiltinType::SChar ||
8610 BTy->
getKind() == BuiltinType::UChar ||
8611 BTy->
getKind() == BuiltinType::Short ||
8612 BTy->
getKind() == BuiltinType::UShort ||
8613 BTy->
getKind() == BuiltinType::Int ||
8614 BTy->
getKind() == BuiltinType::UInt ||
8615 BTy->
getKind() == BuiltinType::Long ||
8616 BTy->
getKind() == BuiltinType::ULong ||
8617 BTy->
getKind() == BuiltinType::LongLong ||
8618 BTy->
getKind() == BuiltinType::ULongLong ||
8619 BTy->
getKind() == BuiltinType::Float ||
8620 BTy->
getKind() == BuiltinType::Half ||
8621 BTy->
getKind() == BuiltinType::BFloat16 ||
8622 BTy->
getKind() == BuiltinType::MFloat8;
8627 const auto *AttrExpr =
Attr.getArgAsExpr(0);
8628 if (!AttrExpr->isTypeDependent()) {
8629 if (std::optional<llvm::APSInt> Res =
8630 AttrExpr->getIntegerConstantExpr(S.
Context)) {
8672 if (
Attr.getNumArgs() != 1) {
8673 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8679 llvm::APSInt numEltsInt(32);
8685 S.
Diag(
Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
8692 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
8693 unsigned vecSize = typeSize * numElts;
8694 if (vecSize != 64 && vecSize != 128) {
8695 S.
Diag(
Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
8707 assert((
Attr.getNumArgs() > 0 &&
Attr.getNumArgs() <= 3) &&
8708 "__ptrauth qualifier takes between 1 and 3 arguments");
8709 Expr *KeyArg =
Attr.getArgAsExpr(0);
8710 Expr *IsAddressDiscriminatedArg =
8711 Attr.getNumArgs() >= 2 ?
Attr.getArgAsExpr(1) :
nullptr;
8712 Expr *ExtraDiscriminatorArg =
8713 Attr.getNumArgs() >= 3 ?
Attr.getArgAsExpr(2) :
nullptr;
8722 bool IsInvalid =
false;
8723 unsigned IsAddressDiscriminated, ExtraDiscriminator;
8726 IsAddressDiscriminated);
8735 if (!
T->isSignableType(Ctx) && !
T->isDependentType()) {
8736 S.
Diag(
Attr.
getLoc(), diag::err_ptrauth_qualifier_invalid_target) <<
T;
8741 if (
T.getPointerAuth()) {
8753 assert((!IsAddressDiscriminatedArg || IsAddressDiscriminated <= 1) &&
8754 "address discriminator arg should be either 0 or 1");
8756 Key, IsAddressDiscriminated, ExtraDiscriminator,
8778 S.
Diag(
Attr.
getLoc(), diag::err_attribute_arm_feature_sve_bits_unsupported)
8785 if (
Attr.getNumArgs() != 1) {
8786 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8793 llvm::APSInt SveVectorSizeInBits(32);
8797 unsigned VecSize =
static_cast<unsigned>(SveVectorSizeInBits.getZExtValue());
8820 if (BT->getKind() == BuiltinType::SveBool) {
8825 VecSize /= TypeSize;
8832 const VectorType *VT = dyn_cast<VectorType>(CurType);
8835 diag::err_attribute_arm_mve_polymorphism);
8842 State.getSema().Context,
Attr),
8854 <<
Attr <<
"'zve32x'";
8861 if (!VScale || !VScale->first || VScale->first != VScale->second) {
8862 S.
Diag(
Attr.
getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
8869 if (
Attr.getNumArgs() != 1) {
8870 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8877 llvm::APSInt RVVVectorSizeInBits(32);
8889 unsigned VecSize =
static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue());
8893 unsigned MinElts = Info.
EC.getKnownMinValue();
8896 unsigned ExpectedSize = VScale->first * MinElts;
8918 ExpectedSize *= EltSize;
8919 NumElts = VecSize / EltSize;
8923 if (VecSize != ExpectedSize) {
8925 << VecSize << ExpectedSize;
8938 S.
Diag(
Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
8944 QualType BaseTy = TypedefTy->desugar();
8946 std::string PrevAccessQual;
8948 if (TypedefTy->getDecl()->hasAttr<OpenCLAccessAttr>()) {
8949 OpenCLAccessAttr *
Attr =
8950 TypedefTy->getDecl()->getAttr<OpenCLAccessAttr>();
8953 PrevAccessQual =
"read_only";
8957 switch (ImgType->getKind()) {
8958 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8959 case BuiltinType::Id: \
8960 PrevAccessQual = #Access; \
8962 #include "clang/Basic/OpenCLImageTypes.def"
8964 llvm_unreachable(
"Unable to find corresponding image type.");
8967 llvm_unreachable(
"unexpected type");
8970 if (PrevAccessQual == AttrName.ltrim(
"_")) {
8976 S.
Diag(
Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
8979 S.
Diag(TypedefTy->getDecl()->getBeginLoc(),
8980 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
8982 if (
Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
8997 if (
Attr.getNumArgs() != 2) {
8998 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
9003 Expr *RowsExpr =
Attr.getArgAsExpr(0);
9004 Expr *ColsExpr =
Attr.getArgAsExpr(1);
9012 Sema &S = State.getSema();
9015 S.
Diag(PA.
getLoc(), diag::err_attribute_too_few_arguments) << PA << 1;
9027 for (
unsigned Idx = 1; Idx < PA.
getNumArgs(); Idx++) {
9033 auto *AnnotateTypeAttr =
9034 AnnotateTypeAttr::Create(S.
Context, Str, Args.data(), Args.size(), PA);
9035 CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType);
9041 if (State.getDeclarator().isDeclarationOfFunction()) {
9042 CurType = State.getAttributedType(
9047 State.getSema().Diag(
Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
9054 if (State.getDeclarator().isDeclarationOfFunction()) {
9055 auto *
Attr = State.getSema().ParseLifetimeCaptureByAttr(PA,
"this");
9057 CurType = State.getAttributedType(
Attr, CurType, CurType);
9069 if (
Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_inout ||
9070 Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_out) {
9071 State.setParsedHLSLParamMod(
true);
9080 state.setParsedNoDeref(
false);
9096 if (
attr.isInvalid())
9099 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute()) {
9104 if (
attr.isGNUScope()) {
9105 assert(
attr.isStandardAttributeSyntax());
9106 bool IsTypeAttr =
attr.isTypeAttr();
9108 state.getSema().Diag(
attr.getLoc(),
9110 ? diag::warn_gcc_ignores_type_attr
9111 : diag::warn_cxx11_gnu_attribute_on_type)
9117 !
attr.isTypeAttr()) {
9130 switch (
attr.getKind()) {
9133 if ((
attr.isStandardAttributeSyntax() ||
9134 attr.isRegularKeywordAttribute()) &&
9136 state.getSema().Diag(
attr.getLoc(), diag::err_attribute_not_type_attr)
9137 <<
attr <<
attr.isRegularKeywordAttribute();
9138 attr.setUsedAsTypeAttr();
9143 if (
attr.isStandardAttributeSyntax()) {
9144 state.getSema().DiagnoseUnknownAttribute(
attr);
9154 case ParsedAttr::AT_BTFTypeTag:
9156 attr.setUsedAsTypeAttr();
9159 case ParsedAttr::AT_MayAlias:
9162 attr.setUsedAsTypeAttr();
9164 case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
9165 case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
9166 state.getSema().Diag(
attr.getLoc(), diag::warn_deprecated_attribute)
9169 case ParsedAttr::AT_OpenCLPrivateAddressSpace:
9170 case ParsedAttr::AT_OpenCLGlobalAddressSpace:
9171 case ParsedAttr::AT_OpenCLLocalAddressSpace:
9172 case ParsedAttr::AT_OpenCLConstantAddressSpace:
9173 case ParsedAttr::AT_OpenCLGenericAddressSpace:
9174 case ParsedAttr::AT_AddressSpace:
9175 case ParsedAttr::AT_SYCLPrivateAddressSpace:
9176 case ParsedAttr::AT_SYCLGlobalAddressSpace:
9177 case ParsedAttr::AT_SYCLLocalAddressSpace:
9178 case ParsedAttr::AT_SYCLConstantAddressSpace:
9179 case ParsedAttr::AT_SYCLGenericAddressSpace:
9181 attr.setUsedAsTypeAttr();
9183 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
9186 if (state.getSema().getLangOpts().getHLSLVersion() <
9188 state.getSema().Diag(
attr.getLoc(), diag::warn_hlsl_groupshared_202x);
9195 attr.setUsedAsTypeAttr();
9197 case ParsedAttr::AT_HLSLRowMajor:
9198 case ParsedAttr::AT_HLSLColumnMajor:
9200 state.getSema().HLSL().buildMatrixLayoutTypeAttr(
type,
attr)) {
9202 attr.getKind() == ParsedAttr::AT_HLSLRowMajor
9206 state.getSema().Context.getMatrixTypeWithLayout(
type, Layout);
9209 attr.setUsedAsTypeAttr();
9214 attr.setUsedAsTypeAttr();
9216 case ParsedAttr::AT_VectorSize:
9218 attr.setUsedAsTypeAttr();
9220 case ParsedAttr::AT_ExtVectorType:
9222 attr.setUsedAsTypeAttr();
9224 case ParsedAttr::AT_NeonVectorType:
9226 attr.setUsedAsTypeAttr();
9228 case ParsedAttr::AT_NeonPolyVectorType:
9231 attr.setUsedAsTypeAttr();
9233 case ParsedAttr::AT_ArmSveVectorBits:
9235 attr.setUsedAsTypeAttr();
9237 case ParsedAttr::AT_ArmMveStrictPolymorphism: {
9239 attr.setUsedAsTypeAttr();
9242 case ParsedAttr::AT_RISCVRVVVectorBits:
9244 attr.setUsedAsTypeAttr();
9246 case ParsedAttr::AT_OpenCLAccess:
9248 attr.setUsedAsTypeAttr();
9250 case ParsedAttr::AT_PointerAuth:
9253 attr.setUsedAsTypeAttr();
9255 case ParsedAttr::AT_LifetimeBound:
9259 case ParsedAttr::AT_LifetimeCaptureBy:
9263 case ParsedAttr::AT_OverflowBehavior:
9265 attr.setUsedAsTypeAttr();
9268 case ParsedAttr::AT_NoDeref: {
9273 if (
attr.isStandardAttributeSyntax()) {
9274 state.getSema().Diag(
attr.getLoc(), diag::warn_attribute_ignored)
9281 attr.setUsedAsTypeAttr();
9282 state.setParsedNoDeref(
true);
9286 case ParsedAttr::AT_MatrixType:
9288 attr.setUsedAsTypeAttr();
9291 case ParsedAttr::AT_WebAssemblyFuncref: {
9293 attr.setUsedAsTypeAttr();
9297 case ParsedAttr::AT_HLSLParamModifier: {
9299 if (attrs.
hasAttribute(ParsedAttr::AT_HLSLGroupSharedAddressSpace)) {
9300 state.getSema().Diag(
attr.getLoc(), diag::err_hlsl_attr_incompatible)
9301 <<
attr <<
"'groupshared'";
9305 attr.setUsedAsTypeAttr();
9309 case ParsedAttr::AT_SwiftAttr: {
9316 attr.setUsedAsTypeAttr();
9324 if (
type->canHaveNullability() ||
type->isDependentType() ||
9325 type->isArrayType() ||
9329 endIndex = state.getCurrentChunkIndex();
9331 endIndex = state.getDeclarator().getNumTypeObjects();
9332 bool allowOnArrayType =
9333 state.getDeclarator().isPrototypeContext() &&
9336 allowOnArrayType)) {
9340 attr.setUsedAsTypeAttr();
9344 case ParsedAttr::AT_ObjCKindOf:
9352 state.getSema().Diag(
attr.getLoc(),
9353 diag::err_objc_kindof_wrong_position)
9356 state.getDeclarator().getDeclSpec().getBeginLoc(),
9366 case ParsedAttr::AT_NoThrow:
9369 if (!state.getSema().getLangOpts().CPlusPlus)
9374 attr.setUsedAsTypeAttr();
9378 if (
attr.isStandardAttributeSyntax() ||
9379 attr.isRegularKeywordAttribute()) {
9396 case ParsedAttr::AT_AcquireHandle: {
9397 if (!
type->isFunctionType())
9400 if (
attr.getNumArgs() != 1) {
9401 state.getSema().Diag(
attr.getLoc(),
9402 diag::err_attribute_wrong_number_arguments)
9408 StringRef HandleType;
9409 if (!state.getSema().checkStringLiteralArgumentAttr(
attr, 0, HandleType))
9411 type = state.getAttributedType(
9412 AcquireHandleAttr::Create(state.getSema().Context, HandleType,
attr),
9414 attr.setUsedAsTypeAttr();
9417 case ParsedAttr::AT_AnnotateType: {
9419 attr.setUsedAsTypeAttr();
9422 case ParsedAttr::AT_HLSLResourceClass:
9423 case ParsedAttr::AT_HLSLResourceDimension:
9424 case ParsedAttr::AT_HLSLIsROV:
9425 case ParsedAttr::AT_HLSLRawBuffer:
9426 case ParsedAttr::AT_HLSLIsArray:
9427 case ParsedAttr::AT_HLSLIsMultiSampled:
9428 case ParsedAttr::AT_HLSLContainedType: {
9433 state.getSema().HLSL().handleResourceTypeAttr(
type,
attr))
9434 attr.setUsedAsTypeAttr();
9442 !
type.getQualifiers().hasObjCLifetime() &&
9443 !
type.getQualifiers().hasObjCGCAttr() &&
9444 attr.getKind() != ParsedAttr::AT_ObjCGC &&
9445 attr.getKind() != ParsedAttr::AT_ObjCOwnership) {
9447 type = state.getSema().Context.getMacroQualifiedType(
type, MacroII);
9448 state.setExpansionLocForMacroQualifiedType(
9450 attr.getMacroExpansionLoc());
9457 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
9459 auto *Def = Var->getDefinition();
9465 Def = Var->getDefinition();
9472 if (Var->getPointOfInstantiation().isInvalid() && Def) {
9473 assert(Var->getTemplateSpecializationKind() ==
9475 "explicit instantiation with no point of instantiation");
9476 Var->setTemplateSpecializationKind(
9477 Var->getTemplateSpecializationKind(), PointOfInstantiation);
9497 if (
const auto CastE = dyn_cast<ExplicitCastExpr>(E)) {
9498 QualType DestType = CastE->getTypeAsWritten();
9499 if (
const auto *IAT =
Context.getAsIncompleteArrayType(DestType)) {
9504 IAT->getElementType(),
9541 if (RequireCompleteTypeImpl(Loc,
T, Kind, &Diagnoser))
9543 if (
auto *TD =
T->getAsTagDecl(); TD && !TD->isCompleteDefinitionRequired()) {
9544 TD->setCompleteDefinitionRequired();
9545 Consumer.HandleTagDeclRequiredDefinition(TD);
9578 auto DefinitionIsAcceptable = [&](
NamedDecl *D) {
9598 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
9599 return RD->isThisDeclarationADefinition();
9600 if (
auto *ED = dyn_cast<EnumDecl>(D))
9601 return ED->isThisDeclarationADefinition();
9602 if (
auto *FD = dyn_cast<FunctionDecl>(D))
9603 return FD->isThisDeclarationADefinition();
9604 if (
auto *VD = dyn_cast<VarDecl>(D))
9606 llvm_unreachable(
"unexpected decl type");
9608 auto FoundAcceptableDefinition = [&](
NamedDecl *D) {
9610 return DefinitionIsAcceptable(D);
9618 return DefinitionIsAcceptable(D);
9620 for (
auto *RD : D->
redecls()) {
9622 if (!IsDefinition(ND))
9624 if (DefinitionIsAcceptable(ND)) {
9633 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9634 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
9636 D = RD->getDefinition();
9637 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
9638 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
9640 if (OnlyNeedComplete && (ED->isFixed() ||
getLangOpts().MSVCCompat)) {
9646 *Suggested =
nullptr;
9647 for (
auto *Redecl : ED->redecls()) {
9650 if (Redecl->isThisDeclarationADefinition() ||
9651 (Redecl->isCanonicalDecl() && !*Suggested))
9652 *Suggested = Redecl;
9657 D = ED->getDefinition();
9658 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
9659 if (
auto *Pattern = FD->getTemplateInstantiationPattern())
9661 D = FD->getDefinition();
9662 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
9663 if (
auto *Pattern = VD->getTemplateInstantiationPattern())
9665 D = VD->getDefinition();
9668 assert(D &&
"missing definition for pattern of instantiated definition");
9672 if (FoundAcceptableDefinition(D))
9677 if (
auto *Source =
Context.getExternalSource()) {
9678 Source->CompleteRedeclChain(D);
9679 return FoundAcceptableDefinition(D);
9695 bool OnlyNeedComplete) {
9712 bool OnlyNeedComplete) {
9720 if (!RD->
hasAttr<MSInheritanceAttr>()) {
9722 bool BestCase =
false;
9742 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
9743 S.
getASTContext(), BestCase, Loc, MSInheritanceAttr::Spelling(IM)));
9749 CompleteTypeKind Kind,
9750 TypeDiagnoser *Diagnoser) {
9759 if (
const auto *MPTy = dyn_cast<MemberPointerType>(
T.getCanonicalType())) {
9760 if (CXXRecordDecl *RD = MPTy->getMostRecentCXXRecordDecl();
9761 RD && !RD->isDependentType()) {
9763 if (
getLangOpts().CompleteMemberPointers && !RD->isBeingDefined() &&
9769 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
9776 NamedDecl *Def =
nullptr;
9788 NamedDecl *Suggested =
nullptr;
9794 if (Diagnoser && Suggested)
9797 return !TreatAsComplete;
9802 TagDecl *
Tag = dyn_cast_or_null<TagDecl>(Def);
9803 ObjCInterfaceDecl *IFace = dyn_cast_or_null<ObjCInterfaceDecl>(Def);
9815 if (
auto *Source =
Context.getExternalSource()) {
9816 if (Tag &&
Tag->hasExternalLexicalStorage())
9817 Source->CompleteType(Tag);
9819 Source->CompleteType(IFace);
9823 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9830 if (
auto *RD = dyn_cast_or_null<CXXRecordDecl>(Tag)) {
9831 bool Instantiated =
false;
9832 bool Diagnosed =
false;
9833 if (RD->isDependentContext()) {
9837 }
else if (
auto *ClassTemplateSpec =
9838 dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
9839 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
9843 Diagnoser, ClassTemplateSpec->hasStrictPackMatch());
9845 Instantiated =
true;
9848 CXXRecordDecl *Pattern = RD->getInstantiatedFromMemberClass();
9849 if (!RD->isBeingDefined() && Pattern) {
9850 MemberSpecializationInfo *MSI = RD->getMemberSpecializationInfo();
9851 assert(MSI &&
"Missing member specialization information?");
9861 Instantiated =
true;
9869 if (Diagnoser && Diagnosed)
9875 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9885 Diagnoser->diagnose(*
this, Loc,
T);
9889 if (Tag && !
Tag->isInvalidDecl() && !
Tag->getLocation().isInvalid())
9890 Diag(
Tag->getLocation(),
Tag->isBeingDefined()
9891 ? diag::note_type_being_defined
9892 : diag::note_forward_declaration)
9893 <<
Context.getCanonicalTagType(Tag);
9926 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
9932 assert(!
T->isDependentType() &&
"type should not be dependent");
9941 if (
T->isVariableArrayType())
9957 Diag(RD->getLocation(), diag::note_non_literal_lambda);
9966 Diag(RD->getLocation(), diag::note_non_literal_virtual_base)
9968 for (
const auto &I : RD->vbases())
9969 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
9970 << I.getSourceRange();
9971 }
else if (!RD->isAggregate() && !RD->hasConstexprNonCopyMoveConstructor() &&
9972 !RD->hasTrivialDefaultConstructor()) {
9973 Diag(RD->getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
9974 }
else if (RD->hasNonLiteralTypeFieldsOrBases()) {
9975 for (
const auto &I : RD->bases()) {
9976 if (!I.getType()->isLiteralType(
Context)) {
9977 Diag(I.getBeginLoc(), diag::note_non_literal_base_class)
9978 << RD << I.getType() << I.getSourceRange();
9982 for (
const auto *I : RD->fields()) {
9983 if (!I->getType()->isLiteralType(
Context) ||
9984 I->getType().isVolatileQualified()) {
9985 Diag(I->getLocation(), diag::note_non_literal_field)
9986 << RD << I << I->getType()
9987 << I->getType().isVolatileQualified();
9992 : !RD->hasTrivialDestructor()) {
9997 assert(Dtor &&
"class has literal fields and bases but no dtor?");
10002 Diag(Dtor->getLocation(), diag::note_non_literal_non_constexpr_dtor)
10005 Diag(Dtor->getLocation(), Dtor->isUserProvided()
10006 ? diag::note_non_literal_user_provided_dtor
10007 : diag::note_non_literal_nontrivial_dtor)
10009 if (!Dtor->isUserProvided())
10033 if (
const TagType *TT =
T->getAs<TagType>())
10036 return Context.getTypeOfExprType(E, Kind);
10054 auto Reject = [&]() ->
bool {
10057 if (!CATy->getCountExpr())
10058 Context.completeCountAttributedType(CATy, Arg, {});
10075 if (!CATy->getCountExpr())
10076 Context.completeCountAttributedType(CATy, Arg, Decls);
10091 return Context.getCountAttributedType(WrappedTy, CountExpr, CountInBytes,
10101 if (
auto *ImplCastExpr = dyn_cast<ImplicitCastExpr>(E))
10102 IDExpr = ImplCastExpr->getSubExpr();
10104 if (
auto *PackExpr = dyn_cast<PackIndexingExpr>(E)) {
10106 IDExpr = PackExpr->getPackIdExpression();
10108 IDExpr = PackExpr->getSelectedExpr();
10124 if (
const auto *SNTTPE = dyn_cast<SubstNonTypeTemplateParmExpr>(IDExpr))
10125 IDExpr = SNTTPE->getReplacement();
10133 if (
const auto *DRE = dyn_cast<DeclRefExpr>(IDExpr)) {
10138 if (
const auto *ME = dyn_cast<MemberExpr>(IDExpr)) {
10139 if (
const auto *VD = ME->getMemberDecl())
10141 return VD->getType();
10142 }
else if (
const auto *IR = dyn_cast<ObjCIvarRefExpr>(IDExpr)) {
10143 return IR->getDecl()->getType();
10144 }
else if (
const auto *PR = dyn_cast<ObjCPropertyRefExpr>(IDExpr)) {
10145 if (PR->isExplicitProperty())
10146 return PR->getExplicitProperty()->getType();
10147 }
else if (
const auto *PE = dyn_cast<PredefinedExpr>(IDExpr)) {
10148 return PE->getType();
10159 if (
auto *DRE = dyn_cast<DeclRefExpr>(IDExpr->
IgnoreParens())) {
10160 if (
auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
10163 return Context.getLValueReferenceType(
T);
10168 return Context.getReferenceQualifiedType(E);
10180 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
10192 Diag(Loc, diag::err_expected_name_of_pack) << Pattern;
10196 if (!
Type.isNull())
10197 DiagCompat(Loc, diag_compat::pack_indexing);
10207 llvm::APSInt
Value;
10214 IndexExpr = Res.
get();
10215 uint64_t
V =
Value.getZExtValue();
10216 if (FullySubstituted &&
V >= Expansions.size()) {
10218 <<
V << Pattern << Expansions.size();
10221 Index =
static_cast<unsigned>(
V);
10224 return Context.getPackIndexingType(Pattern, IndexExpr, FullySubstituted,
10225 Expansions, Index);
10230 assert(BaseType->isEnumeralType());
10231 EnumDecl *ED = BaseType->castAs<EnumType>()->getDecl();
10236 if (Underlying.
isNull()) {
10238 assert(!Underlying.
isNull());
10246 if (!BaseType->isEnumeralType()) {
10247 Diag(Loc, diag::err_only_enums_have_underlying_types);
10254 if (BaseType->isIncompleteType(&FwdDecl)) {
10255 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
10256 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
10264 QualType Pointer = BaseType.isReferenceable() || BaseType->isVoidType()
10273 if (!BaseType->isAnyPointerType())
10282 return Context.getDecayedType(Underlying);
10291 Split.Quals.removeCVRQualifiers();
10292 return Context.getQualifiedType(Split);
10299 BaseType.isReferenceable()
10301 UKind == UnaryTransformType::AddLvalueReference,
10309 if (UKind == UnaryTransformType::RemoveAllExtents)
10310 return Context.getBaseElementType(BaseType);
10312 if (
const auto *AT =
Context.getAsArrayType(BaseType))
10313 return AT->getElementType();
10321 QualType T = BaseType.getNonReferenceType();
10322 if (UKind == UTTKind::RemoveCVRef &&
10323 (
T.isConstQualified() ||
T.isVolatileQualified())) {
10328 T =
Context.getQualifiedType(Unqual, Quals);
10335 if ((BaseType->isReferenceType() && UKind != UTTKind::RemoveRestrict) ||
10336 BaseType->isFunctionType())
10342 if (UKind == UTTKind::RemoveConst || UKind == UTTKind::RemoveCV)
10344 if (UKind == UTTKind::RemoveVolatile || UKind == UTTKind::RemoveCV)
10346 if (UKind == UTTKind::RemoveRestrict)
10349 return Context.getQualifiedType(Unqual, Quals);
10355 if (BaseType->isEnumeralType()) {
10357 if (
auto *
BitInt = dyn_cast<BitIntType>(Underlying)) {
10358 unsigned int Bits =
BitInt->getNumBits();
10362 S.
Diag(Loc, diag::err_make_signed_integral_only)
10363 << IsMakeSigned <<
true << BaseType << 1 << Underlying;
10367 S.
Diag(Loc, diag::err_make_signed_integral_only)
10368 << IsMakeSigned <<
false << BaseType << 1
10375 std::array<CanQualType *, 6> AllSignedIntegers = {
10379 AllSignedIntegers.data(), AllSignedIntegers.size() - Int128Unsupported);
10380 std::array<CanQualType *, 6> AllUnsignedIntegers = {
10385 AllUnsignedIntegers.size() -
10386 Int128Unsupported);
10388 IsMakeSigned ? &AvailableSignedIntegers : &AvailableUnsignedIntegers;
10392 llvm::find_if(*Consider, [&S, BaseSize](
const CanQual<Type> *
T) {
10396 assert(
Result != Consider->end());
10397 return QualType((*Result)->getTypePtr(), 0);
10402 bool IsMakeSigned = UKind == UnaryTransformType::MakeSigned;
10403 if ((!BaseType->isIntegerType() && !BaseType->isEnumeralType()) ||
10404 BaseType->isBooleanType() ||
10405 (BaseType->isBitIntType() &&
10407 Diag(Loc, diag::err_make_signed_integral_only)
10408 << IsMakeSigned << BaseType->isBitIntType() << BaseType << 0;
10412 bool IsNonIntIntegral =
10413 BaseType->
isChar16Type() || BaseType->isChar32Type() ||
10414 BaseType->isWideCharType() || BaseType->isEnumeralType();
10419 : IsMakeSigned ?
Context.getCorrespondingSignedType(BaseType)
10420 :
Context.getCorrespondingUnsignedType(BaseType);
10421 if (Underlying.
isNull())
10428 if (BaseType->isDependentType())
10429 return Context.getUnaryTransformType(BaseType, BaseType, UKind);
10432 case UnaryTransformType::EnumUnderlyingType: {
10436 case UnaryTransformType::AddPointer: {
10440 case UnaryTransformType::RemovePointer: {
10444 case UnaryTransformType::Decay: {
10448 case UnaryTransformType::AddLvalueReference:
10449 case UnaryTransformType::AddRvalueReference: {
10453 case UnaryTransformType::RemoveAllExtents:
10454 case UnaryTransformType::RemoveExtent: {
10458 case UnaryTransformType::RemoveCVRef:
10459 case UnaryTransformType::RemoveReference: {
10463 case UnaryTransformType::RemoveConst:
10464 case UnaryTransformType::RemoveCV:
10465 case UnaryTransformType::RemoveRestrict:
10466 case UnaryTransformType::RemoveVolatile: {
10470 case UnaryTransformType::MakeSigned:
10471 case UnaryTransformType::MakeUnsigned: {
10489 int DisallowedKind = -1;
10490 if (
T->isArrayType())
10491 DisallowedKind = 1;
10492 else if (
T->isFunctionType())
10493 DisallowedKind = 2;
10494 else if (
T->isReferenceType())
10495 DisallowedKind = 3;
10496 else if (
T->isAtomicType())
10497 DisallowedKind = 4;
10498 else if (
T.hasQualifiers())
10499 DisallowedKind = 5;
10500 else if (
T->isSizelessType())
10501 DisallowedKind = 6;
10504 DisallowedKind = 7;
10505 else if (
T->isBitIntType())
10506 DisallowedKind = 8;
10509 DisallowedKind = 9;
10510 else if (
T->isOverflowBehaviorType())
10512 DisallowedKind = 10;
10514 if (DisallowedKind != -1) {
10515 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind <<
T;
Defines the clang::ASTContext interface.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Result
Implement __builtin_bit_cast and related operations.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static StringRef getTriple(const Command &Job)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Defines the clang::Preprocessor interface.
static QualType getUnderlyingType(const SubRegion *R)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S, VectorKind VecKind)
HandleNeonVectorTypeAttr - The "neon_vector_type" and "neon_polyvector_type" attributes are used to c...
static constexpr uint64_t MaxVectorSizeInBits
static QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType)
static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S)
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType type)
Given that an objc_gc attribute was written somewhere on a declaration other than on the declarator i...
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type.
#define MS_TYPE_ATTRS_CASELIST
#define CALLING_CONV_ATTRS_CASELIST
static void emitNullabilityConsistencyWarning(Sema &S, SimplePointerKind PointerKind, SourceLocation PointerLoc, SourceLocation PointerEndLoc)
static void fixItNullability(Sema &S, DiagBuilderT &Diag, SourceLocation PointerLoc, NullabilityKind Nullability)
Creates a fix-it to insert a C-style nullability keyword at pointerLoc, taking into account whitespac...
static ExprResult checkArraySize(Sema &S, Expr *&ArraySize, llvm::APSInt &SizeVal, unsigned VLADiag, bool VLAIsError)
Check whether the specified array bound can be evaluated using the relevant language rules.
static Attr * createNullabilityAttr(ASTContext &Ctx, ParsedAttr &Attr, NullabilityKind NK)
static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
HandleVectorSizeAttribute - this attribute is only applicable to integral and float scalars,...
static void inferARCWriteback(TypeProcessingState &state, QualType &declSpecType)
Given that this is the declaration of a parameter under ARC, attempt to infer attributes and such for...
static TypeSourceInfo * GetTypeSourceInfoForDeclarator(TypeProcessingState &State, QualType T, TypeSourceInfo *ReturnTypeInfo)
Create and instantiate a TypeSourceInfo with type source information.
static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx, const Expr *AddrSpace, SourceLocation AttrLoc)
Build an AddressSpace index from a constant expression and diagnose any errors related to invalid add...
static void HandleBTFTypeTagAttribute(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type.
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk)
static void HandleExtVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
static void HandleHLSLParamModifierAttr(TypeProcessingState &State, QualType &CurType, const ParsedAttr &Attr, Sema &S)
static void HandleLifetimeBoundAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &Attr)
static bool handleArmStateAttribute(Sema &S, FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, FunctionType::ArmStateValue State)
static bool handleArmAgnosticAttribute(Sema &S, FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr)
static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType, CUDAFunctionTarget CFT)
A function type attribute was written in the decl spec.
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
static constexpr uint64_t MaxVectorElements
static QualType inferARCLifetimeForPointee(Sema &S, QualType type, SourceLocation loc, bool isReference)
Given that we're building a pointer or reference to the given.
static bool handleNonBlockingNonAllocatingTypeAttr(TypeProcessingState &TPState, ParsedAttr &PAttr, QualType &QT, FunctionTypeUnwrapper &Unwrapped)
static QualType ChangeIntegralSignedness(Sema &S, QualType BaseType, bool IsMakeSigned, SourceLocation Loc)
static bool CheckNullabilityTypeSpecifier(Sema &S, TypeProcessingState *State, ParsedAttr *PAttr, QualType &QT, NullabilityKind Nullability, SourceLocation NullabilityLoc, bool IsContextSensitive, bool AllowOnArrayType, bool OverrideExisting)
#define OBJC_POINTER_TYPE_ATTRS_CASELIST
static void diagnoseBadTypeAttribute(Sema &S, const ParsedAttr &attr, QualType type)
diagnoseBadTypeAttribute - Diagnoses a type attribute which doesn't apply to the given type.
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator, PointerWrappingDeclaratorKind &wrappingKind)
Classify the given declarator, whose type-specified is type, based on what kind of pointer it refers ...
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr, llvm::APSInt &Result)
static void HandleSwiftAttr(TypeProcessingState &State, TypeAttrLocation TAL, QualType &QT, ParsedAttr &PAttr)
static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
static bool shouldHaveNullability(QualType T)
static void HandleArmMveStrictPolymorphismAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &Attr)
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, DeclaratorChunk &DeclType, QualType RT)
Produce an appropriate diagnostic for an ambiguity between a function declarator and a C++ direct-ini...
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType)
Distribute an objc_gc type attribute that was written on the declarator.
static FileID getNullabilityCompletenessCheckFileID(Sema &S, SourceLocation loc)
static void HandleOverflowBehaviorAttr(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
static void HandleArmSveVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr, Sema &S)
HandleArmSveVectorBitsTypeAttr - The "arm_sve_vector_bits" attribute is used to create fixed-length v...
#define FUNCTION_TYPE_ATTRS_CASELIST
static void HandleLifetimeCaptureByAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &PA)
static bool distributeNullabilityTypeAttr(TypeProcessingState &state, QualType type, ParsedAttr &attr)
Distribute a nullability type attribute that cannot be applied to the type specifier to a pointer,...
static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, QualType &declSpecType, CUDAFunctionTarget CFT)
Given that there are attributes written on the declarator or declaration itself, try to distribute an...
static void fillHLSLAttributedResourceTypeLoc(HLSLAttributedResourceTypeLoc TL, TypeProcessingState &State)
static void distributeFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType type)
A function type attribute was written somewhere in a declaration other than on the declarator itself ...
static void HandleMatrixTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
HandleMatrixTypeAttr - "matrix_type" attribute, like ext_vector_type.
static bool HandleWebAssemblyFuncrefAttr(TypeProcessingState &State, QualType &QT, ParsedAttr &PAttr)
static bool hasOuterPointerLikeChunk(const Declarator &D, unsigned endIndex)
Returns true if any of the declarator chunks before endIndex include a level of indirection: array,...
static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
Handle OpenCL Access Qualifier Attribute.
static NullabilityKind mapNullabilityAttrKind(ParsedAttr::Kind kind)
Map a nullability attribute kind to a nullability kind.
static bool distributeFunctionTypeAttrToInnermost(TypeProcessingState &state, ParsedAttr &attr, ParsedAttributesView &attrList, QualType &declSpecType, CUDAFunctionTarget CFT)
Try to distribute a function type attribute to the innermost function chunk or type.
#define NULLABILITY_TYPE_ATTRS_CASELIST
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TypeSourceInfo *&ReturnTypeInfo)
static void checkNullabilityConsistency(Sema &S, SimplePointerKind pointerKind, SourceLocation pointerLoc, SourceLocation pointerEndLoc=SourceLocation())
Complains about missing nullability if the file containing pointerLoc has other uses of nullability (...
static void transferARCOwnership(TypeProcessingState &state, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Used for transferring ownership in casts resulting in l-values.
static std::string getPrintableNameForEntity(DeclarationName Entity)
static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy)
static QualType rebuildAttributedTypeWithoutNullability(ASTContext &Ctx, QualType Type)
Rebuild an attributed type without the nullability attribute on it.
static DeclaratorChunk * maybeMovePastReturnType(Declarator &declarator, unsigned i, bool onlyBlockPointers)
Given the index of a declarator chunk, check whether that chunk directly specifies the return type of...
static OpenCLAccessAttr::Spelling getImageAccess(const ParsedAttributesView &Attrs)
static void fillMatrixTypeLoc(MatrixTypeLoc MTL, const ParsedAttributesView &Attrs)
static UnaryTransformType::UTTKind TSTToUnaryTransformType(DeclSpec::TST SwitchTST)
static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr, Sema &S)
HandleRISCVRVVVectorBitsTypeAttr - The "riscv_rvv_vector_bits" attribute is used to create fixed-leng...
static void HandleAddressSpaceTypeAttribute(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
HandleAddressSpaceTypeAttribute - Process an address_space attribute on the specified type.
static bool checkQualifiedFunction(Sema &S, QualType T, SourceLocation Loc, QualifiedFunctionKind QFK)
Check whether the type T is a qualified function type, and if it is, diagnose that it cannot be conta...
static bool checkOmittedBlockReturnType(Sema &S, Declarator &declarator, QualType Result)
Return true if this is omitted block return type.
static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, const ParsedAttr &Attr, Sema &S)
Handle the __ptrauth qualifier.
static bool DiagnoseMultipleAddrSpaceAttributes(Sema &S, LangAS ASOld, LangAS ASNew, SourceLocation AttrLoc)
static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T)
Produce an appropriate diagnostic for a declarator with top-level parentheses.
static QualType ConvertDeclSpecToType(TypeProcessingState &state)
Convert the specified declspec to the appropriate type object.
static std::pair< QualType, TypeSourceInfo * > InventTemplateParameter(TypeProcessingState &state, QualType T, TypeSourceInfo *TrailingTSI, AutoType *Auto, InventedTemplateParameterInfo &Info)
static void distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType, CUDAFunctionTarget CFT)
A function type attribute was written on the declarator or declaration.
static void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS, unsigned &TypeQuals, QualType TypeSoFar, unsigned RemoveTQs, unsigned DiagID)
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const ParsedAttributesView &AttrList, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
Helper for figuring out the default CC for a function declarator type.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for literal type diagnostic message.
static void recordNullabilitySeen(Sema &S, SourceLocation loc)
Marks that a nullability feature has been used in the file containing loc.
static bool CheckBitIntElementType(Sema &S, SourceLocation AttrLoc, const BitIntType *BIT, bool ForMatrixType=false)
static void checkExtParameterInfos(Sema &S, ArrayRef< QualType > paramTypes, const FunctionProtoType::ExtProtoInfo &EPI, llvm::function_ref< SourceLocation(unsigned)> getParamLoc)
Check the extended parameter information.
static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type, CUDAFunctionTarget CFT)
Process an individual function attribute.
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
static void BuildTypeCoupledDecls(Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
static void assignInheritanceModel(Sema &S, CXXRecordDecl *RD)
Locks in the inheritance model for the given class and all of its bases.
static bool checkObjCKindOfType(TypeProcessingState &state, QualType &type, ParsedAttr &attr)
Check the application of the Objective-C '__kindof' qualifier to the given type.
static bool hasNullabilityAttr(const ParsedAttributesView &attrs)
Check whether there is a nullability attribute of any kind in the given attribute list.
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type.
static void moveAttrFromListToList(ParsedAttr &attr, ParsedAttributesView &fromList, ParsedAttributesView &toList)
static void HandleAnnotateTypeAttr(TypeProcessingState &State, QualType &CurType, const ParsedAttr &PA)
static void fillAttributedTypeLoc(AttributedTypeLoc TL, TypeProcessingState &State)
TypeAttrLocation
The location of a type attribute.
@ TAL_DeclChunk
The attribute is part of a DeclaratorChunk.
@ TAL_DeclSpec
The attribute is in the decl-specifier-seq.
@ TAL_DeclName
The attribute is immediately after the declaration's name.
static bool isOmittedBlockReturnType(const Declarator &D)
isOmittedBlockReturnType - Return true if this declarator is missing a return type because this is a ...
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
static QualType GetEnumUnderlyingType(Sema &S, QualType BaseType, SourceLocation Loc)
static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, ArrayRef< const ParsedAttributesView * > AttrLists)
static bool IsNoDerefableChunk(const DeclaratorChunk &Chunk)
static AttrT * createSimpleAttr(ASTContext &Ctx, ParsedAttr &AL)
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, const ParsedAttributesView &attrs, CUDAFunctionTarget CFT=CUDAFunctionTarget::HostDevice)
static bool checkMutualExclusion(TypeProcessingState &state, const FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, AttributeCommonInfo::Kind OtherKind)
static Attr * getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr)
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ int max(int __a, int __b)
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
TranslationUnitDecl * getTranslationUnitDecl() const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
CanQualType UnsignedLongTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
CanQualType UnsignedLongLongTy
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
DiagnosticsEngine & getDiagnostics() const
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getPointerAuthType(QualType Ty, PointerAuthQualifier PointerAuth)
Return a type with the given __ptrauth qualifier.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
void setLBracketLoc(SourceLocation Loc)
void setRBracketLoc(SourceLocation Loc)
void setSizeExpr(Expr *Size)
TypeLoc getValueLoc() const
void setKWLoc(SourceLocation Loc)
void setParensRange(SourceRange Range)
Attr - This represents one attribute.
attr::Kind getKind() const
const char * getSpelling() const
SourceRange getRange() const
bool isContextSensitiveKeywordAttribute() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() const
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
void setAttr(const Attr *A)
bool hasExplicitTemplateArgs() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
TemplateName getNamedConcept() const
SourceLocation getLAngleLoc() const
void setConceptReference(ConceptReference *CR)
NamedDecl * getFoundDecl() const
TemplateArgumentLoc getArgLoc(unsigned i) const
unsigned getNumArgs() const
DeclarationNameInfo getConceptNameInfo() const
void setRParenLoc(SourceLocation Loc)
TypeLoc getWrappedLoc() const
Comparison function object.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
void setCaretLoc(SourceLocation Loc)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
TypeSpecifierWidth getWrittenWidthSpec() const
bool needsExtraLocalData() const
void setBuiltinLoc(SourceLocation Loc)
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
TypeSpecifierSign getWrittenSignSpec() const
void expandBuiltinRange(SourceRange Range)
This class is used for builtin types like 'int'.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
bool hasDefinition() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Represents a canonical, potentially-qualified type.
SourceLocation getBegin() const
This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const TypeClass * getTypePtr() const
TypeLoc getNextTypeLoc() const
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
A reference to a declared variable, function, enum, etc.
Captures information about "declaration specifiers".
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
bool isTypeSpecPipe() const
static const TST TST_typeof_unqualType
SourceLocation getTypeSpecSignLoc() const
bool hasAutoTypeSpec() const
static const TST TST_typename
SourceLocation getEndLoc() const LLVM_READONLY
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
static const TST TST_char8
static const TST TST_BFloat16
TST getTypeSpecType() const
SCS getStorageClassSpec() const
SourceLocation getOverflowBehaviorLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isTypeSpecSat() const
SourceRange getSourceRange() const LLVM_READONLY
static const TST TST_auto_type
static const TST TST_interface
static const TST TST_double
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
TemplateIdAnnotation * getRepAsTemplateId() const
static const TST TST_union
static const TST TST_typename_pack_indexing
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
static const TST TST_unknown_anytype
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_accum
static const TST TST_half
ParsedAttributes & getAttributes()
bool isTypeAltiVecPixel() const
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
static const TST TST_ibm128
Expr * getRepAsExpr() const
static const TST TST_enum
AttributePool & getAttributePool() const
bool isWrapSpecified() const
static const TST TST_float128
static const TST TST_decltype
SourceRange getTypeSpecWidthRange() const
SourceLocation getTypeSpecTypeNameLoc() const
SourceLocation getTypeSpecWidthLoc() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_typeof_unqualExpr
static const TST TST_class
bool isOverflowBehaviorSpecified() const
bool hasTagDefinition() const
static const TST TST_decimal64
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isTypeAltiVecBool() const
bool isConstrainedAuto() const
static const TST TST_wchar
SourceLocation getTypeSpecComplexLoc() const
static const TST TST_void
bool isTypeAltiVecVector() const
static const TST TST_bitint
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_float
static const TST TST_atomic
bool isTrapSpecified() const
static const TST TST_fract
Decl * getRepAsDecl() const
static const TST TST_float16
static bool isTransformTypeTrait(TST T)
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
TypeSpecifierSign getTypeSpecSign() const
CXXScopeSpec & getTypeSpecScope()
SourceLocation getTypeSpecTypeLoc() const
OverflowBehaviorState getOverflowBehaviorState() const
static const TST TST_decltype_auto
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
static const TST TST_decimal32
TypeSpecifierWidth getTypeSpecWidth() const
static const TST TST_char32
static const TST TST_decimal128
bool isTypeSpecOwned() const
SourceLocation getTypeSpecSatLoc() const
SourceRange getTypeofParensRange() const
SourceLocation getUnalignedSpecLoc() const
static const TST TST_int128
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
static const TST TST_typeofType
static const TST TST_auto
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
bool isInvalidDecl() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
NameKind getNameKind() const
Determine what kind of name this is.
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk,...
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
FunctionDefinitionKind getFunctionDefinitionKind() const
const ParsedAttributes & getAttributes() const
SourceLocation getIdentifierLoc() const
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
SourceLocation getEndLoc() const LLVM_READONLY
bool isExpressionContext() const
Determine whether this declaration appears in a context where an expression could appear.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
SourceLocation getEllipsisLoc() const
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isFirstDeclarator() const
SourceLocation getCommaLoc() const
AttributePool & getAttributePool() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ParsedType getTrailingReturnType() const
Get the trailing return type appearing (at any level) within this declarator.
bool isInvalidType() const
bool isExplicitObjectMemberFunction()
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
bool isPrototypeContext() const
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
void setEllipsisLoc(SourceLocation EL)
const IdentifierInfo * getIdentifier() const
void setRParenLoc(SourceLocation Loc)
void setDecltypeLoc(SourceLocation Loc)
void setAttrNameLoc(SourceLocation loc)
void setAttrOperandParensRange(SourceRange range)
void setAttrExprOperand(Expr *e)
Represents an extended address space qualifier where the input address space value is dependent.
void copy(DependentNameTypeLoc Loc)
void 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...
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Represents a member of a struct/union/class.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
A SourceLocation and its associated SourceManager.
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
A mutable set of FunctionEffects and possibly conditions attached to them.
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
SmallVector< Conflict > Conflicts
Represents an abstract function effect, using just an enumeration describing its kind.
Kind
Identifies the particular effect.
An immutable set of FunctionEffects and possibly conditions attached to them.
Represents a prototype with parameter type info, e.g.
Qualifiers getMethodQuals() const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
unsigned getNumParams() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
void setParam(unsigned i, ParmVarDecl *VD)
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
CallingConv getCC() const
bool getProducesResult() const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
AArch64SMETypeAttributes
The AArch64 SME ACLE (Arm C/C++ Language Extensions) define a number of function type attributes that...
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_AgnosticZAStateMask
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
CallingConv getCallConv() const
QualType getReturnType() const
bool getHasRegParm() const
Type source information for HLSL attributed resource type.
TypeLoc getWrappedLoc() const
void setContainedTypeSourceInfo(TypeSourceInfo *TSI) const
void setSourceRange(const SourceRange &R)
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
A simple pair of identifier info and location.
void setIdentifierInfo(IdentifierInfo *Ident)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ElaboratedTypeKeyword getKeyword() const
void setAmpLoc(SourceLocation Loc)
An lvalue reference type, per C++11 [dcl.ref].
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
bool isImplicitIntAllowed() const
Returns true if implicit int is supported at all.
bool allowArrayReturnTypes() const
bool isTargetDevice() const
True when compiling for an offloading target device.
bool isImplicitIntRequired() const
Returns true if implicit int is part of the language requirements.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
Represents the results of name lookup.
TypeLoc getInnerLoc() const
void setExpansionLoc(SourceLocation Loc)
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
void setAttrRowOperand(Expr *e)
void setAttrColumnOperand(Expr *e)
void setAttrOperandParensRange(SourceRange range)
void setAttrNameLoc(SourceLocation loc)
static bool isValidElementType(QualType T, const LangOptions &LangOpts)
Valid elements types are the following:
void setStarLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
This represents a decl that may have a name.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents an ObjC class declaration.
void setNameLoc(SourceLocation Loc)
void setNameEndLoc(SourceLocation Loc)
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Wraps an ObjCPointerType with source location information.
void setStarLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
static OpaquePtr make(QualType P)
OpenCL supported extensions and optional core features.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
TypeLoc getWrappedLoc() const
A parameter attribute which changes the argument-passing ABI rule for the parameter.
void setRParenLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
void setInvalid(bool b=true) const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
AttributeCommonInfo::Kind getKind() const
void setUsedAsTypeAttr(bool Used=true)
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
bool hasMSPropertyAttr() const
void addAtEnd(ParsedAttr *newAttr)
bool hasAttribute(ParsedAttr::Kind K) const
void remove(ParsedAttr *ToBeRemoved)
void takeOneFrom(ParsedAttributes &Other, ParsedAttr *PA)
TypeLoc getValueLoc() const
void setKWLoc(SourceLocation Loc)
Pointer-authentication qualifiers.
static PointerAuthQualifier Create(unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues)
@ MaxKey
The maximum supported pointer-authentication key.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
PointerAuthQualifier getPointerAuth() const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
SplitQualType getSplitUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
UnqualTypeLoc getUnqualifiedLoc() const
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
void addCVRUQualifiers(unsigned mask)
static Qualifiers fromCVRMask(unsigned CVR)
void setUnaligned(bool flag)
std::string getAsString() const
@ MaxAddressSpace
The maximum supported address space number.
void addObjCLifetime(ObjCLifetime type)
void setAmpAmpLoc(SourceLocation Loc)
QualType getPointeeType() const
bool isSpelledAsLValue() const
bool isFunctionDeclarationScope() const
isFunctionDeclarationScope - Return true if this scope is a function prototype scope.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
QualType ProcessResourceTypeAttributes(QualType Wrapped)
QualType getInoutParameterType(QualType Ty)
bool isCFError(RecordDecl *D)
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
QualType BuildParenType(QualType T)
Build a paren type including T.
bool ActOnLateParsedTypeAttrArgument(BoundsAttributedType *BATy, FieldDecl *FD, Expr *Arg)
Supply the parsed argument of a late-parsed bounds attribute to the type built for it by ActOnLatePar...
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Scope * getCurScope() const
Retrieve the parser's current scope.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
UnaryTransformType::UTTKind UTTKind
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
bool checkPointerAuthDiscriminatorArg(Expr *Arg, PointerAuthDiscArgKind Kind, unsigned &IntVal)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
std::optional< FunctionEffectMode > ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName)
Try to parse the conditional expression attached to an effect attribute (e.g.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain, bool PrimaryStrictPackMatch)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TrivialABIHandling::IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_TypeConstraint
A type constraint.
const LangOptions & getLangOpts() const
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc)
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
const LangOptions & LangOpts
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
void completeExprArrayBound(Expr *E)
bool hasExplicitCallingConv(QualType T)
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
sema::FunctionScopeInfo * getCurFunction() const
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements, SourceLocation Loc, SourceRange Range=SourceRange())
Diagnose an array of NumElements elements of type ElementType that is too large.
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
QualType BuildMemberPointerType(QualType T, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
ExprResult DefaultLvalueConversion(Expr *E)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
bool isAcceptable(const NamedDecl *D, AcceptableKind Kind)
Determine whether a declaration is acceptable (visible/reachable).
QualType getDecltypeForExpr(Expr *E)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool hasVisibleMergedDefinition(const NamedDecl *Def)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType BuildAtomicType(QualType T, SourceLocation Loc)
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool diagnoseConflictingFunctionEffect(const FunctionEffectsRef &FX, const FunctionEffectWithCondition &EC, SourceLocation NewAttrLoc)
Warn and return true if adding a function effect to a set would create a conflict.
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
TypeResult ActOnTypeName(Declarator &D)
bool isSFINAEContext() const
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
bool CheckImplicitNullabilityTypeSpecifier(QualType &Type, NullabilityKind Nullability, SourceLocation DiagLoc, bool AllowArrayTypes, bool OverrideExisting)
Check whether a nullability type specifier can be added to the given type through some means not writ...
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
llvm::BumpPtrAllocator BumpAlloc
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Information about a FileID, basically just the logical file that it represents and include stack info...
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
Exposes information about the current target.
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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 size_t getMaxBitIntWidth() const
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SourceLocation getRAngleLoc() const
void copy(TemplateSpecializationTypeLoc Loc)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
const Type * getTypeForDecl() const
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
void * getOpaqueData() const
Get the pointer where source information is stored.
void copy(TypeLoc other)
Copies the other type loc into this one.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
bool isIncompleteArrayType() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isUndeducedAutoType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXRecordDecl * castAsCXXRecordDecl() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isSizelessBuiltinType() const
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isChar16Type() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool isMemberPointerType() const
bool isAtomicType() const
bool isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isObjCRetainableType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Base class for declarations which introduce a typedef-name.
void setParensRange(SourceRange range)
void setTypeofLoc(SourceLocation Loc)
Wrapper of type source information for a type with no direct qualifiers.
TypeLocClass getTypeLocClass() const
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
@ Definition
This declaration is definitely a definition.
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.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ ExpectedParameterOrImplicitObjectParameter
@ ExpectedFunctionWithProtoType
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
decltype(auto)
llvm::StringRef getParameterABISpelling(ParameterABI kind)
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
LLVM_READONLY bool isAsciiIdentifierContinue(unsigned char c)
QualType pointeeType(QualType T)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ Success
Annotation was successful.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
TypeOfKind
The kind of 'typeof' expression we're after.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
@ AANT_ArgumentIntegerConstant
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
ArraySizeModifier
Capture whether this is a normal array (e.g.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
static bool isBlockPointer(Expr *Arg)
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ FirstTargetAddressSpace
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ 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)
@ 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.
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.