35 #include "llvm/ADT/SmallPtrSet.h"
36 #include "llvm/ADT/SmallString.h"
37 #include "llvm/Support/ErrorHandling.h"
39 using namespace clang;
69 bool useExpansionLoc =
true;
71 case AttributeList::AT_ObjCGC: WhichType =
TDS_Pointer;
break;
76 useExpansionLoc =
false;
86 if (useExpansionLoc && loc.
isMacroID() && II) {
87 if (II->
isStr(
"strong")) {
89 }
else if (II->
isStr(
"weak")) {
94 S.
Diag(loc, diag::warn_type_attribute_wrong_type) << name << WhichType
100 #define OBJC_POINTER_TYPE_ATTRS_CASELIST \
101 case AttributeList::AT_ObjCGC: \
102 case AttributeList::AT_ObjCOwnership
105 #define FUNCTION_TYPE_ATTRS_CASELIST \
106 case AttributeList::AT_NoReturn: \
107 case AttributeList::AT_CDecl: \
108 case AttributeList::AT_FastCall: \
109 case AttributeList::AT_StdCall: \
110 case AttributeList::AT_ThisCall: \
111 case AttributeList::AT_Pascal: \
112 case AttributeList::AT_VectorCall: \
113 case AttributeList::AT_MSABI: \
114 case AttributeList::AT_SysVABI: \
115 case AttributeList::AT_Regparm: \
116 case AttributeList::AT_Pcs: \
117 case AttributeList::AT_IntelOclBicc
120 #define MS_TYPE_ATTRS_CASELIST \
121 case AttributeList::AT_Ptr32: \
122 case AttributeList::AT_Ptr64: \
123 case AttributeList::AT_SPtr: \
124 case AttributeList::AT_UPtr
127 #define NULLABILITY_TYPE_ATTRS_CASELIST \
128 case AttributeList::AT_TypeNonNull: \
129 case AttributeList::AT_TypeNullable: \
130 case AttributeList::AT_TypeNullUnspecified
135 class TypeProcessingState {
161 : sema(sema), declarator(declarator),
163 trivial(
true), hasSavedAttrs(
false) {}
165 Sema &getSema()
const {
173 bool isProcessingDeclSpec()
const {
177 unsigned getCurrentChunkIndex()
const {
181 void setCurrentChunkIndex(
unsigned idx) {
187 if (isProcessingDeclSpec())
188 return getMutableDeclSpec().getAttributes().getListRef();
193 void saveDeclSpecAttrs() {
195 if (hasSavedAttrs)
return;
197 DeclSpec &spec = getMutableDeclSpec();
200 savedAttrs.push_back(attr);
201 trivial &= savedAttrs.empty();
202 hasSavedAttrs =
true;
208 ignoredTypeAttrs.push_back(&attr);
215 i = ignoredTypeAttrs.begin(), e = ignoredTypeAttrs.end();
220 ~TypeProcessingState() {
223 restoreDeclSpecAttrs();
227 DeclSpec &getMutableDeclSpec()
const {
231 void restoreDeclSpecAttrs() {
232 assert(hasSavedAttrs);
234 if (savedAttrs.empty()) {
235 getMutableDeclSpec().getAttributes().set(
nullptr);
239 getMutableDeclSpec().getAttributes().set(savedAttrs[0]);
240 for (
unsigned i = 0, e = savedAttrs.size() - 1; i != e; ++i)
241 savedAttrs[i]->setNext(savedAttrs[i+1]);
242 savedAttrs.back()->setNext(
nullptr);
260 assert(cur && cur->
getNext() &&
"ran out of attrs?");
306 if (attr.
getKind() == AttributeList::AT_ObjCGC)
308 assert(attr.
getKind() == AttributeList::AT_ObjCOwnership);
323 bool onlyBlockPointers) {
329 for (; i != 0; --i) {
331 switch (fnChunk.
Kind) {
346 for (--i; i != 0; --i) {
348 switch (ptrChunk.
Kind) {
357 if (onlyBlockPointers)
366 llvm_unreachable(
"bad declarator chunk kind");
372 llvm_unreachable(
"bad declarator chunk kind");
390 Declarator &declarator = state.getDeclarator();
393 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
395 switch (chunk.
Kind) {
401 if (state.isProcessingDeclSpec() &&
402 attr.
getKind() == AttributeList::AT_ObjCOwnership)
405 if (!destChunk) destChunk = &chunk;
418 if (state.isProcessingDeclSpec() &&
419 attr.
getKind() == AttributeList::AT_ObjCOwnership) {
424 dest->getAttrListRef());
447 Declarator &declarator = state.getDeclarator();
451 unsigned innermost = -1U;
452 bool considerDeclSpec =
true;
455 switch (chunk.
Kind) {
468 considerDeclSpec =
false;
476 if (considerDeclSpec) {
481 state.saveDeclSpecAttrs();
490 if (innermost != -1U) {
498 state.addIgnoredTypeAttr(attr);
508 Declarator &declarator = state.getDeclarator();
512 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
514 switch (chunk.
Kind) {
541 Declarator &declarator = state.getDeclarator();
561 state.saveDeclSpecAttrs();
568 state.getDeclarator().getAttrListRef());
574 state.getCurrentAttrListRef(),
580 state.addIgnoredTypeAttr(attr);
589 Declarator &declarator = state.getDeclarator();
600 state.addIgnoredTypeAttr(attr);
615 assert(state.getDeclarator().getAttributes() &&
"declarator has no attrs!");
623 if (attr->isCXX11Attribute())
626 switch (attr->getKind()) {
631 case AttributeList::AT_NSReturnsRetained:
632 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
648 case AttributeList::AT_ObjCKindOf:
654 }
while ((attr = next));
661 Declarator &declarator = state.getDeclarator();
711 loc, loc, declarator));
726 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
730 if (!(RemoveTQs & Qual.first))
734 if (TypeQuals & Qual.first)
735 S.
Diag(Qual.second, DiagID)
740 TypeQuals &= ~Qual.first;
748 bool failOnError =
false) {
751 if (!objcObjectType || !objcObjectType->getInterface()) {
752 S.
Diag(loc, diag::err_objc_type_args_non_class)
765 S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
776 if (objcObjectType->isSpecialized()) {
777 S.
Diag(loc, diag::err_objc_type_args_specialized_class)
789 unsigned numTypeParams = typeParams->
size();
790 bool anyPackExpansions =
false;
791 for (
unsigned i = 0, n = typeArgs.size(); i != n; ++i) {
802 diag::err_type_arg_explicit_nullability)
807 finalTypeArgs.push_back(typeArg);
810 anyPackExpansions =
true;
814 if (!anyPackExpansions) {
815 if (i < numTypeParams) {
816 typeParam = typeParams->
begin()[i];
819 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
840 assert(anyPackExpansions &&
"Too many arguments?");
849 if (typeArgObjC->isObjCIdType()) {
852 if (boundObjC->isObjCIdType())
861 diag::err_objc_type_arg_does_not_match_bound)
878 assert(anyPackExpansions &&
"Too many arguments?");
889 diag::err_objc_type_arg_does_not_match_bound)
907 diag::err_objc_type_arg_not_id_compatible)
918 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
919 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
920 << (typeArgs.size() < typeParams->
size())
942 bool failOnError =
false) {
949 objT->getTypeArgsAsWritten(),
951 objT->isKindOfTypeAsWritten());
967 objPtr->isKindOfType());
972 if (
type->isObjCClassType()) {
974 type = ctx.getObjCObjectType(ctx.ObjCBuiltinClassTy, { }, protocols,
976 return ctx.getObjCObjectPointerType(type);
979 S.
Diag(loc, diag::err_invalid_protocol_qualifiers)
999 if (!TypeArgs.empty()) {
1004 if (FailOnError && Result.
isNull())
1008 if (!Protocols.empty()) {
1013 ProtocolLocs.data(),
1015 if (FailOnError && Result.
isNull())
1042 auto ObjCObjectTL = ObjCObjectPointerTL.getPointeeLoc()
1052 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
1053 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
1054 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
1055 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
1058 return CreateParsedType(Result, ResultTInfo);
1083 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
1087 ActualTypeArgInfos.clear();
1091 assert(TypeArgInfo &&
"No type source info?");
1092 ActualTypeArgInfos.push_back(TypeArgInfo);
1098 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
1102 ProtocolLocs, ProtocolRAngleLoc,
1117 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
1123 if (ObjCObjectTL.getNumTypeArgs() > 0) {
1124 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
1126 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
1127 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
1128 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
1135 if (ObjCObjectTL.getNumProtocols() > 0) {
1136 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
1137 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1138 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1139 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1140 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
1147 ObjCObjectTL.setHasBaseTypeAsWritten(
true);
1148 if (ObjCObjectTL.getType() == T)
1149 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
1151 ObjCObjectTL.getBaseLoc().initialize(
Context, Loc);
1167 Sema &S = state.getSema();
1168 Declarator &declarator = state.getDeclarator();
1188 "Unknown TSS value");
1202 "Unknown TSS value");
1211 "Unknown TSS value");
1216 "Unknown TSS value");
1246 S.
Diag(DeclLoc, diag::ext_missing_declspec)
1256 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1264 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1284 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1303 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1332 << Result <<
"cl_khr_fp64";
1341 Result = Context.
IntTy;
1352 Result = Context.
IntTy;
1375 "Can't handle qualifiers on typedef names yet!");
1377 if (Result.isNull()) {
1382 bool NoExtTypes = BT && (BT->
getKind() == BuiltinType::Int ||
1383 BT->
getKind() == BuiltinType::UInt ||
1384 BT->
getKind() == BuiltinType::Float);
1387 << Result <<
"cl_khr_int64_base_atomics";
1393 << Result <<
"cl_khr_int64_extended_atomics";
1397 BT->
getKind() == BuiltinType::Double) {
1399 << Result <<
"cl_khr_fp64";
1411 assert(!Result.isNull() &&
"Didn't get a type for typeof?");
1412 if (!Result->isDependentType())
1420 assert(E &&
"Didn't get an expression for typeof?");
1423 if (Result.isNull()) {
1424 Result = Context.
IntTy;
1431 assert(E &&
"Didn't get an expression for decltype?");
1434 if (Result.isNull()) {
1435 Result = Context.
IntTy;
1442 assert(!Result.isNull() &&
"Didn't get a type for __underlying_type?");
1446 if (Result.isNull()) {
1447 Result = Context.
IntTy;
1460 assert(LSI &&
"No LambdaScopeInfo on the stack!");
1463 const bool IsParameterPack = declarator.
hasEllipsis();
1477 TemplateParameterDepth,
1478 AutoParameterPosition,
1479 nullptr,
false, IsParameterPack);
1501 assert(!Result.isNull() &&
"Didn't get a type for _Atomic?");
1503 if (Result.isNull()) {
1504 Result = Context.
IntTy;
1510 Result = Context.
IntTy;
1522 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1556 if (TypeQuals &&
Result->isFunctionType()) {
1560 ? diag::warn_typecheck_function_qualifiers_ignored
1561 : diag::warn_typecheck_function_qualifiers_unspecified);
1574 if (TypeQuals &&
Result->isReferenceType()) {
1576 S, DS, TypeQuals, Result,
1578 diag::warn_typecheck_reference_qualifiers);
1585 && TypeQuals &
Result.getCVRQualifiers()) {
1604 declarator.setInvalidType(
true);
1609 assert(!
Result.isNull() &&
"This function should not return a null type");
1628 unsigned DiagID = 0;
1644 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1648 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1662 unsigned CVRA,
const DeclSpec *DS) {
1667 unsigned CVR = CVRA & ~
DeclSpec::TQ_atomic;
1741 diag::err_arc_indirect_no_ownership, type, isReference));
1743 S.
Diag(loc, diag::err_arc_indirect_no_ownership) << type << isReference;
1747 assert(implicitLifetime &&
"didn't infer any lifetime!");
1801 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1824 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1859 "Unresolved overloaded function type");
1887 Diag(Loc, diag::err_reference_to_void);
1917 S.
Diag(Loc, diag::ext_vla_folded_to_constant) << SR;
1942 Expr *ArraySize,
unsigned Quals,
1959 Diag(Loc, diag::err_illegal_decl_array_of_references)
1965 Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
1970 diag::err_array_of_abstract_type))
1977 if (!MPTy->getClass()->isDependentType())
1984 diag::err_illegal_decl_array_incomplete_type))
1989 Diag(Loc, diag::err_illegal_decl_array_of_functions)
1997 if (EltTy->getDecl()->hasFlexibleArrayMember())
1998 Diag(Loc, diag::ext_flexible_array_in_array) << T;
2000 Diag(Loc, diag::err_objc_array_of_interfaces) << T;
2008 ArraySize = Result.
get();
2012 if (ArraySize && !ArraySize->
isRValue()) {
2017 ArraySize = Result.
get();
2025 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2026 << ArraySize->
getType() << ArraySize->getSourceRange();
2045 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2046 << ArraySize->
getType() << ArraySize->getSourceRange();
2057 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2059 Diag(ArraySize->getLocStart(), diag::err_decl_negative_array_size)
2062 Diag(ArraySize->getLocStart(), diag::err_typecheck_negative_array_size)
2063 << ArraySize->getSourceRange();
2066 if (ConstVal == 0) {
2069 Diag(ArraySize->getLocStart(),
2071 : diag::ext_typecheck_zero_array_size)
2072 << ArraySize->getSourceRange();
2075 Diag(ArraySize->getLocStart(),
2076 diag::warn_typecheck_zero_static_array_size)
2077 << ArraySize->getSourceRange();
2083 unsigned ActiveSizeBits
2086 Diag(ArraySize->getLocStart(), diag::err_array_too_large)
2087 << ConstVal.toString(10)
2088 << ArraySize->getSourceRange();
2098 Diag(Loc, diag::err_opencl_vla);
2110 Diag(Loc, diag::err_vla_non_pod)
2116 Diag(Loc, diag::err_vla_in_sfinae);
2121 Diag(Loc, diag::ext_vla);
2125 : diag::ext_c99_array_usage) << ASM;
2130 Diag(Loc, diag::warn_vla_used);
2145 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
2150 llvm::APSInt vecSize(32);
2152 Diag(AttrLoc, diag::err_attribute_argument_type)
2154 << ArraySize->getSourceRange();
2160 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue());
2162 if (vectorSize == 0) {
2163 Diag(AttrLoc, diag::err_attribute_zero_size)
2164 << ArraySize->getSourceRange();
2169 Diag(AttrLoc, diag::err_attribute_size_too_large)
2170 << ArraySize->getSourceRange();
2182 Diag(Loc, diag::err_func_returning_array_function)
2189 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2197 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
2208 bool Invalid =
false;
2212 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2216 Diag(Loc, diag::err_param_with_void_type);
2220 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2225 ParamTypes[Idx] = ParamType;
2249 Diag(Loc, diag::err_distant_exception_spec);
2256 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2262 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2268 Diag(Loc, diag::err_mempointer_in_nonclass_type) << Class;
2295 Diag(Loc, diag::err_nonfunction_block_type);
2308 if (TInfo) *TInfo =
nullptr;
2313 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2314 QT = LIT->getType();
2315 DI = LIT->getTypeSourceInfo();
2318 if (TInfo) *TInfo = DI;
2324 unsigned chunkIndex);
2331 Sema &S = state.getSema();
2332 Declarator &declarator = state.getDeclarator();
2338 unsigned outermostPointerIndex = 0;
2339 bool isBlockPointer =
false;
2340 unsigned numPointers = 0;
2342 unsigned chunkIndex = i;
2344 switch (chunk.
Kind) {
2354 outermostPointerIndex = chunkIndex;
2362 if (numPointers != 1)
return;
2364 outermostPointerIndex = chunkIndex;
2365 isBlockPointer =
true;
2381 if (numPointers == 1) {
2399 }
else if (numPointers == 2) {
2413 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
2417 outermostPointerIndex);
2438 }
const QualKinds[4] = {
2446 unsigned NumQuals = 0;
2451 for (
unsigned I = 0; I != 4; ++I) {
2452 if (Quals & QualKinds[I].Mask) {
2453 if (!QualStr.empty()) QualStr +=
' ';
2454 QualStr += QualKinds[I].Name;
2470 << QualStr << NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
2476 unsigned FunctionChunkIndex) {
2486 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
2488 OuterChunkIndex !=
End; ++OuterChunkIndex) {
2490 switch (OuterChunk.
Kind) {
2497 diag::warn_qual_return_type,
2521 llvm_unreachable(
"unknown declarator chunk kind");
2543 Sema &SemaRef = state.getSema();
2546 ReturnTypeInfo =
nullptr;
2549 TagDecl *OwnedTagDecl =
nullptr;
2551 bool ContainsPlaceholderType =
false;
2596 if (ContainsPlaceholderType &&
2602 llvm_unreachable(
"K&R type lists aren't allowed in C++");
2604 llvm_unreachable(
"Can't specify a type specifier in lambda grammar");
2618 switch (cast<TagDecl>(SemaRef.
CurContext)->getTagKind()) {
2619 case TTK_Enum: llvm_unreachable(
"unhandled tag kind");
2673 if (SemaRef.
getLangOpts().CPlusPlus11 && Error != -1) {
2675 unsigned chunkIndex = e - i - 1;
2676 state.setCurrentChunkIndex(chunkIndex);
2693 const bool IsDeclTypeAuto =
2695 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
2696 << IsDeclTypeAuto << Error << AutoRange;
2701 diag::warn_cxx98_compat_auto_type_specifier)
2713 llvm_unreachable(
"parser should not have allowed this");
2729 diag::err_type_defined_in_alias_template)
2741 diag::err_type_defined_in_type_specifier)
2753 diag::err_type_defined_in_param_type)
2762 diag::err_type_defined_in_condition);
2768 assert(!T.
isNull() &&
"This function should not return a null type");
2777 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
2808 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
2809 : diag::warn_empty_parens_are_function_decl)
2820 if (
Comma.getFileID() != Name.getFileID() ||
2821 Comma.getSpellingLineNumber() != Name.getSpellingLineNumber()) {
2840 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
2855 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
2860 if (Init.empty() && S.
LangOpts.CPlusPlus11)
2863 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
2876 unsigned ChunkIndex) {
2879 bool IsCXXInstanceMethod =
false;
2885 unsigned I = ChunkIndex;
2886 bool FoundNonParen =
false;
2887 while (I && !FoundNonParen) {
2890 FoundNonParen =
true;
2893 if (FoundNonParen) {
2896 IsCXXInstanceMethod =
2901 IsCXXInstanceMethod =
true;
2908 IsCXXInstanceMethod =
2916 IsCXXInstanceMethod);
2925 if (
Attr->
getKind() == AttributeList::AT_OpenCLKernel) {
2946 switch (nullability) {
2948 if (!Ident__Nonnull)
2950 return Ident__Nonnull;
2953 if (!Ident__Nullable)
2955 return Ident__Nullable;
2958 if (!Ident__Null_unspecified)
2960 return Ident__Null_unspecified;
2962 llvm_unreachable(
"Unknown nullability kind.");
2970 return Ident_NSError;
2978 if (attr->getKind() == AttributeList::AT_TypeNonNull ||
2979 attr->getKind() == AttributeList::AT_TypeNullable ||
2980 attr->getKind() == AttributeList::AT_TypeNullUnspecified)
2997 MaybePointerToCFRef,
3001 NSErrorPointerPointer,
3012 unsigned numNormalPointers = 0;
3016 return PointerDeclaratorKind::NonPointer;
3021 switch (chunk.
Kind) {
3028 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3029 : PointerDeclaratorKind::SingleLevelPointer;
3036 ++numNormalPointers;
3037 if (numNormalPointers > 2)
3038 return PointerDeclaratorKind::MultiLevelPointer;
3044 unsigned numTypeSpecifierPointers = 0;
3048 ++numNormalPointers;
3050 if (numNormalPointers > 2)
3051 return PointerDeclaratorKind::MultiLevelPointer;
3054 ++numTypeSpecifierPointers;
3060 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3061 : PointerDeclaratorKind::SingleLevelPointer;
3066 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3067 : PointerDeclaratorKind::SingleLevelPointer;
3072 ++numNormalPointers;
3073 ++numTypeSpecifierPointers;
3076 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
3078 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3079 return PointerDeclaratorKind::NSErrorPointerPointer;
3088 if (objcClass->getInterface()->getIdentifier() == S.
getNSErrorIdent()) {
3089 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
3090 return PointerDeclaratorKind::NSErrorPointerPointer;;
3097 if (numNormalPointers == 0)
3098 return PointerDeclaratorKind::NonPointer;
3103 bool isCFError =
false;
3111 if (
auto bridgeAttr = recordDecl->
getAttr<ObjCBridgeAttr>()) {
3121 if (isCFError && numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3122 return PointerDeclaratorKind::CFErrorRefPointer;
3131 switch (numNormalPointers) {
3133 return PointerDeclaratorKind::NonPointer;
3136 return PointerDeclaratorKind::SingleLevelPointer;
3139 return PointerDeclaratorKind::MaybePointerToCFRef;
3142 return PointerDeclaratorKind::MultiLevelPointer;
3151 if (ctx->isFunctionOrMethod())
3154 if (ctx->isFileContext())
3165 bool invalid =
false;
3167 if (invalid || !sloc.
isFile())
3187 Sema &S = state.getSema();
3203 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
3210 S.
Diag(pointerLoc, diag::warn_nullability_missing)
3211 <<
static_cast<unsigned>(pointerKind);
3221 Sema &S = state.getSema();
3231 bool IsTypedefName =
3244 if (AT->isDecltypeAuto()) {
3246 unsigned Index = E - I - 1;
3248 unsigned DiagId = diag::err_decltype_auto_compound_type;
3249 unsigned DiagKind = 0;
3250 switch (DeclChunk.
Kind) {
3258 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
3274 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
3283 bool inferNullabilityCS =
false;
3284 bool inferNullabilityInnerOnly =
false;
3285 bool inferNullabilityInnerOnlyComplete =
false;
3288 bool inAssumeNonNullRegion =
false;
3290 !state.getDeclarator().isObjCWeakProperty() &&
3292 inAssumeNonNullRegion =
true;
3302 S.
Diag(fileNullability.
PointerLoc, diag::warn_nullability_missing)
3303 <<
static_cast<unsigned>(fileNullability.
PointerKind);
3321 } complainAboutMissingNullability = CAMN_No;
3322 unsigned NumPointersRemaining = 0;
3324 if (IsTypedefName) {
3328 complainAboutMissingNullability = CAMN_InnerPointers;
3331 ++NumPointersRemaining;
3336 switch (chunk.
Kind) {
3343 ++NumPointersRemaining;
3351 ++NumPointersRemaining;
3357 switch (
auto context = state.getDeclarator().getContext()) {
3362 isFunctionOrMethod =
true;
3367 complainAboutMissingNullability = CAMN_No;
3374 complainAboutMissingNullability = CAMN_Yes;
3378 case PointerDeclaratorKind::NonPointer:
3379 case PointerDeclaratorKind::MultiLevelPointer:
3383 case PointerDeclaratorKind::SingleLevelPointer:
3385 if (inAssumeNonNullRegion) {
3392 case PointerDeclaratorKind::CFErrorRefPointer:
3393 case PointerDeclaratorKind::NSErrorPointerPointer:
3396 if (isFunctionOrMethod && inAssumeNonNullRegion)
3400 case PointerDeclaratorKind::MaybePointerToCFRef:
3401 if (isFunctionOrMethod) {
3405 auto hasCFReturnsAttr = [](
const AttributeList *NextAttr) ->
bool {
3407 if (NextAttr->getKind() == AttributeList::AT_CFReturnsRetained ||
3408 NextAttr->getKind() == AttributeList::AT_CFReturnsNotRetained)
3410 NextAttr = NextAttr->getNext();
3416 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
3419 inferNullabilityInnerOnly =
true;
3428 complainAboutMissingNullability = CAMN_Yes;
3456 if (NumPointersRemaining > 0)
3457 --NumPointersRemaining;
3464 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
3468 AttributeList *nullabilityAttr = state.getDeclarator().getAttributePool()
3474 nullptr, 0, syntax);
3478 if (inferNullabilityCS) {
3479 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
3483 if (inferNullabilityInnerOnly)
3484 inferNullabilityInnerOnlyComplete =
true;
3485 return nullabilityAttr;
3490 switch (complainAboutMissingNullability) {
3494 case CAMN_InnerPointers:
3495 if (NumPointersRemaining == 0)
3511 pointerKind = SimplePointerKind::BlockPointer;
3513 pointerKind = SimplePointerKind::MemberPointer;
3515 if (
auto *attr = inferPointerNullability(
3520 attr->setUsedAsTypeAttr();
3528 unsigned chunkIndex = e - i - 1;
3529 state.setCurrentChunkIndex(chunkIndex);
3532 switch (DeclType.
Kind) {
3538 if (!LangOpts.Blocks)
3539 S.
Diag(DeclType.
Loc, diag::err_blocks_disable);
3542 inferPointerNullability(SimplePointerKind::BlockPointer,
3559 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
3608 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
3619 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype) <<
3630 unsigned x = chunkIndex;
3642 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost) <<
3662 S.
Diag(DeclType.
Loc, diag::err_illegal_decl_array_of_auto)
3689 ? diag::err_auto_missing_trailing_return
3690 : diag::err_deduced_return_type);
3695 if (isa<ParenType>(T)) {
3697 diag::err_trailing_return_in_parens)
3701 (T.hasQualifiers() || !isa<AutoType>(T) ||
3702 cast<AutoType>(T)->isDecltypeAuto())) {
3704 diag::err_trailing_return_without_auto)
3719 if ((T->isArrayType() || T->isFunctionType()) &&
3721 unsigned diagID = diag::err_func_returning_array_function;
3724 if (chunkIndex == 0 &&
3726 diagID = diag::err_block_returning_array_function;
3727 S.
Diag(DeclType.
Loc, diagID) << T->isFunctionType() << T;
3734 if (T->isHalfType()) {
3742 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
3749 if (T->isObjCObjectType()) {
3758 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
3776 if ((T.getCVRQualifiers() || T->isAtomicType()) &&
3778 (T->isDependentType() || T->isRecordType()))) {
3779 if (T->isVoidType() && !S.
getLangOpts().CPlusPlus &&
3784 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) << T;
3792 if (T.getQualifiers().hasObjCLifetime()) {
3798 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
3799 AttrLoc =
Attr->getLoc();
3808 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
3809 AttrLoc =
Attr->getLoc();
3822 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
3823 << T.getQualifiers().getObjCLifetime();
3857 bool Overloadable =
false;
3859 Attrs; Attrs = Attrs->
getNext()) {
3860 if (Attrs->getKind() == AttributeList::AT_Overloadable) {
3861 Overloadable =
true;
3874 diag::err_ident_list_in_fn_declaration);
3896 ConsumedParameters.reserve(FTI.
NumParams);
3897 bool HasAnyConsumedParameters =
false;
3899 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
3902 assert(!ParamTy.isNull() &&
"Couldn't parse type?");
3907 if (ParamTy->isVoidType()) {
3912 S.
Diag(DeclType.
Loc, diag::err_void_only_param);
3913 ParamTy = Context.
IntTy;
3918 ParamTy = Context.
IntTy;
3922 if (ParamTy.hasQualifiers())
3923 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
3928 }
else if (ParamTy->isHalfType()) {
3934 diag::err_opencl_half_param) << ParamTy;
3940 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
3944 if (ParamTy->isPromotableIntegerType()) {
3948 if (BTy->getKind() == BuiltinType::Float) {
3955 if (LangOpts.ObjCAutoRefCount) {
3956 bool Consumed = Param->
hasAttr<NSConsumedAttr>();
3957 ConsumedParameters.push_back(Consumed);
3958 HasAnyConsumedParameters |= Consumed;
3961 ParamTys.push_back(ParamTy);
3964 if (HasAnyConsumedParameters)
3970 Expr *NoexceptExpr =
nullptr;
3976 DynamicExceptions.reserve(N);
3977 DynamicExceptionRanges.reserve(N);
3978 for (
unsigned I = 0; I != N; ++I) {
3989 DynamicExceptionRanges,
4005 inferPointerNullability(SimplePointerKind::MemberPointer,
4025 llvm_unreachable(
"Nested-name-specifier must name a type");
4035 if (NNSPrefix && isa<TemplateSpecializationType>(NNS->
getAsType()))
4041 diag::err_illegal_decl_mempointer_in_nonclass)
4069 assert(!T.
isNull() &&
"T must not be null after this point");
4073 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
4090 FreeFunction = (DC && !DC->
isRecord());
4109 if (IsQualifiedFunction &&
4129 if (!RemovalLocs.empty()) {
4130 std::sort(RemovalLocs.begin(), RemovalLocs.end(),
4132 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
4133 Loc = RemovalLocs.front();
4137 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
4163 state.diagnoseIgnoredTypeAttrs(T);
4193 diag::err_function_parameter_pack_without_parameter_packs)
4213 LangOpts.CPlusPlus11
4214 ? diag::warn_cxx98_compat_variadic_templates
4215 : diag::ext_variadic_templates);
4240 diag::err_ellipsis_in_declarator_not_parameter);
4246 assert(!T.
isNull() &&
"T must not be null at the end of this function");
4262 TypeProcessingState state(*
this, D);
4286 unsigned chunkIndex) {
4287 Sema &S = state.getSema();
4294 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
4297 const char *attrStr =
nullptr;
4298 switch (ownership) {
4327 Sema &S = state.getSema();
4331 bool hasIndirection =
false;
4334 switch (chunk.
Kind) {
4343 hasIndirection =
true;
4375 TypeProcessingState state(*
this, D);
4393 return AttributeList::AT_AddressSpace;
4395 return AttributeList::AT_Regparm;
4397 return AttributeList::AT_VectorSize;
4399 return AttributeList::AT_NeonVectorType;
4401 return AttributeList::AT_NeonPolyVectorType;
4403 return AttributeList::AT_ObjCGC;
4405 return AttributeList::AT_ObjCOwnership;
4407 return AttributeList::AT_NoReturn;
4409 return AttributeList::AT_CDecl;
4411 return AttributeList::AT_FastCall;
4413 return AttributeList::AT_StdCall;
4415 return AttributeList::AT_ThisCall;
4417 return AttributeList::AT_Pascal;
4419 return AttributeList::AT_VectorCall;
4422 return AttributeList::AT_Pcs;
4424 return AttributeList::AT_IntelOclBicc;
4426 return AttributeList::AT_MSABI;
4428 return AttributeList::AT_SysVABI;
4430 return AttributeList::AT_Ptr32;
4432 return AttributeList::AT_Ptr64;
4434 return AttributeList::AT_SPtr;
4436 return AttributeList::AT_UPtr;
4438 return AttributeList::AT_TypeNonNull;
4440 return AttributeList::AT_TypeNullable;
4442 return AttributeList::AT_TypeNullUnspecified;
4444 return AttributeList::AT_ObjCKindOf;
4446 llvm_unreachable(
"unexpected attribute kind!");
4453 assert((attrs || DeclAttrs) &&
4454 "no type attributes in the expected location!");
4458 while (attrs && attrs->
getKind() != parsedKind)
4463 while (DeclAttrs && (!DeclAttrs->isCXX11Attribute() ||
4464 DeclAttrs->getKind() != parsedKind))
4465 DeclAttrs = DeclAttrs->
getNext();
4469 assert(attrs &&
"no matching type attribute in expected location!");
4471 TL.setAttrNameLoc(attrs->
getLoc());
4473 assert(attrs->
isArgExpr(0) &&
"mismatched attribute operand kind");
4477 "unexpected attribute operand kind");
4490 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
4496 : Context(Context), DS(DS) {}
4500 Visit(TL.getModifiedLoc());
4612 void VisitDependentTemplateSpecializationTypeLoc(
4643 void VisitTypeLoc(
TypeLoc TL) {
4649 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
4655 : Context(Context), Chunk(Chunk) {}
4658 llvm_unreachable(
"qualified type locs not expected here!");
4661 llvm_unreachable(
"decayed type locs not expected here!");
4694 assert(isa<DependentNameType>(ClsTy) &&
"Unexpected TypeLoc");
4705 if (isa<ElaboratedType>(ClsTy)) {
4720 llvm_unreachable(
"Nested-name-specifier must name a type");
4735 assert(!Chunk.Ref.LValueRef);
4742 TL.
setSizeExpr(static_cast<Expr*>(Chunk.Arr.NumElts));
4752 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
4764 void VisitTypeLoc(
TypeLoc TL) {
4765 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
4772 switch (Chunk.
Kind) {
4776 llvm_unreachable(
"cannot be _Atomic qualified");
4809 if (isa<PackExpansionType>(T)) {
4837 if (ReturnTypeInfo) {
4857 "LocInfoType's TypeClass conflicts with an existing Type class");
4863 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
4864 " was used directly instead of getting the QualType through"
4865 " GetTypeFromParser");
4872 "Type name should have no identifier!");
4918 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_multiple_qualifiers);
4926 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_function_type);
4932 if (Attr.
getKind() == AttributeList::AT_AddressSpace) {
4935 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
4941 llvm::APSInt addrSpace(32);
4944 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
4946 << ASArgExpr->getSourceRange();
4952 if (addrSpace.isSigned()) {
4953 if (addrSpace.isNegative()) {
4954 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_negative)
4955 << ASArgExpr->getSourceRange();
4959 addrSpace.setIsSigned(
false);
4961 llvm::APSInt max(addrSpace.getBitWidth());
4963 if (addrSpace > max) {
4964 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_too_high)
4969 ASIdx =
static_cast<unsigned>(addrSpace.getZExtValue());
4973 case AttributeList::AT_OpenCLGlobalAddressSpace:
4975 case AttributeList::AT_OpenCLLocalAddressSpace:
4977 case AttributeList::AT_OpenCLConstantAddressSpace:
4979 case AttributeList::AT_OpenCLGenericAddressSpace:
4982 assert(Attr.
getKind() == AttributeList::AT_OpenCLPrivateAddressSpace);
4999 if (
const AttributedType *attr = dyn_cast<AttributedType>(type)) {
5003 type = attr->getModifiedType();
5006 }
else if (
const ParenType *paren = dyn_cast<ParenType>(type)) {
5007 type = paren->getInnerType();
5027 bool NonObjCPointer =
false;
5037 NonObjCPointer =
true;
5044 if (state.isProcessingDeclSpec()) {
5052 Sema &S = state.getSema();
5058 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
5071 if (II->
isStr(
"none"))
5073 else if (II->
isStr(
"strong"))
5075 else if (II->
isStr(
"weak"))
5077 else if (II->
isStr(
"autoreleasing"))
5080 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported)
5093 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
5100 if (previousLifetime != lifetime) {
5112 if (NonObjCPointer) {
5122 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
5127 if (!NonObjCPointer)
5138 !S.
getLangOpts().ObjCARCWeak && !NonObjCPointer) {
5145 diag::err_arc_weak_no_runtime,
type, 0));
5147 S.
Diag(AttrLoc, diag::err_arc_weak_no_runtime);
5160 if (Class->isArcWeakrefUnavailable()) {
5161 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
5162 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
5163 diag::note_class_declared);
5179 Sema &S = state.getSema();
5188 S.
Diag(attr.
getLoc(), diag::err_attribute_multiple_objc_gc);
5195 S.
Diag(attr.
getLoc(), diag::err_attribute_argument_type)
5202 S.
Diag(attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5209 if (II->
isStr(
"weak"))
5211 else if (II->
isStr(
"strong"))
5214 S.
Diag(attr.
getLoc(), diag::warn_attribute_type_not_supported)
5242 struct FunctionTypeUnwrapper {
5256 FunctionTypeUnwrapper(
Sema &S,
QualType T) : Original(T) {
5259 if (isa<FunctionType>(Ty)) {
5260 Fn = cast<FunctionType>(Ty);
5262 }
else if (isa<ParenType>(Ty)) {
5263 T = cast<ParenType>(Ty)->getInnerType();
5264 Stack.push_back(Parens);
5265 }
else if (isa<PointerType>(Ty)) {
5266 T = cast<PointerType>(Ty)->getPointeeType();
5267 Stack.push_back(Pointer);
5268 }
else if (isa<BlockPointerType>(Ty)) {
5269 T = cast<BlockPointerType>(Ty)->getPointeeType();
5270 Stack.push_back(BlockPointer);
5271 }
else if (isa<MemberPointerType>(Ty)) {
5272 T = cast<MemberPointerType>(Ty)->getPointeeType();
5273 Stack.push_back(MemberPointer);
5274 }
else if (isa<ReferenceType>(Ty)) {
5275 T = cast<ReferenceType>(Ty)->getPointeeType();
5276 Stack.push_back(Reference);
5290 bool isFunctionType()
const {
return (Fn !=
nullptr); }
5295 if (New ==
get())
return Original;
5298 return wrap(S.
Context, Original, 0);
5303 if (I ==
Stack.size())
5312 return wrap(C, SplitOld.
Ty, I);
5319 switch (static_cast<WrapKind>(
Stack[I++])) {
5326 QualType New = wrap(C, cast<ParenType>(Old)->getInnerType(), I);
5331 QualType New = wrap(C, cast<PointerType>(Old)->getPointeeType(), I);
5335 case BlockPointer: {
5336 QualType New = wrap(C, cast<BlockPointerType>(Old)->getPointeeType(),I);
5340 case MemberPointer: {
5349 if (isa<LValueReferenceType>(OldRef))
5356 llvm_unreachable(
"unknown wrapping kind");
5364 Sema &S = State.getSema();
5375 S.
Diag(Attr.
getLoc(), diag::warn_duplicate_attribute_exact)
5383 Kind == AttributeList::AT_Ptr64) ||
5385 Kind == AttributeList::AT_Ptr32)) {
5386 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5387 <<
"'__ptr32'" <<
"'__ptr64'";
5390 Kind == AttributeList::AT_UPtr) ||
5392 Kind == AttributeList::AT_SPtr)) {
5393 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5394 <<
"'__sptr'" <<
"'__uptr'";
5404 if (!isa<PointerType>(Desugared)) {
5406 diag::err_attribute_no_member_pointers :
5407 diag::err_attribute_pointers_only) << Attr.
getName();
5413 default: llvm_unreachable(
"Unknown attribute kind");
5427 bool isContextSensitive) {
5438 <<
static_cast<unsigned>(fileNullability.
PointerKind);
5447 while (
auto attributed = dyn_cast<AttributedType>(desugared.
getTypePtr())) {
5449 if (
auto existingNullability = attributed->getImmediateNullability()) {
5451 if (nullability == *existingNullability) {
5452 Diag(nullabilityLoc, diag::warn_nullability_duplicate)
5460 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5466 desugared = attributed->getModifiedType();
5474 if (nullability != *existingNullability) {
5475 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5483 if (
auto typedefNullability
5485 if (*typedefNullability == *existingNullability) {
5498 Diag(nullabilityLoc, diag::err_nullability_nonpointer)
5505 if (isContextSensitive) {
5511 Diag(nullabilityLoc, diag::err_nullability_cs_multilevel)
5514 Diag(nullabilityLoc, diag::note_nullability_type_specifier)
5538 Diag(loc, diag::err_objc_kindof_nonobject)
5546 objType->getTypeArgsAsWritten(),
5547 objType->getProtocols(),
5570 case AttributeList::AT_TypeNonNull:
5573 case AttributeList::AT_TypeNullable:
5576 case AttributeList::AT_TypeNullUnspecified:
5580 llvm_unreachable(
"not a nullability attribute kind");
5593 Declarator &declarator = state.getDeclarator();
5596 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
5609 PK_MemberFunctionPointer,
5614 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
5616 auto diag = state.getSema().Diag(attr.
getLoc(),
5617 diag::warn_nullability_declspec)
5621 << static_cast<unsigned>(pointerKind);
5627 state.getSema().getPreprocessor()
5628 .getLocForEndOfToken(chunk.
Loc),
5639 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
5641 switch (chunk.
Kind) {
5645 return moveToChunk(chunk,
false);
5657 return moveToChunk(*dest,
true);
5675 llvm_unreachable(
"not a calling convention attribute");
5676 case AttributeList::AT_CDecl:
5678 case AttributeList::AT_FastCall:
5680 case AttributeList::AT_StdCall:
5682 case AttributeList::AT_ThisCall:
5684 case AttributeList::AT_Pascal:
5686 case AttributeList::AT_VectorCall:
5688 case AttributeList::AT_Pcs: {
5694 Str = cast<StringLiteral>(Attr.
getArgAsExpr(0))->getString();
5697 return llvm::StringSwitch<AttributedType::Kind>(Str)
5701 case AttributeList::AT_IntelOclBicc:
5703 case AttributeList::AT_MSABI:
5705 case AttributeList::AT_SysVABI:
5708 llvm_unreachable(
"unexpected attribute kind!");
5716 Sema &S = state.getSema();
5718 FunctionTypeUnwrapper unwrapped(S, type);
5720 if (attr.
getKind() == AttributeList::AT_NoReturn) {
5725 if (!unwrapped.isFunctionType())
5736 if (attr.
getKind() == AttributeList::AT_NSReturnsRetained) {
5738 "ns_returns_retained treated as type attribute in non-ARC");
5742 if (!unwrapped.isFunctionType())
5746 = unwrapped.get()->getExtInfo().withProducesResult(
true);
5751 if (attr.
getKind() == AttributeList::AT_Regparm) {
5757 if (!unwrapped.isFunctionType())
5764 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5772 unwrapped.get()->getExtInfo().withRegParm(value);
5778 if (!unwrapped.isFunctionType())
return false;
5794 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5806 unsigned DiagID = diag::err_cconv_varargs;
5810 DiagID = diag::warn_cconv_varargs;
5820 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5839 if (AT->isCallingConv())
5841 R = AT->getModifiedType().IgnoreParens();
5847 FunctionTypeUnwrapper Unwrapped(*
this, T);
5849 bool IsVariadic = (isa<FunctionProtoType>(FT) &&
5850 cast<FunctionProtoType>(FT)->isVariadic());
5859 if (CurCC != FromCC || FromCC == ToCC)
5866 QualType Wrapped = Unwrapped.wrap(*
this, FT);
5881 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5887 llvm::APSInt vecSize(32);
5890 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
5892 << sizeExpr->getSourceRange();
5900 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
5906 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue() * 8);
5909 if (vectorSize % typeSize) {
5910 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_size)
5911 << sizeExpr->getSourceRange();
5916 S.
Diag(Attr.
getLoc(), diag::err_attribute_size_too_large)
5917 << sizeExpr->getSourceRange();
5921 if (vectorSize == 0) {
5922 S.
Diag(Attr.
getLoc(), diag::err_attribute_zero_size)
5923 << sizeExpr->getSourceRange();
5941 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5960 sizeExpr = Size.
get();
5981 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
5982 Triple.getArch() == llvm::Triple::aarch64_be;
5984 if (IsPolyUnsigned) {
5986 return BTy->
getKind() == BuiltinType::UChar ||
5987 BTy->
getKind() == BuiltinType::UShort ||
5988 BTy->
getKind() == BuiltinType::ULong ||
5989 BTy->
getKind() == BuiltinType::ULongLong;
5992 return BTy->
getKind() == BuiltinType::SChar ||
5993 BTy->
getKind() == BuiltinType::Short;
5999 bool Is64Bit = Triple.getArch() == llvm::Triple::aarch64 ||
6000 Triple.getArch() == llvm::Triple::aarch64_be;
6002 if (Is64Bit && BTy->
getKind() == BuiltinType::Double)
6005 return BTy->
getKind() == BuiltinType::SChar ||
6006 BTy->
getKind() == BuiltinType::UChar ||
6007 BTy->
getKind() == BuiltinType::Short ||
6008 BTy->
getKind() == BuiltinType::UShort ||
6009 BTy->
getKind() == BuiltinType::Int ||
6010 BTy->
getKind() == BuiltinType::UInt ||
6011 BTy->
getKind() == BuiltinType::Long ||
6012 BTy->
getKind() == BuiltinType::ULong ||
6013 BTy->
getKind() == BuiltinType::LongLong ||
6014 BTy->
getKind() == BuiltinType::ULongLong ||
6015 BTy->
getKind() == BuiltinType::Float ||
6016 BTy->
getKind() == BuiltinType::Half;
6037 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6044 llvm::APSInt numEltsInt(32);
6047 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6049 << numEltsExpr->getSourceRange();
6055 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6062 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
6063 unsigned vecSize = typeSize * numElts;
6064 if (vecSize != 64 && vecSize != 128) {
6065 S.
Diag(Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
6095 state.getSema().Diag(attr.
getLoc(),
6096 diag::warn_cxx11_gnu_attribute_on_type)
6113 state.getSema().Diag(attr.
getLoc(), diag::err_attribute_not_type_attr)
6121 state.getSema().Diag(attr.
getLoc(),
6122 diag::warn_unknown_attribute_ignored)
6129 case AttributeList::AT_MayAlias:
6134 case AttributeList::AT_OpenCLPrivateAddressSpace:
6135 case AttributeList::AT_OpenCLGlobalAddressSpace:
6136 case AttributeList::AT_OpenCLLocalAddressSpace:
6137 case AttributeList::AT_OpenCLConstantAddressSpace:
6138 case AttributeList::AT_OpenCLGenericAddressSpace:
6139 case AttributeList::AT_AddressSpace:
6148 case AttributeList::AT_VectorSize:
6152 case AttributeList::AT_ExtVectorType:
6156 case AttributeList::AT_NeonVectorType:
6161 case AttributeList::AT_NeonPolyVectorType:
6166 case AttributeList::AT_OpenCLImageAccess:
6184 if (state.getSema().checkNullabilityTypeSpecifier(
6196 case AttributeList::AT_ObjCKindOf:
6204 state.getSema().Diag(attr.
getLoc(),
6205 diag::err_objc_kindof_wrong_position)
6208 state.getDeclarator().getDeclSpec().getLocStart(),
"__kindof ");
6213 if (state.getSema().checkObjCKindOfType(type, attr.
getLoc()))
6218 case AttributeList::AT_NSReturnsRetained:
6219 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
6236 }
while ((attrs = next));
6267 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
6272 Var->getMemberSpecializationInfo()) {
6274 if (MSInfo->getPointOfInstantiation().isInvalid()) {
6275 MSInfo->setPointOfInstantiation(PointOfInstantiation);
6280 L->StaticDataMemberInstantiated(Var);
6284 cast<VarTemplateSpecializationDecl>(Var);
6322 TypeDiagnoserDiag(
unsigned DiagID)
6323 :
Sema::TypeDiagnoser(DiagID == 0), DiagID(DiagID) {}
6326 if (Suppressed)
return;
6327 S.
Diag(Loc, DiagID) << T;
6333 TypeDiagnoserDiag Diagnoser(DiagID);
6356 if (RequireCompleteTypeImpl(Loc, T, Diagnoser))
6359 if (!Tag->getDecl()->isCompleteDefinitionRequired()) {
6360 Tag->getDecl()->setCompleteDefinitionRequired();
6377 bool OnlyNeedComplete) {
6384 if (isa<TagDecl>(D) && cast<TagDecl>(D)->isBeingDefined()) {
6388 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6389 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
6391 D = RD->getDefinition();
6392 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
6393 while (
auto *NewED = ED->getInstantiatedFromMemberEnum())
6395 if (OnlyNeedComplete && ED->isFixed()) {
6399 *Suggested =
nullptr;
6400 for (
auto *Redecl : ED->redecls()) {
6403 if (Redecl->isThisDeclarationADefinition() ||
6404 (Redecl->isCanonicalDecl() && !*Suggested))
6405 *Suggested = Redecl;
6409 D = ED->getDefinition();
6411 assert(D &&
"missing definition for pattern of instantiated definition");
6420 Source->CompleteRedeclChain(D);
6430 if (!RD->
hasAttr<MSInheritanceAttr>()) {
6431 MSInheritanceAttr::Spelling IM;
6438 IM = MSInheritanceAttr::Keyword_single_inheritance;
6441 IM = MSInheritanceAttr::Keyword_multiple_inheritance;
6444 IM = MSInheritanceAttr::Keyword_unspecified_inheritance;
6448 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
6460 TypeDiagnoser &Diagnoser) {
6474 if (!Diagnoser.Suppressed && Def &&
6482 if (!MPTy->getClass()->isDependentType()) {
6514 Source->CompleteType(Tag->
getDecl());
6516 Source->CompleteType(IFace->getDecl());
6521 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
6531 MaybeTemplate = Array->getElementType();
6534 = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
6535 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared)
6538 !Diagnoser.Suppressed);
6540 = dyn_cast<CXXRecordDecl>(Record->getDecl())) {
6542 if (!Rec->isBeingDefined() && Pattern) {
6544 assert(MSI &&
"Missing member specialization information?");
6550 !Diagnoser.Suppressed);
6555 if (Diagnoser.Suppressed)
6559 if (Ident___float128 &&
6561 Diag(Loc, diag::err_typecheck_decl_incomplete_type___float128);
6565 Diagnoser.diagnose(*
this, Loc, T);
6572 : diag::note_forward_declaration)
6576 if (IFace && !IFace->getDecl()->isInvalidDecl())
6577 Diag(IFace->getDecl()->getLocation(), diag::note_forward_class);
6589 TypeDiagnoserDiag Diagnoser(DiagID);
6603 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
6664 for (
const auto &I : RD->
vbases())
6665 Diag(I.getLocStart(), diag::note_constexpr_virtual_base_here)
6666 << I.getSourceRange();
6669 Diag(RD->
getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
6671 for (
const auto &I : RD->
bases()) {
6672 if (!I.getType()->isLiteralType(
Context)) {
6673 Diag(I.getLocStart(),
6674 diag::note_non_literal_base_class)
6675 << RD << I.getType() << I.getSourceRange();
6679 for (
const auto *I : RD->
fields()) {
6680 if (!I->getType()->isLiteralType(
Context) ||
6681 I->getType().isVolatileQualified()) {
6682 Diag(I->getLocation(), diag::note_non_literal_field)
6683 << RD << I << I->getType()
6684 << I->getType().isVolatileQualified();
6692 assert(Dtor &&
"class has literal fields and bases but no dtor?");
6697 diag::note_non_literal_user_provided_dtor :
6698 diag::note_non_literal_nontrivial_dtor) << RD;
6707 TypeDiagnoserDiag Diagnoser(DiagID);
6758 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl()))
6759 return VD->getType();
6760 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
6761 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
6762 return FD->getType();
6763 }
else if (
const ObjCIvarRefExpr *IR = dyn_cast<ObjCIvarRefExpr>(E)) {
6764 return IR->getDecl()->getType();
6766 if (PR->isExplicitProperty())
6767 return PR->getExplicitProperty()->getType();
6768 }
else if (
auto *PE = dyn_cast<PredefinedExpr>(E)) {
6769 return PE->getType();
6779 using namespace sema;
6781 if (isa<ParenExpr>(E)) {
6783 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
6811 bool AsUnevaluated) {
6820 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
6832 Diag(Loc, diag::err_only_enums_have_underlying_types);
6841 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
6842 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
6847 assert(ED &&
"EnumType has no EnumDecl");
6852 assert(!Underlying.
isNull());
6858 llvm_unreachable(
"unknown unary transform type");
6868 int DisallowedKind = -1;
6883 if (DisallowedKind != -1) {
6884 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Abstract class used to diagnose incomplete types.
static QualType applyObjCProtocolQualifiers(Sema &S, SourceLocation loc, SourceRange range, QualType type, ArrayRef< ObjCProtocolDecl * > protocols, const SourceLocation *protocolLocs, bool failOnError=false)
Apply Objective-C protocol qualifiers to the given type.
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
bool CheckNoReturnAttr(const AttributeList &attr)
unsigned getAddressSpace() const
getAddressSpace - Return the address space of this type.
static void HandleExtVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
Defines the clang::ASTContext interface.
const AttributedType * getCallingConvAttributedType(QualType T) const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
SourceLocation getEnd() const
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
const Type * Ty
The locally-unqualified type.
IdKind getKind() const
Determine what kind of name we have.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for literal type diagnostic message. WARNING: Indexes apply ...
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference. Otherwise, it's an rvalue reference...
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
Scope * getCurScope() const
Retrieve the parser's current scope.
static bool isOmittedBlockReturnType(const Declarator &D)
no exception specification
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
This is a discriminated union of FileInfo and ExpansionInfo.
SourceLocation getRestrictSpecLoc() const
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
void setStarLoc(SourceLocation Loc)
SourceLocation getConstSpecLoc() const
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.
Wrapper for source info for tag types. Note that this only records source info for the name itself; a...
ExtInfo withCallingConv(CallingConv cc) const
TSW getTypeSpecWidth() const
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static const TSS TSS_unsigned
bool isMemberPointerType() const
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
TheContext getContext() const
QualType BuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
SourceLocation findNullabilityLoc() const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
void setNameEndLoc(SourceLocation Loc)
static const TST TST_wchar
Decl * getRepAsDecl() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
unsigned deduceWeakPropertyFromType(QualType T)
The attribute is immediately after the declaration's name.
void setRParenLoc(SourceLocation Loc)
bool isUserProvided() const
void setStarLoc(SourceLocation Loc)
NullabilityKind
Describes the nullability of a particular type.
TypeLoc getNamedTypeLoc() const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool canHaveNullability() const
void setEmbeddedInDeclarator(bool isInDeclarator)
IdentifierInfo * getIdentifierInfo(StringRef Name) const
void addConst()
addConst - add the specified type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Qualifiers::GC getObjCGCAttr() const
getObjCGCAttr - Returns gc attribute of this type.
A conversion function name, e.g., operator int.
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
bool isRecordType() const
static const TST TST_typeofExpr
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
static const TST TST_char16
static NullabilityKind mapNullabilityAttrKind(AttributeList::Kind kind)
Map a nullability attribute kind to a nullability kind.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
bool isTypeAltiVecBool() const
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
AttributePool & getAttributePool() const
bool isLiteralType(const ASTContext &Ctx) const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Defines the C++ template declaration subclasses.
static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, AttributeList *attrs)
Represents a C++11 auto or C++1y decltype(auto) type.
bool isEnumeralType() const
QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
SCS getStorageClassSpec() const
bool hasDefinition() const
FunctionDefinitionKind getFunctionDefinitionKind() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
QualType getPointeeType() const
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
One instance of this struct is used for each type in a declarator that is parsed. ...
const ObjCObjectType * getObjectType() const
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Wrapper for source info for typedefs.
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk)
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
bool isDecltypeAuto() const
The attribute is part of a DeclaratorChunk.
bool isBooleanType() const
RefQualifierKind RefQualifier
A container of type source information.
static void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS, unsigned &TypeQuals, QualType TypeSoFar, unsigned RemoveTQs, unsigned DiagID)
static void transferARCOwnership(TypeProcessingState &state, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Used for transferring ownership in casts resulting in l-values.
bool getHasRegParm() const
AttributeList *& getAttrListRef()
bool isBlockPointerType() const
Wrapper for source info for pointers decayed from arrays and functions.
bool hasAttrEnumOperand() const
Abstract base class used for diagnosing integer constant expression violations.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
TypeLoc getNextTypeLoc() const
bool isSpelledAsLValue() const
#define NULLABILITY_TYPE_ATTRS_CASELIST
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr)
bool checkObjCKindOfType(QualType &type, SourceLocation loc)
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
void setParensRange(SourceRange range)
SourceLocation getIncludeLoc() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
An identifier, stored as an IdentifierInfo*.
SourceLocation getCommaLoc() const
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
static DeclaratorChunk * maybeMovePastReturnType(Declarator &declarator, unsigned i, bool onlyBlockPointers)
static const TST TST_underlyingType
Information about one declarator, including the parsed type information and the identifier.
void removeObjCLifetime()
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
ObjCLifetime getObjCLifetime() const
bool hasAttrExprOperand() const
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
SourceLocation getEllipsisLoc() const
ExtProtoInfo - Extra information about a function prototype.
CallingConv getCallConv() const
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Represents a variable template specialization, which refers to a variable template with a given set o...
static const TST TST_interface
static const TST TST_char
A namespace, stored as a NamespaceDecl*.
Describes how types, statements, expressions, and declarations should be printed. ...
bool hasAttrOperand() const
unsigned size() const
Determine the number of type parameters in this list.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isArgIdent(unsigned Arg) const
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
static bool handleFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
OpenCLOptions & getOpenCLOptions()
const Type * getUnqualifiedDesugaredType() const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setParensRange(SourceRange Range)
static const TST TST_unknown_anytype
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
Base wrapper for a particular "section" of type source info.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
__ptr16, alignas(...), etc.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
void setLocalRangeEnd(SourceLocation L)
static bool checkQualifiedFunction(Sema &S, QualType T, SourceLocation Loc, QualifiedFunctionKind QFK)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
static void distributeFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
static const TST TST_decimal32
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
AttributeList * getList() const
QualType getAutoType(QualType DeducedType, bool IsDecltypeAuto, bool IsDependent) const
C++11 deduced auto type.
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an AttributeList as an argument...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the 'restrict' qualifier, if any.
ArrayRef< QualType > getParamTypes() const
bool isObjCARCImplicitlyUnretainedType() const
QualType BuildParenType(QualType T)
Build a paren type including T.
void setBuiltinLoc(SourceLocation Loc)
const CXXScopeSpec & getCXXScopeSpec() const
SourceLocation getTypeSpecSignLoc() const
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
TSS getTypeSpecSign() const
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isReferenceType() const
static bool distributeNullabilityTypeAttr(TypeProcessingState &state, QualType type, AttributeList &attr)
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
static const TST TST_class
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...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
bool isCompleteDefinition() const
bool isAnyPointerType() const
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
static const TST TST_double
static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, QualType type)
void setElaboratedKeywordLoc(SourceLocation Loc)
static std::string getPrintableNameForEntity(DeclarationName Entity)
TagKind getTagKind() const
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
static const TST TST_error
virtual bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, QualType T)
Produces a diagnostic note if the external source contains a complete definition for T...
static const TST TST_enum
QualType getTypeOfType(QualType t) const
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
SourceLocation getTypeSpecTypeLoc() const
SourceLocation getLocStart() const LLVM_READONLY
static const TSW TSW_unspecified
void copy(DependentTemplateSpecializationTypeLoc Loc)
static unsigned getNumAddressingBits(ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
Wrapper of type source information for a type with no direct qualifiers.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
virtual void HandleTagDeclRequiredDefinition(const TagDecl *D)
This callback is invoked the first time each TagDecl is required to be complete.
void CheckExtraCXXDefaultArguments(Declarator &D)
void adjustMemberFunctionCC(QualType &T, bool IsStatic)
std::pair< NullabilityKind, bool > DiagNullabilityKind
llvm::BumpPtrAllocator BumpAlloc
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Values of this type can be null.
static void inferARCWriteback(TypeProcessingState &state, QualType &declSpecType)
bool hasStatic
True if this dimension included the 'static' keyword.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
Represents a C++ unqualified-id that has been parsed.
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
QualType getParenType(QualType NamedType) const
void setNameLoc(SourceLocation Loc)
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TypeSourceInfo *&ReturnTypeInfo)
Represents the results of name lookup.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
const TargetInfo & getTargetInfo() const
static void HandleVectorSizeAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
An lvalue ref-qualifier was provided (&).
unsigned ConstQualLoc
The location of the const-qualifier, if any.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
void setCaretLoc(SourceLocation Loc)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static void spliceAttrOutOfList(AttributeList &attr, AttributeList *&head)
SourceLocation getRAngleLoc() const
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
QualType getReturnType() const
Wrapper for source info for functions.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
static bool hasDirectOwnershipQualifier(QualType type)
An x-value expression is a reference to an object with independent storage but which can be "moved"...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > recordDecl
Matches C++ class declarations.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, QualType &declSpecType)
Given that there are attributes written on the declarator itself, try to distribute any type attribut...
field_range fields() const
SplitQualType getSplitUnqualifiedType() const
bool isObjCLifetimeType() const
bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
void addCVRQualifiers(unsigned mask)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
An implicit 'self' parameter.
bool isValueDependent() const
bool needsExtraLocalData() const
RecordDecl * getDecl() const
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
Wrapper for source info for ObjC interfaces.
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
Represents an Objective-C protocol declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
#define MS_TYPE_ATTRS_CASELIST
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
static FileID getNullabilityCompletenessCheckFileID(Sema &S, SourceLocation loc)
void setLocalRangeBegin(SourceLocation L)
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Represents an ObjC class declaration.
const SourceRange & getSourceRange() const LLVM_READONLY
void copy(ElaboratedTypeLoc Loc)
SourceLocation getLocStart() const LLVM_READONLY
void setInvalid(bool b=true) const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
unsigned getNumParams() const
SmallVector< TemplateTypeParmDecl *, 4 > AutoTemplateParams
Store the list of the auto parameters for a generic lambda. If this is a generic lambda, store the list of the auto parameters converted into TemplateTypeParmDecls into a vector that can be used to construct the generic lambda's template parameter list, during initial AST construction.
CanQualType UnsignedCharTy
const LangOptions & LangOpts
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy)
uint8_t PointerKind
Which kind of pointer declarator we saw.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
DiagnosticsEngine & getDiagnostics() const
static const TST TST_float
TyLocType push(QualType T)
void setUnderlyingTInfo(TypeSourceInfo *TI) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
AttributedType::Kind getAttrKind() const
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
DeclSpec & getMutableDeclSpec()
SourceRange getTypeofParensRange() const
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
static const TSW TSW_long
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
CXXRecordDecl * getMostRecentDecl()
static bool handleObjCGCTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
bool isFunctionDeclarator(unsigned &idx) const
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
TST getTypeSpecType() const
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
std::vector< bool > & Stack
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/atomic.
void addObjCLifetime(ObjCLifetime type)
static QualType ConvertDeclSpecToType(TypeProcessingState &state)
Convert the specified declspec to the appropriate type object.
void setSizeExpr(Expr *Size)
bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability, SourceLocation nullabilityLoc, bool isContextSensitive)
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location. ...
QualType getPointeeType() const
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
bool isRealFloatingType() const
Floating point categories.
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
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=false)
Build an Objective-C object pointer type.
SourceLocation getLParenLoc() const
bool isKindOfType() const
Whether this is a "__kindof" type.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier, if any.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Type source information for an attributed type.
const Type * getTypeForDecl() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
StringRef getName() const
Return the actual identifier string.
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
SourceLocation getAtomicSpecLoc() const
void * getOpaqueData() const
Get the pointer where source information is stored.
SourceLocation getTypeSpecComplexLoc() const
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Declaration of a template type parameter.
TypeSpecifierWidth getWrittenWidthSpec() const
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isAtomicType() const
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
QualType BuildAtomicType(QualType T, SourceLocation Loc)
bool isVariableArrayType() const
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
ExtProtoInfo getExtProtoInfo() const
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void HandleNeonVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S, VectorType::VectorKind VecKind)
SourceLocation getVolatileSpecLoc() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls. Unprototyped calls also use the ...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
ExprResult CheckPlaceholderExpr(Expr *E)
const bool * ConsumedParameters
static const TST TST_decimal64
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isObjCIdType() const
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
static QualType getDecltypeForExpr(Sema &S, Expr *E)
bool isConstexprSpecified() const
CanQualType UnsignedInt128Ty
void setNameLoc(SourceLocation Loc)
ASTMutationListener * getASTMutationListener() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
const SourceRange & getRange() const
bool isDependentType() const
SourceLocation Loc
Loc - The place where this type was defined.
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier, if any.
void setHasBaseTypeAsWritten(bool HasBaseType)
void setEllipsisLoc(SourceLocation EL)
static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
void setPointOfInstantiation(SourceLocation Loc)
static QualType inferARCLifetimeForPointee(Sema &S, QualType type, SourceLocation loc, bool isReference)
Given that we're building a pointer or reference to the given.
TypeSourceInfo * GetTypeSourceInfoForDeclarator(Declarator &D, QualType T, TypeSourceInfo *ReturnTypeInfo)
Create and instantiate a TypeSourceInfo with type source information.
Compare two source locations.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
static const TST TST_half
DeclarationName getDeclName() const
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Wraps an identifier and optional source location for the identifier.
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA)
The result type of a method or function.
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
A type, stored as a Type*.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
static const TSW TSW_short
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
AttributeList * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
CallingConv
CallingConv - Specifies the calling convention that a function uses.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation PointerLoc
const clang::PrintingPolicy & getPrintingPolicy() const
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool isObjectType() const
Determine whether this type is an object type.
bool hasObjCLifetime() const
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
bool getSuppressSystemWarnings() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void setStarLoc(SourceLocation Loc)
static const TST TST_char32
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
void setTypeofLoc(SourceLocation Loc)
Context-sensitive version of a keyword attribute.
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
void initializeFullCopy(TypeLoc Other) const
Initializes this by copying its information from another TypeLoc of the same type.
bool isPrototypeContext() const
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
Wrapper for source info for arrays.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
There is no lifetime qualification on this type.
Information about a FileID, basically just the logical file that it represents and include stack info...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void setAttrOperandParensRange(SourceRange range)
TypeLoc getValueLoc() const
The attribute is in the decl-specifier-seq.
void setKNRPromoted(bool promoted)
static bool distributeFunctionTypeAttrToInnermost(TypeProcessingState &state, AttributeList &attr, AttributeList *&attrList, QualType &declSpecType)
static bool isPermittedNeonBaseType(QualType &Ty, VectorType::VectorKind VecKind, Sema &S)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
const Type * getTypePtr() const
bool CheckDistantExceptionSpec(QualType T)
PointerDeclaratorKind
Describes the kind of a pointer a declarator describes.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isBuiltinType() const
isBuiltinType - returns true if the type is a builtin type.
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
bool isConstantSizeType() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::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...
static const TST TST_union
ParsedType getRepAsType() const
static void moveAttrFromListToList(AttributeList &attr, AttributeList *&fromList, AttributeList *&toList)
TSC getTypeSpecComplex() const
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
static const TSS TSS_signed
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine whether there is any declaration of D that was ever a definition (perhaps before module mer...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
No ref-qualifier was provided.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T)
Retrieve a version of the type 'T' that is elaborated by Keyword and qualified by the nested-name-spe...
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
bool isInvalid() const
An error occurred during parsing of the scope specifier.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
MemberPointerTypeInfo Mem
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
static QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type, ArrayRef< TypeSourceInfo * > typeArgs, SourceRange typeArgsRange, bool failOnError=false)
Apply Objective-C type arguments to the given type.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
const DeclaratorChunk * getInnermostNonParenChunk() const
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
const FileInfo & getFile() const
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceLocation ESpecLoc, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
static const TST TST_typeofType
SourceLocation getBegin() const
void setAmpLoc(SourceLocation Loc)
bool isTypeDependent() const
SourceLocation getBeginLoc() const
bool isArgExpr(unsigned Arg) const
const SourceRange & getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setLBracketLoc(SourceLocation Loc)
AttributeList *& getAttrListRef()
IdentifierInfo * getScopeName() const
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/_Atomic.
static bool isVectorSizeTooLarge(unsigned NumElements)
IdentifierLoc * getArgAsIdent(unsigned Arg) const
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getExprLoc() const LLVM_READONLY
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
bool isFunctionProtoType() const
A constructor named via a template-id.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a pack expansion of types.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool containsPlaceholderType() const
void setLParenLoc(SourceLocation Loc)
void setTypeArgsLAngleLoc(SourceLocation Loc)
CanQualType UnsignedShortTy
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Base class for declarations which introduce a typedef-name.
attr::Kind getKind() const
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
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 ...
static const TST TST_decltype_auto
void setClassTInfo(TypeSourceInfo *TI)
TagTypeKind
The kind of a tag type.
CanQualType ObjCBuiltinIdTy
void checkUnusedDeclAttributes(Declarator &D)
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/_Atomic.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
static const TSS TSS_unspecified
void setAmpAmpLoc(SourceLocation Loc)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
static const TST TST_decltype
static const TST TST_auto
bool isFriendSpecified() const
static const TST TST_void
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getTypeSpecTypeNameLoc() const
static const TST TST_int128
bool isInvalidDecl() const
QualType IgnoreParens() const
QualType getEquivalentType() const
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
CanQualType UnsignedLongLongTy
static void checkNullabilityConsistency(TypeProcessingState &state, SimplePointerKind pointerKind, SourceLocation pointerLoc)
Check for consistent use of nullability.
bool hasTagDefinition() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Expr * getArgAsExpr(unsigned Arg) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
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.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
SourceLocation getLocEnd() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
#define FUNCTION_TYPE_ATTRS_CASELIST
static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal)
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A type that was preceded by the 'template' keyword, stored as a Type*.
static const TST TST_unspecified
enum clang::DeclaratorChunk::@184 Kind
bool isFirstDeclarator() const
void setNameLoc(SourceLocation Loc)
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Syntax
The style used to specify an attribute.
bool isObjCObjectType() const
void setAttrEnumOperandLoc(SourceLocation loc)
TypeSpecifierSign getWrittenSignSpec() const
bool isTriviallyCopyableType(ASTContext &Context) const
IdentifierInfo * getName() const
static const TST TST_decimal128
SourceManager & getSourceManager() const
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
unsigned getTypeQuals() const
ObjCTypeParamList * getTypeParamList() const
#define OBJC_POINTER_TYPE_ATTRS_CASELIST
CanQualType UnsignedLongTy
static bool isFunctionOrMethod(const Decl *D)
void setNext(AttributeList *N)
UnqualTypeLoc getUnqualifiedLoc() const
QualType getIntegerType() const
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, bool NeedDefinition, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool isFunctionType() const
static const TST TST_typename
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void copy(TemplateSpecializationTypeLoc Loc)
Copy the location information from the given info.
Wraps an ObjCPointerType with source location information.
unsigned AtomicQualLoc
The location of the _Atomic-qualifier, if any.
SourceLocation getLoc() const
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.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
A template-id, e.g., f<int>.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
QualType getPointeeType() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, DeclaratorChunk &DeclType, QualType RT)
IdentifierInfo * getIdentifier() const
TypeDecl * getFloat128StubType() const
Retrieve the declaration for a 128-bit float stub type.
static bool hasNullabilityAttr(const AttributeList *attrs)
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool CheckRegparmAttr(const AttributeList &attr, unsigned &value)
bool isCXX11Attribute() const
const Type * getClass() const
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
bool isContextSensitiveKeywordAttribute() const
unsigned AutoTemplateParameterDepth
If this is a generic lambda, use this as the depth of each 'auto' parameter, during initial AST const...
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
QualType getTypeOfExprType(Expr *e) const
GCC extension.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
void setKWLoc(SourceLocation Loc)
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
Captures information about "declaration specifiers".
SourceLocation getIdentifierLoc() const
Represents a C++ struct/union/class.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation())
A user-defined literal name, e.g., operator "" _i.
bool isObjCObjectPointerType() const
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
void setParam(unsigned i, ParmVarDecl *VD)
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Provides information a specialization of a member of a class template, which may be a member function...
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
void setLParenLoc(SourceLocation Loc)
static const TST TST_bool
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
static void assignInheritanceModel(Sema &S, CXXRecordDecl *RD)
Locks in the inheritance model for the given class and all of its bases.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
SourceLocation getRParenLoc() const
static void HandleAddressSpaceTypeAttribute(QualType &Type, const AttributeList &Attr, Sema &S)
bool isTypeSpecOwned() const
SourceLocation getExceptionSpecLoc() const
Defines the clang::TargetInfo interface.
SourceLocation getTypeSpecWidthLoc() const
bool isStar
True if this dimension was [*]. In this case, NumElts is null.
A SourceLocation and its associated SourceManager.
static Qualifiers fromCVRMask(unsigned CVR)
static const TSW TSW_longlong
TagDecl * getDecl() const
bool isIncompleteArrayType() const
static OpaquePtr make(QualTypeP)
bool isTypeAltiVecVector() const
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
void copy(TypeLoc other)
Copies the other type loc into this one.
static const TST TST_atomic
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceManager & SourceMgr
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
static const TST TST_struct
SplitQualType getSingleStepDesugaredType() const
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false)
const DeclaratorChunk & getTypeObject(unsigned i) const
AttributeList * getNext() const
static StringRef getNameForCallConv(CallingConv CC)
Wrapper for source info for builtin types.
An l-value expression is a reference to an object with independent storage.
void setRParenLoc(SourceLocation Loc)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
bool isInvalidType() const
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
void copy(DependentNameTypeLoc Loc)
bool hasExplicitCallingConv(QualType &T)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
No keyword precedes the qualified type name.
bool isConstQualified() const
Determine whether this type is const-qualified.
TypeAttrLocation
The location of a type attribute.
static void distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
const Type * getClass() const
static void spliceAttrIntoList(AttributeList &attr, AttributeList *&head)
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
The global specifier '::'. There is no stored value.
void pushFullCopy(TypeLoc L)
void setType(QualType newType)
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Wrapper for source info for block pointers.
bool isTypeAltiVecPixel() const
base_class_range vbases()
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static AttributeList::Kind getAttrListKind(AttributedType::Kind kind)
Map an AttributedType::Kind to an AttributeList::Kind.
AttributeList *& getListRef()
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
bool isIntegerType() const
QualType BuildTypeofExprType(Expr *E, SourceLocation Loc)
Expr * IgnoreParens() LLVM_READONLY
const DeclSpec & getDeclSpec() const
CanQualType UnsignedIntTy
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static void fillAttributedTypeLoc(AttributedTypeLoc TL, const AttributeList *attrs, const AttributeList *DeclAttrs=nullptr)
bool isPointerType() const
SourceLocation getEllipsisLoc() const
const AttributeList * getAttributes() const
bool isIncompleteOrObjectType() const
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?