33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/SmallString.h"
35 #include "llvm/ADT/StringSwitch.h"
36 #include "llvm/Support/ErrorHandling.h"
38 using namespace clang;
68 bool useExpansionLoc =
true;
70 case AttributeList::AT_ObjCGC: WhichType =
TDS_Pointer;
break;
75 useExpansionLoc =
false;
85 if (useExpansionLoc && loc.
isMacroID() && II) {
86 if (II->
isStr(
"strong")) {
88 }
else if (II->
isStr(
"weak")) {
93 S.
Diag(loc, diag::warn_type_attribute_wrong_type) << name << WhichType
99 #define OBJC_POINTER_TYPE_ATTRS_CASELIST \
100 case AttributeList::AT_ObjCGC: \
101 case AttributeList::AT_ObjCOwnership
104 #define CALLING_CONV_ATTRS_CASELIST \
105 case AttributeList::AT_CDecl: \
106 case AttributeList::AT_FastCall: \
107 case AttributeList::AT_StdCall: \
108 case AttributeList::AT_ThisCall: \
109 case AttributeList::AT_Pascal: \
110 case AttributeList::AT_SwiftCall: \
111 case AttributeList::AT_VectorCall: \
112 case AttributeList::AT_MSABI: \
113 case AttributeList::AT_SysVABI: \
114 case AttributeList::AT_Pcs: \
115 case AttributeList::AT_IntelOclBicc: \
116 case AttributeList::AT_PreserveMost: \
117 case AttributeList::AT_PreserveAll
120 #define FUNCTION_TYPE_ATTRS_CASELIST \
121 case AttributeList::AT_NoReturn: \
122 case AttributeList::AT_Regparm: \
123 CALLING_CONV_ATTRS_CASELIST
126 #define MS_TYPE_ATTRS_CASELIST \
127 case AttributeList::AT_Ptr32: \
128 case AttributeList::AT_Ptr64: \
129 case AttributeList::AT_SPtr: \
130 case AttributeList::AT_UPtr
133 #define NULLABILITY_TYPE_ATTRS_CASELIST \
134 case AttributeList::AT_TypeNonNull: \
135 case AttributeList::AT_TypeNullable: \
136 case AttributeList::AT_TypeNullUnspecified
141 class TypeProcessingState {
167 : sema(sema), declarator(declarator),
169 trivial(
true), hasSavedAttrs(
false) {}
171 Sema &getSema()
const {
179 bool isProcessingDeclSpec()
const {
183 unsigned getCurrentChunkIndex()
const {
187 void setCurrentChunkIndex(
unsigned idx) {
193 if (isProcessingDeclSpec())
194 return getMutableDeclSpec().getAttributes().getListRef();
199 void saveDeclSpecAttrs() {
201 if (hasSavedAttrs)
return;
203 DeclSpec &spec = getMutableDeclSpec();
206 savedAttrs.push_back(attr);
207 trivial &= savedAttrs.empty();
208 hasSavedAttrs =
true;
214 ignoredTypeAttrs.push_back(&attr);
220 for (
auto *
Attr : ignoredTypeAttrs)
224 ~TypeProcessingState() {
227 restoreDeclSpecAttrs();
231 DeclSpec &getMutableDeclSpec()
const {
235 void restoreDeclSpecAttrs() {
236 assert(hasSavedAttrs);
238 if (savedAttrs.empty()) {
239 getMutableDeclSpec().getAttributes().set(
nullptr);
243 getMutableDeclSpec().getAttributes().set(savedAttrs[0]);
244 for (
unsigned i = 0, e = savedAttrs.size() - 1; i != e; ++i)
245 savedAttrs[i]->setNext(savedAttrs[i+1]);
246 savedAttrs.back()->setNext(
nullptr);
264 assert(cur && cur->
getNext() &&
"ran out of attrs?");
310 if (attr.
getKind() == AttributeList::AT_ObjCGC)
312 assert(attr.
getKind() == AttributeList::AT_ObjCOwnership);
327 bool onlyBlockPointers) {
333 for (; i != 0; --i) {
335 switch (fnChunk.
Kind) {
351 for (--i; i != 0; --i) {
353 switch (ptrChunk.
Kind) {
363 if (onlyBlockPointers)
372 llvm_unreachable(
"bad declarator chunk kind");
378 llvm_unreachable(
"bad declarator chunk kind");
396 Declarator &declarator = state.getDeclarator();
399 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
401 switch (chunk.
Kind) {
407 if (state.isProcessingDeclSpec() &&
408 attr.
getKind() == AttributeList::AT_ObjCOwnership)
411 if (!destChunk) destChunk = &chunk;
424 if (state.isProcessingDeclSpec() &&
425 attr.
getKind() == AttributeList::AT_ObjCOwnership) {
430 dest->getAttrListRef());
454 Declarator &declarator = state.getDeclarator();
458 unsigned innermost = -1U;
459 bool considerDeclSpec =
true;
462 switch (chunk.
Kind) {
476 considerDeclSpec =
false;
484 if (considerDeclSpec) {
489 state.saveDeclSpecAttrs();
498 if (innermost != -1U) {
506 state.addIgnoredTypeAttr(attr);
516 Declarator &declarator = state.getDeclarator();
520 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
522 switch (chunk.
Kind) {
550 Declarator &declarator = state.getDeclarator();
570 state.saveDeclSpecAttrs();
577 state.getDeclarator().getAttrListRef());
583 state.getCurrentAttrListRef(),
589 state.addIgnoredTypeAttr(attr);
598 Declarator &declarator = state.getDeclarator();
609 state.addIgnoredTypeAttr(attr);
624 assert(state.getDeclarator().getAttributes() &&
"declarator has no attrs!");
632 if (attr->isCXX11Attribute())
635 switch (attr->getKind()) {
640 case AttributeList::AT_NSReturnsRetained:
641 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
657 case AttributeList::AT_ObjCKindOf:
663 }
while ((attr = next));
670 Declarator &declarator = state.getDeclarator();
720 loc, loc, declarator));
735 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
740 if (!(RemoveTQs & Qual.first))
744 if (TypeQuals & Qual.first)
745 S.
Diag(Qual.second, DiagID)
750 TypeQuals &= ~Qual.first;
774 diag::warn_block_literal_attributes_on_omitted_return_type)
789 diag::warn_block_literal_qualifiers_on_omitted_return_type);
799 bool failOnError =
false) {
802 if (!objcObjectType || !objcObjectType->getInterface()) {
803 S.
Diag(loc, diag::err_objc_type_args_non_class)
816 S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
827 if (objcObjectType->isSpecialized()) {
828 S.
Diag(loc, diag::err_objc_type_args_specialized_class)
840 unsigned numTypeParams = typeParams->
size();
841 bool anyPackExpansions =
false;
842 for (
unsigned i = 0, n = typeArgs.size(); i != n; ++i) {
850 bool diagnosed =
false;
853 rangeToRemove = attr.getLocalSourceRange();
854 if (attr.getTypePtr()->getImmediateNullability()) {
855 typeArg = attr.
getTypePtr()->getModifiedType();
856 S.
Diag(attr.getLocStart(),
857 diag::err_objc_type_arg_explicit_nullability)
864 S.
Diag(qual.getLocStart(), diag::err_objc_type_arg_qualified)
873 finalTypeArgs.push_back(typeArg);
876 anyPackExpansions =
true;
880 if (!anyPackExpansions) {
881 if (i < numTypeParams) {
882 typeParam = typeParams->
begin()[i];
885 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
890 S.
Diag(objcClass->getLocation(), diag::note_previous_decl)
906 assert(anyPackExpansions &&
"Too many arguments?");
915 if (typeArgObjC->isObjCIdType()) {
918 if (boundObjC->isObjCIdType())
927 diag::err_objc_type_arg_does_not_match_bound)
929 S.
Diag(typeParam->getLocation(), diag::note_objc_type_param_here)
944 assert(anyPackExpansions &&
"Too many arguments?");
955 diag::err_objc_type_arg_does_not_match_bound)
957 S.
Diag(typeParam->getLocation(), diag::note_objc_type_param_here)
973 diag::err_objc_type_arg_not_id_compatible)
984 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
985 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
986 << (typeArgs.size() < typeParams->
size())
990 S.
Diag(objcClass->getLocation(), diag::note_previous_decl)
1008 bool failOnError =
false) {
1015 objT->getTypeArgsAsWritten(),
1017 objT->isKindOfTypeAsWritten());
1033 objPtr->isKindOfType());
1038 if (
type->isObjCClassType()) {
1040 type = ctx.getObjCObjectType(ctx.ObjCBuiltinClassTy, { }, protocols,
1042 return ctx.getObjCObjectPointerType(type);
1045 S.
Diag(loc, diag::err_invalid_protocol_qualifiers)
1065 if (!TypeArgs.empty()) {
1070 if (FailOnError && Result.
isNull())
1074 if (!Protocols.empty()) {
1079 ProtocolLocs.data(),
1081 if (FailOnError && Result.
isNull())
1108 auto ObjCObjectTL = ObjCObjectPointerTL.getPointeeLoc()
1118 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
1119 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
1120 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
1121 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
1124 return CreateParsedType(Result, ResultTInfo);
1149 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
1153 ActualTypeArgInfos.clear();
1157 assert(TypeArgInfo &&
"No type source info?");
1158 ActualTypeArgInfos.push_back(TypeArgInfo);
1164 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
1168 ProtocolLocs, ProtocolRAngleLoc,
1183 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
1189 if (ObjCObjectTL.getNumTypeArgs() > 0) {
1190 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
1192 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
1193 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
1194 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
1201 if (ObjCObjectTL.getNumProtocols() > 0) {
1202 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
1203 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1204 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1205 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1206 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
1213 ObjCObjectTL.setHasBaseTypeAsWritten(
true);
1214 if (ObjCObjectTL.getType() == T)
1215 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
1217 ObjCObjectTL.getBaseLoc().initialize(
Context, Loc);
1230 if (Attr.
getKind() == AttributeList::AT_OpenCLAccess) {
1248 Sema &S = state.getSema();
1249 Declarator &declarator = state.getDeclarator();
1269 "Unknown TSS value");
1283 "Unknown TSS value");
1292 "Unknown TSS value");
1297 "Unknown TSS value");
1328 S.
Diag(DeclLoc, diag::ext_missing_declspec)
1338 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1346 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1350 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1370 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1389 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1419 << Result <<
"cl_khr_fp64";
1435 Result = Context.
IntTy;
1446 Result = Context.
IntTy;
1469 "Can't handle qualifiers on typedef names yet!");
1471 if (Result.isNull()) {
1475 StringRef TypeName = Result.getBaseTypeIdentifier()->getName();
1477 llvm::StringSwitch<bool>(TypeName)
1478 .Cases(
"atomic_int",
"atomic_uint",
"atomic_float",
1479 "atomic_flag",
true)
1483 << Result <<
"cl_khr_int64_base_atomics";
1489 << Result <<
"cl_khr_int64_extended_atomics";
1493 !TypeName.compare(
"atomic_double")) {
1495 << Result <<
"cl_khr_fp64";
1499 (Result->isOCLImage2dArrayMSAADepthROType() ||
1500 Result->isOCLImage2dArrayMSAADepthWOType() ||
1501 Result->isOCLImage2dArrayMSAADepthRWType() ||
1502 Result->isOCLImage2dArrayMSAAROType() ||
1503 Result->isOCLImage2dArrayMSAARWType() ||
1504 Result->isOCLImage2dArrayMSAAWOType() ||
1505 Result->isOCLImage2dMSAADepthROType() ||
1506 Result->isOCLImage2dMSAADepthRWType() ||
1507 Result->isOCLImage2dMSAADepthWOType() ||
1508 Result->isOCLImage2dMSAAROType() ||
1509 Result->isOCLImage2dMSAARWType() ||
1510 Result->isOCLImage2dMSAAWOType())) {
1512 << Result <<
"cl_khr_gl_msaa_sharing";
1523 assert(!Result.isNull() &&
"Didn't get a type for typeof?");
1524 if (!Result->isDependentType())
1532 assert(E &&
"Didn't get an expression for typeof?");
1535 if (Result.isNull()) {
1536 Result = Context.
IntTy;
1543 assert(E &&
"Didn't get an expression for decltype?");
1546 if (Result.isNull()) {
1547 Result = Context.
IntTy;
1554 assert(!Result.isNull() &&
"Didn't get a type for __underlying_type?");
1558 if (Result.isNull()) {
1559 Result = Context.
IntTy;
1572 assert(LSI &&
"No LambdaScopeInfo on the stack!");
1575 const bool IsParameterPack = declarator.
hasEllipsis();
1589 TemplateParameterDepth,
1590 AutoParameterPosition,
1591 nullptr,
false, IsParameterPack);
1616 assert(!Result.isNull() &&
"Didn't get a type for _Atomic?");
1618 if (Result.isNull()) {
1619 Result = Context.
IntTy;
1624 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
1625 case DeclSpec::TST_##ImgType##_t: \
1626 Result = llvm::StringSwitch<QualType>( \
1627 getImageAccessAttrStr(DS.getAttributes().getList())) \
1628 .Cases("write_only", "__write_only", Context.Id##WOTy) \
1629 .Cases("read_write", "__read_write", Context.Id##RWTy) \
1630 .Default(Context.Id##ROTy); \
1632 #include "clang/Basic/OpenCLImageTypes.def"
1635 Result = Context.
IntTy;
1647 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1682 if (TypeQuals &&
Result->isFunctionType()) {
1686 ? diag::warn_typecheck_function_qualifiers_ignored
1687 : diag::warn_typecheck_function_qualifiers_unspecified);
1700 if (TypeQuals &&
Result->isReferenceType()) {
1702 S, DS, TypeQuals, Result,
1704 diag::warn_typecheck_reference_qualifiers);
1711 && TypeQuals &
Result.getCVRQualifiers()) {
1730 declarator.setInvalidType(
true);
1735 assert(!
Result.isNull() &&
"This function should not return a null type");
1754 unsigned DiagID = 0;
1770 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1774 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1788 unsigned CVRAU,
const DeclSpec *DS) {
1870 diag::err_arc_indirect_no_ownership, type, isReference));
1872 S.
Diag(loc, diag::err_arc_indirect_no_ownership) << type << isReference;
1876 assert(implicitLifetime &&
"didn't infer any lifetime!");
1930 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1953 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1988 "Unresolved overloaded function type");
2016 Diag(Loc, diag::err_reference_to_void);
2061 S.
Diag(Loc, diag::ext_vla_folded_to_constant) << SR;
2086 Expr *ArraySize,
unsigned Quals,
2103 Diag(Loc, diag::err_illegal_decl_array_of_references)
2109 Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
2114 diag::err_array_of_abstract_type))
2121 if (!MPTy->getClass()->isDependentType())
2128 diag::err_illegal_decl_array_incomplete_type))
2133 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2141 if (EltTy->getDecl()->hasFlexibleArrayMember())
2142 Diag(Loc, diag::ext_flexible_array_in_array) << T;
2144 Diag(Loc, diag::err_objc_array_of_interfaces) << T;
2152 ArraySize = Result.
get();
2156 if (ArraySize && !ArraySize->
isRValue()) {
2161 ArraySize = Result.
get();
2169 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2170 << ArraySize->
getType() << ArraySize->getSourceRange();
2189 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2190 << ArraySize->
getType() << ArraySize->getSourceRange();
2201 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2203 Diag(ArraySize->getLocStart(), diag::err_decl_negative_array_size)
2206 Diag(ArraySize->getLocStart(), diag::err_typecheck_negative_array_size)
2207 << ArraySize->getSourceRange();
2210 if (ConstVal == 0) {
2213 Diag(ArraySize->getLocStart(),
2215 : diag::ext_typecheck_zero_array_size)
2216 << ArraySize->getSourceRange();
2219 Diag(ArraySize->getLocStart(),
2220 diag::warn_typecheck_zero_static_array_size)
2221 << ArraySize->getSourceRange();
2227 unsigned ActiveSizeBits
2230 Diag(ArraySize->getLocStart(), diag::err_array_too_large)
2231 << ConstVal.toString(10)
2232 << ArraySize->getSourceRange();
2242 Diag(Loc, diag::err_opencl_vla);
2250 Diag(Loc, diag::err_vla_in_sfinae);
2255 Diag(Loc, diag::ext_vla);
2259 : diag::ext_c99_array_usage) << ASM;
2264 Diag(Loc, diag::warn_vla_used);
2274 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2297 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
2302 llvm::APSInt vecSize(32);
2304 Diag(AttrLoc, diag::err_attribute_argument_type)
2306 << ArraySize->getSourceRange();
2312 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue());
2314 if (vectorSize == 0) {
2315 Diag(AttrLoc, diag::err_attribute_zero_size)
2316 << ArraySize->getSourceRange();
2321 Diag(AttrLoc, diag::err_attribute_size_too_large)
2322 << ArraySize->getSourceRange();
2334 Diag(Loc, diag::err_func_returning_array_function)
2341 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2349 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
2364 bool hasCheckedSwiftCall =
false;
2365 auto checkForSwiftCC = [&](
unsigned paramIndex) {
2367 if (hasCheckedSwiftCall)
return;
2368 hasCheckedSwiftCall =
true;
2370 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
2374 for (
size_t paramIndex = 0, numParams = paramTypes.size();
2375 paramIndex != numParams; ++paramIndex) {
2384 checkForSwiftCC(paramIndex);
2385 if (paramIndex != 0 &&
2388 S.
Diag(getParamLoc(paramIndex),
2389 diag::err_swift_indirect_result_not_first);
2396 checkForSwiftCC(paramIndex);
2397 if (!(paramIndex == numParams - 1 ||
2398 (paramIndex == numParams - 2 &&
2401 S.
Diag(getParamLoc(paramIndex),
2402 diag::err_swift_context_not_before_swift_error_result);
2408 checkForSwiftCC(paramIndex);
2409 if (paramIndex != numParams - 1) {
2410 S.
Diag(getParamLoc(paramIndex),
2411 diag::err_swift_error_result_not_last);
2412 }
else if (paramIndex == 0 ||
2415 S.
Diag(getParamLoc(paramIndex),
2416 diag::err_swift_error_result_not_after_swift_context);
2420 llvm_unreachable(
"bad ABI kind");
2428 bool Invalid =
false;
2432 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2436 Diag(Loc, diag::err_param_with_void_type);
2440 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2445 ParamTypes[Idx] = ParamType;
2450 [=](
unsigned i) {
return Loc; });
2474 Diag(Loc, diag::err_distant_exception_spec);
2481 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2487 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2493 Diag(Loc, diag::err_mempointer_in_nonclass_type) << Class;
2523 Diag(Loc, diag::err_nonfunction_block_type);
2536 if (TInfo) *TInfo =
nullptr;
2541 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2542 QT = LIT->getType();
2543 DI = LIT->getTypeSourceInfo();
2546 if (TInfo) *TInfo = DI;
2552 unsigned chunkIndex);
2559 Sema &S = state.getSema();
2560 Declarator &declarator = state.getDeclarator();
2566 unsigned outermostPointerIndex = 0;
2568 unsigned numPointers = 0;
2570 unsigned chunkIndex = i;
2572 switch (chunk.
Kind) {
2582 outermostPointerIndex = chunkIndex;
2590 if (numPointers != 1)
return;
2592 outermostPointerIndex = chunkIndex;
2593 isBlockPointer =
true;
2610 if (numPointers == 1) {
2628 }
else if (numPointers == 2) {
2642 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
2646 outermostPointerIndex);
2668 }
const QualKinds[5] = {
2677 unsigned NumQuals = 0;
2682 for (
auto &
E : QualKinds) {
2683 if (Quals &
E.Mask) {
2684 if (!QualStr.empty()) QualStr +=
' ';
2701 << QualStr << NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
2707 unsigned FunctionChunkIndex) {
2717 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
2719 OuterChunkIndex !=
End; ++OuterChunkIndex) {
2721 switch (OuterChunk.
Kind) {
2728 diag::warn_qual_return_type,
2754 llvm_unreachable(
"unknown declarator chunk kind");
2777 Sema &SemaRef = state.getSema();
2780 ReturnTypeInfo =
nullptr;
2783 TagDecl *OwnedTagDecl =
nullptr;
2827 llvm_unreachable(
"Can't specify a type specifier in lambda grammar");
2844 switch (cast<TagDecl>(SemaRef.
CurContext)->getTagKind()) {
2845 case TTK_Enum: llvm_unreachable(
"unhandled tag kind");
2847 case TTK_Union: Error = Cxx ? 3 : 4;
break;
2908 bool HaveTrailing =
false;
2918 unsigned chunkIndex = e - i - 1;
2919 state.setCurrentChunkIndex(chunkIndex);
2924 HaveTrailing =
true;
2942 default: llvm_unreachable(
"unknown auto TypeSpecType");
2944 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
2945 << Keyword << Error << AutoRange;
2948 }
else if (!HaveTrailing) {
2952 diag::warn_cxx98_compat_auto_type_specifier)
2961 unsigned DiagID = 0;
2966 llvm_unreachable(
"parser should not have allowed this");
2982 DiagID = diag::err_type_defined_in_alias_template;
2991 DiagID = diag::err_type_defined_in_type_specifier;
3000 DiagID = diag::err_type_defined_in_param_type;
3006 DiagID = diag::err_type_defined_in_condition;
3011 SemaRef.
Diag(OwnedTagDecl->getLocation(), DiagID)
3017 assert(!T.
isNull() &&
"This function should not return a null type");
3026 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3057 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3058 : diag::warn_empty_parens_are_function_decl)
3069 if (
Comma.getFileID() !=
Name.getFileID() ||
3070 Comma.getSpellingLineNumber() !=
Name.getSpellingLineNumber()) {
3089 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3104 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
3109 if (Init.empty() && S.
LangOpts.CPlusPlus11)
3112 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
3125 unsigned ChunkIndex) {
3148 bool IsCXXInstanceMethod =
false;
3154 unsigned I = ChunkIndex;
3155 bool FoundNonParen =
false;
3156 while (I && !FoundNonParen) {
3159 FoundNonParen =
true;
3162 if (FoundNonParen) {
3165 IsCXXInstanceMethod =
3170 IsCXXInstanceMethod =
true;
3177 IsCXXInstanceMethod =
3185 IsCXXInstanceMethod);
3194 if (
Attr->
getKind() == AttributeList::AT_OpenCLKernel) {
3196 if (arch == llvm::Triple::spir || arch == llvm::Triple::spir64 ||
3197 arch == llvm::Triple::amdgcn) {
3219 switch (nullability) {
3221 if (!Ident__Nonnull)
3223 return Ident__Nonnull;
3226 if (!Ident__Nullable)
3228 return Ident__Nullable;
3231 if (!Ident__Null_unspecified)
3233 return Ident__Null_unspecified;
3235 llvm_unreachable(
"Unknown nullability kind.");
3243 return Ident_NSError;
3251 if (attr->getKind() == AttributeList::AT_TypeNonNull ||
3252 attr->getKind() == AttributeList::AT_TypeNullable ||
3253 attr->getKind() == AttributeList::AT_TypeNullUnspecified)
3270 MaybePointerToCFRef,
3274 NSErrorPointerPointer,
3285 unsigned numNormalPointers = 0;
3289 return PointerDeclaratorKind::NonPointer;
3294 switch (chunk.
Kind) {
3302 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3303 : PointerDeclaratorKind::SingleLevelPointer;
3310 ++numNormalPointers;
3311 if (numNormalPointers > 2)
3312 return PointerDeclaratorKind::MultiLevelPointer;
3318 unsigned numTypeSpecifierPointers = 0;
3322 ++numNormalPointers;
3324 if (numNormalPointers > 2)
3325 return PointerDeclaratorKind::MultiLevelPointer;
3328 ++numTypeSpecifierPointers;
3334 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3335 : PointerDeclaratorKind::SingleLevelPointer;
3340 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3341 : PointerDeclaratorKind::SingleLevelPointer;
3346 ++numNormalPointers;
3347 ++numTypeSpecifierPointers;
3350 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
3352 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3353 return PointerDeclaratorKind::NSErrorPointerPointer;
3362 if (objcClass->getInterface()->getIdentifier() == S.
getNSErrorIdent()) {
3363 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
3364 return PointerDeclaratorKind::NSErrorPointerPointer;;
3371 if (numNormalPointers == 0)
3372 return PointerDeclaratorKind::NonPointer;
3377 bool isCFError =
false;
3385 if (
auto bridgeAttr = recordDecl->getAttr<ObjCBridgeAttr>()) {
3395 if (isCFError && numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3396 return PointerDeclaratorKind::CFErrorRefPointer;
3404 switch (numNormalPointers) {
3406 return PointerDeclaratorKind::NonPointer;
3409 return PointerDeclaratorKind::SingleLevelPointer;
3412 return PointerDeclaratorKind::MaybePointerToCFRef;
3415 return PointerDeclaratorKind::MultiLevelPointer;
3424 if (ctx->isFunctionOrMethod())
3427 if (ctx->isFileContext())
3438 bool invalid =
false;
3440 if (invalid || !sloc.
isFile())
3460 Sema &S = state.getSema();
3476 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
3483 S.
Diag(pointerLoc, diag::warn_nullability_missing)
3484 <<
static_cast<unsigned>(pointerKind);
3494 Sema &S = state.getSema();
3504 bool IsTypedefName =
3517 if (AT->isDecltypeAuto()) {
3519 unsigned Index =
E -
I - 1;
3521 unsigned DiagId = diag::err_decltype_auto_compound_type;
3522 unsigned DiagKind = 0;
3523 switch (DeclChunk.
Kind) {
3531 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
3549 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
3558 bool inferNullabilityCS =
false;
3559 bool inferNullabilityInnerOnly =
false;
3560 bool inferNullabilityInnerOnlyComplete =
false;
3563 bool inAssumeNonNullRegion =
false;
3565 inAssumeNonNullRegion =
true;
3575 S.
Diag(fileNullability.
PointerLoc, diag::warn_nullability_missing)
3576 <<
static_cast<unsigned>(fileNullability.
PointerKind);
3594 } complainAboutMissingNullability = CAMN_No;
3595 unsigned NumPointersRemaining = 0;
3597 if (IsTypedefName) {
3601 complainAboutMissingNullability = CAMN_InnerPointers;
3604 ++NumPointersRemaining;
3609 switch (chunk.
Kind) {
3617 ++NumPointersRemaining;
3625 ++NumPointersRemaining;
3631 switch (
auto context = state.getDeclarator().getContext()) {
3636 isFunctionOrMethod =
true;
3641 complainAboutMissingNullability = CAMN_No;
3646 if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) {
3655 complainAboutMissingNullability = CAMN_Yes;
3659 case PointerDeclaratorKind::NonPointer:
3660 case PointerDeclaratorKind::MultiLevelPointer:
3664 case PointerDeclaratorKind::SingleLevelPointer:
3666 if (inAssumeNonNullRegion) {
3673 case PointerDeclaratorKind::CFErrorRefPointer:
3674 case PointerDeclaratorKind::NSErrorPointerPointer:
3677 if (isFunctionOrMethod && inAssumeNonNullRegion)
3681 case PointerDeclaratorKind::MaybePointerToCFRef:
3682 if (isFunctionOrMethod) {
3686 auto hasCFReturnsAttr = [](
const AttributeList *NextAttr) ->
bool {
3688 if (NextAttr->getKind() == AttributeList::AT_CFReturnsRetained ||
3689 NextAttr->getKind() == AttributeList::AT_CFReturnsNotRetained)
3691 NextAttr = NextAttr->getNext();
3697 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
3700 inferNullabilityInnerOnly =
true;
3709 complainAboutMissingNullability = CAMN_Yes;
3738 if (NumPointersRemaining > 0)
3739 --NumPointersRemaining;
3746 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
3750 AttributeList *nullabilityAttr = state.getDeclarator().getAttributePool()
3756 nullptr, 0, syntax);
3760 if (inferNullabilityCS) {
3761 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
3765 if (inferNullabilityInnerOnly)
3766 inferNullabilityInnerOnlyComplete =
true;
3767 return nullabilityAttr;
3772 switch (complainAboutMissingNullability) {
3776 case CAMN_InnerPointers:
3777 if (NumPointersRemaining == 0)
3793 pointerKind = SimplePointerKind::BlockPointer;
3795 pointerKind = SimplePointerKind::MemberPointer;
3797 if (
auto *attr = inferPointerNullability(
3802 attr->setUsedAsTypeAttr();
3810 unsigned chunkIndex = e - i - 1;
3811 state.setCurrentChunkIndex(chunkIndex);
3814 switch (DeclType.
Kind) {
3820 if (!LangOpts.Blocks)
3821 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
3824 inferPointerNullability(SimplePointerKind::BlockPointer,
3831 if (LangOpts.OpenCL)
3846 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
3859 if (LangOpts.OpenCL) {
3860 if (T->isImageType() || T->isSamplerT() || T->isPipeType() ||
3861 T->isBlockPointerType()) {
3906 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
3917 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype) <<
3928 unsigned x = chunkIndex;
3940 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost) <<
3961 S.
Diag(DeclType.
Loc, diag::err_illegal_decl_array_of_auto)
3988 ? diag::err_auto_missing_trailing_return
3989 : diag::err_deduced_return_type);
3994 if (isa<ParenType>(T)) {
3996 diag::err_trailing_return_in_parens)
4000 (T.hasQualifiers() || !isa<AutoType>(T) ||
4003 diag::err_trailing_return_without_auto)
4018 if ((T->isArrayType() || T->isFunctionType()) &&
4020 unsigned diagID = diag::err_func_returning_array_function;
4023 if (chunkIndex == 0 &&
4025 diagID = diag::err_block_returning_array_function;
4026 S.
Diag(DeclType.
Loc, diagID) << T->isFunctionType() << T;
4033 if (T->isHalfType()) {
4042 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
4049 if (LangOpts.OpenCL && (T->isBlockPointerType() || T->isImageType() ||
4050 T->isSamplerT() || T->isPipeType())) {
4058 if (T->isObjCObjectType()) {
4067 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
4085 if ((T.getCVRQualifiers() || T->isAtomicType()) &&
4087 (T->isDependentType() || T->isRecordType()))) {
4088 if (T->isVoidType() && !S.
getLangOpts().CPlusPlus &&
4093 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) << T;
4101 if (T.getQualifiers().hasObjCLifetime()) {
4107 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
4108 AttrLoc =
Attr->getLoc();
4117 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
4118 AttrLoc =
Attr->getLoc();
4131 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
4132 << T.getQualifiers().getObjCLifetime();
4140 S.
Diag(Tag->getLocation(), diag::err_type_defined_in_result_type)
4148 diag::err_exception_spec_in_typedef)
4167 bool Overloadable =
false;
4169 Attrs; Attrs = Attrs->
getNext()) {
4170 if (Attrs->getKind() == AttributeList::AT_Overloadable) {
4171 Overloadable =
true;
4184 diag::err_ident_list_in_fn_declaration);
4207 bool HasAnyInterestingExtParameterInfos =
false;
4209 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
4212 assert(!ParamTy.isNull() &&
"Couldn't parse type?");
4217 if (ParamTy->isVoidType()) {
4222 S.
Diag(DeclType.
Loc, diag::err_void_only_param);
4223 ParamTy = Context.
IntTy;
4228 ParamTy = Context.
IntTy;
4232 if (ParamTy.hasQualifiers())
4233 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
4238 }
else if (ParamTy->isHalfType()) {
4243 S.
Diag(Param->getLocation(),
4244 diag::err_opencl_half_param) << ParamTy;
4246 Param->setInvalidDecl();
4249 S.
Diag(Param->getLocation(),
4250 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
4254 if (ParamTy->isPromotableIntegerType()) {
4258 if (BTy->getKind() == BuiltinType::Float) {
4265 if (LangOpts.ObjCAutoRefCount && Param->hasAttr<NSConsumedAttr>()) {
4266 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
4267 HasAnyInterestingExtParameterInfos =
true;
4271 ExtParameterInfos[i] =
4272 ExtParameterInfos[i].withABI(attr->getABI());
4273 HasAnyInterestingExtParameterInfos =
true;
4276 ParamTys.push_back(ParamTy);
4279 if (HasAnyInterestingExtParameterInfos) {
4282 [&](
unsigned i) {
return FTI.
Params[i].
Param->getLocation(); });
4288 Expr *NoexceptExpr =
nullptr;
4294 DynamicExceptions.reserve(N);
4295 DynamicExceptionRanges.reserve(N);
4296 for (
unsigned I = 0;
I != N; ++
I) {
4307 DynamicExceptionRanges,
4322 inferPointerNullability(SimplePointerKind::MemberPointer,
4342 llvm_unreachable(
"Nested-name-specifier must name a type");
4352 if (NNSPrefix && isa<TemplateSpecializationType>(NNS->
getAsType()))
4358 diag::err_illegal_decl_mempointer_in_nonclass)
4389 const_cast<AttributeList *>(DeclType.
getAttrs()));
4392 assert(!T.
isNull() &&
"T must not be null after this point");
4396 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
4413 FreeFunction = (DC && !DC->
isRecord());
4432 if (IsQualifiedFunction &&
4452 if (!RemovalLocs.empty()) {
4453 std::sort(RemovalLocs.begin(), RemovalLocs.end(),
4455 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
4456 Loc = RemovalLocs.front();
4460 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
4485 state.diagnoseIgnoredTypeAttrs(T);
4515 diag::err_function_parameter_pack_without_parameter_packs)
4535 LangOpts.CPlusPlus11
4536 ? diag::warn_cxx98_compat_variadic_templates
4537 : diag::ext_variadic_templates);
4563 diag::err_ellipsis_in_declarator_not_parameter);
4569 assert(!T.
isNull() &&
"T must not be null at the end of this function");
4585 TypeProcessingState
state(*
this, D);
4609 unsigned chunkIndex) {
4610 Sema &S = state.getSema();
4617 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
4620 const char *attrStr =
nullptr;
4621 switch (ownership) {
4650 Sema &S = state.getSema();
4654 bool hasIndirection =
false;
4657 switch (chunk.
Kind) {
4666 hasIndirection =
true;
4699 TypeProcessingState
state(*
this, D);
4717 return AttributeList::AT_AddressSpace;
4719 return AttributeList::AT_Regparm;
4721 return AttributeList::AT_VectorSize;
4723 return AttributeList::AT_NeonVectorType;
4725 return AttributeList::AT_NeonPolyVectorType;
4727 return AttributeList::AT_ObjCGC;
4730 return AttributeList::AT_ObjCOwnership;
4732 return AttributeList::AT_NoReturn;
4734 return AttributeList::AT_CDecl;
4736 return AttributeList::AT_FastCall;
4738 return AttributeList::AT_StdCall;
4740 return AttributeList::AT_ThisCall;
4742 return AttributeList::AT_Pascal;
4744 return AttributeList::AT_SwiftCall;
4746 return AttributeList::AT_VectorCall;
4749 return AttributeList::AT_Pcs;
4751 return AttributeList::AT_IntelOclBicc;
4753 return AttributeList::AT_MSABI;
4755 return AttributeList::AT_SysVABI;
4757 return AttributeList::AT_PreserveMost;
4759 return AttributeList::AT_PreserveAll;
4761 return AttributeList::AT_Ptr32;
4763 return AttributeList::AT_Ptr64;
4765 return AttributeList::AT_SPtr;
4767 return AttributeList::AT_UPtr;
4769 return AttributeList::AT_TypeNonNull;
4771 return AttributeList::AT_TypeNullable;
4773 return AttributeList::AT_TypeNullUnspecified;
4775 return AttributeList::AT_ObjCKindOf;
4777 llvm_unreachable(
"unexpected attribute kind!");
4784 assert((attrs || DeclAttrs) &&
4785 "no type attributes in the expected location!");
4789 while (attrs && attrs->
getKind() != parsedKind)
4794 while (DeclAttrs && (!DeclAttrs->isCXX11Attribute() ||
4795 DeclAttrs->getKind() != parsedKind))
4796 DeclAttrs = DeclAttrs->
getNext();
4800 assert(attrs &&
"no matching type attribute in expected location!");
4802 TL.setAttrNameLoc(attrs->
getLoc());
4804 assert(attrs->
isArgExpr(0) &&
"mismatched attribute operand kind");
4808 "unexpected attribute operand kind");
4821 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
4827 : Context(Context), DS(DS) {}
4831 Visit(TL.getModifiedLoc());
4943 void VisitDependentTemplateSpecializationTypeLoc(
4982 void VisitTypeLoc(
TypeLoc TL) {
4988 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
4994 : Context(Context), Chunk(Chunk) {}
4997 llvm_unreachable(
"qualified type locs not expected here!");
5000 llvm_unreachable(
"decayed type locs not expected here!");
5033 assert(isa<DependentNameType>(ClsTy) &&
"Unexpected TypeLoc");
5044 if (isa<ElaboratedType>(ClsTy)) {
5059 llvm_unreachable(
"Nested-name-specifier must name a type");
5074 assert(!Chunk.Ref.LValueRef);
5081 TL.
setSizeExpr(static_cast<Expr*>(Chunk.Arr.NumElts));
5091 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
5107 void VisitTypeLoc(
TypeLoc TL) {
5108 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
5115 switch (Chunk.
Kind) {
5120 llvm_unreachable(
"cannot be _Atomic qualified");
5153 if (isa<PackExpansionType>(T)) {
5181 if (ReturnTypeInfo) {
5201 "LocInfoType's TypeClass conflicts with an existing Type class");
5207 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
5208 " was used directly instead of getting the QualType through"
5209 " GetTypeFromParser");
5216 "Type name should have no identifier!");
5261 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_multiple_qualifiers);
5269 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_function_type);
5275 if (Attr.
getKind() == AttributeList::AT_AddressSpace) {
5278 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5284 llvm::APSInt addrSpace(32);
5287 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
5289 << ASArgExpr->getSourceRange();
5295 if (addrSpace.isSigned()) {
5296 if (addrSpace.isNegative()) {
5297 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_negative)
5298 << ASArgExpr->getSourceRange();
5302 addrSpace.setIsSigned(
false);
5304 llvm::APSInt
max(addrSpace.getBitWidth());
5306 if (addrSpace > max) {
5307 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_too_high)
5312 ASIdx =
static_cast<unsigned>(addrSpace.getZExtValue());
5316 case AttributeList::AT_OpenCLGlobalAddressSpace:
5318 case AttributeList::AT_OpenCLLocalAddressSpace:
5320 case AttributeList::AT_OpenCLConstantAddressSpace:
5322 case AttributeList::AT_OpenCLGenericAddressSpace:
5325 assert(Attr.
getKind() == AttributeList::AT_OpenCLPrivateAddressSpace);
5342 if (
const AttributedType *attr = dyn_cast<AttributedType>(type)) {
5346 type = attr->getModifiedType();
5349 }
else if (
const ParenType *paren = dyn_cast<ParenType>(type)) {
5350 type = paren->getInnerType();
5370 bool NonObjCPointer =
false;
5380 NonObjCPointer =
true;
5387 if (state.isProcessingDeclSpec()) {
5395 Sema &S = state.getSema();
5401 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
5409 if (II->
isStr(
"none"))
5411 else if (II->
isStr(
"strong"))
5413 else if (II->
isStr(
"weak"))
5415 else if (II->
isStr(
"autoreleasing"))
5418 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported)
5439 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
5446 if (previousLifetime != lifetime) {
5449 const Type *prevTy =
nullptr;
5450 while (!prevTy || prevTy != underlyingType.
Ty) {
5451 prevTy = underlyingType.
Ty;
5460 if (NonObjCPointer) {
5470 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
5494 if (!NonObjCPointer)
5509 diagnostic,
type, 0));
5511 S.
Diag(loc, diagnostic);
5520 unsigned diagnostic =
5521 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
5522 : diag::err_arc_weak_no_runtime);
5525 diagnoseOrDelay(S, AttrLoc, diagnostic, type);
5537 if (Class->isArcWeakrefUnavailable()) {
5538 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
5539 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
5540 diag::note_class_declared);
5556 Sema &S = state.getSema();
5565 S.
Diag(attr.
getLoc(), diag::err_attribute_multiple_objc_gc);
5572 S.
Diag(attr.
getLoc(), diag::err_attribute_argument_type)
5579 S.
Diag(attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5586 if (II->
isStr(
"weak"))
5588 else if (II->
isStr(
"strong"))
5591 S.
Diag(attr.
getLoc(), diag::warn_attribute_type_not_supported)
5619 struct FunctionTypeUnwrapper {
5634 FunctionTypeUnwrapper(
Sema &S,
QualType T) : Original(T) {
5637 if (isa<FunctionType>(Ty)) {
5638 Fn = cast<FunctionType>(Ty);
5640 }
else if (isa<ParenType>(Ty)) {
5641 T = cast<ParenType>(Ty)->getInnerType();
5642 Stack.push_back(Parens);
5643 }
else if (isa<PointerType>(Ty)) {
5644 T = cast<PointerType>(Ty)->getPointeeType();
5645 Stack.push_back(Pointer);
5646 }
else if (isa<BlockPointerType>(Ty)) {
5647 T = cast<BlockPointerType>(Ty)->getPointeeType();
5648 Stack.push_back(BlockPointer);
5649 }
else if (isa<MemberPointerType>(Ty)) {
5650 T = cast<MemberPointerType>(Ty)->getPointeeType();
5651 Stack.push_back(MemberPointer);
5652 }
else if (isa<ReferenceType>(Ty)) {
5653 T = cast<ReferenceType>(Ty)->getPointeeType();
5654 Stack.push_back(Reference);
5655 }
else if (isa<AttributedType>(Ty)) {
5656 T = cast<AttributedType>(Ty)->getEquivalentType();
5657 Stack.push_back(Attributed);
5671 bool isFunctionType()
const {
return (Fn !=
nullptr); }
5676 if (New ==
get())
return Original;
5679 return wrap(S.
Context, Original, 0);
5684 if (I ==
Stack.size())
5693 return wrap(C, SplitOld.
Ty, I);
5700 switch (static_cast<WrapKind>(
Stack[I++])) {
5707 return wrap(C, cast<AttributedType>(Old)->getEquivalentType(), I);
5710 QualType New = wrap(C, cast<ParenType>(Old)->getInnerType(), I);
5715 QualType New = wrap(C, cast<PointerType>(Old)->getPointeeType(), I);
5719 case BlockPointer: {
5720 QualType New = wrap(C, cast<BlockPointerType>(Old)->getPointeeType(),I);
5724 case MemberPointer: {
5733 if (isa<LValueReferenceType>(OldRef))
5740 llvm_unreachable(
"unknown wrapping kind");
5748 Sema &S = State.getSema();
5759 S.
Diag(Attr.
getLoc(), diag::warn_duplicate_attribute_exact)
5767 Kind == AttributeList::AT_Ptr64) ||
5769 Kind == AttributeList::AT_Ptr32)) {
5770 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5771 <<
"'__ptr32'" <<
"'__ptr64'";
5774 Kind == AttributeList::AT_UPtr) ||
5776 Kind == AttributeList::AT_SPtr)) {
5777 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5778 <<
"'__sptr'" <<
"'__uptr'";
5788 if (!isa<PointerType>(Desugared)) {
5790 S.
Diag(Attr.
getLoc(), diag::err_attribute_no_member_pointers)
5793 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
5800 default: llvm_unreachable(
"Unknown attribute kind");
5814 bool isContextSensitive) {
5825 <<
static_cast<unsigned>(fileNullability.
PointerKind);
5834 while (
auto attributed = dyn_cast<AttributedType>(desugared.
getTypePtr())) {
5836 if (
auto existingNullability = attributed->getImmediateNullability()) {
5838 if (nullability == *existingNullability) {
5839 Diag(nullabilityLoc, diag::warn_nullability_duplicate)
5847 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5853 desugared = attributed->getModifiedType();
5861 if (nullability != *existingNullability) {
5862 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5870 if (
auto typedefNullability
5872 if (*typedefNullability == *existingNullability) {
5873 Diag(typedefDecl->getLocation(), diag::note_nullability_here)
5885 Diag(nullabilityLoc, diag::err_nullability_nonpointer)
5892 if (isContextSensitive) {
5898 Diag(nullabilityLoc, diag::err_nullability_cs_multilevel)
5901 Diag(nullabilityLoc, diag::note_nullability_type_specifier)
5925 Diag(loc, diag::err_objc_kindof_nonobject)
5934 objType->getBaseType(), objType->getTypeArgsAsWritten(),
5935 objType->getProtocols(),
5936 objType->isObjCUnqualifiedId() ?
false :
true);
5958 case AttributeList::AT_TypeNonNull:
5961 case AttributeList::AT_TypeNullable:
5964 case AttributeList::AT_TypeNullUnspecified:
5968 llvm_unreachable(
"not a nullability attribute kind");
5981 Declarator &declarator = state.getDeclarator();
5984 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
5997 PK_MemberFunctionPointer,
6002 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
6004 auto diag = state.getSema().Diag(attr.
getLoc(),
6005 diag::warn_nullability_declspec)
6009 << static_cast<unsigned>(pointerKind);
6015 state.getSema().getPreprocessor()
6016 .getLocForEndOfToken(chunk.
Loc),
6027 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
6029 switch (chunk.
Kind) {
6033 return moveToChunk(chunk,
false);
6045 return moveToChunk(*dest,
true);
6064 llvm_unreachable(
"not a calling convention attribute");
6065 case AttributeList::AT_CDecl:
6067 case AttributeList::AT_FastCall:
6069 case AttributeList::AT_StdCall:
6071 case AttributeList::AT_ThisCall:
6073 case AttributeList::AT_Pascal:
6075 case AttributeList::AT_SwiftCall:
6077 case AttributeList::AT_VectorCall:
6079 case AttributeList::AT_Pcs: {
6085 Str = cast<StringLiteral>(Attr.
getArgAsExpr(0))->getString();
6088 return llvm::StringSwitch<AttributedType::Kind>(Str)
6092 case AttributeList::AT_IntelOclBicc:
6094 case AttributeList::AT_MSABI:
6096 case AttributeList::AT_SysVABI:
6098 case AttributeList::AT_PreserveMost:
6100 case AttributeList::AT_PreserveAll:
6103 llvm_unreachable(
"unexpected attribute kind!");
6111 Sema &S = state.getSema();
6113 FunctionTypeUnwrapper unwrapped(S, type);
6115 if (attr.
getKind() == AttributeList::AT_NoReturn) {
6120 if (!unwrapped.isFunctionType())
6131 if (attr.
getKind() == AttributeList::AT_NSReturnsRetained) {
6133 "ns_returns_retained treated as type attribute in non-ARC");
6137 if (!unwrapped.isFunctionType())
6141 = unwrapped.get()->getExtInfo().withProducesResult(
true);
6146 if (attr.
getKind() == AttributeList::AT_Regparm) {
6152 if (!unwrapped.isFunctionType())
6159 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6167 unwrapped.get()->getExtInfo().withRegParm(value);
6173 if (!unwrapped.isFunctionType())
return false;
6189 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6207 unsigned DiagID = diag::err_cconv_varargs;
6211 bool IsInvalid =
true;
6213 DiagID = diag::warn_cconv_varargs;
6225 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6238 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
6249 if (AT->isCallingConv())
6251 R = AT->getModifiedType().IgnoreParens();
6258 FunctionTypeUnwrapper Unwrapped(*
this, T);
6260 bool IsVariadic = (isa<FunctionProtoType>(FT) &&
6261 cast<FunctionProtoType>(FT)->isVariadic());
6274 Diag(Loc, diag::warn_cconv_structors)
6284 if (CurCC != DefaultCC || DefaultCC == ToCC)
6292 QualType Wrapped = Unwrapped.wrap(*
this, FT);
6307 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6313 llvm::APSInt vecSize(32);
6316 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6318 << sizeExpr->getSourceRange();
6326 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6332 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue() * 8);
6335 if (vectorSize % typeSize) {
6336 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_size)
6337 << sizeExpr->getSourceRange();
6342 S.
Diag(Attr.
getLoc(), diag::err_attribute_size_too_large)
6343 << sizeExpr->getSourceRange();
6347 if (vectorSize == 0) {
6348 S.
Diag(Attr.
getLoc(), diag::err_attribute_zero_size)
6349 << sizeExpr->getSourceRange();
6367 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6386 sizeExpr = Size.
get();
6407 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
6408 Triple.getArch() == llvm::Triple::aarch64_be;
6410 if (IsPolyUnsigned) {
6412 return BTy->
getKind() == BuiltinType::UChar ||
6413 BTy->
getKind() == BuiltinType::UShort ||
6414 BTy->
getKind() == BuiltinType::ULong ||
6415 BTy->
getKind() == BuiltinType::ULongLong;
6418 return BTy->
getKind() == BuiltinType::SChar ||
6419 BTy->
getKind() == BuiltinType::Short;
6425 bool Is64Bit = Triple.getArch() == llvm::Triple::aarch64 ||
6426 Triple.getArch() == llvm::Triple::aarch64_be;
6428 if (Is64Bit && BTy->
getKind() == BuiltinType::Double)
6431 return BTy->
getKind() == BuiltinType::SChar ||
6432 BTy->
getKind() == BuiltinType::UChar ||
6433 BTy->
getKind() == BuiltinType::Short ||
6434 BTy->
getKind() == BuiltinType::UShort ||
6435 BTy->
getKind() == BuiltinType::Int ||
6436 BTy->
getKind() == BuiltinType::UInt ||
6437 BTy->
getKind() == BuiltinType::Long ||
6438 BTy->
getKind() == BuiltinType::ULong ||
6439 BTy->
getKind() == BuiltinType::LongLong ||
6440 BTy->
getKind() == BuiltinType::ULongLong ||
6441 BTy->
getKind() == BuiltinType::Float ||
6442 BTy->
getKind() == BuiltinType::Half;
6463 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6470 llvm::APSInt numEltsInt(32);
6473 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6475 << numEltsExpr->getSourceRange();
6481 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6488 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
6489 unsigned vecSize = typeSize * numElts;
6490 if (vecSize != 64 && vecSize != 128) {
6491 S.
Diag(Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
6504 S.
Diag(Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
6510 QualType PointeeTy = TypedefTy->desugar();
6511 S.
Diag(Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
6513 std::string PrevAccessQual;
6515 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6516 case BuiltinType::Id: \
6517 PrevAccessQual = #Access; \
6519 #include "clang/Basic/OpenCLImageTypes.def"
6521 assert(0 &&
"Unable to find corresponding image type.");
6524 S.
Diag(TypedefTy->getDecl()->getLocStart(),
6525 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
6536 bool hasOpenCLAddressSpace =
false;
6552 state.getSema().Diag(attr.
getLoc(),
6553 diag::warn_cxx11_gnu_attribute_on_type)
6570 state.getSema().Diag(attr.
getLoc(), diag::err_attribute_not_type_attr)
6578 state.getSema().Diag(attr.
getLoc(),
6579 diag::warn_unknown_attribute_ignored)
6586 case AttributeList::AT_MayAlias:
6591 case AttributeList::AT_OpenCLPrivateAddressSpace:
6592 case AttributeList::AT_OpenCLGlobalAddressSpace:
6593 case AttributeList::AT_OpenCLLocalAddressSpace:
6594 case AttributeList::AT_OpenCLConstantAddressSpace:
6595 case AttributeList::AT_OpenCLGenericAddressSpace:
6596 case AttributeList::AT_AddressSpace:
6599 hasOpenCLAddressSpace =
true;
6606 case AttributeList::AT_VectorSize:
6610 case AttributeList::AT_ExtVectorType:
6614 case AttributeList::AT_NeonVectorType:
6619 case AttributeList::AT_NeonPolyVectorType:
6624 case AttributeList::AT_OpenCLAccess:
6641 if (state.getSema().checkNullabilityTypeSpecifier(
6653 case AttributeList::AT_ObjCKindOf:
6661 state.getSema().Diag(attr.
getLoc(),
6662 diag::err_objc_kindof_wrong_position)
6665 state.getDeclarator().getDeclSpec().getLocStart(),
"__kindof ");
6670 if (state.getSema().checkObjCKindOfType(type, attr.
getLoc()))
6675 case AttributeList::AT_NSReturnsRetained:
6676 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
6704 if (state.getSema().getLangOpts().OpenCLVersion >= 200 &&
6708 if (state.getCurrentChunkIndex() > 0 &&
6711 type = state.getSema().Context.getAddrSpaceQualType(
6713 }
else if (state.getCurrentChunkIndex() == 0 &&
6718 type = state.getSema().Context.getAddrSpaceQualType(
6720 else if (state.getCurrentChunkIndex() == 0 &&
6723 type = state.getSema().Context.getAddrSpaceQualType(
6730 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
6735 Var->getMemberSpecializationInfo()) {
6737 if (MSInfo->getPointOfInstantiation().isInvalid()) {
6738 MSInfo->setPointOfInstantiation(PointOfInstantiation);
6743 L->StaticDataMemberInstantiated(Var);
6747 cast<VarTemplateSpecializationDecl>(Var);
6828 if (RequireCompleteTypeImpl(Loc, T, &Diagnoser))
6831 if (!Tag->getDecl()->isCompleteDefinitionRequired()) {
6832 Tag->getDecl()->setCompleteDefinitionRequired();
6849 bool OnlyNeedComplete) {
6856 if (isa<TagDecl>(D) && cast<TagDecl>(D)->isBeingDefined()) {
6860 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6861 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
6863 D = RD->getDefinition();
6864 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
6865 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
6867 if (OnlyNeedComplete && ED->isFixed()) {
6871 *Suggested =
nullptr;
6872 for (
auto *Redecl : ED->redecls()) {
6875 if (Redecl->isThisDeclarationADefinition() ||
6876 (Redecl->isCanonicalDecl() && !*Suggested))
6877 *Suggested = Redecl;
6881 D = ED->getDefinition();
6883 assert(D &&
"missing definition for pattern of instantiated definition");
6892 Source->CompleteRedeclChain(D);
6902 if (!RD->hasAttr<MSInheritanceAttr>()) {
6903 MSInheritanceAttr::Spelling IM;
6910 IM = MSInheritanceAttr::Keyword_single_inheritance;
6913 IM = MSInheritanceAttr::Keyword_multiple_inheritance;
6916 IM = MSInheritanceAttr::Keyword_unspecified_inheritance;
6920 RD->addAttr(MSInheritanceAttr::CreateImplicit(
6933 TypeDiagnoser *Diagnoser) {
6946 if (!MPTy->getClass()->isDependentType()) {
6958 if (Def && !isa<EnumDecl>(Def))
6973 return !TreatAsComplete;
6998 if (D->isInvalidDecl())
7004 Source->CompleteType(Tag->
getDecl());
7006 Source->CompleteType(IFace->getDecl());
7011 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
7021 MaybeTemplate = Array->getElementType();
7023 bool Instantiated =
false;
7024 bool Diagnosed =
false;
7026 = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
7027 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
7031 Instantiated =
true;
7034 = dyn_cast<CXXRecordDecl>(Record->getDecl())) {
7036 if (!Rec->isBeingDefined() && Pattern) {
7038 assert(MSI &&
"Missing member specialization information?");
7046 Instantiated =
true;
7054 if (Diagnoser && Diagnosed)
7060 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
7070 Diagnoser->diagnose(*
this, Loc, T);
7074 if (Tag && !Tag->
getDecl()->isInvalidDecl())
7077 : diag::note_forward_declaration)
7081 if (IFace && !IFace->getDecl()->isInvalidDecl())
7082 Diag(IFace->getDecl()->getLocation(), diag::note_forward_class);
7108 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
7161 Diag(RD->getLocation(), diag::note_non_literal_virtual_base)
7163 for (
const auto &I : RD->
vbases())
7164 Diag(I.getLocStart(), diag::note_constexpr_virtual_base_here)
7165 << I.getSourceRange();
7168 Diag(RD->getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
7170 for (
const auto &I : RD->
bases()) {
7171 if (!I.getType()->isLiteralType(
Context)) {
7172 Diag(I.getLocStart(),
7173 diag::note_non_literal_base_class)
7174 << RD << I.getType() << I.getSourceRange();
7178 for (
const auto *I : RD->
fields()) {
7179 if (!I->getType()->isLiteralType(
Context) ||
7180 I->getType().isVolatileQualified()) {
7181 Diag(I->getLocation(), diag::note_non_literal_field)
7182 << RD << I << I->getType()
7183 << I->getType().isVolatileQualified();
7191 assert(Dtor &&
"class has literal fields and bases but no dtor?");
7196 diag::note_non_literal_user_provided_dtor :
7197 diag::note_non_literal_nontrivial_dtor) << RD;
7233 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
7260 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl()))
7261 return VD->getType();
7262 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
7263 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
7264 return FD->getType();
7265 }
else if (
const ObjCIvarRefExpr *IR = dyn_cast<ObjCIvarRefExpr>(E)) {
7266 return IR->getDecl()->getType();
7268 if (PR->isExplicitProperty())
7269 return PR->getExplicitProperty()->getType();
7270 }
else if (
auto *PE = dyn_cast<PredefinedExpr>(E)) {
7271 return PE->getType();
7281 using namespace sema;
7283 if (isa<ParenExpr>(E)) {
7285 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
7313 bool AsUnevaluated) {
7322 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
7334 Diag(Loc, diag::err_only_enums_have_underlying_types);
7343 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
7344 Diag(FwdDecl->getLocation(), diag::note_forward_declaration) << FwdDecl;
7349 assert(ED &&
"EnumType has no EnumDecl");
7354 assert(!Underlying.
isNull());
7360 llvm_unreachable(
"unknown unary transform type");
7370 int DisallowedKind = -1;
7385 if (DisallowedKind != -1) {
7386 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.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
Helper for figuring out the default CC for a function declarator type.
bool CheckNoReturnAttr(const AttributeList &attr)
unsigned getAddressSpace() const
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
Get the outermost AttributedType node that sets a calling convention.
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...
unsigned UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
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.
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()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue 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)
isOmittedBlockReturnType - Return true if this declarator is missing a return type because this is a ...
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.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getRestrictSpecLoc() const
A (possibly-)qualified type.
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.
ExtInfo withCallingConv(CallingConv cc) const
TSW getTypeSpecWidth() const
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
Distribute an objc_gc type attribute that was written on the declarator.
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)
__auto_type (GNU extension)
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
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
#define CALLING_CONV_ATTRS_CASELIST
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
void setKWLoc(SourceLocation Loc)
The attribute is immediately after the declaration's name.
void setRParenLoc(SourceLocation Loc)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
void setStarLoc(SourceLocation Loc)
NullabilityKind
Describes the nullability of a particular type.
FunctionType - C99 6.7.5.3 - Function Declarators.
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
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type or a dependent type that could instantiate to any kind of pointer type.
void setEmbeddedInDeclarator(bool isInDeclarator)
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Qualifiers::GC getObjCGCAttr() const
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
Return true if this is a literal type (C++11 [basic.types]p10)
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++14 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...
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, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
QualType getPointeeType() const
The base class of the type hierarchy.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator)
Classify the given declarator, whose type-specified is type, based on what kind of pointer it refers ...
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
Gets the type pointed to by this ObjC pointer.
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
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
TypeLoc getNextTypeLoc() const
bool isSpelledAsLValue() const
QualType getPipeType(QualType T) const
Return pipe type for the specified type.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
#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)
Check the application of the Objective-C '__kindof' qualifier to the given type.
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.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
static DeclaratorChunk * maybeMovePastReturnType(Declarator &declarator, unsigned i, bool onlyBlockPointers)
Given the index of a declarator chunk, check whether that chunk directly specifies the return type of...
static 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
Extra information about a function prototype.
CallingConv getCallConv() const
std::string getAsString() 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)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
static bool handleFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
Process an individual function attribute.
OpenCLOptions & getOpenCLOptions()
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs, typeofs, etc., as well as any qualifiers.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
The collection of all-type qualifiers we support.
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::*.
RecordDecl - Represents a struct/union/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...
One of these records is kept for each identifier that is lexed.
void setLocalRangeEnd(SourceLocation L)
static bool checkQualifiedFunction(Sema &S, QualType T, SourceLocation Loc, QualifiedFunctionKind QFK)
Check whether the type T is a qualified function type, and if it is, diagnose that it cannot be conta...
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
ParameterABI getABI() const
Return the ABI treatment of this parameter.
static void distributeFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
A function type attribute was written somewhere in a declaration other than on the declarator itself ...
static const TST TST_decimal32
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Represents a class type in Objective C.
AttributeList * getList() const
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.
bool isTypeSpecPipe() const
ArrayRef< QualType > getParamTypes() const
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
QualType BuildParenType(QualType T)
Build a paren type including T.
void setBuiltinLoc(SourceLocation Loc)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
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)
Distribute a nullability type attribute that cannot be applied to the type specifier to a pointer...
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...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
bool isAnyPointerType() const
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type...
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
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)
diagnoseBadTypeAttribute - Diagnoses a type attribute which doesn't apply to the given type...
void setElaboratedKeywordLoc(SourceLocation Loc)
static std::string getPrintableNameForEntity(DeclarationName Entity)
TagKind getTagKind() const
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
static const TST TST_error
TypeLoc getValueLoc() const
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
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes...
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type...
SourceLocation getTypeSpecTypeLoc() const
SourceLocation getLocStart() const LLVM_READONLY
static const TSW TSW_unspecified
void copy(DependentTemplateSpecializationTypeLoc Loc)
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...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
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)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
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)
Given that this is the declaration of a parameter under ARC, attempt to infer attributes and such for...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly...
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
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)
HandleVectorSizeAttribute - this attribute is only applicable to integral and float scalars...
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)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
static bool hasDirectOwnershipQualifier(QualType type)
Does this type have a "direct" ownership qualifier? That is, is it written like "__strong id"...
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
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
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
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)
TypeDecl - Represents a declaration of a type.
An implicit 'self' parameter.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
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...
Scope - A scope is a transient data structure that is used while parsing the program.
Wrapper for source info for ObjC interfaces.
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
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
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
#define MS_TYPE_ATTRS_CASELIST
void setUnaligned(bool flag)
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.
void copy(ElaboratedTypeLoc Loc)
SourceLocation getLocStart() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
void setInvalid(bool b=true) const
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
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.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
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)
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
uint8_t PointerKind
Which kind of pointer declarator we saw.
This object can be modified without requiring retains or releases.
SourceRange getRange() const
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)
Pushes space for a new TypeLoc of the given type.
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()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
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)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type...
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
TST getTypeSpecType() const
Represents a prototype with parameter type info, e.g.
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.
static void checkExtParameterInfos(Sema &S, ArrayRef< QualType > paramTypes, const FunctionProtoType::ExtProtoInfo &EPI, llvm::function_ref< SourceLocation(unsigned)> getParamLoc)
Check the extended parameter information.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
ArraySizeModifier
Capture whether this is a normal array (e.g.
std::vector< bool > & Stack
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/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)
Check whether a nullability type specifier can be added to the given type.
unsigned NumExceptions
NumExceptions - This is the number of types in the dynamic-exception- decl, if the function has one...
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
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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.
unsigned hasStatic
True if this dimension included the 'static' keyword.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
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...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
StringRef getName() const
Return the actual identifier string.
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)
Retrieve the attribute kind corresponding to the given nullability kind.
Declaration of a template type parameter.
TypeSpecifierWidth getWrittenWidthSpec() const
bool isFunctionDefinition() const
static void HandleOpenCLAccessAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
Handle OpenCL Access Qualifier Attribute.
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.
TranslationUnitDecl * getTranslationUnitDecl() const
QualType BuildAtomicType(QualType T, SourceLocation Loc)
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
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)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ExtProtoInfo getExtProtoInfo() const
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void HandleNeonVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S, VectorType::VectorKind VecKind)
HandleNeonVectorTypeAttr - The "neon_vector_type" and "neon_polyvector_type" attributes are used ...
void completeExprArrayBound(Expr *E)
SourceLocation getVolatileSpecLoc() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
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.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
enum clang::DeclaratorChunk::@185 Kind
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)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
bool isConstexprSpecified() const
CanQualType UnsignedInt128Ty
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
void setNameLoc(SourceLocation Loc)
ASTMutationListener * getASTMutationListener() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
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.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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)
A function type attribute was written in the decl spec.
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.
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
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
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
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.
This template specialization was implicitly instantiated from a template.
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())
static StringRef getImageAccessAttrStr(AttributeList *attrs)
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
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
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.
static bool checkOmittedBlockReturnType(Sema &S, Declarator &declarator, QualType Result)
Return true if this is omitted block return type.
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.
bool isPrototypeContext() const
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
A parameter attribute which changes the argument-passing ABI rule for the parameter.
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)
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
TypeLoc getValueLoc() const
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
The attribute is in the decl-specifier-seq.
void setKNRPromoted(bool promoted)
static bool distributeFunctionTypeAttrToInnermost(TypeProcessingState &state, AttributeList &attr, AttributeList *&attrList, QualType &declSpecType)
Try to distribute a function type attribute to the innermost function chunk or type.
static bool isPermittedNeonBaseType(QualType &Ty, VectorType::VectorKind VecKind, Sema &S)
const ExtParameterInfo * ExtParameterInfos
Encodes a location in the source.
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static const TST TST_auto_type
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
PointerDeclaratorKind
Describes the kind of a pointer a declarator describes.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Interfaces are the core concept in Objective-C for object oriented design.
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isBuiltinType() const
Helper methods to distinguish type categories.
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
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
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 if D has a visible definition.
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
const ConstantArrayType * getAsConstantArrayType(QualType T) const
MemberPointerTypeInfo Mem
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
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.
SimplePointerKind
A simple notion of pointer kinds, which matches up with the various pointer declarators.
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
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
static bool isBlockPointer(Expr *Arg)
const FileInfo & getFile() const
is AltiVec 'vector bool ...'
SourceLocation getUnalignedSpecLoc() const
static const TST TST_typeofType
SourceLocation getBegin() const
void setAmpLoc(SourceLocation Loc)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
bool isArgExpr(unsigned Arg) const
void setLBracketLoc(SourceLocation Loc)
AttributeList *& getAttrListRef()
IdentifierInfo * getScopeName() const
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
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/__unaligned/_Atomic.
static bool isVectorSizeTooLarge(unsigned NumElements)
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool isStaticMember()
Returns true if this declares a static member.
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.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
SourceLocation getExceptionSpecLocBeg() const
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
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)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
CanQualType UnsignedShortTy
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
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)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
static const TSS TSS_unspecified
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void setAmpAmpLoc(SourceLocation Loc)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
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
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
SourceLocation getTypeSpecTypeNameLoc() const
static const TST TST_int128
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
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).
The maximum supported address space number.
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
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.
CallingConv getCC() const
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.
EnumDecl - Represents an enum.
#define FUNCTION_TYPE_ATTRS_CASELIST
static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal)
Check whether the specified array size makes the array type a VLA.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
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
bool isFirstDeclarator() const
void setNameLoc(SourceLocation Loc)
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
Represents a pointer to an Objective C object.
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)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
Syntax
The style used to specify an attribute.
bool isObjCObjectType() const
void setAttrEnumOperandLoc(SourceLocation loc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
TypeSpecifierSign getWrittenSignSpec() const
IdentifierInfo * getName() const
static const TST TST_decimal128
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
unsigned getTypeQuals() const
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
#define OBJC_POINTER_TYPE_ATTRS_CASELIST
CanQualType UnsignedLongTy
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
void setNext(AttributeList *N)
UnqualTypeLoc getUnqualifiedLoc() const
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
bool isFunctionType() const
QualType BuildPipeType(QualType T, SourceLocation Loc)
Build a Pipe type.
static const TST TST_typename
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Base for LValueReferenceType and RValueReferenceType.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
llvm::StringRef getParameterABISpelling(ParameterABI kind)
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)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
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)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
QualType getPointeeType() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, DeclaratorChunk &DeclType, QualType RT)
Produce an appropriate diagnostic for an ambiguity between a function declarator and a C++ direct-ini...
IdentifierInfo * getIdentifier() const
static bool hasNullabilityAttr(const AttributeList *attrs)
Check whether there is a nullability attribute of any kind in the given attribute list...
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)
Describes whether we've seen any nullability information for the given file.
bool CheckRegparmAttr(const AttributeList &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
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...
QualType getTypeOfExprType(Expr *e) const
GCC extension.
An attributed type is a type to which a type attribute has been applied.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
void setKWLoc(SourceLocation Loc)
unsigned TypeQuals
For now, sema will catch these as invalid.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
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".
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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...
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
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.
static const TST TST_float128
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.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
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...
This class is used for builtin types like 'int'.
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
SourceLocation getRParenLoc() const
static void HandleAddressSpaceTypeAttribute(QualType &Type, const AttributeList &Attr, Sema &S)
HandleAddressSpaceTypeAttribute - Process an address_space attribute on the specified type...
bool isTypeSpecOwned() const
Defines the clang::TargetInfo interface.
SourceLocation getTypeSpecWidthLoc() const
A SourceLocation and its associated SourceManager.
static Qualifiers fromCVRMask(unsigned CVR)
static const TSW TSW_longlong
TagDecl * getDecl() const
bool isIncompleteArrayType() const
static Decl::Kind getKind(const Decl *D)
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.
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.
bool isSet() const
Deprecated.
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 initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
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.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
NamedDecl - This represents a decl with a name.
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)
QualifiedFunctionKind
Kinds of declarator that cannot contain a qualified function type.
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)
A function type attribute was written on the declarator.
const Type * getClass() const
static void spliceAttrIntoList(AttributeList &attr, AttributeList *&head)
bool isNull() const
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)
Pushes a copy of the given TypeLoc onto this builder.
void setType(QualType newType)
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Wrapper for source info for block pointers.
bool isTypeAltiVecPixel() const
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
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.
A class which abstracts out some details necessary for making a call.
AttributeList *& getListRef()
Returns a reference to the attribute list.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
Given that an objc_gc attribute was written somewhere on a declaration other than on the declarator i...
This parameter (which must have pointer type) is a Swift indirect result parameter.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
QualType BuildTypeofExprType(Expr *E, SourceLocation Loc)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
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
Return true if this is an incomplete or object type, in other words, not a function type...
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?