41#include "llvm/ADT/ArrayRef.h"
42#include "llvm/ADT/STLForwardCompat.h"
43#include "llvm/ADT/SmallPtrSet.h"
44#include "llvm/ADT/SmallString.h"
45#include "llvm/ADT/StringExtras.h"
46#include "llvm/IR/DerivedTypes.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/ErrorHandling.h"
63 if (D.
getContext() != DeclaratorContext::BlockLiteral ||
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();
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_AMDGPUKernelCall: \
137 case ParsedAttr::AT_MSABI: \
138 case ParsedAttr::AT_SysVABI: \
139 case ParsedAttr::AT_Pcs: \
140 case ParsedAttr::AT_IntelOclBicc: \
141 case ParsedAttr::AT_PreserveMost: \
142 case ParsedAttr::AT_PreserveAll: \
143 case ParsedAttr::AT_M68kRTD: \
144 case ParsedAttr::AT_PreserveNone: \
145 case ParsedAttr::AT_RISCVVectorCC
148#define FUNCTION_TYPE_ATTRS_CASELIST \
149 case ParsedAttr::AT_NSReturnsRetained: \
150 case ParsedAttr::AT_NoReturn: \
151 case ParsedAttr::AT_Regparm: \
152 case ParsedAttr::AT_CmseNSCall: \
153 case ParsedAttr::AT_ArmStreaming: \
154 case ParsedAttr::AT_ArmStreamingCompatible: \
155 case ParsedAttr::AT_ArmPreserves: \
156 case ParsedAttr::AT_ArmIn: \
157 case ParsedAttr::AT_ArmOut: \
158 case ParsedAttr::AT_ArmInOut: \
159 case ParsedAttr::AT_AnyX86NoCallerSavedRegisters: \
160 case ParsedAttr::AT_AnyX86NoCfCheck: \
161 CALLING_CONV_ATTRS_CASELIST
164#define MS_TYPE_ATTRS_CASELIST \
165 case ParsedAttr::AT_Ptr32: \
166 case ParsedAttr::AT_Ptr64: \
167 case ParsedAttr::AT_SPtr: \
168 case ParsedAttr::AT_UPtr
171#define NULLABILITY_TYPE_ATTRS_CASELIST \
172 case ParsedAttr::AT_TypeNonNull: \
173 case ParsedAttr::AT_TypeNullable: \
174 case ParsedAttr::AT_TypeNullableResult: \
175 case ParsedAttr::AT_TypeNullUnspecified
180 class TypeProcessingState {
204 using TypeAttrPair = std::pair<const AttributedType*, const Attr*>;
206 bool AttrsForTypesSorted =
true;
210 llvm::DenseMap<const MacroQualifiedType *, SourceLocation> LocsForMacros;
218 : sema(sema), declarator(declarator),
221 Sema &getSema()
const {
229 bool isProcessingDeclSpec()
const {
233 unsigned getCurrentChunkIndex()
const {
237 void setCurrentChunkIndex(
unsigned idx) {
243 if (isProcessingDeclSpec())
244 return getMutableDeclSpec().getAttributes();
249 void saveDeclSpecAttrs() {
251 if (!savedAttrs.empty())
254 DeclSpec &spec = getMutableDeclSpec();
255 llvm::append_range(savedAttrs,
262 ignoredTypeAttrs.push_back(&
attr);
268 for (
auto *
Attr : ignoredTypeAttrs)
278 AttrsForTypes.push_back({cast<AttributedType>(
T.getTypePtr()), A});
279 AttrsForTypesSorted =
false;
284 QualType getBTFTagAttributedType(
const BTFTypeTagAttr *BTFAttr,
296 auto *NewAttrTy = cast<AttributedType>(
T.getTypePtr());
297 for (TypeAttrPair &A : AttrsForTypes) {
298 if (A.first == AttrTy)
301 AttrsForTypesSorted =
false;
308 if (!AttrsForTypesSorted) {
309 llvm::stable_sort(AttrsForTypes, llvm::less_first());
310 AttrsForTypesSorted =
true;
315 for (
auto It = std::partition_point(
316 AttrsForTypes.begin(), AttrsForTypes.end(),
317 [=](
const TypeAttrPair &A) { return A.first < AT; });
318 It != AttrsForTypes.end() && It->first == AT; ++It) {
320 const Attr *Result = It->second;
321 It->second =
nullptr;
326 llvm_unreachable(
"no Attr* for AttributedType*");
331 auto FoundLoc = LocsForMacros.find(MQT);
332 assert(FoundLoc != LocsForMacros.end() &&
333 "Unable to find macro expansion location for MacroQualifedType");
334 return FoundLoc->second;
339 LocsForMacros[MQT] = Loc;
342 void setParsedNoDeref(
bool parsed) { parsedNoDeref = parsed; }
344 bool didParseNoDeref()
const {
return parsedNoDeref; }
346 ~TypeProcessingState() {
347 if (savedAttrs.empty())
350 getMutableDeclSpec().getAttributes().clearListOnly();
352 getMutableDeclSpec().getAttributes().addAtEnd(AL);
356 DeclSpec &getMutableDeclSpec()
const {
398 if (
attr.getKind() == ParsedAttr::AT_ObjCGC)
400 assert(
attr.getKind() == ParsedAttr::AT_ObjCOwnership);
415 bool onlyBlockPointers) {
421 for (; i != 0; --i) {
423 switch (fnChunk.
Kind) {
439 for (--i; i != 0; --i) {
441 switch (ptrChunk.
Kind) {
451 if (onlyBlockPointers)
460 llvm_unreachable(
"bad declarator chunk kind");
466 llvm_unreachable(
"bad declarator chunk kind");
483 Declarator &declarator = state.getDeclarator();
486 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
488 switch (chunk.
Kind) {
494 if (state.isProcessingDeclSpec() &&
495 attr.getKind() == ParsedAttr::AT_ObjCOwnership)
498 if (!destChunk) destChunk = &chunk;
511 if (state.isProcessingDeclSpec() &&
512 attr.getKind() == ParsedAttr::AT_ObjCOwnership) {
539 Declarator &declarator = state.getDeclarator();
543 unsigned innermost = -1U;
544 bool considerDeclSpec =
true;
547 switch (chunk.
Kind) {
561 considerDeclSpec =
false;
569 if (considerDeclSpec) {
574 state.saveDeclSpecAttrs();
583 if (innermost != -1U) {
591 state.addIgnoredTypeAttr(
attr);
600 Declarator &declarator = state.getDeclarator();
604 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
606 switch (chunk.
Kind) {
633 Declarator &declarator = state.getDeclarator();
653 state.saveDeclSpecAttrs();
657 state,
attr, state.getCurrentAttributes(), declSpecType, CFT))
662 state.addIgnoredTypeAttr(
attr);
673 Declarator &declarator = state.getDeclarator();
683 state.addIgnoredTypeAttr(
attr);
708 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute())
711 switch (
attr.getKind()) {
728 case ParsedAttr::AT_ObjCKindOf:
741 Declarator &declarator = state.getDeclarator();
787 std::nullopt, loc, loc, declarator));
802 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
807 if (!(RemoveTQs & Qual.first))
811 if (TypeQuals & Qual.first)
812 S.
Diag(Qual.second, DiagID)
817 TypeQuals &= ~Qual.first;
831 if (AL.isInvalid() || !AL.isTypeAttr())
834 diag::warn_block_literal_attributes_on_omitted_return_type)
836 ToBeRemoved.push_back(&AL);
846 diag::warn_block_literal_qualifiers_on_omitted_return_type);
859 if (!objcObjectType || !objcObjectType->getInterface()) {
860 S.
Diag(loc, diag::err_objc_type_args_non_class)
873 S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
884 if (objcObjectType->isSpecialized()) {
885 S.
Diag(loc, diag::err_objc_type_args_specialized_class)
897 unsigned numTypeParams = typeParams->
size();
898 bool anyPackExpansions =
false;
899 for (
unsigned i = 0, n = typeArgs.size(); i != n; ++i) {
907 bool diagnosed =
false;
910 rangeToRemove =
attr.getLocalSourceRange();
911 if (
attr.getTypePtr()->getImmediateNullability()) {
912 typeArg =
attr.getTypePtr()->getModifiedType();
914 diag::err_objc_type_arg_explicit_nullability)
922 if (!rebuilding && !diagnosed) {
923 S.
Diag(qual.getBeginLoc(), diag::err_objc_type_arg_qualified)
932 finalTypeArgs.push_back(typeArg);
935 anyPackExpansions =
true;
939 if (!anyPackExpansions) {
940 if (i < numTypeParams) {
941 typeParam = typeParams->
begin()[i];
944 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
965 assert(anyPackExpansions &&
"Too many arguments?");
974 if (typeArgObjC->isObjCIdType()) {
977 if (boundObjC->isObjCIdType())
986 diag::err_objc_type_arg_does_not_match_bound)
1003 assert(anyPackExpansions &&
"Too many arguments?");
1014 diag::err_objc_type_arg_does_not_match_bound)
1037 diag::err_objc_type_arg_not_id_compatible)
1047 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
1048 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
1049 << (typeArgs.size() < typeParams->
size())
1073 if (!Protocols.empty()) {
1079 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
1082 if (FailOnError &&
Result.isNull())
1094 bool FailOnError,
bool Rebuilding) {
1096 if (!TypeArgs.empty()) {
1099 SourceRange(TypeArgsLAngleLoc, TypeArgsRAngleLoc),
1100 FailOnError, Rebuilding);
1101 if (FailOnError &&
Result.isNull())
1105 if (!Protocols.empty()) {
1110 Diag(Loc, diag::err_invalid_protocol_qualifiers)
1111 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
1114 if (FailOnError &&
Result.isNull())
1140 auto ObjCObjectTL = ObjCObjectPointerTL.getPointeeLoc()
1150 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
1151 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
1152 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
1153 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
1181 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
1185 ActualTypeArgInfos.clear();
1189 assert(TypeArgInfo &&
"No type source info?");
1190 ActualTypeArgInfos.push_back(TypeArgInfo);
1196 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
1200 ProtocolLocs, ProtocolRAngleLoc,
1216 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
1221 if (OTPTL.getNumProtocols() > 0) {
1222 assert(OTPTL.getNumProtocols() == Protocols.size());
1223 OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1224 OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1225 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1226 OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
1236 if (ObjCObjectTL.getNumTypeArgs() > 0) {
1237 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
1238 ObjCObjectTL.setTypeArgsLAngleLoc(TypeArgsLAngleLoc);
1239 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
1240 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
1241 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
1248 if (ObjCObjectTL.getNumProtocols() > 0) {
1249 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
1250 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1251 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1252 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1253 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
1260 ObjCObjectTL.setHasBaseTypeAsWritten(
true);
1261 if (ObjCObjectTL.getType() ==
T)
1262 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
1264 ObjCObjectTL.getBaseLoc().initialize(
Context, Loc);
1270static OpenCLAccessAttr::Spelling
1273 if (AL.getKind() == ParsedAttr::AT_OpenCLAccess)
1274 return static_cast<OpenCLAccessAttr::Spelling
>(AL.getSemanticSpelling());
1275 return OpenCLAccessAttr::Keyword_read_only;
1280 switch (SwitchTST) {
1281#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1283 return UnaryTransformType::Enum;
1284#include "clang/Basic/TransformTypeTraits.def"
1286 llvm_unreachable(
"attempted to parse a non-unary transform builtin");
1300 Sema &S = state.getSema();
1301 Declarator &declarator = state.getDeclarator();
1321 "Unknown TSS value");
1335 "Unknown TSS value");
1344 "Unknown TSS value");
1349 "Unknown TSS value");
1354 "Unknown TSS value");
1382 S.
Diag(DeclLoc, diag::warn_missing_type_specifier)
1391 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1400 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1405 "implicit int is disabled?");
1406 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1433 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1458 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1491 llvm_unreachable(
"Unable to specify long long as _Accum width");
1514 llvm_unreachable(
"Unable to specify long long as _Fract width");
1565 ?
"cl_khr_fp64 and __opencl_c_fp64"
1615 "No qualifiers on tag names!");
1631 "Can't handle qualifiers on typedef names yet!");
1644 assert(!
Result.isNull() &&
"Didn't get a type for typeof?");
1645 if (!
Result->isDependentType())
1657 assert(E &&
"Didn't get an expression for typeof?");
1671 assert(E &&
"Didn't get an expression for decltype?");
1682 assert(E &&
"Didn't get an expression for pack indexing");
1693#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
1694#include "clang/Basic/TransformTypeTraits.def"
1696 assert(!
Result.isNull() &&
"Didn't get a type for the transformation?");
1716 TypeConstraintConcept =
1717 cast<ConceptDecl>(TemplateId->Template.get().getAsTemplateDecl());
1722 TemplateId->NumArgs);
1724 for (
const auto &ArgLoc : TemplateArgsInfo.
arguments())
1725 TemplateArgs.push_back(ArgLoc.getArgument());
1732 TypeConstraintConcept, TemplateArgs);
1746 assert(!
Result.isNull() &&
"Didn't get a type for _Atomic?");
1754#define GENERIC_IMAGE_TYPE(ImgType, Id) \
1755 case DeclSpec::TST_##ImgType##_t: \
1756 switch (getImageAccess(DS.getAttributes())) { \
1757 case OpenCLAccessAttr::Keyword_write_only: \
1758 Result = Context.Id##WOTy; \
1760 case OpenCLAccessAttr::Keyword_read_write: \
1761 Result = Context.Id##RWTy; \
1763 case OpenCLAccessAttr::Keyword_read_only: \
1764 Result = Context.Id##ROTy; \
1766 case OpenCLAccessAttr::SpellingNotCalculated: \
1767 llvm_unreachable("Spelling not yet calculated"); \
1770#include "clang/Basic/OpenCLImageTypes.def"
1781 if (
Result->containsErrors())
1786 bool IsOpenCLC30Compatible =
1796 (IsOpenCLC30Compatible &&
1799 << 0 <<
Result <<
"__opencl_c_images";
1801 }
else if (
Result->isOCLImage3dWOType() &&
1806 << (IsOpenCLC30Compatible
1807 ?
"cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
1808 :
"cl_khr_3d_image_writes");
1829 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1858 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
1869 if (AL.isStandardAttributeSyntax() && AL.isClangScope() &&
1870 !(AL.getKind() == ParsedAttr::AT_MatrixType &&
1872 S.
Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl)
1898 if (
Result->isFunctionType()) {
1902 ? diag::warn_typecheck_function_qualifiers_ignored
1903 : diag::warn_typecheck_function_qualifiers_unspecified);
1916 if (TypeQuals &&
Result->isReferenceType()) {
1918 S, DS, TypeQuals,
Result,
1920 diag::warn_typecheck_reference_qualifiers);
1927 && TypeQuals &
Result.getCVRQualifiers()) {
1951 assert(!
Result.isNull() &&
"This function should not return a null type");
1966 const auto *AT = dyn_cast<AutoType>(
T);
1967 return AT && AT->isGNUAutoType();
1984 unsigned DiagID = 0;
2000 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
2007 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
2021 unsigned CVRAU,
const DeclSpec *DS) {
2055 Split.Quals.addCVRQualifiers(CVR);
2074 if (!
type->isObjCLifetimeType() ||
2084 if (
type.isConstQualified()) {
2090 }
else if (
type->isObjCARCImplicitlyUnretainedType()) {
2108 diag::err_arc_indirect_no_ownership,
type, isReference));
2110 S.
Diag(loc, diag::err_arc_indirect_no_ownership) <<
type << isReference;
2114 assert(implicitLifetime &&
"didn't infer any lifetime!");
2155enum QualifiedFunctionKind { QFK_BlockPointer, QFK_Pointer, QFK_Reference };
2161 QualifiedFunctionKind QFK) {
2168 S.
Diag(Loc, diag::err_compound_qualified_function_type)
2169 << QFK << isa<FunctionType>(
T.IgnoreParens()) <<
T
2180 Diag(Loc, diag::err_qualified_function_typeid)
2212 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
2220 Diag(Loc, diag::err_opencl_function_pointer) << 0;
2225 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
2244 if (
T.isWebAssemblyReferenceType()) {
2245 Diag(Loc, diag::err_wasm_reference_pr) << 0;
2251 Diag(Loc, diag::err_wasm_table_pr) << 0;
2277 "Unresolved overloaded function type");
2305 Diag(Loc, diag::err_reference_to_void);
2310 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
2320 Diag(Loc, diag::err_opencl_function_pointer) << 1;
2333 T.isWebAssemblyReferenceType()) {
2334 Diag(Loc, diag::err_wasm_reference_pr) << 1;
2338 Diag(Loc, diag::err_wasm_table_pr) << 1;
2385 llvm::APSInt Bits(32);
2392 size_t NumBits = Bits.getZExtValue();
2393 if (!IsUnsigned && NumBits < 2) {
2394 Diag(Loc, diag::err_bit_int_bad_size) << 0;
2398 if (IsUnsigned && NumBits < 1) {
2399 Diag(Loc, diag::err_bit_int_bad_size) << 1;
2405 Diag(Loc, diag::err_bit_int_max_size)
2419 llvm::APSInt &SizeVal,
unsigned VLADiag,
2444 VLADiagnoser(
unsigned VLADiag,
bool VLAIsError)
2445 : VLADiag(VLADiag), VLAIsError(VLAIsError) {}
2449 return S.
Diag(Loc, diag::err_array_size_non_int) <<
T;
2454 IsVLA = !VLAIsError;
2455 return S.
Diag(Loc, VLADiag);
2460 return S.
Diag(Loc, diag::ext_vla_folded_to_constant);
2462 } Diagnoser(VLADiag, VLAIsError);
2466 if (Diagnoser.IsVLA)
2480 if (Size.isMultipleOf(Alignment))
2483 Diag(Loc, diag::err_array_element_alignment)
2484 << EltTy << Size.getQuantity() << Alignment.
getQuantity();
2504 Expr *ArraySize,
unsigned Quals,
2521 Diag(Loc, diag::err_illegal_decl_array_of_references)
2527 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 <<
T;
2532 diag::err_array_of_abstract_type))
2539 if (!MPTy->getClass()->isDependentType())
2545 if (!
T.isWebAssemblyReferenceType() &&
2547 diag::err_array_incomplete_or_sizeless_type))
2553 const auto *ATy = dyn_cast<ArrayType>(
T);
2554 if (ATy && ATy->getElementType().isWebAssemblyReferenceType()) {
2555 Diag(Loc, diag::err_wasm_reftype_multidimensional_array);
2561 Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 1 <<
T;
2566 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2574 if (EltTy->getDecl()->hasFlexibleArrayMember())
2575 Diag(Loc, diag::ext_flexible_array_in_array) <<
T;
2577 Diag(Loc, diag::err_objc_array_of_interfaces) <<
T;
2588 ArraySize =
Result.get();
2592 if (ArraySize && !ArraySize->
isPRValue()) {
2597 ArraySize =
Result.get();
2620 if (
const auto *CondExpr = dyn_cast_if_present<ConditionalOperator>(
2622 std::optional<llvm::APSInt> LHS =
2623 CondExpr->getLHS()->getIntegerConstantExpr(
Context);
2624 std::optional<llvm::APSInt> RHS =
2625 CondExpr->getRHS()->getIntegerConstantExpr(
Context);
2626 return LHS && RHS && LHS->isNegative() != RHS->isNegative();
2636 VLADiag = diag::err_opencl_vla;
2639 VLADiag = diag::warn_vla_used;
2642 VLADiag = diag::err_vla_in_sfinae;
2645 VLADiag = diag::err_openmp_vla_in_task_untied;
2650 ? diag::ext_vla_cxx_in_gnu_mode_static_assert
2651 : diag::ext_vla_cxx_static_assert;
2653 VLADiag =
getLangOpts().GNUMode ? diag::ext_vla_cxx_in_gnu_mode
2654 : diag::ext_vla_cxx;
2657 VLADiag = diag::ext_vla;
2698 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2705 diag::err_typecheck_negative_array_size)
2709 if (ConstVal == 0 && !
T.isWebAssemblyReferenceType()) {
2714 : diag::ext_typecheck_zero_array_size)
2719 unsigned ActiveSizeBits =
2723 : ConstVal.getActiveBits();
2739 IsCUDADevice ? diag::err_cuda_vla : diag::err_vla_unsupported)
2740 << (IsCUDADevice ? llvm::to_underlying(
CUDA().CurrentTarget()) : 0);
2744 FSI->setHasVLA(Loc);
2752 : diag::ext_c99_array_usage)
2753 << llvm::to_underlying(ASM);
2763 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2780 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
2785 unsigned NumBits = BIT->getNumBits();
2786 if (!llvm::isPowerOf2_32(NumBits) || NumBits < 8) {
2787 Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
2797 std::optional<llvm::APSInt> VecSize =
2800 Diag(AttrLoc, diag::err_attribute_argument_type)
2811 if (!VecSize->isIntN(61)) {
2813 Diag(AttrLoc, diag::err_attribute_size_too_large)
2817 uint64_t VectorSizeBits = VecSize->getZExtValue() * 8;
2820 if (VectorSizeBits == 0) {
2821 Diag(AttrLoc, diag::err_attribute_zero_size)
2826 if (!TypeSize || VectorSizeBits % TypeSize) {
2827 Diag(AttrLoc, diag::err_attribute_invalid_size)
2832 if (VectorSizeBits / TypeSize > std::numeric_limits<uint32_t>::max()) {
2833 Diag(AttrLoc, diag::err_attribute_size_too_large)
2860 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) <<
T;
2867 if (!llvm::isPowerOf2_32(NumBits) || NumBits < 8) {
2868 Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
2875 std::optional<llvm::APSInt> vecSize =
2878 Diag(AttrLoc, diag::err_attribute_argument_type)
2884 if (!vecSize->isIntN(32)) {
2885 Diag(AttrLoc, diag::err_attribute_size_too_large)
2891 unsigned vectorSize =
static_cast<unsigned>(vecSize->getZExtValue());
2893 if (vectorSize == 0) {
2894 Diag(AttrLoc, diag::err_attribute_zero_size)
2908 "Should never build a matrix type when it is disabled");
2913 Diag(AttrLoc, diag::err_attribute_invalid_matrix_type) << ElementTy;
2922 std::optional<llvm::APSInt> ValueRows =
2924 std::optional<llvm::APSInt> ValueColumns =
2931 if (!ValueRows && !ValueColumns) {
2932 Diag(AttrLoc, diag::err_attribute_argument_type)
2940 Diag(AttrLoc, diag::err_attribute_argument_type)
2946 if (!ValueColumns) {
2947 Diag(AttrLoc, diag::err_attribute_argument_type)
2953 unsigned MatrixRows =
static_cast<unsigned>(ValueRows->getZExtValue());
2954 unsigned MatrixColumns =
static_cast<unsigned>(ValueColumns->getZExtValue());
2955 if (MatrixRows == 0 && MatrixColumns == 0) {
2956 Diag(AttrLoc, diag::err_attribute_zero_size)
2957 <<
"matrix" << RowRange << ColRange;
2960 if (MatrixRows == 0) {
2961 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << RowRange;
2964 if (MatrixColumns == 0) {
2965 Diag(AttrLoc, diag::err_attribute_zero_size) <<
"matrix" << ColRange;
2969 Diag(AttrLoc, diag::err_attribute_size_too_large)
2970 << RowRange <<
"matrix row";
2974 Diag(AttrLoc, diag::err_attribute_size_too_large)
2975 << ColRange <<
"matrix column";
2983 Diag(Loc, diag::err_func_returning_array_function)
2991 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2999 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
3004 if (
T.hasNonTrivialToPrimitiveDestructCUnion() ||
3005 T.hasNonTrivialToPrimitiveCopyCUnion())
3012 Diag(Loc, diag::warn_deprecated_volatile_return) <<
T;
3027 bool emittedError =
false;
3029 enum class RequiredCC { OnlySwift, SwiftOrSwiftAsync };
3030 auto checkCompatible = [&](
unsigned paramIndex, RequiredCC required) {
3032 (required == RequiredCC::OnlySwift)
3035 if (isCompatible || emittedError)
3037 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
3039 << (required == RequiredCC::OnlySwift);
3040 emittedError =
true;
3042 for (
size_t paramIndex = 0, numParams = paramTypes.size();
3043 paramIndex != numParams; ++paramIndex) {
3052 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
3053 if (paramIndex != 0 &&
3056 S.
Diag(getParamLoc(paramIndex),
3057 diag::err_swift_indirect_result_not_first);
3062 checkCompatible(paramIndex, RequiredCC::SwiftOrSwiftAsync);
3071 checkCompatible(paramIndex, RequiredCC::OnlySwift);
3072 if (paramIndex == 0 ||
3075 S.
Diag(getParamLoc(paramIndex),
3076 diag::err_swift_error_result_not_after_swift_context);
3080 llvm_unreachable(
"bad ABI kind");
3092 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
3096 Diag(Loc, diag::err_param_with_void_type);
3101 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
3105 Diag(Loc, diag::err_wasm_table_as_function_parameter);
3112 Diag(Loc, diag::warn_deprecated_volatile_param) << ParamType;
3114 ParamTypes[Idx] = ParamType;
3119 [=](
unsigned i) {
return Loc; });
3148 Diag(Loc, diag::err_distant_exception_spec);
3155 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
3161 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
3166 if (!
Class->isDependentType() && !
Class->isRecordType()) {
3167 Diag(Loc, diag::err_mempointer_in_nonclass_type) <<
Class;
3174 Diag(Loc, diag::err_opencl_function_pointer) << 0;
3179 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
3209 Diag(Loc, diag::err_nonfunction_block_type);
3225 if (TInfo) *TInfo =
nullptr;
3230 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
3231 QT = LIT->getType();
3232 DI = LIT->getTypeSourceInfo();
3235 if (TInfo) *TInfo = DI;
3241 unsigned chunkIndex);
3248 Sema &S = state.getSema();
3249 Declarator &declarator = state.getDeclarator();
3255 unsigned outermostPointerIndex = 0;
3257 unsigned numPointers = 0;
3259 unsigned chunkIndex = i;
3261 switch (chunk.
Kind) {
3271 outermostPointerIndex = chunkIndex;
3279 if (numPointers != 1)
return;
3281 outermostPointerIndex = chunkIndex;
3299 if (numPointers == 1) {
3317 }
else if (numPointers == 2) {
3330 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership)
3334 outermostPointerIndex);
3356 }
const QualKinds[5] = {
3365 unsigned NumQuals = 0;
3370 for (
auto &E : QualKinds) {
3371 if (Quals & E.Mask) {
3372 if (!QualStr.empty()) QualStr +=
' ';
3389 << QualStr << NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
3395 unsigned FunctionChunkIndex) {
3405 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
3407 OuterChunkIndex != End; ++OuterChunkIndex) {
3409 switch (OuterChunk.
Kind) {
3416 diag::warn_qual_return_type,
3442 llvm_unreachable(
"unknown declarator chunk kind");
3463static std::pair<QualType, TypeSourceInfo *>
3467 Sema &S = state.getSema();
3471 const unsigned AutoParameterPosition = Info.
TemplateParams.size();
3485 TemplateParameterDepth, AutoParameterPosition,
3488 IsParameterPack,
Auto->isConstrained());
3493 if (
Auto->isConstrained()) {
3500 for (
unsigned Idx = 0; Idx < AutoLoc.
getNumArgs(); ++Idx) {
3547 USD ? cast<NamedDecl>(USD) : CD,
3559 QualType NewT = state.ReplaceAutoType(
T, Replacement);
3563 return {NewT, NewTSI};
3572 Sema &SemaRef = state.getSema();
3575 ReturnTypeInfo =
nullptr;
3578 TagDecl *OwnedTagDecl =
nullptr;
3629 bool DeducedIsTrailingReturnType =
false;
3633 DeducedIsTrailingReturnType =
true;
3643 bool IsCXXAutoType =
3645 bool IsDeducedReturnType =
false;
3682 assert(Info &&
"No LambdaScopeInfo on the stack!");
3688 if (!DeducedIsTrailingReturnType)
3697 if (isa<ObjCContainerDecl>(SemaRef.
CurContext)) {
3700 switch (cast<TagDecl>(SemaRef.
CurContext)->getTagKind()) {
3702 llvm_unreachable(
"unhandled tag kind");
3704 Error = Cxx ? 1 : 2;
3707 Error = Cxx ? 3 : 4;
3726 if (isa<DeducedTemplateSpecializationType>(Deduced) &&
3738 if (isa<DeducedTemplateSpecializationType>(Deduced) &&
3752 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3754 IsDeducedReturnType =
true;
3757 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
3759 IsDeducedReturnType =
true;
3762 if (isa<DeducedTemplateSpecializationType>(Deduced))
3764 if (SemaRef.
getLangOpts().CPlusPlus23 && IsCXXAutoType &&
3765 !
Auto->isDecltypeAuto())
3784 if (!IsCXXAutoType && !isa<DeducedTemplateSpecializationType>(Deduced))
3798 (!SemaRef.
getLangOpts().CPlusPlus11 || !IsCXXAutoType))
3808 switch (
Auto->getKeyword()) {
3814 assert(isa<DeducedTemplateSpecializationType>(Deduced) &&
3815 "unknown auto type");
3819 auto *DTST = dyn_cast<DeducedTemplateSpecializationType>(Deduced);
3822 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
3824 <<
QualType(Deduced, 0) << AutoRange;
3835 ? diag::warn_cxx11_compat_generic_lambda
3836 : IsDeducedReturnType
3837 ? diag::warn_cxx11_compat_deduced_return_type
3838 : diag::warn_cxx98_compat_auto_type_specifier)
3847 unsigned DiagID = 0;
3853 llvm_unreachable(
"parser should not have allowed this");
3869 DiagID = diag::err_type_defined_in_alias_template;
3881 DiagID = diag::err_type_defined_in_type_specifier;
3891 DiagID = diag::err_type_defined_in_param_type;
3897 DiagID = diag::err_type_defined_in_condition;
3908 assert(!
T.isNull() &&
"This function should not return a null type");
3917 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3947 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3948 : diag::warn_empty_parens_are_function_decl)
3959 if (Comma.getFileID() != Name.getFileID() ||
3960 Comma.getSpellingLineNumber() != Name.getSpellingLineNumber()) {
3967 Result.suppressDiagnostics();
3980 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3995 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
4003 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
4014 "do not have redundant top-level parentheses");
4023 bool CouldBeTemporaryObject =
4030 bool StartsWithDeclaratorId =
true;
4038 StartsWithDeclaratorId =
false;
4043 CouldBeTemporaryObject =
false;
4051 CouldBeTemporaryObject =
false;
4052 StartsWithDeclaratorId =
false;
4062 CouldBeTemporaryObject =
false;
4069 CouldBeTemporaryObject =
false;
4070 StartsWithDeclaratorId =
false;
4080 if (CouldBeTemporaryObject) {
4084 CouldBeTemporaryObject =
false;
4085 Result.suppressDiagnostics();
4090 if (!CouldBeTemporaryObject) {
4103 S.
Diag(
Paren.Loc, diag::warn_redundant_parens_around_declarator)
4109 S.
Diag(
Paren.Loc, diag::warn_parens_disambiguated_as_variable_declaration)
4112 if (!RD || !RD->hasDefinition() || RD->hasNonTrivialDestructor())
4113 S.
Diag(
Paren.Loc, diag::note_raii_guard_add_name)
4118 S.
Diag(D.
getBeginLoc(), diag::note_function_style_cast_add_parentheses)
4121 S.
Diag(
Paren.Loc, diag::note_remove_parens_for_variable_declaration)
4137 switch (AL.getKind()) {
4156 bool IsCXXInstanceMethod =
false;
4162 unsigned I = ChunkIndex;
4163 bool FoundNonParen =
false;
4164 while (I && !FoundNonParen) {
4167 FoundNonParen =
true;
4170 if (FoundNonParen) {
4173 IsCXXInstanceMethod =
4178 IsCXXInstanceMethod =
4186 IsCXXInstanceMethod =
4194 IsCXXInstanceMethod);
4202 if (AL.getKind() == ParsedAttr::AT_OpenCLKernel) {
4212 if (Triple.getArch() == llvm::Triple::spirv32 ||
4213 Triple.getArch() == llvm::Triple::spirv64) {
4215 if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
4229 enum class SimplePointerKind {
4238 switch (nullability) {
4240 if (!Ident__Nonnull)
4242 return Ident__Nonnull;
4245 if (!Ident__Nullable)
4247 return Ident__Nullable;
4250 if (!Ident__Nullable_result)
4252 return Ident__Nullable_result;
4255 if (!Ident__Null_unspecified)
4257 return Ident__Null_unspecified;
4259 llvm_unreachable(
"Unknown nullability kind.");
4267 return Ident_NSError;
4274 if (AL.getKind() == ParsedAttr::AT_TypeNonNull ||
4275 AL.getKind() == ParsedAttr::AT_TypeNullable ||
4276 AL.getKind() == ParsedAttr::AT_TypeNullableResult ||
4277 AL.getKind() == ParsedAttr::AT_TypeNullUnspecified)
4286 enum class PointerDeclaratorKind {
4294 MaybePointerToCFRef,
4298 NSErrorPointerPointer,
4304 enum class PointerWrappingDeclaratorKind {
4318static PointerDeclaratorKind
4320 PointerWrappingDeclaratorKind &wrappingKind) {
4321 unsigned numNormalPointers = 0;
4324 if (
type->isDependentType())
4325 return PointerDeclaratorKind::NonPointer;
4330 switch (chunk.
Kind) {
4332 if (numNormalPointers == 0)
4333 wrappingKind = PointerWrappingDeclaratorKind::Array;
4342 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4343 : PointerDeclaratorKind::SingleLevelPointer;
4349 if (numNormalPointers == 0)
4350 wrappingKind = PointerWrappingDeclaratorKind::Reference;
4354 ++numNormalPointers;
4355 if (numNormalPointers > 2)
4356 return PointerDeclaratorKind::MultiLevelPointer;
4362 unsigned numTypeSpecifierPointers = 0;
4366 ++numNormalPointers;
4368 if (numNormalPointers > 2)
4369 return PointerDeclaratorKind::MultiLevelPointer;
4371 type = ptrType->getPointeeType();
4372 ++numTypeSpecifierPointers;
4378 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4379 : PointerDeclaratorKind::SingleLevelPointer;
4384 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
4385 : PointerDeclaratorKind::SingleLevelPointer;
4390 ++numNormalPointers;
4391 ++numTypeSpecifierPointers;
4394 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
4396 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
4397 return PointerDeclaratorKind::NSErrorPointerPointer;
4406 if (objcClass->getInterface()->getIdentifier() == S.
getNSErrorIdent()) {
4407 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
4408 return PointerDeclaratorKind::NSErrorPointerPointer;
4415 if (numNormalPointers == 0)
4416 return PointerDeclaratorKind::NonPointer;
4422 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2 &&
4424 return PointerDeclaratorKind::CFErrorRefPointer;
4432 switch (numNormalPointers) {
4434 return PointerDeclaratorKind::NonPointer;
4437 return PointerDeclaratorKind::SingleLevelPointer;
4440 return PointerDeclaratorKind::MaybePointerToCFRef;
4443 return PointerDeclaratorKind::MultiLevelPointer;
4458 if (
auto bridgeAttr = RD->
getAttr<ObjCBridgeAttr>())
4459 bridgedType = bridgeAttr->getBridgedType();
4460 else if (
auto bridgeAttr = RD->
getAttr<ObjCBridgeMutableAttr>())
4461 bridgedType = bridgeAttr->getBridgedType();
4477 if (ctx->isFunctionOrMethod())
4480 if (ctx->isFileContext())
4491 bool invalid =
false;
4493 if (invalid || !sloc.
isFile())
4511template <
typename DiagBuilderT>
4520 if (!FixItLoc.
isValid() || FixItLoc == PointerLoc)
4529 InsertionTextBuf +=
" ";
4530 StringRef InsertionText = InsertionTextBuf.str();
4533 InsertionText = InsertionText.drop_back();
4534 }
else if (NextChar[-1] ==
'[') {
4535 if (NextChar[0] ==
']')
4536 InsertionText = InsertionText.drop_back().drop_front();
4538 InsertionText = InsertionText.drop_front();
4541 InsertionText = InsertionText.drop_back().drop_front();
4548 SimplePointerKind PointerKind,
4553 if (PointerKind == SimplePointerKind::Array) {
4554 S.
Diag(PointerLoc, diag::warn_nullability_missing_array);
4556 S.
Diag(PointerLoc, diag::warn_nullability_missing)
4557 <<
static_cast<unsigned>(PointerKind);
4560 auto FixItLoc = PointerEndLoc.
isValid() ? PointerEndLoc : PointerLoc;
4561 if (FixItLoc.isMacroID())
4565 auto Diag = S.
Diag(FixItLoc, diag::note_nullability_fix_it);
4566 Diag << static_cast<unsigned>(Nullability);
4567 Diag << static_cast<unsigned>(PointerKind);
4596 if (pointerKind == SimplePointerKind::Array)
4597 diagKind = diag::warn_nullability_missing_array;
4599 diagKind = diag::warn_nullability_missing;
4605 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
4637 auto kind =
static_cast<SimplePointerKind
>(fileNullability.
PointerKind);
4652 unsigned i = endIndex;
4680template<
typename AttrT>
4683 return ::new (Ctx) AttrT(Ctx, AL);
4690 return createSimpleAttr<TypeNonNullAttr>(Ctx,
Attr);
4693 return createSimpleAttr<TypeNullableAttr>(Ctx,
Attr);
4696 return createSimpleAttr<TypeNullableResultAttr>(Ctx,
Attr);
4699 return createSimpleAttr<TypeNullUnspecifiedAttr>(Ctx,
Attr);
4701 llvm_unreachable(
"unknown NullabilityKind");
4712 if (ASOld != ASNew) {
4713 S.
Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
4718 diag::warn_attribute_address_multiple_identical_qualifiers);
4732 !isa<RecordType, TemplateSpecializationType>(
4743 Sema &S = state.getSema();
4753 bool IsTypedefName =
4769 bool IsClassTemplateDeduction = isa<DeducedTemplateSpecializationType>(DT);
4772 unsigned Index = E - I - 1;
4774 unsigned DiagId = IsClassTemplateDeduction
4775 ? diag::err_deduced_class_template_compound_type
4776 : diag::err_decltype_auto_compound_type;
4777 unsigned DiagKind = 0;
4778 switch (DeclChunk.
Kind) {
4781 if (IsClassTemplateDeduction) {
4787 if (IsClassTemplateDeduction) {
4795 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
4813 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
4821 std::optional<NullabilityKind> inferNullability;
4822 bool inferNullabilityCS =
false;
4823 bool inferNullabilityInnerOnly =
false;
4824 bool inferNullabilityInnerOnlyComplete =
false;
4827 bool inAssumeNonNullRegion =
false;
4829 if (assumeNonNullLoc.
isValid()) {
4830 inAssumeNonNullRegion =
true;
4844 } complainAboutMissingNullability = CAMN_No;
4845 unsigned NumPointersRemaining = 0;
4846 auto complainAboutInferringWithinChunk = PointerWrappingDeclaratorKind::None;
4848 if (IsTypedefName) {
4852 complainAboutMissingNullability = CAMN_InnerPointers;
4856 ++NumPointersRemaining;
4861 switch (chunk.
Kind) {
4869 ++NumPointersRemaining;
4877 ++NumPointersRemaining;
4883 switch (
auto context = state.getDeclarator().getContext()) {
4894 complainAboutMissingNullability = CAMN_No;
4899 if (state.getDeclarator().isObjCWeakProperty()) {
4902 complainAboutMissingNullability = CAMN_No;
4903 if (inAssumeNonNullRegion) {
4913 complainAboutMissingNullability = CAMN_Yes;
4916 auto wrappingKind = PointerWrappingDeclaratorKind::None;
4918 case PointerDeclaratorKind::NonPointer:
4919 case PointerDeclaratorKind::MultiLevelPointer:
4923 case PointerDeclaratorKind::SingleLevelPointer:
4925 if (inAssumeNonNullRegion) {
4926 complainAboutInferringWithinChunk = wrappingKind;
4933 case PointerDeclaratorKind::CFErrorRefPointer:
4934 case PointerDeclaratorKind::NSErrorPointerPointer:
4941 case PointerDeclaratorKind::MaybePointerToCFRef:
4946 auto hasCFReturnsAttr =
4948 return AttrList.hasAttribute(ParsedAttr::AT_CFReturnsRetained) ||
4949 AttrList.hasAttribute(ParsedAttr::AT_CFReturnsNotRetained);
4954 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
4957 inferNullabilityInnerOnly =
true;
4967 complainAboutMissingNullability = CAMN_Yes;
4995 auto isVaList = [&S](
QualType T) ->
bool {
5001 if (typedefTy->getDecl() == vaListTypedef)
5003 if (
auto *name = typedefTy->getDecl()->getIdentifier())
5004 if (name->isStr(
"va_list"))
5006 typedefTy = typedefTy->desugar()->getAs<
TypedefType>();
5007 }
while (typedefTy);
5013 auto inferPointerNullability =
5018 if (NumPointersRemaining > 0)
5019 --NumPointersRemaining;
5026 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
5029 ? ParsedAttr::Form::ContextSensitiveKeyword()
5030 : ParsedAttr::Form::Keyword(
false ,
5036 attrs.addAtEnd(nullabilityAttr);
5038 if (inferNullabilityCS) {
5039 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
5043 if (pointerLoc.isValid() &&
5044 complainAboutInferringWithinChunk !=
5045 PointerWrappingDeclaratorKind::None) {
5047 S.
Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
5048 Diag << static_cast<int>(complainAboutInferringWithinChunk);
5052 if (inferNullabilityInnerOnly)
5053 inferNullabilityInnerOnlyComplete =
true;
5054 return nullabilityAttr;
5059 switch (complainAboutMissingNullability) {
5063 case CAMN_InnerPointers:
5064 if (NumPointersRemaining == 0)
5080 if (NumPointersRemaining > 0)
5081 --NumPointersRemaining;
5083 SimplePointerKind pointerKind = SimplePointerKind::Pointer;
5085 pointerKind = SimplePointerKind::BlockPointer;
5087 pointerKind = SimplePointerKind::MemberPointer;
5089 if (
auto *
attr = inferPointerNullability(
5094 T = state.getAttributedType(
5100 if (complainAboutMissingNullability == CAMN_Yes &&
T->
isArrayType() &&
5108 bool ExpectNoDerefChunk =
5109 state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
5119 bool AreDeclaratorChunksValid =
true;
5121 unsigned chunkIndex = e - i - 1;
5122 state.setCurrentChunkIndex(chunkIndex);
5125 switch (DeclType.
Kind) {
5133 if (!LangOpts.Blocks)
5134 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
5137 inferPointerNullability(SimplePointerKind::BlockPointer, DeclType.
Loc,
5139 state.getDeclarator().getAttributePool());
5145 if (LangOpts.OpenCL)
5160 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
5162 state.getDeclarator().getAttributePool());
5174 if (LangOpts.OpenCL) {
5215 if (chunkIndex != 0 && !ArraySize &&
5234 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
5245 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype)
5247 :
"type qualifier");
5258 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost)
5260 :
"type qualifier");
5270 if (complainAboutMissingNullability == CAMN_Yes &&
5286 IsQualifiedFunction =
5299 ? diag::err_auto_missing_trailing_return
5300 : diag::err_deduced_return_type);
5303 AreDeclaratorChunksValid =
false;
5306 diag::warn_cxx11_compat_deduced_return_type);
5310 if (isa<ParenType>(
T)) {
5315 AreDeclaratorChunksValid =
false;
5320 diag::err_deduction_guide_with_complex_decl)
5324 AreDeclaratorChunksValid =
false;
5327 (
T.hasQualifiers() || !isa<AutoType>(
T) ||
5328 cast<AutoType>(
T)->getKeyword() !=
5330 cast<AutoType>(
T)->isConstrained())) {
5332 diag::err_trailing_return_without_auto)
5336 AreDeclaratorChunksValid =
false;
5352 if (InventedParamInfo) {
5354 state,
T, TInfo,
Auto, *InventedParamInfo);
5368 unsigned diagID = diag::err_func_returning_array_function;
5371 if (chunkIndex == 0 &&
5373 diagID = diag::err_block_returning_array_function;
5377 AreDeclaratorChunksValid =
false;
5390 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5393 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
5398 if (LangOpts.OpenCL) {
5412 "__cl_clang_variadic_functions", S.
getLangOpts()) &&
5433 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
5445 AreDeclaratorChunksValid =
false;
5462 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) <<
T;
5468 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20)
5469 S.
Diag(DeclType.
Loc, diag::warn_deprecated_volatile_return) <<
T;
5475 if (
T.getQualifiers().hasObjCLifetime()) {
5480 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5481 AttrLoc = AL.getLoc();
5488 if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) {
5489 AttrLoc = AL.getLoc();
5503 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
5504 <<
T.getQualifiers().getObjCLifetime();
5520 diag::err_exception_spec_in_typedef)
5546 diag::warn_c17_compat_ellipsis_only_parameter);
5548 ParsedAttr::AT_Overloadable) &&
5550 ParsedAttr::AT_Overloadable) &&
5552 ParsedAttr::AT_Overloadable))
5560 diag::err_ident_list_in_fn_declaration);
5566 AreDeclaratorChunksValid =
false;
5589 bool HasAnyInterestingExtParameterInfos =
false;
5591 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
5594 assert(!ParamTy.
isNull() &&
"Couldn't parse type?");
5605 ParamTy = Context.
IntTy;
5610 ParamTy = Context.
IntTy;
5615 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
5631 }
else if (!S.
getLangOpts().NativeHalfArgsAndReturns &&
5634 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
5642 if (BTy->getKind() == BuiltinType::Float) {
5654 if (LangOpts.ObjCAutoRefCount && Param->
hasAttr<NSConsumedAttr>()) {
5655 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
5656 HasAnyInterestingExtParameterInfos =
true;
5660 ExtParameterInfos[i] =
5661 ExtParameterInfos[i].withABI(
attr->getABI());
5662 HasAnyInterestingExtParameterInfos =
true;
5665 if (Param->
hasAttr<PassObjectSizeAttr>()) {
5666 ExtParameterInfos[i] = ExtParameterInfos[i].withHasPassObjectSize();
5667 HasAnyInterestingExtParameterInfos =
true;
5670 if (Param->
hasAttr<NoEscapeAttr>()) {
5671 ExtParameterInfos[i] = ExtParameterInfos[i].withIsNoEscape(
true);
5672 HasAnyInterestingExtParameterInfos =
true;
5675 ParamTys.push_back(ParamTy);
5678 if (HasAnyInterestingExtParameterInfos) {
5687 Expr *NoexceptExpr =
nullptr;
5693 DynamicExceptions.reserve(N);
5694 DynamicExceptionRanges.reserve(N);
5695 for (
unsigned I = 0; I != N; ++I) {
5706 DynamicExceptionRanges,
5713 auto IsClassMember = [&]() {
5714 return (!state.getDeclarator().getCXXScopeSpec().isEmpty() &&
5715 state.getDeclarator()
5719 state.getDeclarator().getContext() ==
5721 state.getDeclarator().getContext() ==
5725 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
5755 inferPointerNullability(SimplePointerKind::MemberPointer, DeclType.
Loc,
5757 state.getDeclarator().getAttributePool());
5776 llvm_unreachable(
"Nested-name-specifier must name a type");
5786 if (isa<TemplateSpecializationType>(NNS->
getAsType()))
5788 NNSPrefix, ClsType);
5793 diag::err_illegal_decl_mempointer_in_nonclass)
5803 AreDeclaratorChunksValid =
false;
5808 AreDeclaratorChunksValid =
false;
5826 AreDeclaratorChunksValid =
false;
5835 S.
Diag(DeclType.
Loc, diag::warn_noderef_on_non_pointer_or_array);
5837 ExpectNoDerefChunk = state.didParseNoDeref();
5841 if (ExpectNoDerefChunk)
5842 S.
Diag(state.getDeclarator().getBeginLoc(),
5843 diag::warn_noderef_on_non_pointer_or_array);
5856 bool IsBlock =
false;
5858 switch (DeclType.Kind) {
5870 S.
Diag(DeclType.Loc, diag::warn_strict_prototypes)
5882 assert(!
T.isNull() &&
"T must not be null after this point");
5886 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
5899 ExplicitObjectMember,
5903 Kind = DeductionGuide;
5921 if (
P &&
P->isExplicitObjectParameter())
5922 Kind = ExplicitObjectMember;
5948 if (IsQualifiedFunction &&
5973 if (!RemovalLocs.empty()) {
5974 llvm::sort(RemovalLocs,
5976 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
5977 Loc = RemovalLocs.front();
5981 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
6005 if (!AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
6013 state.diagnoseIgnoredTypeAttrs(
T);
6024 if (
T.isVolatileQualified() && S.
getLangOpts().CPlusPlus20 &&
6052 diag::err_function_parameter_pack_without_parameter_packs)
6073 LangOpts.CPlusPlus11
6074 ? diag::warn_cxx98_compat_variadic_templates
6075 : diag::ext_variadic_templates);
6105 diag::err_ellipsis_in_declarator_not_parameter);
6111 assert(!
T.isNull() &&
"T must not be null at the end of this function");
6112 if (!AreDeclaratorChunksValid)
6126 TypeProcessingState state(*
this, D);
6149 unsigned chunkIndex) {
6150 Sema &S = state.getSema();
6158 const char *attrStr =
nullptr;
6159 switch (ownership) {
6178 &Args, 1, ParsedAttr::Form::GNU());
6187 Sema &S = state.getSema();
6191 bool hasIndirection =
false;
6194 switch (chunk.
Kind) {
6203 hasIndirection =
true;
6236 TypeProcessingState state(*
this, D);
6251 TypeProcessingState &State) {
6258 if (AL.getKind() == ParsedAttr::AT_MatrixType) {
6267 llvm_unreachable(
"no matrix_type attribute found at the expected location!");
6271 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
6274 TypeProcessingState &State;
6278 TypeSpecLocFiller(
Sema &S,
ASTContext &Context, TypeProcessingState &State,
6280 : SemaRef(S), Context(Context), State(State), DS(DS) {}
6292 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6415 void VisitDependentTemplateSpecializationTypeLoc(
6444 if (TemplateId->
NumArgs > 0) {
6455 TN.getKind() == TemplateName::NameKind::UsingTemplate
6456 ? cast<NamedDecl>(TN.getAsUsingShadowDecl())
6457 : cast_if_present<NamedDecl>(TN.getAsTemplateDecl()),
6500 void VisitTypeLoc(
TypeLoc TL) {
6506 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
6508 TypeProcessingState &State;
6512 DeclaratorLocFiller(
ASTContext &Context, TypeProcessingState &State,
6514 : Context(Context), State(State), Chunk(Chunk) {}
6517 llvm_unreachable(
"qualified type locs not expected here!");
6520 llvm_unreachable(
"decayed type locs not expected here!");
6523 llvm_unreachable(
"array parameter type locs not expected here!");
6562 assert(isa<DependentNameType>(ClsTy) &&
"Unexpected TypeLoc");
6573 if (isa<ElaboratedType>(ClsTy)) {
6588 llvm_unreachable(
"Nested-name-specifier must name a type");
6620 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
6656 void VisitTypeLoc(
TypeLoc TL) {
6657 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
6664 switch (Chunk.
Kind) {
6669 llvm_unreachable(
"cannot be _Atomic qualified");
6690 if (AL.getKind() == ParsedAttr::AT_AddressSpace) {
6699 "no address_space attribute found at the expected location!");
6713 Sema &S = State.getSema();
6720 if (isa<PackExpansionType>(
T)) {
6739 bool HasDesugaredTypeLoc =
true;
6740 while (HasDesugaredTypeLoc) {
6742 case TypeLoc::MacroQualified: {
6745 State.getExpansionLocForMacroQualifiedType(TL.
getTypePtr()));
6750 case TypeLoc::Attributed: {
6757 case TypeLoc::Adjusted:
6758 case TypeLoc::BTFTagAttributed: {
6763 case TypeLoc::DependentAddressSpace: {
6771 HasDesugaredTypeLoc =
false;
6782 if (ReturnTypeInfo) {
6802 "LocInfoType's TypeClass conflicts with an existing Type class");
6808 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
6809 " was used directly instead of getting the QualType through"
6810 " GetTypeFromParser");
6817 "Type name should have no identifier!");
6856 const Expr *AddrSpace,
6859 std::optional<llvm::APSInt> OptAddrSpace =
6861 if (!OptAddrSpace) {
6862 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
6867 llvm::APSInt &addrSpace = *OptAddrSpace;
6870 if (addrSpace.isSigned()) {
6871 if (addrSpace.isNegative()) {
6872 S.
Diag(AttrLoc, diag::err_attribute_address_space_negative)
6876 addrSpace.setIsSigned(
false);
6879 llvm::APSInt
max(addrSpace.getBitWidth());
6883 if (addrSpace >
max) {
6884 S.
Diag(AttrLoc, diag::err_attribute_address_space_too_high)
6919 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
6935 TypeProcessingState &State) {
6936 Sema &S = State.getSema();
6939 if (
Attr.getNumArgs() != 1) {
6940 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6947 auto *StrLiteral = dyn_cast<StringLiteral>(
Attr.getArgAsExpr(0));
6956 StringRef BTFTypeTag = StrLiteral->getString();
6957 Type = State.getBTFTagAttributedType(
6958 ::new (Ctx) BTFTypeTagAttr(Ctx,
Attr, BTFTypeTag),
Type);
6966 TypeProcessingState &State) {
6967 Sema &S = State.getSema();
6972 S.
Diag(
Attr.
getLoc(), diag::err_attribute_address_function_type);
6978 if (
Attr.
getKind() == ParsedAttr::AT_AddressSpace) {
6981 if (
Attr.getNumArgs() != 1) {
6988 Expr *ASArgExpr =
static_cast<Expr *
>(
Attr.getArgAsExpr(0));
6997 ::new (Ctx) AddressSpaceAttr(Ctx,
Attr,
static_cast<unsigned>(ASIdx));
7009 if (EquivType.
isNull()) {
7013 T = State.getAttributedType(ASAttr,
Type, EquivType);
7015 T = State.getAttributedType(ASAttr,
Type,
Type);
7026 :
Attr.asOpenCLLangAS();
7028 ASIdx =
Attr.asHLSLLangAS();
7031 llvm_unreachable(
"Invalid address space");
7049 bool NonObjCPointer =
false;
7051 if (!
type->isDependentType() && !
type->isUndeducedType()) {
7059 NonObjCPointer =
true;
7060 }
else if (!
type->isObjCRetainableType()) {
7066 if (state.isProcessingDeclSpec()) {
7074 Sema &S = state.getSema();
7080 if (!
attr.isArgIdent(0)) {
7081 S.
Diag(AttrLoc, diag::err_attribute_argument_type) <<
attr
7089 if (II->
isStr(
"none"))
7091 else if (II->
isStr(
"strong"))
7093 else if (II->
isStr(
"weak"))
7095 else if (II->
isStr(
"autoreleasing"))
7098 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported) <<
attr << II;
7115 =
type.getQualifiers().getObjCLifetime()) {
7118 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
7125 if (previousLifetime != lifetime) {
7128 const Type *prevTy =
nullptr;
7129 while (!prevTy || prevTy != underlyingType.
Ty) {
7130 prevTy = underlyingType.
Ty;
7139 if (NonObjCPointer) {
7140 StringRef name =
attr.getAttrName()->getName();
7149 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
7166 type = state.getAttributedType(
7167 createSimpleAttr<ObjCInertUnsafeUnretainedAttr>(S.
Context,
attr),
7173 if (!NonObjCPointer)
7190 diagnostic,
type, 0));
7192 S.
Diag(loc, diagnostic);
7201 unsigned diagnostic =
7202 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
7203 : diag::err_arc_weak_no_runtime);
7206 diagnoseOrDelay(S, AttrLoc, diagnostic,
type);
7218 if (
Class->isArcWeakrefUnavailable()) {
7219 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
7220 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
7221 diag::note_class_declared);
7236 Sema &S = state.getSema();
7239 if (!
type->isPointerType() &&
7240 !
type->isObjCObjectPointerType() &&
7241 !
type->isBlockPointerType())
7245 S.
Diag(
attr.getLoc(), diag::err_attribute_multiple_objc_gc);
7251 if (!
attr.isArgIdent(0)) {
7252 S.
Diag(
attr.getLoc(), diag::err_attribute_argument_type)
7258 if (
attr.getNumArgs() > 1) {
7259 S.
Diag(
attr.getLoc(), diag::err_attribute_wrong_number_arguments) <<
attr
7266 if (II->
isStr(
"weak"))
7268 else if (II->
isStr(
"strong"))
7271 S.
Diag(
attr.getLoc(), diag::warn_attribute_type_not_supported)
7281 if (
attr.getLoc().isValid())
7282 type = state.getAttributedType(
7299 struct FunctionTypeUnwrapper {
7318 const Type *Ty =
T.getTypePtr();
7319 if (isa<FunctionType>(Ty)) {
7320 Fn = cast<FunctionType>(Ty);
7322 }
else if (isa<ParenType>(Ty)) {
7323 T = cast<ParenType>(Ty)->getInnerType();
7325 }
else if (isa<ConstantArrayType>(Ty) || isa<VariableArrayType>(Ty) ||
7326 isa<IncompleteArrayType>(Ty)) {
7327 T = cast<ArrayType>(Ty)->getElementType();
7328 Stack.push_back(Array);
7329 }
else if (isa<PointerType>(Ty)) {
7332 }
else if (isa<BlockPointerType>(Ty)) {
7334 Stack.push_back(BlockPointer);
7335 }
else if (isa<MemberPointerType>(Ty)) {
7337 Stack.push_back(MemberPointer);
7338 }
else if (isa<ReferenceType>(Ty)) {
7340 Stack.push_back(Reference);
7341 }
else if (isa<AttributedType>(Ty)) {
7342 T = cast<AttributedType>(Ty)->getEquivalentType();
7343 Stack.push_back(Attributed);
7344 }
else if (isa<MacroQualifiedType>(Ty)) {
7345 T = cast<MacroQualifiedType>(Ty)->getUnderlyingType();
7346 Stack.push_back(MacroQualified);
7355 Stack.push_back(Desugar);
7360 bool isFunctionType()
const {
return (Fn !=
nullptr); }
7365 if (New == get())
return Original;
7368 return wrap(S.
Context, Original, 0);
7373 if (I == Stack.size())
7382 return wrap(
C, SplitOld.
Ty, I);
7383 return C.getQualifiedType(wrap(
C, SplitOld.
Ty, I), SplitOld.
Quals);
7387 if (I == Stack.size())
return QualType(Fn, 0);
7389 switch (
static_cast<WrapKind
>(Stack[I++])) {
7396 return wrap(
C, cast<AttributedType>(Old)->getEquivalentType(), I);
7399 QualType New = wrap(
C, cast<ParenType>(Old)->getInnerType(), I);
7400 return C.getParenType(New);
7403 case MacroQualified:
7407 if (
const auto *CAT = dyn_cast<ConstantArrayType>(Old)) {
7408 QualType New = wrap(
C, CAT->getElementType(), I);
7409 return C.getConstantArrayType(New, CAT->getSize(), CAT->getSizeExpr(),
7410 CAT->getSizeModifier(),
7411 CAT->getIndexTypeCVRQualifiers());
7414 if (
const auto *VAT = dyn_cast<VariableArrayType>(Old)) {
7415 QualType New = wrap(
C, VAT->getElementType(), I);
7416 return C.getVariableArrayType(
7417 New, VAT->getSizeExpr(), VAT->getSizeModifier(),
7418 VAT->getIndexTypeCVRQualifiers(), VAT->getBracketsRange());
7421 const auto *IAT = cast<IncompleteArrayType>(Old);
7422 QualType New = wrap(
C, IAT->getElementType(), I);
7423 return C.getIncompleteArrayType(New, IAT->getSizeModifier(),
7424 IAT->getIndexTypeCVRQualifiers());
7428 QualType New = wrap(
C, cast<PointerType>(Old)->getPointeeType(), I);
7429 return C.getPointerType(New);
7432 case BlockPointer: {
7433 QualType New = wrap(
C, cast<BlockPointerType>(Old)->getPointeeType(),I);
7434 return C.getBlockPointerType(New);
7437 case MemberPointer: {
7440 return C.getMemberPointerType(New, OldMPT->
getClass());
7446 if (isa<LValueReferenceType>(OldRef))
7449 return C.getRValueReferenceType(New);
7453 llvm_unreachable(
"unknown wrapping kind");
7460 Sema &S = State.getSema();
7464 default: llvm_unreachable(
"Unknown attribute kind");
7465 case ParsedAttr::AT_Ptr32:
7466 A = createSimpleAttr<Ptr32Attr>(S.
Context, PAttr);
7468 case ParsedAttr::AT_Ptr64:
7469 A = createSimpleAttr<Ptr64Attr>(S.
Context, PAttr);
7471 case ParsedAttr::AT_SPtr:
7472 A = createSimpleAttr<SPtrAttr>(S.
Context, PAttr);
7474 case ParsedAttr::AT_UPtr:
7475 A = createSimpleAttr<UPtrAttr>(S.
Context, PAttr);
7479 std::bitset<attr::LastAttr> Attrs;
7482 if (
const TypedefType *TT = dyn_cast<TypedefType>(Desugared)) {
7483 Desugared = TT->desugar();
7485 }
else if (
const ElaboratedType *ET = dyn_cast<ElaboratedType>(Desugared)) {
7486 Desugared = ET->desugar();
7499 if (Attrs[NewAttrKind]) {
7500 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7503 Attrs[NewAttrKind] =
true;
7507 if (Attrs[attr::Ptr32] && Attrs[attr::Ptr64]) {
7508 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7510 <<
"'__ptr64'" << 0;
7512 }
else if (Attrs[attr::SPtr] && Attrs[attr::UPtr]) {
7513 S.
Diag(PAttr.
getLoc(), diag::err_attributes_are_not_compatible)
7521 if (!isa<PointerType>(Desugared)) {
7525 S.
Diag(PAttr.
getLoc(), diag::err_attribute_no_member_pointers) << PAttr;
7527 S.
Diag(PAttr.
getLoc(), diag::err_attribute_pointers_only) << PAttr << 0;
7535 if (PtrWidth == 32) {
7536 if (Attrs[attr::Ptr64])
7538 else if (Attrs[attr::UPtr])
7540 }
else if (PtrWidth == 64 && Attrs[attr::Ptr32]) {
7541 if (Attrs[attr::UPtr])
7557 assert(PAttr.
getKind() == ParsedAttr::AT_WebAssemblyFuncref);
7559 Sema &S = State.getSema();
7560 Attr *A = createSimpleAttr<WebAssemblyFuncrefAttr>(S.
Context, PAttr);
7562 std::bitset<attr::LastAttr> Attrs;
7564 const auto *AT = dyn_cast<AttributedType>(QT);
7566 Attrs[AT->getAttrKind()] =
true;
7567 AT = dyn_cast<AttributedType>(AT->getModifiedType());
7572 if (Attrs[NewAttrKind]) {
7573 S.
Diag(PAttr.
getLoc(), diag::warn_duplicate_attribute_exact) << PAttr;
7589 auto Attributed = dyn_cast<AttributedType>(
Type.getTypePtr());
7594 if (Attributed->getImmediateNullability())
7595 return Attributed->getModifiedType();
7599 Ctx, Attributed->getModifiedType());
7600 assert(Modified.
getTypePtr() != Attributed->getModifiedType().getTypePtr());
7602 Attributed->getEquivalentType());
7608 case ParsedAttr::AT_TypeNonNull:
7611 case ParsedAttr::AT_TypeNullable:
7614 case ParsedAttr::AT_TypeNullableResult:
7617 case ParsedAttr::AT_TypeNullUnspecified:
7621 llvm_unreachable(
"not a nullability attribute kind");
7628 bool IsContextSensitive,
bool AllowOnArrayType,
bool OverrideExisting) {
7629 bool Implicit = (State ==
nullptr);
7635 while (
auto *Attributed = dyn_cast<AttributedType>(Desugared.
getTypePtr())) {
7637 if (
auto ExistingNullability = Attributed->getImmediateNullability()) {
7639 if (Nullability == *ExistingNullability) {
7643 S.
Diag(NullabilityLoc, diag::warn_nullability_duplicate)
7650 if (!OverrideExisting) {
7652 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7662 Desugared = Attributed->getModifiedType();
7670 if (Nullability != *ExistingNullability && !
Implicit) {
7671 S.
Diag(NullabilityLoc, diag::err_nullability_conflicting)
7679 if (
auto typedefNullability =
7681 if (*typedefNullability == *ExistingNullability) {
7694 !(AllowOnArrayType && Desugared->
isArrayType())) {
7696 S.
Diag(NullabilityLoc, diag::err_nullability_nonpointer)
7704 if (IsContextSensitive) {
7706 const Type *pointeeType =
nullptr;
7715 S.
Diag(NullabilityLoc, diag::err_nullability_cs_multilevel)
7717 S.
Diag(NullabilityLoc, diag::note_nullability_type_specifier)
7729 QT = State->getAttributedType(A, QT, QT);
7739 bool AllowOnArrayType) {
7745 Nullability, NullabilityLoc,
7746 IsContextSensitive, AllowOnArrayType,
7753 bool AllowArrayTypes,
7754 bool OverrideExisting) {
7756 *
this,
nullptr,
nullptr,
Type, Nullability, DiagLoc,
7757 false, AllowArrayTypes, OverrideExisting);
7764 Sema &S = state.getSema();
7766 if (isa<ObjCTypeParamType>(
type)) {
7768 type = state.getAttributedType(
7781 S.
Diag(
attr.getLoc(), diag::err_objc_kindof_nonobject)
7790 objType->getBaseType(), objType->getTypeArgsAsWritten(),
7791 objType->getProtocols(),
7792 objType->isObjCUnqualifiedId() ?
false :
true);
7797 if (
auto nullability =
type->getNullability()) {
7800 assert(
attr.getAttributeSpellingListIndex() == 0 &&
7801 "multiple spellings for __kindof?");
7804 equivType = state.getAttributedType(A, equivType, equivType);
7809 type = state.getAttributedType(
7822 Declarator &declarator = state.getDeclarator();
7825 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
7838 PK_MemberFunctionPointer,
7843 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
7845 auto diag = state.getSema().Diag(
attr.getLoc(),
7846 diag::warn_nullability_declspec)
7848 attr.isContextSensitiveKeywordAttribute())
7850 <<
static_cast<unsigned>(pointerKind);
7856 state.getSema().getPreprocessor().getLocForEndOfToken(
7858 " " +
attr.getAttrName()->getName().str() +
" ");
7868 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
7870 switch (chunk.
Kind) {
7874 return moveToChunk(chunk,
false);
7886 return moveToChunk(*dest,
true);
7902 assert(!
Attr.isInvalid());
7905 llvm_unreachable(
"not a calling convention attribute");
7906 case ParsedAttr::AT_CDecl:
7907 return createSimpleAttr<CDeclAttr>(Ctx,
Attr);
7908 case ParsedAttr::AT_FastCall:
7909 return createSimpleAttr<FastCallAttr>(Ctx,
Attr);
7910 case ParsedAttr::AT_StdCall:
7911 return createSimpleAttr<StdCallAttr>(Ctx,
Attr);
7912 case ParsedAttr::AT_ThisCall:
7913 return createSimpleAttr<ThisCallAttr>(Ctx,
Attr);
7914 case ParsedAttr::AT_RegCall:
7915 return createSimpleAttr<RegCallAttr>(Ctx,
Attr);
7916 case ParsedAttr::AT_Pascal:
7917 return createSimpleAttr<PascalAttr>(Ctx,
Attr);
7918 case ParsedAttr::AT_SwiftCall:
7919 return createSimpleAttr<SwiftCallAttr>(Ctx,
Attr);
7920 case ParsedAttr::AT_SwiftAsyncCall:
7921 return createSimpleAttr<SwiftAsyncCallAttr>(Ctx,
Attr);
7922 case ParsedAttr::AT_VectorCall:
7923 return createSimpleAttr<VectorCallAttr>(Ctx,
Attr);
7924 case ParsedAttr::AT_AArch64VectorPcs:
7925 return createSimpleAttr<AArch64VectorPcsAttr>(Ctx,
Attr);
7926 case ParsedAttr::AT_AArch64SVEPcs:
7927 return createSimpleAttr<AArch64SVEPcsAttr>(Ctx,
Attr);
7928 case ParsedAttr::AT_ArmStreaming:
7929 return createSimpleAttr<ArmStreamingAttr>(Ctx,
Attr);
7930 case ParsedAttr::AT_AMDGPUKernelCall:
7931 return createSimpleAttr<AMDGPUKernelCallAttr>(Ctx,
Attr);
7932 case ParsedAttr::AT_Pcs: {
7937 if (
Attr.isArgExpr(0))
7938 Str = cast<StringLiteral>(
Attr.getArgAsExpr(0))->getString();
7940 Str =
Attr.getArgAsIdent(0)->Ident->getName();
7941 PcsAttr::PCSType
Type;
7942 if (!PcsAttr::ConvertStrToPCSType(Str,
Type))
7943 llvm_unreachable(
"already validated the attribute");
7944 return ::new (Ctx) PcsAttr(Ctx,
Attr,
Type);
7946 case ParsedAttr::AT_IntelOclBicc:
7947 return createSimpleAttr<IntelOclBiccAttr>(Ctx,
Attr);
7948 case ParsedAttr::AT_MSABI:
7949 return createSimpleAttr<MSABIAttr>(Ctx,
Attr);
7950 case ParsedAttr::AT_SysVABI:
7951 return createSimpleAttr<SysVABIAttr>(Ctx,
Attr);
7952 case ParsedAttr::AT_PreserveMost:
7953 return createSimpleAttr<PreserveMostAttr>(Ctx,
Attr);
7954 case ParsedAttr::AT_PreserveAll:
7955 return createSimpleAttr<PreserveAllAttr>(Ctx,
Attr);
7956 case ParsedAttr::AT_M68kRTD:
7957 return createSimpleAttr<M68kRTDAttr>(Ctx,
Attr);
7958 case ParsedAttr::AT_PreserveNone:
7959 return createSimpleAttr<PreserveNoneAttr>(Ctx,
Attr);
7960 case ParsedAttr::AT_RISCVVectorCC:
7961 return createSimpleAttr<RISCVVectorCCAttr>(Ctx,
Attr);
7963 llvm_unreachable(
"unexpected attribute kind!");
7970 auto OtherAttr = std::find_if(
7971 state.getCurrentAttributes().begin(), state.getCurrentAttributes().end(),
7972 [OtherKind](
const ParsedAttr &A) { return A.getKind() == OtherKind; });
7973 if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
7976 Sema &S = state.getSema();
7978 << *OtherAttr <<
Attr
7979 << (OtherAttr->isRegularKeywordAttribute() ||
7981 S.
Diag(OtherAttr->getLoc(), diag::note_conflicting_attribute);
7990 if (!
Attr.getNumArgs()) {
7996 for (
unsigned I = 0; I <
Attr.getNumArgs(); ++I) {
7997 StringRef StateName;
8004 if (StateName ==
"za") {
8007 }
else if (StateName ==
"zt0") {
8011 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
8020 S.
Diag(LiteralLoc, diag::err_conflicting_attributes_arm_state)
8036 Sema &S = state.getSema();
8038 FunctionTypeUnwrapper unwrapped(S,
type);
8040 if (
attr.getKind() == ParsedAttr::AT_NoReturn) {
8045 if (!unwrapped.isFunctionType())
8054 if (
attr.getKind() == ParsedAttr::AT_CmseNSCall) {
8056 if (!unwrapped.isFunctionType())
8061 S.
Diag(
attr.getLoc(), diag::warn_attribute_ignored) <<
attr;
8068 unwrapped.get()->getExtInfo().withCmseNSCall(
true);
8075 if (
attr.getKind() == ParsedAttr::AT_NSReturnsRetained) {
8076 if (
attr.getNumArgs())
return true;
8079 if (!unwrapped.isFunctionType())
8084 unwrapped.get()->getReturnType()))
8089 if (state.getSema().getLangOpts().ObjCAutoRefCount) {
8091 = unwrapped.get()->getExtInfo().withProducesResult(
true);
8094 type = state.getAttributedType(
8095 createSimpleAttr<NSReturnsRetainedAttr>(S.
Context,
attr),
8100 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCallerSavedRegisters) {
8105 if (!unwrapped.isFunctionType())
8109 unwrapped.get()->getExtInfo().withNoCallerSavedRegs(
true);
8114 if (
attr.getKind() == ParsedAttr::AT_AnyX86NoCfCheck) {
8116 S.
Diag(
attr.getLoc(), diag::warn_nocf_check_attribute_ignored);
8126 if (!unwrapped.isFunctionType())
8130 unwrapped.get()->getExtInfo().withNoCfCheck(
true);
8135 if (
attr.getKind() == ParsedAttr::AT_Regparm) {
8141 if (!unwrapped.isFunctionType())
8148 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8150 <<
attr.isRegularKeywordAttribute();
8156 unwrapped.get()->getExtInfo().withRegParm(value);
8161 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8162 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible ||
8163 attr.getKind() == ParsedAttr::AT_ArmPreserves ||
8164 attr.getKind() == ParsedAttr::AT_ArmIn ||
8165 attr.getKind() == ParsedAttr::AT_ArmOut ||
8166 attr.getKind() == ParsedAttr::AT_ArmInOut) {
8170 if (
attr.getKind() == ParsedAttr::AT_ArmStreaming ||
8171 attr.getKind() == ParsedAttr::AT_ArmStreamingCompatible)
8175 if (!unwrapped.isFunctionType())
8182 S.
Diag(
attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
8189 switch (
attr.getKind()) {
8190 case ParsedAttr::AT_ArmStreaming:
8192 ParsedAttr::AT_ArmStreamingCompatible))
8196 case ParsedAttr::AT_ArmStreamingCompatible:
8201 case ParsedAttr::AT_ArmPreserves:
8205 case ParsedAttr::AT_ArmIn:
8209 case ParsedAttr::AT_ArmOut:
8213 case ParsedAttr::AT_ArmInOut:
8218 llvm_unreachable(
"Unsupported attribute");
8222 FnTy->getParamTypes(), EPI);
8227 if (
attr.getKind() == ParsedAttr::AT_NoThrow) {
8229 if (!unwrapped.isFunctionType())
8242 if (Proto->hasExceptionSpec()) {
8243 switch (Proto->getExceptionSpecType()) {
8245 llvm_unreachable(
"This doesn't have an exception spec!");
8263 S.
Diag(
attr.getLoc(), diag::warn_nothrow_attribute_ignored);
8269 type = unwrapped.wrap(
8279 if (!unwrapped.isFunctionType())
return false;
8294 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8297 <<
attr.isRegularKeywordAttribute();
8316 return S.
Diag(
attr.getLoc(), diag::warn_cconv_unsupported)
8321 return S.
Diag(
attr.getLoc(), diag::err_cconv_varargs)
8328 S.
Diag(
attr.getLoc(), diag::err_attributes_are_not_compatible)
8330 <<
attr.isRegularKeywordAttribute();
8342 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
8366 FunctionTypeUnwrapper Unwrapped(*
this,
T);
8368 bool IsVariadic = (isa<FunctionProtoType>(FT) &&
8369 cast<FunctionProtoType>(FT)->isVariadic());
8383 Diag(Loc, diag::warn_cconv_unsupported)
8394 if (CurCC != DefaultCC)
8402 QualType Wrapped = Unwrapped.wrap(*
this, FT);
8416 if (
Attr.getNumArgs() != 1) {
8423 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8436 if (
Attr.getNumArgs() != 1) {
8442 Expr *SizeExpr =
Attr.getArgAsExpr(0);
8457 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
8458 Triple.getArch() == llvm::Triple::aarch64_32 ||
8459 Triple.getArch() == llvm::Triple::aarch64_be;
8461 if (IsPolyUnsigned) {
8463 return BTy->
getKind() == BuiltinType::UChar ||
8464 BTy->
getKind() == BuiltinType::UShort ||
8465 BTy->
getKind() == BuiltinType::ULong ||
8466 BTy->
getKind() == BuiltinType::ULongLong;
8469 return BTy->
getKind() == BuiltinType::SChar ||
8470 BTy->
getKind() == BuiltinType::Short ||
8471 BTy->
getKind() == BuiltinType::LongLong;
8477 if ((Triple.isArch64Bit() || Triple.getArch() == llvm::Triple::aarch64_32) &&
8478 BTy->
getKind() == BuiltinType::Double)
8481 return BTy->
getKind() == BuiltinType::SChar ||
8482 BTy->
getKind() == BuiltinType::UChar ||
8483 BTy->
getKind() == BuiltinType::Short ||
8484 BTy->
getKind() == BuiltinType::UShort ||
8485 BTy->
getKind() == BuiltinType::Int ||
8486 BTy->
getKind() == BuiltinType::UInt ||
8487 BTy->
getKind() == BuiltinType::Long ||
8488 BTy->
getKind() == BuiltinType::ULong ||
8489 BTy->
getKind() == BuiltinType::LongLong ||
8490 BTy->
getKind() == BuiltinType::ULongLong ||
8491 BTy->
getKind() == BuiltinType::Float ||
8492 BTy->
getKind() == BuiltinType::Half ||
8493 BTy->
getKind() == BuiltinType::BFloat16;
8498 const auto *AttrExpr =
Attr.getArgAsExpr(0);
8499 if (!AttrExpr->isTypeDependent()) {
8500 if (std::optional<llvm::APSInt> Res =
8501 AttrExpr->getIntegerConstantExpr(S.
Context)) {
8521 bool IsTargetCUDAAndHostARM =
false;
8524 IsTargetCUDAAndHostARM =
8534 IsTargetCUDAAndHostARM) &&
8537 <<
Attr <<
"'neon', 'mve', 'sve' or 'sme'";
8543 IsTargetCUDAAndHostARM) &&
8546 <<
Attr <<
"'neon' or 'mve'";
8552 if (
Attr.getNumArgs() != 1) {
8553 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8559 llvm::APSInt numEltsInt(32);
8565 !IsTargetCUDAAndHostARM) {
8566 S.
Diag(
Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
8573 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
8574 unsigned vecSize = typeSize * numElts;
8575 if (vecSize != 64 && vecSize != 128) {
8576 S.
Diag(
Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
8600 S.
Diag(
Attr.
getLoc(), diag::err_attribute_arm_feature_sve_bits_unsupported)
8607 if (
Attr.getNumArgs() != 1) {
8608 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8615 llvm::APSInt SveVectorSizeInBits(32);
8619 unsigned VecSize =
static_cast<unsigned>(SveVectorSizeInBits.getZExtValue());
8642 if (BT->getKind() == BuiltinType::SveBool) {
8647 VecSize /= TypeSize;
8654 const VectorType *VT = dyn_cast<VectorType>(CurType);
8657 diag::err_attribute_arm_mve_polymorphism);
8663 State.getAttributedType(createSimpleAttr<ArmMveStrictPolymorphismAttr>(
8664 State.getSema().Context,
Attr),
8676 <<
Attr <<
"'zve32x'";
8682 if (!VScale || !VScale->first || VScale->first != VScale->second) {
8683 S.
Diag(
Attr.
getLoc(), diag::err_attribute_riscv_rvv_bits_unsupported)
8690 if (
Attr.getNumArgs() != 1) {
8691 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8698 llvm::APSInt RVVVectorSizeInBits(32);
8710 unsigned VecSize =
static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue());
8714 unsigned MinElts = Info.
EC.getKnownMinValue();
8717 unsigned ExpectedSize = VScale->first * MinElts;
8725 ExpectedSize *= EltSize;
8726 NumElts = VecSize / EltSize;
8730 if (ExpectedSize % 8 != 0 || VecSize != ExpectedSize) {
8732 << VecSize << ExpectedSize;
8745 S.
Diag(
Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
8751 QualType BaseTy = TypedefTy->desugar();
8753 std::string PrevAccessQual;
8755 if (TypedefTy->getDecl()->hasAttr<OpenCLAccessAttr>()) {
8756 OpenCLAccessAttr *
Attr =
8757 TypedefTy->getDecl()->getAttr<OpenCLAccessAttr>();
8760 PrevAccessQual =
"read_only";
8764 switch (ImgType->getKind()) {
8765 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8766 case BuiltinType::Id: \
8767 PrevAccessQual = #Access; \
8769 #include "clang/Basic/OpenCLImageTypes.def"
8771 llvm_unreachable(
"Unable to find corresponding image type.");
8774 llvm_unreachable(
"unexpected type");
8777 if (PrevAccessQual == AttrName.ltrim(
"_")) {
8783 S.
Diag(
Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
8786 S.
Diag(TypedefTy->getDecl()->getBeginLoc(),
8787 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
8789 if (
Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
8804 if (
Attr.getNumArgs() != 2) {
8805 S.
Diag(
Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
8810 Expr *RowsExpr =
Attr.getArgAsExpr(0);
8811 Expr *ColsExpr =
Attr.getArgAsExpr(1);
8819 Sema &S = State.getSema();
8822 S.
Diag(PA.
getLoc(), diag::err_attribute_too_few_arguments) << PA << 1;
8834 for (
unsigned Idx = 1; Idx < PA.
getNumArgs(); Idx++) {
8840 auto *AnnotateTypeAttr =
8841 AnnotateTypeAttr::Create(S.
Context, Str, Args.data(), Args.size(), PA);
8842 CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType);
8848 if (State.getDeclarator().isDeclarationOfFunction()) {
8849 CurType = State.getAttributedType(
8850 createSimpleAttr<LifetimeBoundAttr>(State.getSema().Context,
Attr),
8861 if (
Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_inout ||
8862 Attr.getSemanticSpelling() == HLSLParamModifierAttr::Keyword_out)
8871 state.setParsedNoDeref(
false);
8887 if (
attr.isInvalid())
8890 if (
attr.isStandardAttributeSyntax() ||
attr.isRegularKeywordAttribute()) {
8895 if (
attr.isGNUScope()) {
8896 assert(
attr.isStandardAttributeSyntax());
8897 bool IsTypeAttr =
attr.isTypeAttr();
8899 state.getSema().Diag(
attr.getLoc(),
8901 ? diag::warn_gcc_ignores_type_attr
8902 : diag::warn_cxx11_gnu_attribute_on_type)
8908 !
attr.isTypeAttr()) {
8921 switch (
attr.getKind()) {
8924 if ((
attr.isStandardAttributeSyntax() ||
8925 attr.isRegularKeywordAttribute()) &&
8927 state.getSema().Diag(
attr.getLoc(), diag::err_attribute_not_type_attr)
8928 <<
attr <<
attr.isRegularKeywordAttribute();
8929 attr.setUsedAsTypeAttr();
8934 if (
attr.isStandardAttributeSyntax()) {
8935 state.getSema().Diag(
attr.getLoc(),
8936 diag::warn_unknown_attribute_ignored)
8947 case ParsedAttr::AT_BTFTypeTag:
8949 attr.setUsedAsTypeAttr();
8952 case ParsedAttr::AT_MayAlias:
8955 attr.setUsedAsTypeAttr();
8957 case ParsedAttr::AT_OpenCLPrivateAddressSpace:
8958 case ParsedAttr::AT_OpenCLGlobalAddressSpace:
8959 case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
8960 case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
8961 case ParsedAttr::AT_OpenCLLocalAddressSpace:
8962 case ParsedAttr::AT_OpenCLConstantAddressSpace:
8963 case ParsedAttr::AT_OpenCLGenericAddressSpace:
8964 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
8965 case ParsedAttr::AT_AddressSpace:
8967 attr.setUsedAsTypeAttr();
8972 attr.setUsedAsTypeAttr();
8974 case ParsedAttr::AT_VectorSize:
8976 attr.setUsedAsTypeAttr();
8978 case ParsedAttr::AT_ExtVectorType:
8980 attr.setUsedAsTypeAttr();
8982 case ParsedAttr::AT_NeonVectorType:
8984 attr.setUsedAsTypeAttr();
8986 case ParsedAttr::AT_NeonPolyVectorType:
8989 attr.setUsedAsTypeAttr();
8991 case ParsedAttr::AT_ArmSveVectorBits:
8993 attr.setUsedAsTypeAttr();
8995 case ParsedAttr::AT_ArmMveStrictPolymorphism: {
8997 attr.setUsedAsTypeAttr();
9000 case ParsedAttr::AT_RISCVRVVVectorBits:
9002 attr.setUsedAsTypeAttr();
9004 case ParsedAttr::AT_OpenCLAccess:
9006 attr.setUsedAsTypeAttr();
9008 case ParsedAttr::AT_LifetimeBound:
9013 case ParsedAttr::AT_NoDeref: {
9018 if (
attr.isStandardAttributeSyntax()) {
9019 state.getSema().Diag(
attr.getLoc(), diag::warn_attribute_ignored)
9024 type = state.getAttributedType(createSimpleAttr<NoDerefAttr>(Ctx,
attr),
9026 attr.setUsedAsTypeAttr();
9027 state.setParsedNoDeref(
true);
9031 case ParsedAttr::AT_MatrixType:
9033 attr.setUsedAsTypeAttr();
9036 case ParsedAttr::AT_WebAssemblyFuncref: {
9038 attr.setUsedAsTypeAttr();
9042 case ParsedAttr::AT_HLSLParamModifier: {
9044 attr.setUsedAsTypeAttr();
9050 attr.setUsedAsTypeAttr();
9058 if (
type->canHaveNullability() ||
type->isDependentType() ||
9059 type->isArrayType() ||
9063 endIndex = state.getCurrentChunkIndex();
9065 endIndex = state.getDeclarator().getNumTypeObjects();
9066 bool allowOnArrayType =
9067 state.getDeclarator().isPrototypeContext() &&
9070 allowOnArrayType)) {
9074 attr.setUsedAsTypeAttr();
9078 case ParsedAttr::AT_ObjCKindOf:
9086 state.getSema().Diag(
attr.getLoc(),
9087 diag::err_objc_kindof_wrong_position)
9090 state.getDeclarator().getDeclSpec().getBeginLoc(),
9100 case ParsedAttr::AT_NoThrow:
9103 if (!state.getSema().getLangOpts().CPlusPlus)
9107 attr.setUsedAsTypeAttr();
9111 if (
attr.isStandardAttributeSyntax() ||
9112 attr.isRegularKeywordAttribute()) {
9129 case ParsedAttr::AT_AcquireHandle: {
9130 if (!
type->isFunctionType())
9133 if (
attr.getNumArgs() != 1) {
9134 state.getSema().Diag(
attr.getLoc(),
9135 diag::err_attribute_wrong_number_arguments)
9141 StringRef HandleType;
9142 if (!state.getSema().checkStringLiteralArgumentAttr(
attr, 0, HandleType))
9144 type = state.getAttributedType(
9145 AcquireHandleAttr::Create(state.getSema().Context, HandleType,
attr),
9147 attr.setUsedAsTypeAttr();
9150 case ParsedAttr::AT_AnnotateType: {
9152 attr.setUsedAsTypeAttr();
9159 if (isa<AttributedType>(
type) &&
attr.hasMacroIdentifier() &&
9160 !
type.getQualifiers().hasObjCLifetime() &&
9161 !
type.getQualifiers().hasObjCGCAttr() &&
9162 attr.getKind() != ParsedAttr::AT_ObjCGC &&
9163 attr.getKind() != ParsedAttr::AT_ObjCOwnership) {
9165 type = state.getSema().Context.getMacroQualifiedType(
type, MacroII);
9166 state.setExpansionLocForMacroQualifiedType(
9167 cast<MacroQualifiedType>(
type.getTypePtr()),
9168 attr.getMacroExpansionLoc());
9175 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
9177 auto *Def = Var->getDefinition();
9183 Def = Var->getDefinition();
9190 if (Var->getPointOfInstantiation().isInvalid() && Def) {
9191 assert(Var->getTemplateSpecializationKind() ==
9193 "explicit instantiation with no point of instantiation");
9194 Var->setTemplateSpecializationKind(
9195 Var->getTemplateSpecializationKind(), PointOfInstantiation);
9279 if (RequireCompleteTypeImpl(Loc,
T, Kind, &Diagnoser))
9282 if (!Tag->getDecl()->isCompleteDefinitionRequired()) {
9283 Tag->getDecl()->setCompleteDefinitionRequired();
9313 if (isa<TagDecl>(D) && cast<TagDecl>(D)->isBeingDefined()) {
9317 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
9318 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
9320 D = RD->getDefinition();
9321 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
9322 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
9324 if (OnlyNeedComplete && (ED->isFixed() ||
getLangOpts().MSVCCompat)) {
9330 *Suggested =
nullptr;
9331 for (
auto *Redecl : ED->redecls()) {
9334 if (Redecl->isThisDeclarationADefinition() ||
9335 (Redecl->isCanonicalDecl() && !*Suggested))
9336 *Suggested = Redecl;
9341 D = ED->getDefinition();
9342 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
9343 if (
auto *Pattern = FD->getTemplateInstantiationPattern())
9345 D = FD->getDefinition();
9346 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
9347 if (
auto *Pattern = VD->getTemplateInstantiationPattern())
9349 D = VD->getDefinition();
9352 assert(D &&
"missing definition for pattern of instantiated definition");
9356 auto DefinitionIsAcceptable = [&] {
9376 if (DefinitionIsAcceptable())
9382 Source->CompleteRedeclChain(D);
9383 return DefinitionIsAcceptable();
9399 bool OnlyNeedComplete) {
9416 bool OnlyNeedComplete) {
9424 if (!RD->
hasAttr<MSInheritanceAttr>()) {
9426 bool BestCase =
false;
9446 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
9447 S.
getASTContext(), BestCase, Loc, MSInheritanceAttr::Spelling(IM)));
9454 CompleteTypeKind Kind,
9455 TypeDiagnoser *Diagnoser) {
9465 if (!MPTy->getClass()->isDependentType()) {
9467 !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
9469 diag::err_memptr_incomplete))
9488 if (Def && !isa<EnumDecl>(Def))
9499 if (Diagnoser && Suggested)
9502 return !TreatAsComplete;
9504 CodeSynthesisContext TempInst;
9506 TempInst.Template = Def;
9507 TempInst.Entity = Def;
9508 TempInst.PointOfInstantiation = Loc;
9516 TagDecl *Tag = dyn_cast_or_null<TagDecl>(Def);
9531 Source->CompleteType(Tag);
9533 Source->CompleteType(IFace);
9537 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9544 if (
auto *RD = dyn_cast_or_null<CXXRecordDecl>(Tag)) {
9545 bool Instantiated =
false;
9546 bool Diagnosed =
false;
9547 if (RD->isDependentContext()) {
9551 }
else if (
auto *ClassTemplateSpec =
9552 dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
9553 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
9559 Instantiated =
true;
9563 if (!RD->isBeingDefined() && Pattern) {
9565 assert(MSI &&
"Missing member specialization information?");
9575 Instantiated =
true;
9583 if (Diagnoser && Diagnosed)
9589 return RequireCompleteTypeImpl(Loc,
T, Kind, Diagnoser);
9599 Diagnoser->diagnose(*
this, Loc,
T);
9606 : diag::note_forward_declaration)
9640 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
9702 for (
const auto &I : RD->
vbases())
9703 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
9704 << I.getSourceRange();
9707 Diag(RD->
getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
9709 for (
const auto &I : RD->
bases()) {
9710 if (!I.getType()->isLiteralType(
Context)) {
9711 Diag(I.getBeginLoc(), diag::note_non_literal_base_class)
9712 << RD << I.getType() << I.getSourceRange();
9716 for (
const auto *I : RD->
fields()) {
9717 if (!I->getType()->isLiteralType(
Context) ||
9718 I->getType().isVolatileQualified()) {
9719 Diag(I->getLocation(), diag::note_non_literal_field)
9720 << RD << I << I->getType()
9721 << I->getType().isVolatileQualified();
9731 assert(Dtor &&
"class has literal fields and bases but no dtor?");
9740 ? diag::note_non_literal_user_provided_dtor
9741 : diag::note_non_literal_nontrivial_dtor)
9789 auto *CountDecl = cast<DeclRefExpr>(E)->getDecl();
9802 WrappedTy, CountExpr,
false,
false, Decls);
9813 if (
auto *ImplCastExpr = dyn_cast<ImplicitCastExpr>(E))
9814 IDExpr = ImplCastExpr->getSubExpr();
9816 if (
auto *PackExpr = dyn_cast<PackIndexingExpr>(E))
9817 IDExpr = PackExpr->getSelectedExpr();
9829 if (
const auto *SNTTPE = dyn_cast<SubstNonTypeTemplateParmExpr>(IDExpr))
9830 return SNTTPE->getParameterType(
Context);
9838 if (
const auto *DRE = dyn_cast<DeclRefExpr>(IDExpr)) {
9841 return isa<TemplateParamObjectDecl>(VD) ?
T.getUnqualifiedType() :
T;
9843 if (
const auto *ME = dyn_cast<MemberExpr>(IDExpr)) {
9844 if (
const auto *VD = ME->getMemberDecl())
9845 if (isa<FieldDecl>(VD) || isa<VarDecl>(VD))
9846 return VD->getType();
9847 }
else if (
const auto *IR = dyn_cast<ObjCIvarRefExpr>(IDExpr)) {
9848 return IR->getDecl()->getType();
9849 }
else if (
const auto *PR = dyn_cast<ObjCPropertyRefExpr>(IDExpr)) {
9850 if (PR->isExplicitProperty())
9851 return PR->getExplicitProperty()->getType();
9852 }
else if (
const auto *PE = dyn_cast<PredefinedExpr>(IDExpr)) {
9853 return PE->getType();
9864 if (
auto *DRE = dyn_cast<DeclRefExpr>(IDExpr->
IgnoreParens())) {
9865 if (
auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
9885 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
9898 Diag(Loc, diag::err_expected_name_of_pack) << Pattern;
9904 : diag::ext_pack_indexing);
9911 bool FullySubstituted,
9914 std::optional<int64_t> Index;
9922 Index =
Value.getExtValue();
9923 IndexExpr = Res.
get();
9926 if (FullySubstituted && Index) {
9927 if (*Index < 0 || *Index >= int64_t(Expansions.size())) {
9929 << *Index << Pattern << Expansions.size();
9935 Expansions, Index.value_or(-1));
9942 assert(ED &&
"EnumType has no EnumDecl");
9947 assert(!Underlying.
isNull());
9955 Diag(Loc, diag::err_only_enums_have_underlying_types);
9963 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
9964 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
10000 Split.Quals.removeCVRQualifiers();
10010 UKind == UnaryTransformType::AddLvalueReference,
10013 return Reference.isNull() ?
QualType() : Reference;
10018 if (UKind == UnaryTransformType::RemoveAllExtents)
10022 return AT->getElementType();
10031 if (UKind == UTTKind::RemoveCVRef &&
10032 (
T.isConstQualified() ||
T.isVolatileQualified())) {
10044 if ((BaseType->
isReferenceType() && UKind != UTTKind::RemoveRestrict) ||
10051 if (UKind == UTTKind::RemoveConst || UKind == UTTKind::RemoveCV)
10053 if (UKind == UTTKind::RemoveVolatile || UKind == UTTKind::RemoveCV)
10055 if (UKind == UTTKind::RemoveRestrict)
10066 if (
auto *
BitInt = dyn_cast<BitIntType>(Underlying)) {
10067 unsigned int Bits =
BitInt->getNumBits();
10071 S.
Diag(Loc, diag::err_make_signed_integral_only)
10072 << IsMakeSigned <<
true << BaseType << 1 << Underlying;
10076 S.
Diag(Loc, diag::err_make_signed_integral_only)
10077 << IsMakeSigned <<
false << BaseType << 1
10084 std::array<CanQualType *, 6> AllSignedIntegers = {
10088 AllSignedIntegers.data(), AllSignedIntegers.size() - Int128Unsupported);
10089 std::array<CanQualType *, 6> AllUnsignedIntegers = {
10094 AllUnsignedIntegers.size() -
10095 Int128Unsupported);
10097 IsMakeSigned ? &AvailableSignedIntegers : &AvailableUnsignedIntegers;
10101 llvm::find_if(*Consider, [&S, BaseSize](
const CanQual<Type> *
T) {
10105 assert(
Result != Consider->end());
10106 return QualType((*Result)->getTypePtr(), 0);
10111 bool IsMakeSigned = UKind == UnaryTransformType::MakeSigned;
10116 Diag(Loc, diag::err_make_signed_integral_only)
10117 << IsMakeSigned << BaseType->
isBitIntType() << BaseType << 0;
10121 bool IsNonIntIntegral =
10130 if (Underlying.
isNull())
10141 case UnaryTransformType::EnumUnderlyingType: {
10145 case UnaryTransformType::AddPointer: {
10149 case UnaryTransformType::RemovePointer: {
10153 case UnaryTransformType::Decay: {
10157 case UnaryTransformType::AddLvalueReference:
10158 case UnaryTransformType::AddRvalueReference: {
10162 case UnaryTransformType::RemoveAllExtents:
10163 case UnaryTransformType::RemoveExtent: {
10167 case UnaryTransformType::RemoveCVRef:
10168 case UnaryTransformType::RemoveReference: {
10172 case UnaryTransformType::RemoveConst:
10173 case UnaryTransformType::RemoveCV:
10174 case UnaryTransformType::RemoveRestrict:
10175 case UnaryTransformType::RemoveVolatile: {
10179 case UnaryTransformType::MakeSigned:
10180 case UnaryTransformType::MakeUnsigned: {
10198 int DisallowedKind = -1;
10200 DisallowedKind = 1;
10202 DisallowedKind = 2;
10204 DisallowedKind = 3;
10206 DisallowedKind = 4;
10207 else if (
T.hasQualifiers())
10208 DisallowedKind = 5;
10210 DisallowedKind = 6;
10213 DisallowedKind = 7;
10215 DisallowedKind = 8;
10218 DisallowedKind = 9;
10220 if (DisallowedKind != -1) {
10221 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind <<
T;
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
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.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
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.
static bool isBlockPointer(Expr *Arg)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
This file declares semantic analysis for OpenMP constructs and clauses.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S, VectorKind VecKind)
HandleNeonVectorTypeAttr - The "neon_vector_type" and "neon_polyvector_type" attributes are used to c...
static QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType)
static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S)
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType type)
Given that an objc_gc attribute was written somewhere on a declaration other than on the declarator i...
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type.
#define MS_TYPE_ATTRS_CASELIST
#define CALLING_CONV_ATTRS_CASELIST
static void emitNullabilityConsistencyWarning(Sema &S, SimplePointerKind PointerKind, SourceLocation PointerLoc, SourceLocation PointerEndLoc)
static void fixItNullability(Sema &S, DiagBuilderT &Diag, SourceLocation PointerLoc, NullabilityKind Nullability)
Creates a fix-it to insert a C-style nullability keyword at pointerLoc, taking into account whitespac...
static ExprResult checkArraySize(Sema &S, Expr *&ArraySize, llvm::APSInt &SizeVal, unsigned VLADiag, bool VLAIsError)
Check whether the specified array bound can be evaluated using the relevant language rules.
static Attr * createNullabilityAttr(ASTContext &Ctx, ParsedAttr &Attr, NullabilityKind NK)
static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
HandleVectorSizeAttribute - this attribute is only applicable to integral and float scalars,...
static void inferARCWriteback(TypeProcessingState &state, QualType &declSpecType)
Given that this is the declaration of a parameter under ARC, attempt to infer attributes and such for...
static TypeSourceInfo * GetTypeSourceInfoForDeclarator(TypeProcessingState &State, QualType T, TypeSourceInfo *ReturnTypeInfo)
Create and instantiate a TypeSourceInfo with type source information.
static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx, const Expr *AddrSpace, SourceLocation AttrLoc)
Build an AddressSpace index from a constant expression and diagnose any errors related to invalid add...
static void HandleBTFTypeTagAttribute(QualType &Type, const ParsedAttr &Attr, TypeProcessingState &State)
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type.
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk)
static void HandleExtVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
static void HandleLifetimeBoundAttr(TypeProcessingState &State, QualType &CurType, ParsedAttr &Attr)
static bool handleArmStateAttribute(Sema &S, FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, FunctionType::ArmStateValue State)
static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType, CUDAFunctionTarget CFT)
A function type attribute was written in the decl spec.
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
static QualType inferARCLifetimeForPointee(Sema &S, QualType type, SourceLocation loc, bool isReference)
Given that we're building a pointer or reference to the given.
static 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 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 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 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 bool isDependentOrGNUAutoType(QualType T)
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 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 QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type, ArrayRef< TypeSourceInfo * > typeArgs, SourceRange typeArgsRange, bool failOnError, bool rebuilding)
Apply Objective-C type arguments to the given type.
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 void HandleHLSLParamModifierAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S)
static void checkExtParameterInfos(Sema &S, ArrayRef< QualType > paramTypes, const FunctionProtoType::ExtProtoInfo &EPI, llvm::function_ref< SourceLocation(unsigned)> getParamLoc)
Check the extended parameter information.
static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type, CUDAFunctionTarget CFT)
Process an individual function attribute.
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
static void BuildTypeCoupledDecls(Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
static void assignInheritanceModel(Sema &S, CXXRecordDecl *RD)
Locks in the inheritance model for the given class and all of its bases.
static bool checkObjCKindOfType(TypeProcessingState &state, QualType &type, ParsedAttr &attr)
Check the application of the Objective-C '__kindof' qualifier to the given type.
static bool hasNullabilityAttr(const ParsedAttributesView &attrs)
Check whether there is a nullability attribute of any kind in the given attribute list.
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type.
static void moveAttrFromListToList(ParsedAttr &attr, ParsedAttributesView &fromList, ParsedAttributesView &toList)
static void HandleAnnotateTypeAttr(TypeProcessingState &State, QualType &CurType, const ParsedAttr &PA)
static void fillAttributedTypeLoc(AttributedTypeLoc TL, TypeProcessingState &State)
static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, const ParsedAttributesView &Attrs)
TypeAttrLocation
The location of a type attribute.
@ TAL_DeclChunk
The attribute is part of a DeclaratorChunk.
@ TAL_DeclSpec
The attribute is in the decl-specifier-seq.
@ TAL_DeclName
The attribute is immediately after the declaration's name.
static bool isOmittedBlockReturnType(const Declarator &D)
isOmittedBlockReturnType - Return true if this declarator is missing a return type because this is a ...
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
static QualType GetEnumUnderlyingType(Sema &S, QualType BaseType, SourceLocation Loc)
static bool IsNoDerefableChunk(const DeclaratorChunk &Chunk)
static AttrT * createSimpleAttr(ASTContext &Ctx, ParsedAttr &AL)
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, const ParsedAttributesView &attrs, CUDAFunctionTarget CFT=CUDAFunctionTarget::HostDevice)
static bool checkMutualExclusion(TypeProcessingState &state, const FunctionProtoType::ExtProtoInfo &EPI, ParsedAttr &Attr, AttributeCommonInfo::Kind OtherKind)
static Attr * getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr)
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
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 HandleTagDeclRequiredDefinition(const TagDecl *D)
This callback is invoked the first time each TagDecl is required to be complete.
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
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
unsigned getIntWidth(QualType T) const
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped)
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
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 getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCorrespondingSaturatedType(QualType Ty) const
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
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.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
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
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
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.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, int Index=-1) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
QualType getCorrespondingUnsignedType(QualType T) 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 ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
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.
The result of parsing/analyzing an expression, statement etc.
Wrapper for source info for array parameter types.
Wrapper for source info for arrays.
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, IdentifierInfo *scopeName, SourceLocation scopeLoc, 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)
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool hasExplicitTemplateArgs() const
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
SourceLocation getRAngleLoc() const
ConceptDecl * 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)
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
bool isDecltypeAuto() const
ConceptDecl * getTypeConstraintConcept() const
Type source information for an btf_tag attributed type.
TypeLoc getWrappedLoc() const
Comparison function object.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
Wrapper for source info for block pointers.
void setCaretLoc(SourceLocation Loc)
Wrapper for source info for builtin types.
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.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
CXXRecordDecl * getMostRecentNonInjectedDecl()
base_class_range vbases()
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]).
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Represents a canonical, potentially-qualified type.
SourceLocation getBegin() const
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *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...
static constexpr bool isDimensionValid(size_t NumElements)
Returns true if NumElements is a valid matrix dimension.
Wrapper for source info for pointers decayed from arrays and functions.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isFunctionOrMethod() const
A reference to a declared variable, function, enum, etc.
Captures information about "declaration specifiers".
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
bool isTypeSpecPipe() const
static const TST TST_typeof_unqualType
SourceLocation getTypeSpecSignLoc() const
bool hasAutoTypeSpec() const
static const TST TST_typename
SourceLocation getEndLoc() const LLVM_READONLY
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
static const TST TST_char8
static const TST TST_BFloat16
Expr * getPackIndexingExpr() const
TST getTypeSpecType() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isTypeSpecSat() const
SourceRange getSourceRange() const LLVM_READONLY
static const TST TST_auto_type
static const TST TST_interface
static const TST TST_double
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
TemplateIdAnnotation * getRepAsTemplateId() const
static const TST TST_union
static const TST TST_typename_pack_indexing
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
static const TST TST_unknown_anytype
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_accum
static const TST TST_half
ParsedAttributes & getAttributes()
SourceLocation getEllipsisLoc() const
bool isTypeAltiVecPixel() const
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
static const TST TST_ibm128
Expr * getRepAsExpr() const
static const TST TST_enum
AttributePool & getAttributePool() const
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 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
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
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.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
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.
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)
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
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 setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void copy(DependentTemplateSpecializationTypeLoc Loc)
void setNameLoc(SourceLocation Loc)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
void copy(ElaboratedTypeLoc Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
A SourceLocation and its associated SourceManager.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
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.
Wrapper for source info for functions.
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)
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
CallingConv getCallConv() const
QualType getReturnType() const
bool getHasRegParm() const
AArch64SMETypeAttributes
The AArch64 SME ACLE (Arm C/C++ Language Extensions) define a number of function type attributes that...
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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 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)
Valid elements types are the following:
Wrapper for source info for member pointers.
void setStarLoc(SourceLocation Loc)
void setClassTInfo(TypeSourceInfo *TI)
const Type * getClass() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
const Type * getClass() const
Provides information a specialization of a member of a class template, which may be a member function...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
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.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Wrapper for source info for ObjC interfaces.
void setNameLoc(SourceLocation Loc)
void setNameEndLoc(SourceLocation Loc)
Interfaces are the core concept in Objective-C for object oriented design.
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.
void setHasBaseTypeAsWritten(bool HasBaseType)
Represents a class type in Objective C.
Represents an Objective-C protocol declaration.
Represents the declaration of an Objective-C type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
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
Represents a pack expansion of types.
void setEllipsisLoc(SourceLocation Loc)
A parameter attribute which changes the argument-passing ABI rule for the parameter.
void setRParenLoc(SourceLocation Loc)
void setLParenLoc(SourceLocation Loc)
Represents a parameter to a function.
void setKNRPromoted(bool promoted)
ParsedAttr - Represents a syntactic attribute.
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 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)
Wrapper for source info for pointers.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
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.
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.
bool isReferenceable() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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.
Wrapper of type source information for a type with non-trivial direct qualifiers.
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)
@ MaxAddressSpace
The maximum supported address space number.
static Qualifiers fromCVRMask(unsigned CVR)
void setUnaligned(bool flag)
std::string getAsString() const
void addObjCLifetime(ObjCLifetime type)
void setAmpAmpLoc(SourceLocation Loc)
Represents a struct/union/class.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
bool isSpelledAsLValue() const
Scope - A scope is a transient data structure that is used while parsing the program.
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 Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool isInOpenMPTaskUntiedContext() const
Return true if currently in OpenMP task with untied clause context.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
QualType BuildParenType(QualType T)
Build a paren type including T.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Scope * getCurScope() const
Retrieve the parser's current scope.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError, bool Rebuilding)
Build an Objective-C object pointer type.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
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 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
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
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
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.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
void completeExprArrayBound(Expr *E)
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
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.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
ExprResult DefaultLvalueConversion(Expr *E)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
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 isCFError(RecordDecl *D)
bool hasVisibleMergedDefinition(const NamedDecl *Def)
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType BuildAtomicType(QualType T, SourceLocation Loc)
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
TypeResult ActOnTypeName(Declarator &D)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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 AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
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...
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.
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
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 BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
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)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
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.
bool isBeingDefined() const
Return true if this decl is currently being defined.
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.
TagKind getTagKind() const
Wrapper for source info for tag types.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual size_t getMaxBitIntWidth() const
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.
bool isVLASupported() const
Whether target supports variable-length arrays.
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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.
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts) const
Returns target-specific min and max values VScale_Range.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SourceLocation getRAngleLoc() const
void copy(TemplateSpecializationTypeLoc Loc)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, std::optional< unsigned > 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 findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
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.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
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)
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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 isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isUndeducedAutoType() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
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
bool isEnumeralType() const
bool isObjCNSObjectType() const
bool isVariableArrayType() const
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.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this 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
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
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 isFunctionProtoType() const
bool isObjCIdType() const
bool isChar32Type() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCObjectType() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isWideCharType() const
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
std::optional< NullabilityKind > 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.
QualType getUnderlyingType() const
Wrapper for source info for typedefs.
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 ...
void setType(QualType newType)
Represents a variable declaration or 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< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ ExpectedFunctionWithProtoType
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
decltype(auto)
llvm::StringRef getParameterABISpelling(ParameterABI kind)
LLVM_READONLY bool isAsciiIdentifierContinue(unsigned char c)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ 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.
@ AANT_ArgumentIntegerConstant
@ Result
The result type of a method or function.
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.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
ActionResult< Expr * > ExprResult
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',...
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ FirstTargetAddressSpace
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ 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
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ 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.
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 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.
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.
enum clang::DeclaratorChunk::@221 Kind
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.
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.
Holds information about the various types of exception specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
void setArmSMEAttribute(AArch64SMETypeAttributes Kind, bool Enable=true)
FunctionType::ExtInfo ExtInfo
Wraps an identifier and optional source location for the identifier.
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...
Describes how types, statements, expressions, and declarations should be printed.
@ Memoization
Added for Template instantiation observation.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
SplitQualType getSingleStepDesugaredType() const
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
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.