34 #include "llvm/ADT/SmallPtrSet.h" 35 #include "llvm/ADT/SmallString.h" 36 #include "llvm/ADT/StringSwitch.h" 37 #include "llvm/Support/ErrorHandling.h" 39 using namespace clang;
69 bool useExpansionLoc =
true;
71 case AttributeList::AT_ObjCGC: WhichType =
TDS_Pointer;
break;
76 useExpansionLoc =
false;
86 if (useExpansionLoc && loc.
isMacroID() && II) {
87 if (II->
isStr(
"strong")) {
89 }
else if (II->
isStr(
"weak")) {
94 S.
Diag(loc, diag::warn_type_attribute_wrong_type) << name << WhichType
100 #define OBJC_POINTER_TYPE_ATTRS_CASELIST \ 101 case AttributeList::AT_ObjCGC: \ 102 case AttributeList::AT_ObjCOwnership 105 #define CALLING_CONV_ATTRS_CASELIST \ 106 case AttributeList::AT_CDecl: \ 107 case AttributeList::AT_FastCall: \ 108 case AttributeList::AT_StdCall: \ 109 case AttributeList::AT_ThisCall: \ 110 case AttributeList::AT_RegCall: \ 111 case AttributeList::AT_Pascal: \ 112 case AttributeList::AT_SwiftCall: \ 113 case AttributeList::AT_VectorCall: \ 114 case AttributeList::AT_MSABI: \ 115 case AttributeList::AT_SysVABI: \ 116 case AttributeList::AT_Pcs: \ 117 case AttributeList::AT_IntelOclBicc: \ 118 case AttributeList::AT_PreserveMost: \ 119 case AttributeList::AT_PreserveAll 122 #define FUNCTION_TYPE_ATTRS_CASELIST \ 123 case AttributeList::AT_NSReturnsRetained: \ 124 case AttributeList::AT_NoReturn: \ 125 case AttributeList::AT_Regparm: \ 126 case AttributeList::AT_AnyX86NoCallerSavedRegisters: \ 127 CALLING_CONV_ATTRS_CASELIST 130 #define MS_TYPE_ATTRS_CASELIST \ 131 case AttributeList::AT_Ptr32: \ 132 case AttributeList::AT_Ptr64: \ 133 case AttributeList::AT_SPtr: \ 134 case AttributeList::AT_UPtr 137 #define NULLABILITY_TYPE_ATTRS_CASELIST \ 138 case AttributeList::AT_TypeNonNull: \ 139 case AttributeList::AT_TypeNullable: \ 140 case AttributeList::AT_TypeNullUnspecified 145 class TypeProcessingState {
171 : sema(sema), declarator(declarator),
173 trivial(
true), hasSavedAttrs(
false) {}
175 Sema &getSema()
const {
183 bool isProcessingDeclSpec()
const {
187 unsigned getCurrentChunkIndex()
const {
191 void setCurrentChunkIndex(
unsigned idx) {
197 if (isProcessingDeclSpec())
198 return getMutableDeclSpec().getAttributes().getListRef();
203 void saveDeclSpecAttrs() {
205 if (hasSavedAttrs)
return;
207 DeclSpec &spec = getMutableDeclSpec();
210 savedAttrs.push_back(attr);
211 trivial &= savedAttrs.empty();
212 hasSavedAttrs =
true;
218 ignoredTypeAttrs.push_back(&attr);
224 for (
auto *
Attr : ignoredTypeAttrs)
228 ~TypeProcessingState() {
231 restoreDeclSpecAttrs();
235 DeclSpec &getMutableDeclSpec()
const {
239 void restoreDeclSpecAttrs() {
240 assert(hasSavedAttrs);
242 if (savedAttrs.empty()) {
243 getMutableDeclSpec().getAttributes().set(
nullptr);
247 getMutableDeclSpec().getAttributes().set(savedAttrs[0]);
248 for (
unsigned i = 0, e = savedAttrs.size() - 1; i != e; ++i)
249 savedAttrs[i]->setNext(savedAttrs[i+1]);
250 savedAttrs.back()->setNext(
nullptr);
268 assert(cur && cur->
getNext() &&
"ran out of attrs?");
314 if (attr.
getKind() == AttributeList::AT_ObjCGC)
316 assert(attr.
getKind() == AttributeList::AT_ObjCOwnership);
331 bool onlyBlockPointers) {
337 for (; i != 0; --i) {
339 switch (fnChunk.
Kind) {
355 for (--i; i != 0; --i) {
357 switch (ptrChunk.
Kind) {
367 if (onlyBlockPointers)
376 llvm_unreachable(
"bad declarator chunk kind");
382 llvm_unreachable(
"bad declarator chunk kind");
400 Declarator &declarator = state.getDeclarator();
403 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
405 switch (chunk.
Kind) {
411 if (state.isProcessingDeclSpec() &&
412 attr.
getKind() == AttributeList::AT_ObjCOwnership)
415 if (!destChunk) destChunk = &chunk;
428 if (state.isProcessingDeclSpec() &&
429 attr.
getKind() == AttributeList::AT_ObjCOwnership) {
434 dest->getAttrListRef());
458 Declarator &declarator = state.getDeclarator();
462 unsigned innermost = -1U;
463 bool considerDeclSpec =
true;
466 switch (chunk.
Kind) {
480 considerDeclSpec =
false;
488 if (considerDeclSpec) {
493 state.saveDeclSpecAttrs();
502 if (innermost != -1U) {
510 state.addIgnoredTypeAttr(attr);
520 Declarator &declarator = state.getDeclarator();
524 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
526 switch (chunk.
Kind) {
554 Declarator &declarator = state.getDeclarator();
574 state.saveDeclSpecAttrs();
581 state.getDeclarator().getAttrListRef());
587 state.getCurrentAttrListRef(),
593 state.addIgnoredTypeAttr(attr);
602 Declarator &declarator = state.getDeclarator();
613 state.addIgnoredTypeAttr(attr);
628 assert(state.getDeclarator().getAttributes() &&
"declarator has no attrs!");
636 if (attr->isCXX11Attribute())
639 switch (attr->getKind()) {
656 case AttributeList::AT_ObjCKindOf:
662 }
while ((attr = next));
669 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)
888 << (unsigned)typeArgs.size()
906 assert(anyPackExpansions &&
"Too many arguments?");
915 if (typeArgObjC->isObjCIdType()) {
918 if (boundObjC->isObjCIdType())
927 diag::err_objc_type_arg_does_not_match_bound)
944 assert(anyPackExpansions &&
"Too many arguments?");
955 diag::err_objc_type_arg_does_not_match_bound)
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())
988 << (unsigned)finalTypeArgs.size()
989 << (unsigned)numTypeParams;
1010 if (!Protocols.empty()) {
1016 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
1017 if (FailOnError) Result =
QualType();
1019 if (FailOnError && Result.
isNull())
1037 if (!TypeArgs.empty()) {
1042 if (FailOnError && Result.
isNull())
1046 if (!Protocols.empty()) {
1051 Diag(Loc, diag::err_invalid_protocol_qualifiers)
1052 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
1053 if (FailOnError) Result =
QualType();
1055 if (FailOnError && Result.
isNull())
1082 auto ObjCObjectTL = ObjCObjectPointerTL.getPointeeLoc()
1092 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
1093 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
1094 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
1095 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
1098 return CreateParsedType(Result, ResultTInfo);
1113 QualType T = GetTypeFromParser(BaseType, &BaseTypeInfo);
1123 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
1125 QualType TypeArg = GetTypeFromParser(TypeArgs[i], &TypeArgInfo);
1127 ActualTypeArgInfos.clear();
1131 assert(TypeArgInfo &&
"No type source info?");
1132 ActualTypeArgInfos.push_back(TypeArgInfo);
1138 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
1142 ProtocolLocs, ProtocolRAngleLoc,
1157 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
1162 if (OTPTL.getNumProtocols() > 0) {
1163 assert(OTPTL.getNumProtocols() == Protocols.size());
1164 OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1165 OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1166 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1167 OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
1171 return CreateParsedType(Result, ResultTInfo);
1177 if (ObjCObjectTL.getNumTypeArgs() > 0) {
1178 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
1180 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
1181 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
1182 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
1189 if (ObjCObjectTL.getNumProtocols() > 0) {
1190 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
1191 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1192 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1193 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1194 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
1201 ObjCObjectTL.setHasBaseTypeAsWritten(
true);
1202 if (ObjCObjectTL.getType() ==
T)
1203 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
1205 ObjCObjectTL.getBaseLoc().initialize(Context, Loc);
1208 return CreateParsedType(Result, ResultTInfo);
1217 if (Attr.
getKind() == AttributeList::AT_OpenCLAccess) {
1218 return static_cast<OpenCLAccessAttr::Spelling
>(
1223 return OpenCLAccessAttr::Keyword_read_only;
1236 Sema &S = state.getSema();
1237 Declarator &declarator = state.getDeclarator();
1257 "Unknown TSS value");
1271 "Unknown TSS value");
1280 "Unknown TSS value");
1285 "Unknown TSS value");
1317 S.
Diag(DeclLoc, diag::ext_missing_declspec)
1327 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1335 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1339 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1359 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1378 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1417 Result = Context.
IntTy;
1428 Result = Context.
IntTy;
1451 "Can't handle qualifiers on typedef names yet!");
1453 if (Result.isNull()) {
1463 assert(!Result.isNull() &&
"Didn't get a type for typeof?");
1464 if (!Result->isDependentType())
1472 assert(E &&
"Didn't get an expression for typeof?");
1475 if (Result.isNull()) {
1476 Result = Context.
IntTy;
1483 assert(E &&
"Didn't get an expression for decltype?");
1486 if (Result.isNull()) {
1487 Result = Context.
IntTy;
1494 assert(!Result.isNull() &&
"Didn't get a type for __underlying_type?");
1498 if (Result.isNull()) {
1499 Result = Context.
IntTy;
1523 assert(!Result.isNull() &&
"Didn't get a type for _Atomic?");
1525 if (Result.isNull()) {
1526 Result = Context.
IntTy;
1531 #define GENERIC_IMAGE_TYPE(ImgType, Id) \ 1532 case DeclSpec::TST_##ImgType##_t: \ 1533 switch (getImageAccess(DS.getAttributes().getList())) { \ 1534 case OpenCLAccessAttr::Keyword_write_only: \ 1535 Result = Context.Id##WOTy; break; \ 1536 case OpenCLAccessAttr::Keyword_read_write: \ 1537 Result = Context.Id##RWTy; break; \ 1538 case OpenCLAccessAttr::Keyword_read_only: \ 1539 Result = Context.Id##ROTy; break; \ 1542 #include "clang/Basic/OpenCLImageTypes.def" 1545 Result = Context.
IntTy;
1552 declarator.setInvalidType(
true);
1557 S.
Diag(DS.getTypeSpecComplexLoc(), diag::ext_freestanding_complex);
1559 }
else if (DS.isTypeAltiVecVector()) {
1561 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1563 if (DS.isTypeAltiVecPixel())
1565 else if (DS.isTypeAltiVecBool())
1572 S.
Diag(DS.getTypeSpecComplexLoc(), diag::err_imaginary_not_supported);
1583 if (!DS.isTypeSpecPipe())
1587 if (
unsigned TypeQuals = DS.getTypeQualifiers()) {
1596 if (TypeQuals &&
Result->isFunctionType()) {
1600 ? diag::warn_typecheck_function_qualifiers_ignored
1601 : diag::warn_typecheck_function_qualifiers_unspecified);
1614 if (TypeQuals &&
Result->isReferenceType()) {
1616 S, DS, TypeQuals,
Result,
1618 diag::warn_typecheck_reference_qualifiers);
1625 && TypeQuals &
Result.getCVRQualifiers()) {
1627 S.
Diag(DS.getConstSpecLoc(), diag::ext_duplicate_declspec)
1632 S.
Diag(DS.getVolatileSpecLoc(), diag::ext_duplicate_declspec)
1644 declarator.setInvalidType(
true);
1649 assert(!
Result.isNull() &&
"This function should not return a null type");
1674 unsigned DiagID = 0;
1690 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1694 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1708 unsigned CVRAU,
const DeclSpec *DS) {
1743 return BuildQualifiedType(T, Loc, Split.
Quals);
1748 return BuildQualifiedType(T, Loc, Q, DS);
1795 diag::err_arc_indirect_no_ownership, type, isReference));
1797 S.
Diag(loc, diag::err_arc_indirect_no_ownership) << type << isReference;
1801 assert(implicitLifetime &&
"didn't infer any lifetime!");
1855 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1878 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1884 Diag(Loc, diag::err_opencl_function_pointer);
1894 if (getLangOpts().ObjCAutoRefCount)
1918 "Unresolved overloaded function type");
1946 Diag(Loc, diag::err_reference_to_void);
1954 if (getLangOpts().ObjCAutoRefCount)
2000 S.
Diag(Loc, diag::ext_vla_folded_to_constant) << SR;
2025 Expr *ArraySize,
unsigned Quals,
2042 Diag(Loc, diag::err_illegal_decl_array_of_references)
2048 Diag(Loc, diag::err_illegal_decl_array_incomplete_type) <<
T;
2052 if (RequireNonAbstractType(Brackets.
getBegin(),
T,
2053 diag::err_array_of_abstract_type))
2060 if (!MPTy->getClass()->isDependentType())
2061 (
void)isCompleteType(Loc, T);
2066 if (RequireCompleteType(Loc, T,
2067 diag::err_illegal_decl_array_incomplete_type))
2072 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2080 if (EltTy->getDecl()->hasFlexibleArrayMember())
2081 Diag(Loc, diag::ext_flexible_array_in_array) <<
T;
2083 Diag(Loc, diag::err_objc_array_of_interfaces) <<
T;
2091 ArraySize = Result.
get();
2095 if (ArraySize && !ArraySize->
isRValue()) {
2100 ArraySize = Result.
get();
2126 if (getLangOpts().CPlusPlus11 &&
2140 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2145 Diag(ArraySize->
getLocStart(), diag::err_typecheck_negative_array_size)
2149 if (ConstVal == 0) {
2153 isSFINAEContext()? diag::err_typecheck_zero_array_size
2154 : diag::ext_typecheck_zero_array_size)
2159 diag::warn_typecheck_zero_static_array_size)
2166 unsigned ActiveSizeBits
2170 << ConstVal.toString(10)
2181 Diag(Loc, diag::err_opencl_vla);
2186 if (getLangOpts().CUDA) {
2188 CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
2189 }
else if (!getLangOpts().OpenMP ||
2190 shouldDiagnoseTargetSupportFromOpenMP()) {
2192 Diag(Loc, diag::err_vla_unsupported);
2198 if (!getLangOpts().
C99) {
2201 if (isSFINAEContext()) {
2202 Diag(Loc, diag::err_vla_in_sfinae);
2207 Diag(Loc, diag::ext_vla);
2210 getLangOpts().
CPlusPlus? diag::err_c99_array_usage_cxx
2211 : diag::ext_c99_array_usage) << ASM;
2216 Diag(Loc, diag::warn_vla_used);
2222 if (getLangOpts().
OpenCL) {
2226 Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
2249 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) <<
T;
2254 llvm::APSInt vecSize(32);
2256 Diag(AttrLoc, diag::err_attribute_argument_type)
2264 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue());
2266 if (vectorSize == 0) {
2267 Diag(AttrLoc, diag::err_attribute_zero_size)
2273 Diag(AttrLoc, diag::err_attribute_size_too_large)
2286 Diag(Loc, diag::err_func_returning_array_function)
2292 if (T->
isHalfType() && !getLangOpts().HalfArgsAndReturns) {
2293 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2301 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value)
2317 bool hasCheckedSwiftCall =
false;
2318 auto checkForSwiftCC = [&](
unsigned paramIndex) {
2320 if (hasCheckedSwiftCall)
return;
2321 hasCheckedSwiftCall =
true;
2323 S.
Diag(getParamLoc(paramIndex), diag::err_swift_param_attr_not_swiftcall)
2327 for (
size_t paramIndex = 0, numParams = paramTypes.size();
2328 paramIndex != numParams; ++paramIndex) {
2337 checkForSwiftCC(paramIndex);
2338 if (paramIndex != 0 &&
2341 S.
Diag(getParamLoc(paramIndex),
2342 diag::err_swift_indirect_result_not_first);
2347 checkForSwiftCC(paramIndex);
2352 checkForSwiftCC(paramIndex);
2353 if (paramIndex == 0 ||
2356 S.
Diag(getParamLoc(paramIndex),
2357 diag::err_swift_error_result_not_after_swift_context);
2361 llvm_unreachable(
"bad ABI kind");
2369 bool Invalid =
false;
2371 Invalid |= CheckFunctionReturnType(T, Loc);
2373 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2377 Diag(Loc, diag::err_param_with_void_type);
2379 }
else if (ParamType->
isHalfType() && !getLangOpts().HalfArgsAndReturns) {
2381 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2386 ParamTypes[Idx] = ParamType;
2391 [=](
unsigned i) {
return Loc; });
2396 checkNSReturnsRetainedReturnType(Loc, T);
2419 if (CheckDistantExceptionSpec(T)) {
2420 Diag(Loc, diag::err_distant_exception_spec);
2427 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2433 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2439 Diag(Loc, diag::err_mempointer_in_nonclass_type) << Class;
2449 adjustMemberFunctionCC(T,
false, IsCtorOrDtor, Loc);
2469 Diag(Loc, diag::err_nonfunction_block_type);
2482 if (TInfo) *TInfo =
nullptr;
2487 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2488 QT = LIT->getType();
2489 DI = LIT->getTypeSourceInfo();
2492 if (TInfo) *TInfo = DI;
2498 unsigned chunkIndex);
2505 Sema &S = state.getSema();
2506 Declarator &declarator = state.getDeclarator();
2512 unsigned outermostPointerIndex = 0;
2514 unsigned numPointers = 0;
2516 unsigned chunkIndex = i;
2518 switch (chunk.
Kind) {
2528 outermostPointerIndex = chunkIndex;
2536 if (numPointers != 1)
return;
2538 outermostPointerIndex = chunkIndex;
2539 isBlockPointer =
true;
2556 if (numPointers == 1) {
2574 }
else if (numPointers == 2) {
2588 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
2592 outermostPointerIndex);
2614 }
const QualKinds[5] = {
2623 unsigned NumQuals = 0;
2628 for (
auto &E : QualKinds) {
2629 if (Quals & E.Mask) {
2630 if (!QualStr.empty()) QualStr +=
' ';
2638 getSourceManager().isBeforeInTranslationUnit(QualLoc, Loc))
2647 << QualStr << NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
2653 unsigned FunctionChunkIndex) {
2663 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
2665 OuterChunkIndex !=
End; ++OuterChunkIndex) {
2667 switch (OuterChunk.
Kind) {
2674 diag::warn_qual_return_type,
2700 llvm_unreachable(
"unknown declarator chunk kind");
2723 Sema &SemaRef = state.getSema();
2726 ReturnTypeInfo =
nullptr;
2729 TagDecl *OwnedTagDecl =
nullptr;
2780 bool IsCXXAutoType =
2802 assert(LSI &&
"No LambdaScopeInfo on the stack!");
2814 TemplateParameterDepth, AutoParameterPosition,
2815 nullptr,
false, IsParameterPack);
2830 switch (cast<TagDecl>(SemaRef.
CurContext)->getTagKind()) {
2831 case TTK_Enum: llvm_unreachable(
"unhandled tag kind");
2833 case TTK_Union: Error = Cxx ? 3 : 4;
break;
2846 if (isa<DeducedTemplateSpecializationType>(Deduced))
2862 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
2866 if (!SemaRef.
getLangOpts().CPlusPlus14 || !IsCXXAutoType)
2870 if (isa<DeducedTemplateSpecializationType>(Deduced))
2888 if (!IsCXXAutoType && !isa<DeducedTemplateSpecializationType>(Deduced))
2902 (!SemaRef.
getLangOpts().CPlusPlus11 || !IsCXXAutoType))
2905 bool HaveTrailing =
false;
2913 if (SemaRef.
getLangOpts().CPlusPlus11 && IsCXXAutoType &&
2915 HaveTrailing =
true;
2932 assert(isa<DeducedTemplateSpecializationType>(Deduced) &&
2933 "unknown auto type");
2940 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
2942 <<
QualType(Deduced, 0) << AutoRange;
2943 if (
auto *TD = TN.getAsTemplateDecl())
2944 SemaRef.
Diag(TD->getLocation(), diag::note_template_decl_here);
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;
2992 DiagID = diag::err_type_defined_in_type_specifier;
3001 DiagID = diag::err_type_defined_in_param_type;
3007 DiagID = diag::err_type_defined_in_condition;
3018 assert(!T.
isNull() &&
"This function should not return a null type");
3027 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
3058 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
3059 : diag::warn_empty_parens_are_function_decl)
3070 if (
Comma.getFileID() != Name.getFileID() ||
3071 Comma.getSpellingLineNumber() != Name.getSpellingLineNumber()) {
3078 Result.suppressDiagnostics();
3091 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
3106 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
3111 if (Init.empty() && S.
LangOpts.CPlusPlus11)
3114 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
3125 "do not have redundant top-level parentheses");
3134 bool CouldBeTemporaryObject =
3141 bool StartsWithDeclaratorId =
true;
3149 StartsWithDeclaratorId =
false;
3154 CouldBeTemporaryObject =
false;
3162 CouldBeTemporaryObject =
false;
3163 StartsWithDeclaratorId =
false;
3173 CouldBeTemporaryObject =
false;
3180 CouldBeTemporaryObject =
false;
3181 StartsWithDeclaratorId =
false;
3191 if (CouldBeTemporaryObject) {
3195 CouldBeTemporaryObject =
false;
3196 Result.suppressDiagnostics();
3201 if (!CouldBeTemporaryObject) {
3214 S.
Diag(Paren.
Loc, diag::warn_redundant_parens_around_declarator)
3220 S.
Diag(Paren.
Loc, diag::warn_parens_disambiguated_as_variable_declaration)
3223 if (!RD || !RD->hasDefinition() || RD->hasNonTrivialDestructor())
3224 S.
Diag(Paren.
Loc, diag::note_raii_guard_add_name)
3229 S.
Diag(D.
getLocStart(), diag::note_function_style_cast_add_parentheses)
3232 S.
Diag(Paren.
Loc, diag::note_remove_parens_for_variable_declaration)
3244 unsigned ChunkIndex) {
3267 bool IsCXXInstanceMethod =
false;
3273 unsigned I = ChunkIndex;
3274 bool FoundNonParen =
false;
3275 while (I && !FoundNonParen) {
3278 FoundNonParen =
true;
3281 if (FoundNonParen) {
3284 IsCXXInstanceMethod =
3289 IsCXXInstanceMethod =
true;
3296 IsCXXInstanceMethod =
3304 IsCXXInstanceMethod);
3313 if (
Attr->
getKind() == AttributeList::AT_OpenCLKernel) {
3335 switch (nullability) {
3337 if (!Ident__Nonnull)
3338 Ident__Nonnull = PP.getIdentifierInfo(
"_Nonnull");
3339 return Ident__Nonnull;
3342 if (!Ident__Nullable)
3343 Ident__Nullable = PP.getIdentifierInfo(
"_Nullable");
3344 return Ident__Nullable;
3347 if (!Ident__Null_unspecified)
3348 Ident__Null_unspecified = PP.getIdentifierInfo(
"_Null_unspecified");
3349 return Ident__Null_unspecified;
3351 llvm_unreachable(
"Unknown nullability kind.");
3357 Ident_NSError = PP.getIdentifierInfo(
"NSError");
3359 return Ident_NSError;
3367 if (attr->getKind() == AttributeList::AT_TypeNonNull ||
3368 attr->getKind() == AttributeList::AT_TypeNullable ||
3369 attr->getKind() == AttributeList::AT_TypeNullUnspecified)
3386 MaybePointerToCFRef,
3390 NSErrorPointerPointer,
3413 unsigned numNormalPointers = 0;
3417 return PointerDeclaratorKind::NonPointer;
3422 switch (chunk.
Kind) {
3424 if (numNormalPointers == 0)
3425 wrappingKind = PointerWrappingDeclaratorKind::Array;
3434 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3435 : PointerDeclaratorKind::SingleLevelPointer;
3441 if (numNormalPointers == 0)
3442 wrappingKind = PointerWrappingDeclaratorKind::Reference;
3446 ++numNormalPointers;
3447 if (numNormalPointers > 2)
3448 return PointerDeclaratorKind::MultiLevelPointer;
3454 unsigned numTypeSpecifierPointers = 0;
3458 ++numNormalPointers;
3460 if (numNormalPointers > 2)
3461 return PointerDeclaratorKind::MultiLevelPointer;
3464 ++numTypeSpecifierPointers;
3470 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3471 : PointerDeclaratorKind::SingleLevelPointer;
3476 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3477 : PointerDeclaratorKind::SingleLevelPointer;
3482 ++numNormalPointers;
3483 ++numTypeSpecifierPointers;
3486 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
3488 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3489 return PointerDeclaratorKind::NSErrorPointerPointer;
3498 if (objcClass->getInterface()->getIdentifier() == S.
getNSErrorIdent()) {
3499 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
3500 return PointerDeclaratorKind::NSErrorPointerPointer;
3507 if (numNormalPointers == 0)
3508 return PointerDeclaratorKind::NonPointer;
3513 bool isCFError =
false;
3524 if (
auto bridgeAttr = recordDecl->
getAttr<ObjCBridgeAttr>())
3525 bridgedType = bridgeAttr->getBridgedType();
3526 else if (
auto bridgeAttr =
3527 recordDecl->
getAttr<ObjCBridgeMutableAttr>())
3528 bridgedType = bridgeAttr->getBridgedType();
3538 if (isCFError && numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3539 return PointerDeclaratorKind::CFErrorRefPointer;
3547 switch (numNormalPointers) {
3549 return PointerDeclaratorKind::NonPointer;
3552 return PointerDeclaratorKind::SingleLevelPointer;
3555 return PointerDeclaratorKind::MaybePointerToCFRef;
3558 return PointerDeclaratorKind::MultiLevelPointer;
3567 if (ctx->isFunctionOrMethod())
3570 if (ctx->isFileContext())
3581 bool invalid =
false;
3583 if (invalid || !sloc.
isFile())
3609 if (!FixItLoc.
isValid() || FixItLoc == PointerLoc)
3618 InsertionTextBuf +=
" ";
3619 StringRef InsertionText = InsertionTextBuf.str();
3622 InsertionText = InsertionText.drop_back();
3623 }
else if (NextChar[-1] ==
'[') {
3624 if (NextChar[0] ==
']')
3625 InsertionText = InsertionText.drop_back().drop_front();
3627 InsertionText = InsertionText.drop_front();
3630 InsertionText = InsertionText.drop_back().drop_front();
3642 if (PointerKind == SimplePointerKind::Array) {
3643 S.
Diag(PointerLoc, diag::warn_nullability_missing_array);
3645 S.
Diag(PointerLoc, diag::warn_nullability_missing)
3646 <<
static_cast<unsigned>(PointerKind);
3649 auto FixItLoc = PointerEndLoc.
isValid() ? PointerEndLoc : PointerLoc;
3650 if (FixItLoc.isMacroID())
3654 auto Diag = S.
Diag(FixItLoc, diag::note_nullability_fix_it);
3656 Diag << static_cast<unsigned>(PointerKind);
3685 if (pointerKind == SimplePointerKind::Array)
3686 diagKind = diag::warn_nullability_missing_array;
3688 diagKind = diag::warn_nullability_missing;
3694 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
3741 unsigned i = endIndex;
3771 Sema &S = state.getSema();
3781 bool IsTypedefName =
3797 bool IsClassTemplateDeduction = isa<DeducedTemplateSpecializationType>(DT);
3800 unsigned Index = E - I - 1;
3802 unsigned DiagId = IsClassTemplateDeduction
3803 ? diag::err_deduced_class_template_compound_type
3804 : diag::err_decltype_auto_compound_type;
3805 unsigned DiagKind = 0;
3806 switch (DeclChunk.
Kind) {
3809 if (IsClassTemplateDeduction) {
3815 if (IsClassTemplateDeduction) {
3823 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
3841 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
3850 bool inferNullabilityCS =
false;
3851 bool inferNullabilityInnerOnly =
false;
3852 bool inferNullabilityInnerOnlyComplete =
false;
3855 bool inAssumeNonNullRegion =
false;
3857 if (assumeNonNullLoc.
isValid()) {
3858 inAssumeNonNullRegion =
true;
3872 } complainAboutMissingNullability = CAMN_No;
3873 unsigned NumPointersRemaining = 0;
3876 if (IsTypedefName) {
3880 complainAboutMissingNullability = CAMN_InnerPointers;
3885 ++NumPointersRemaining;
3890 switch (chunk.
Kind) {
3898 ++NumPointersRemaining;
3906 ++NumPointersRemaining;
3912 switch (
auto context = state.getDeclarator().getContext()) {
3917 isFunctionOrMethod =
true;
3922 complainAboutMissingNullability = CAMN_No;
3927 if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) {
3936 complainAboutMissingNullability = CAMN_Yes;
3941 case PointerDeclaratorKind::NonPointer:
3942 case PointerDeclaratorKind::MultiLevelPointer:
3946 case PointerDeclaratorKind::SingleLevelPointer:
3948 if (inAssumeNonNullRegion) {
3949 complainAboutInferringWithinChunk = wrappingKind;
3951 inferNullabilityCS =
3957 case PointerDeclaratorKind::CFErrorRefPointer:
3958 case PointerDeclaratorKind::NSErrorPointerPointer:
3961 if (isFunctionOrMethod && inAssumeNonNullRegion)
3965 case PointerDeclaratorKind::MaybePointerToCFRef:
3966 if (isFunctionOrMethod) {
3970 auto hasCFReturnsAttr = [](
const AttributeList *NextAttr) ->
bool {
3972 if (NextAttr->getKind() == AttributeList::AT_CFReturnsRetained ||
3973 NextAttr->getKind() == AttributeList::AT_CFReturnsNotRetained)
3975 NextAttr = NextAttr->getNext();
3981 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
3984 inferNullabilityInnerOnly =
true;
3994 complainAboutMissingNullability = CAMN_Yes;
4019 auto isVaList = [&S](
QualType T) ->
bool {
4025 if (typedefTy->getDecl() == vaListTypedef)
4027 if (
auto *name = typedefTy->getDecl()->getIdentifier())
4028 if (name->isStr(
"va_list"))
4030 typedefTy = typedefTy->desugar()->getAs<
TypedefType>();
4031 }
while (typedefTy);
4042 if (NumPointersRemaining > 0)
4043 --NumPointersRemaining;
4050 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
4054 AttributeList *nullabilityAttr = state.getDeclarator().getAttributePool()
4060 nullptr, 0, syntax);
4064 if (inferNullabilityCS) {
4065 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
4069 if (pointerLoc.isValid() &&
4070 complainAboutInferringWithinChunk !=
4073 S.
Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
4074 Diag << static_cast<int>(complainAboutInferringWithinChunk);
4078 if (inferNullabilityInnerOnly)
4079 inferNullabilityInnerOnlyComplete =
true;
4080 return nullabilityAttr;
4085 switch (complainAboutMissingNullability) {
4089 case CAMN_InnerPointers:
4090 if (NumPointersRemaining == 0)
4107 if (NumPointersRemaining > 0)
4108 --NumPointersRemaining;
4112 pointerKind = SimplePointerKind::BlockPointer;
4114 pointerKind = SimplePointerKind::MemberPointer;
4116 if (
auto *attr = inferPointerNullability(
4122 attr->setUsedAsTypeAttr();
4127 if (complainAboutMissingNullability == CAMN_Yes &&
4140 unsigned chunkIndex = e - i - 1;
4141 state.setCurrentChunkIndex(chunkIndex);
4144 switch (DeclType.
Kind) {
4152 if (!LangOpts.Blocks)
4153 S.
Diag(DeclType.
Loc, diag::err_blocks_disable) << LangOpts.OpenCL;
4156 inferPointerNullability(SimplePointerKind::BlockPointer, DeclType.
Loc,
4163 if (LangOpts.OpenCL)
4178 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
4191 if (LangOpts.OpenCL) {
4192 if (T->isImageType() || T->isSamplerT() || T->isPipeType() ||
4193 T->isBlockPointerType()) {
4238 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
4249 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype) <<
4261 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost) <<
4276 S.
Diag(DeclType.
Loc, diag::err_illegal_decl_array_of_auto)
4284 if (complainAboutMissingNullability == CAMN_Yes &&
4313 ? diag::err_auto_missing_trailing_return
4314 : diag::err_deduced_return_type);
4319 if (isa<ParenType>(T)) {
4321 diag::err_trailing_return_in_parens)
4328 diag::err_deduction_guide_with_complex_decl)
4333 (T.hasQualifiers() || !isa<AutoType>(
T) ||
4334 cast<AutoType>(T)->getKeyword() !=
4337 diag::err_trailing_return_without_auto)
4352 if (!D.
isInvalidType() && (T->isArrayType() || T->isFunctionType()) &&
4355 unsigned diagID = diag::err_func_returning_array_function;
4358 if (chunkIndex == 0 &&
4360 diagID = diag::err_block_returning_array_function;
4361 S.
Diag(DeclType.
Loc, diagID) << T->isFunctionType() <<
T;
4368 if (T->isHalfType()) {
4377 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
4382 if (LangOpts.OpenCL) {
4385 if (T->isBlockPointerType() || T->isImageType() || T->isSamplerT() ||
4397 LangOpts.OpenCLVersion >= 120) ||
4406 if (T->isObjCObjectType()) {
4415 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
4433 if ((T.getCVRQualifiers() || T->isAtomicType()) &&
4435 (T->isDependentType() || T->isRecordType()))) {
4436 if (T->isVoidType() && !S.
getLangOpts().CPlusPlus &&
4441 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) <<
T;
4449 if (T.getQualifiers().hasObjCLifetime()) {
4455 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
4456 AttrLoc =
Attr->getLoc();
4465 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
4466 AttrLoc =
Attr->getLoc();
4479 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
4480 << T.getQualifiers().getObjCLifetime();
4496 diag::err_exception_spec_in_typedef)
4508 && !LangOpts.OpenCL) {
4516 bool Overloadable =
false;
4518 Attrs; Attrs = Attrs->
getNext()) {
4519 if (Attrs->getKind() == AttributeList::AT_Overloadable) {
4520 Overloadable =
true;
4533 diag::err_ident_list_in_fn_declaration);
4556 bool HasAnyInterestingExtParameterInfos =
false;
4558 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
4561 assert(!ParamTy.isNull() &&
"Couldn't parse type?");
4566 if (ParamTy->isVoidType()) {
4571 S.
Diag(DeclType.
Loc, diag::err_void_only_param);
4572 ParamTy = Context.
IntTy;
4577 ParamTy = Context.
IntTy;
4581 if (ParamTy.hasQualifiers())
4582 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
4587 }
else if (ParamTy->isHalfType()) {
4593 diag::err_opencl_half_param) << ParamTy;
4599 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
4603 if (ParamTy->isPromotableIntegerType()) {
4607 if (BTy->getKind() == BuiltinType::Float) {
4614 if (LangOpts.ObjCAutoRefCount && Param->
hasAttr<NSConsumedAttr>()) {
4615 ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(
true);
4616 HasAnyInterestingExtParameterInfos =
true;
4620 ExtParameterInfos[i] =
4621 ExtParameterInfos[i].withABI(attr->getABI());
4622 HasAnyInterestingExtParameterInfos =
true;
4625 if (Param->
hasAttr<PassObjectSizeAttr>()) {
4626 ExtParameterInfos[i] = ExtParameterInfos[i].withHasPassObjectSize();
4627 HasAnyInterestingExtParameterInfos =
true;
4630 if (Param->
hasAttr<NoEscapeAttr>()) {
4631 ExtParameterInfos[i] = ExtParameterInfos[i].withIsNoEscape(
true);
4632 HasAnyInterestingExtParameterInfos =
true;
4635 ParamTys.push_back(ParamTy);
4638 if (HasAnyInterestingExtParameterInfos) {
4647 Expr *NoexceptExpr =
nullptr;
4653 DynamicExceptions.reserve(N);
4654 DynamicExceptionRanges.reserve(N);
4655 for (
unsigned I = 0; I != N; ++I) {
4666 DynamicExceptionRanges,
4681 inferPointerNullability(SimplePointerKind::MemberPointer, DeclType.
Loc,
4701 llvm_unreachable(
"Nested-name-specifier must name a type");
4711 if (NNSPrefix && isa<TemplateSpecializationType>(NNS->
getAsType()))
4717 diag::err_illegal_decl_mempointer_in_nonclass)
4750 const_cast<AttributeList *>(DeclType.
getAttrs()));
4762 bool IsBlock =
false;
4764 switch (DeclType.Kind) {
4771 S.
Diag(DeclType.Loc, diag::warn_strict_prototypes)
4783 assert(!T.
isNull() &&
"T must not be null after this point");
4787 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
4797 enum { NonMember, Member, DeductionGuide }
Kind = NonMember;
4799 Kind = DeductionGuide;
4827 if (IsQualifiedFunction &&
4847 if (!RemovalLocs.empty()) {
4848 std::sort(RemovalLocs.begin(), RemovalLocs.end(),
4850 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
4851 Loc = RemovalLocs.front();
4855 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
4880 state.diagnoseIgnoredTypeAttrs(T);
4910 diag::err_function_parameter_pack_without_parameter_packs)
4930 LangOpts.CPlusPlus11
4931 ? diag::warn_cxx98_compat_variadic_templates
4932 : diag::ext_variadic_templates);
4961 diag::err_ellipsis_in_declarator_not_parameter);
4967 assert(!T.
isNull() &&
"T must not be null at the end of this function");
4983 TypeProcessingState
state(*
this, D);
5006 unsigned chunkIndex) {
5007 Sema &S = state.getSema();
5014 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
5017 const char *attrStr =
nullptr;
5018 switch (ownership) {
5047 Sema &S = state.getSema();
5051 bool hasIndirection =
false;
5054 switch (chunk.
Kind) {
5063 hasIndirection =
true;
5096 TypeProcessingState
state(*
this, D);
5101 if (getLangOpts().ObjC1) {
5114 return AttributeList::AT_AddressSpace;
5116 return AttributeList::AT_Regparm;
5118 return AttributeList::AT_VectorSize;
5120 return AttributeList::AT_NeonVectorType;
5122 return AttributeList::AT_NeonPolyVectorType;
5124 return AttributeList::AT_ObjCGC;
5127 return AttributeList::AT_ObjCOwnership;
5129 return AttributeList::AT_NoReturn;
5131 return AttributeList::AT_CDecl;
5133 return AttributeList::AT_FastCall;
5135 return AttributeList::AT_StdCall;
5137 return AttributeList::AT_ThisCall;
5139 return AttributeList::AT_RegCall;
5141 return AttributeList::AT_Pascal;
5143 return AttributeList::AT_SwiftCall;
5145 return AttributeList::AT_VectorCall;
5148 return AttributeList::AT_Pcs;
5150 return AttributeList::AT_IntelOclBicc;
5152 return AttributeList::AT_MSABI;
5154 return AttributeList::AT_SysVABI;
5156 return AttributeList::AT_PreserveMost;
5158 return AttributeList::AT_PreserveAll;
5160 return AttributeList::AT_Ptr32;
5162 return AttributeList::AT_Ptr64;
5164 return AttributeList::AT_SPtr;
5166 return AttributeList::AT_UPtr;
5168 return AttributeList::AT_TypeNonNull;
5170 return AttributeList::AT_TypeNullable;
5172 return AttributeList::AT_TypeNullUnspecified;
5174 return AttributeList::AT_ObjCKindOf;
5176 return AttributeList::AT_NSReturnsRetained;
5178 llvm_unreachable(
"unexpected attribute kind!");
5185 assert((attrs || DeclAttrs) &&
5186 "no type attributes in the expected location!");
5190 while (attrs && attrs->
getKind() != parsedKind)
5195 while (DeclAttrs && (!DeclAttrs->isCXX11Attribute() ||
5196 DeclAttrs->getKind() != parsedKind))
5197 DeclAttrs = DeclAttrs->
getNext();
5201 assert(attrs &&
"no matching type attribute in expected location!");
5205 assert(attrs->
isArgExpr(0) &&
"mismatched attribute operand kind");
5209 "unexpected attribute operand kind");
5222 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
5228 : Context(Context), DS(DS) {}
5342 void VisitDependentTemplateSpecializationTypeLoc(
5381 void VisitTypeLoc(
TypeLoc TL) {
5387 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
5393 : Context(Context), Chunk(Chunk) {}
5396 llvm_unreachable(
"qualified type locs not expected here!");
5399 llvm_unreachable(
"decayed type locs not expected here!");
5432 assert(isa<DependentNameType>(ClsTy) &&
"Unexpected TypeLoc");
5443 if (isa<ElaboratedType>(ClsTy)) {
5458 llvm_unreachable(
"Nested-name-specifier must name a type");
5490 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
5506 void VisitTypeLoc(
TypeLoc TL) {
5507 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
5514 switch (Chunk.
Kind) {
5519 llvm_unreachable(
"cannot be _Atomic qualified");
5538 while (Attrs && Attrs->
getKind() != AttributeList::AT_AddressSpace)
5541 assert(Attrs &&
"no address_space attribute found at the expected location!");
5564 if (isa<PackExpansionType>(T)) {
5593 DeclaratorLocFiller(Context, D.
getTypeObject(i)).Visit(CurrTL);
5599 if (ReturnTypeInfo) {
5604 TypeSpecLocFiller(Context, D.
getDeclSpec()).Visit(CurrTL);
5619 "LocInfoType's TypeClass conflicts with an existing Type class");
5625 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*" 5626 " was used directly instead of getting the QualType through" 5627 " GetTypeFromParser");
5634 "Type name should have no identifier!");
5651 if (getLangOpts().CPlusPlus) {
5653 CheckExtraCXXDefaultArguments(D);
5656 return CreateParsedType(T, TInfo);
5662 return CreateParsedType(T, TInfo);
5681 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
5685 llvm::APSInt addrSpace(32);
5687 Diag(AttrLoc, diag::err_attribute_argument_type)
5694 if (addrSpace.isSigned()) {
5695 if (addrSpace.isNegative()) {
5696 Diag(AttrLoc, diag::err_attribute_address_space_negative)
5700 addrSpace.setIsSigned(
false);
5703 llvm::APSInt
max(addrSpace.getBitWidth());
5706 if (addrSpace > max) {
5707 Diag(AttrLoc, diag::err_attribute_address_space_too_high)
5724 Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
5740 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_multiple_qualifiers);
5748 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_function_type);
5754 if (Attr.
getKind() == AttributeList::AT_AddressSpace) {
5758 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5777 ASArgExpr =
static_cast<Expr *
>(AddrSpace.
get());
5793 case AttributeList::AT_OpenCLGlobalAddressSpace:
5795 case AttributeList::AT_OpenCLLocalAddressSpace:
5797 case AttributeList::AT_OpenCLConstantAddressSpace:
5799 case AttributeList::AT_OpenCLGenericAddressSpace:
5801 case AttributeList::AT_OpenCLPrivateAddressSpace:
5804 llvm_unreachable(
"Invalid address space");
5820 if (
const AttributedType *attr = dyn_cast<AttributedType>(type)) {
5824 type = attr->getModifiedType();
5827 }
else if (
const ParenType *paren = dyn_cast<ParenType>(type)) {
5828 type = paren->getInnerType();
5848 bool NonObjCPointer =
false;
5858 NonObjCPointer =
true;
5865 if (state.isProcessingDeclSpec()) {
5873 Sema &S = state.getSema();
5879 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
5887 if (II->
isStr(
"none"))
5889 else if (II->
isStr(
"strong"))
5891 else if (II->
isStr(
"weak"))
5893 else if (II->
isStr(
"autoreleasing"))
5896 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported)
5917 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
5924 if (previousLifetime != lifetime) {
5927 const Type *prevTy =
nullptr;
5928 while (!prevTy || prevTy != underlyingType.
Ty) {
5929 prevTy = underlyingType.
Ty;
5938 if (NonObjCPointer) {
5948 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
5972 if (!NonObjCPointer)
5987 diagnostic,
type, 0));
5989 S.
Diag(loc, diagnostic);
5998 unsigned diagnostic =
5999 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
6000 : diag::err_arc_weak_no_runtime);
6003 diagnoseOrDelay(S, AttrLoc, diagnostic, type);
6015 if (Class->isArcWeakrefUnavailable()) {
6016 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
6017 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
6018 diag::note_class_declared);
6034 Sema &S = state.getSema();
6043 S.
Diag(attr.
getLoc(), diag::err_attribute_multiple_objc_gc);
6050 S.
Diag(attr.
getLoc(), diag::err_attribute_argument_type)
6057 S.
Diag(attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6064 if (II->
isStr(
"weak"))
6066 else if (II->
isStr(
"strong"))
6069 S.
Diag(attr.
getLoc(), diag::warn_attribute_type_not_supported)
6097 struct FunctionTypeUnwrapper {
6115 if (isa<FunctionType>(Ty)) {
6116 Fn = cast<FunctionType>(Ty);
6118 }
else if (isa<ParenType>(Ty)) {
6119 T = cast<ParenType>(Ty)->getInnerType();
6120 Stack.push_back(Parens);
6121 }
else if (isa<PointerType>(Ty)) {
6122 T = cast<PointerType>(Ty)->getPointeeType();
6123 Stack.push_back(Pointer);
6124 }
else if (isa<BlockPointerType>(Ty)) {
6125 T = cast<BlockPointerType>(Ty)->getPointeeType();
6126 Stack.push_back(BlockPointer);
6127 }
else if (isa<MemberPointerType>(Ty)) {
6128 T = cast<MemberPointerType>(Ty)->getPointeeType();
6129 Stack.push_back(MemberPointer);
6130 }
else if (isa<ReferenceType>(Ty)) {
6131 T = cast<ReferenceType>(Ty)->getPointeeType();
6132 Stack.push_back(Reference);
6133 }
else if (isa<AttributedType>(Ty)) {
6134 T = cast<AttributedType>(Ty)->getEquivalentType();
6135 Stack.push_back(Attributed);
6149 bool isFunctionType()
const {
return (Fn !=
nullptr); }
6154 if (New ==
get())
return Original;
6157 return wrap(S.
Context, Original, 0);
6162 if (I == Stack.size())
6171 return wrap(C, SplitOld.
Ty, I);
6176 if (I == Stack.size())
return QualType(Fn, 0);
6178 switch (static_cast<WrapKind>(Stack[I++])) {
6185 return wrap(C, cast<AttributedType>(Old)->getEquivalentType(), I);
6188 QualType New = wrap(C, cast<ParenType>(Old)->getInnerType(), I);
6193 QualType New = wrap(C, cast<PointerType>(Old)->getPointeeType(), I);
6197 case BlockPointer: {
6198 QualType New = wrap(C, cast<BlockPointerType>(Old)->getPointeeType(),I);
6202 case MemberPointer: {
6211 if (isa<LValueReferenceType>(OldRef))
6218 llvm_unreachable(
"unknown wrapping kind");
6226 Sema &S = State.getSema();
6237 S.
Diag(Attr.
getLoc(), diag::warn_duplicate_attribute_exact)
6245 Kind == AttributeList::AT_Ptr64) ||
6247 Kind == AttributeList::AT_Ptr32)) {
6248 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
6249 <<
"'__ptr32'" <<
"'__ptr64'";
6252 Kind == AttributeList::AT_UPtr) ||
6254 Kind == AttributeList::AT_SPtr)) {
6255 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
6256 <<
"'__sptr'" <<
"'__uptr'";
6266 if (!isa<PointerType>(Desugared)) {
6268 S.
Diag(Attr.
getLoc(), diag::err_attribute_no_member_pointers)
6271 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
6278 default: llvm_unreachable(
"Unknown attribute kind");
6292 bool isContextSensitive,
6293 bool allowOnArrayType) {
6298 while (
auto attributed = dyn_cast<AttributedType>(desugared.
getTypePtr())) {
6300 if (
auto existingNullability = attributed->getImmediateNullability()) {
6302 if (nullability == *existingNullability) {
6303 Diag(nullabilityLoc, diag::warn_nullability_duplicate)
6311 Diag(nullabilityLoc, diag::err_nullability_conflicting)
6317 desugared = attributed->getModifiedType();
6324 if (
auto existingNullability = desugared->
getNullability(Context)) {
6325 if (nullability != *existingNullability) {
6326 Diag(nullabilityLoc, diag::err_nullability_conflicting)
6334 if (
auto typedefNullability
6336 if (*typedefNullability == *existingNullability) {
6349 !(allowOnArrayType && desugared->
isArrayType())) {
6350 Diag(nullabilityLoc, diag::err_nullability_nonpointer)
6357 if (isContextSensitive) {
6359 const Type *pointeeType;
6368 Diag(nullabilityLoc, diag::err_nullability_cs_multilevel)
6371 Diag(nullabilityLoc, diag::note_nullability_type_specifier)
6387 if (isa<ObjCTypeParamType>(type)) {
6402 Diag(loc, diag::err_objc_kindof_nonobject)
6411 objType->getBaseType(), objType->getTypeArgsAsWritten(),
6412 objType->getProtocols(),
6413 objType->isObjCUnqualifiedId() ?
false :
true);
6435 case AttributeList::AT_TypeNonNull:
6438 case AttributeList::AT_TypeNullable:
6441 case AttributeList::AT_TypeNullUnspecified:
6445 llvm_unreachable(
"not a nullability attribute kind");
6458 Declarator &declarator = state.getDeclarator();
6461 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
6474 PK_MemberFunctionPointer,
6479 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
6481 auto diag = state.getSema().Diag(attr.
getLoc(),
6482 diag::warn_nullability_declspec)
6486 << static_cast<unsigned>(pointerKind);
6492 state.getSema().getPreprocessor()
6493 .getLocForEndOfToken(chunk.
Loc),
6504 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
6506 switch (chunk.
Kind) {
6510 return moveToChunk(chunk,
false);
6522 return moveToChunk(*dest,
true);
6541 llvm_unreachable(
"not a calling convention attribute");
6542 case AttributeList::AT_CDecl:
6544 case AttributeList::AT_FastCall:
6546 case AttributeList::AT_StdCall:
6548 case AttributeList::AT_ThisCall:
6550 case AttributeList::AT_RegCall:
6552 case AttributeList::AT_Pascal:
6554 case AttributeList::AT_SwiftCall:
6556 case AttributeList::AT_VectorCall:
6558 case AttributeList::AT_Pcs: {
6564 Str = cast<StringLiteral>(Attr.
getArgAsExpr(0))->getString();
6567 return llvm::StringSwitch<AttributedType::Kind>(Str)
6571 case AttributeList::AT_IntelOclBicc:
6573 case AttributeList::AT_MSABI:
6575 case AttributeList::AT_SysVABI:
6577 case AttributeList::AT_PreserveMost:
6579 case AttributeList::AT_PreserveAll:
6582 llvm_unreachable(
"unexpected attribute kind!");
6590 Sema &S = state.getSema();
6592 FunctionTypeUnwrapper unwrapped(S, type);
6594 if (attr.
getKind() == AttributeList::AT_NoReturn) {
6599 if (!unwrapped.isFunctionType())
6610 if (attr.
getKind() == AttributeList::AT_NSReturnsRetained) {
6614 if (!unwrapped.isFunctionType())
6619 unwrapped.get()->getReturnType()))
6624 if (state.getSema().getLangOpts().ObjCAutoRefCount) {
6626 = unwrapped.get()->getExtInfo().withProducesResult(
true);
6634 if (attr.
getKind() == AttributeList::AT_AnyX86NoCallerSavedRegisters) {
6639 if (!unwrapped.isFunctionType())
6643 unwrapped.get()->getExtInfo().withNoCallerSavedRegs(
true);
6648 if (attr.
getKind() == AttributeList::AT_Regparm) {
6654 if (!unwrapped.isFunctionType())
6661 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6669 unwrapped.get()->getExtInfo().withRegParm(value);
6675 if (!unwrapped.isFunctionType())
return false;
6691 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6709 unsigned DiagID = diag::err_cconv_varargs;
6713 bool IsInvalid =
true;
6715 DiagID = diag::warn_cconv_varargs;
6727 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
6740 auto EI = unwrapped.get()->getExtInfo().withCallingConv(CC);
6751 if (AT->isCallingConv())
6753 R = AT->getModifiedType().IgnoreParens();
6760 FunctionTypeUnwrapper Unwrapped(*
this, T);
6762 bool IsVariadic = (isa<FunctionProtoType>(FT) &&
6763 cast<FunctionProtoType>(FT)->isVariadic());
6776 Diag(Loc, diag::warn_cconv_structors)
6786 if (CurCC != DefaultCC || DefaultCC == ToCC)
6789 if (hasExplicitCallingConv(T))
6794 QualType Wrapped = Unwrapped.wrap(*
this, FT);
6809 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6815 llvm::APSInt vecSize(32);
6818 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6828 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6834 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue() * 8);
6837 if (vectorSize % typeSize) {
6838 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_size)
6844 S.
Diag(Attr.
getLoc(), diag::err_attribute_size_too_large)
6849 if (vectorSize == 0) {
6850 S.
Diag(Attr.
getLoc(), diag::err_attribute_zero_size)
6869 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6888 sizeExpr = Size.
get();
6909 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
6910 Triple.getArch() == llvm::Triple::aarch64_be;
6912 if (IsPolyUnsigned) {
6914 return BTy->
getKind() == BuiltinType::UChar ||
6915 BTy->
getKind() == BuiltinType::UShort ||
6916 BTy->
getKind() == BuiltinType::ULong ||
6917 BTy->
getKind() == BuiltinType::ULongLong;
6920 return BTy->
getKind() == BuiltinType::SChar ||
6921 BTy->
getKind() == BuiltinType::Short;
6927 bool Is64Bit = Triple.getArch() == llvm::Triple::aarch64 ||
6928 Triple.getArch() == llvm::Triple::aarch64_be;
6930 if (Is64Bit && BTy->
getKind() == BuiltinType::Double)
6933 return BTy->
getKind() == BuiltinType::SChar ||
6934 BTy->
getKind() == BuiltinType::UChar ||
6935 BTy->
getKind() == BuiltinType::Short ||
6936 BTy->
getKind() == BuiltinType::UShort ||
6937 BTy->
getKind() == BuiltinType::Int ||
6938 BTy->
getKind() == BuiltinType::UInt ||
6939 BTy->
getKind() == BuiltinType::Long ||
6940 BTy->
getKind() == BuiltinType::ULong ||
6941 BTy->
getKind() == BuiltinType::LongLong ||
6942 BTy->
getKind() == BuiltinType::ULongLong ||
6943 BTy->
getKind() == BuiltinType::Float ||
6944 BTy->
getKind() == BuiltinType::Half;
6965 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6972 llvm::APSInt numEltsInt(32);
6975 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6983 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6990 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
6991 unsigned vecSize = typeSize * numElts;
6992 if (vecSize != 64 && vecSize != 128) {
6993 S.
Diag(Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
7006 S.
Diag(Attr.
getLoc(), diag::err_opencl_invalid_access_qualifier);
7012 QualType PointeeTy = TypedefTy->desugar();
7013 S.
Diag(Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers);
7015 std::string PrevAccessQual;
7017 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 7018 case BuiltinType::Id: \ 7019 PrevAccessQual = #Access; \ 7021 #include "clang/Basic/OpenCLImageTypes.def" 7023 assert(0 &&
"Unable to find corresponding image type.");
7026 S.
Diag(TypedefTy->getDecl()->getLocStart(),
7027 diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
7059 auto ChunkIndex = State.getCurrentChunkIndex();
7064 bool IsFuncReturnType =
7072 IsFuncReturnType || IsFuncType ||
7092 if (State.getSema().getLangOpts().OpenCLVersion <= 120) {
7119 T = State.getSema().Context.getAddrSpaceQualType(T, ImpAddr);
7144 state.getSema().Diag(attr.
getLoc(),
7145 diag::warn_cxx11_gnu_attribute_on_type)
7162 state.getSema().Diag(attr.
getLoc(), diag::err_attribute_not_type_attr)
7170 state.getSema().Diag(attr.
getLoc(),
7171 diag::warn_unknown_attribute_ignored)
7178 case AttributeList::AT_MayAlias:
7183 case AttributeList::AT_OpenCLPrivateAddressSpace:
7184 case AttributeList::AT_OpenCLGlobalAddressSpace:
7185 case AttributeList::AT_OpenCLLocalAddressSpace:
7186 case AttributeList::AT_OpenCLConstantAddressSpace:
7187 case AttributeList::AT_OpenCLGenericAddressSpace:
7188 case AttributeList::AT_AddressSpace:
7197 case AttributeList::AT_VectorSize:
7201 case AttributeList::AT_ExtVectorType:
7205 case AttributeList::AT_NeonVectorType:
7210 case AttributeList::AT_NeonPolyVectorType:
7215 case AttributeList::AT_OpenCLAccess:
7235 endIndex = state.getCurrentChunkIndex();
7237 endIndex = state.getDeclarator().getNumTypeObjects();
7238 bool allowOnArrayType =
7239 state.getDeclarator().isPrototypeContext() &&
7241 if (state.getSema().checkNullabilityTypeSpecifier(
7246 allowOnArrayType)) {
7254 case AttributeList::AT_ObjCKindOf:
7262 state.getSema().Diag(attr.
getLoc(),
7263 diag::err_objc_kindof_wrong_position)
7266 state.getDeclarator().getDeclSpec().getLocStart(),
"__kindof ");
7271 if (state.getSema().checkObjCKindOfType(type, attr.
getLoc()))
7291 if (!state.getSema().getLangOpts().OpenCL ||
7300 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
7302 auto *Def = Var->getDefinition();
7305 InstantiateVariableDefinition(PointOfInstantiation, Var);
7306 Def = Var->getDefinition();
7313 if (Var->getPointOfInstantiation().isInvalid() && Def) {
7314 assert(Var->getTemplateSpecializationKind() ==
7316 "explicit instantiation with no point of instantiation");
7317 Var->setTemplateSpecializationKind(
7318 Var->getTemplateSpecializationKind(), PointOfInstantiation);
7362 completeExprArrayBound(E);
7369 return RequireCompleteType(E->
getExprLoc(),
T, Diagnoser);
7374 return RequireCompleteExprType(E, Diagnoser);
7396 if (RequireCompleteTypeImpl(Loc, T, &Diagnoser))
7399 if (!Tag->getDecl()->isCompleteDefinitionRequired()) {
7400 Tag->getDecl()->setCompleteDefinitionRequired();
7401 Consumer.HandleTagDeclRequiredDefinition(Tag->getDecl());
7431 bool OnlyNeedComplete) {
7433 if (!getLangOpts().Modules && !getLangOpts().ModulesLocalVisibility)
7438 if (isa<TagDecl>(D) && cast<TagDecl>(D)->isBeingDefined()) {
7442 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
7443 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
7445 D = RD->getDefinition();
7446 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
7447 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
7449 if (OnlyNeedComplete && ED->isFixed()) {
7453 *Suggested =
nullptr;
7454 for (
auto *Redecl : ED->redecls()) {
7455 if (isVisible(Redecl))
7457 if (Redecl->isThisDeclarationADefinition() ||
7458 (Redecl->isCanonicalDecl() && !*Suggested))
7459 *Suggested = Redecl;
7463 D = ED->getDefinition();
7464 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7465 if (
auto *Pattern = FD->getTemplateInstantiationPattern())
7467 D = FD->getDefinition();
7468 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
7469 if (
auto *Pattern = VD->getTemplateInstantiationPattern())
7471 D = VD->getDefinition();
7473 assert(D &&
"missing definition for pattern of instantiated definition");
7482 Source->CompleteRedeclChain(D);
7483 return isVisible(D);
7492 if (!RD->
hasAttr<MSInheritanceAttr>()) {
7493 MSInheritanceAttr::Spelling IM;
7500 IM = MSInheritanceAttr::Keyword_single_inheritance;
7503 IM = MSInheritanceAttr::Keyword_multiple_inheritance;
7506 IM = MSInheritanceAttr::Keyword_unspecified_inheritance;
7510 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
7523 TypeDiagnoser *Diagnoser) {
7536 if (!MPTy->getClass()->isDependentType()) {
7537 (void)isCompleteType(Loc,
QualType(MPTy->getClass(), 0));
7548 if (Def && !isa<EnumDecl>(Def))
7549 checkSpecializationVisibility(Loc, Def);
7556 !hasVisibleDefinition(Def, &SuggestedDef,
true)) {
7559 bool TreatAsComplete = Diagnoser && !isSFINAEContext();
7561 diagnoseMissingImport(Loc, SuggestedDef, MissingImportKind::Definition,
7563 return !TreatAsComplete;
7596 Source->CompleteType(TagD);
7600 Source->CompleteType(IFace->getDecl());
7605 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
7615 MaybeTemplate = Array->getElementType();
7617 bool Instantiated =
false;
7618 bool Diagnosed =
false;
7620 = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
7621 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
7622 Diagnosed = InstantiateClassTemplateSpecialization(
7625 Instantiated =
true;
7628 = dyn_cast<CXXRecordDecl>(Record->getDecl())) {
7630 if (!Rec->isBeingDefined() && Pattern) {
7632 assert(MSI &&
"Missing member specialization information?");
7636 Diagnosed = InstantiateClass(Loc, Rec, Pattern,
7637 getTemplateInstantiationArgs(Rec),
7640 Instantiated =
true;
7648 if (Diagnoser && Diagnosed)
7654 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
7664 Diagnoser->diagnose(*
this, Loc, T);
7671 : diag::note_forward_declaration)
7675 if (IFace && !IFace->getDecl()->isInvalidDecl())
7676 Diag(IFace->getDecl()->getLocation(), diag::note_forward_class);
7681 ExternalSource->MaybeDiagnoseMissingCompleteType(Loc, T);
7689 return RequireCompleteType(Loc, T, Diagnoser);
7702 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
7729 if ((isCompleteType(Loc, ElemType) || ElemType->isVoidType()) &&
7747 if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
7757 for (
const auto &I : RD->
vbases())
7758 Diag(I.getLocStart(), diag::note_constexpr_virtual_base_here)
7759 << I.getSourceRange();
7762 Diag(RD->
getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
7764 for (
const auto &I : RD->
bases()) {
7765 if (!I.getType()->isLiteralType(Context)) {
7766 Diag(I.getLocStart(),
7767 diag::note_non_literal_base_class)
7768 << RD << I.getType() << I.getSourceRange();
7772 for (
const auto *I : RD->
fields()) {
7773 if (!I->getType()->isLiteralType(Context) ||
7774 I->getType().isVolatileQualified()) {
7775 Diag(I->getLocation(), diag::note_non_literal_field)
7776 << RD << I << I->getType()
7777 << I->getType().isVolatileQualified();
7785 assert(Dtor &&
"class has literal fields and bases but no dtor?");
7790 diag::note_non_literal_user_provided_dtor :
7791 diag::note_non_literal_nontrivial_dtor) << RD;
7793 SpecialMemberIsTrivial(Dtor, CXXDestructor,
true);
7801 return RequireLiteralType(Loc, T, Diagnoser);
7827 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
7832 DiagnoseUseOfDecl(TT->getDecl(), E->
getExprLoc());
7854 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl()))
7855 return VD->getType();
7856 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
7857 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
7858 return FD->getType();
7859 }
else if (
const ObjCIvarRefExpr *IR = dyn_cast<ObjCIvarRefExpr>(E)) {
7860 return IR->getDecl()->getType();
7862 if (PR->isExplicitProperty())
7863 return PR->getExplicitProperty()->getType();
7864 }
else if (
auto *PE = dyn_cast<PredefinedExpr>(E)) {
7865 return PE->getType();
7875 using namespace sema;
7877 if (isa<ParenExpr>(E)) {
7879 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
7907 bool AsUnevaluated) {
7912 if (AsUnevaluated && CodeSynthesisContexts.empty() &&
7916 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
7928 Diag(Loc, diag::err_only_enums_have_underlying_types);
7937 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
7938 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
7943 assert(ED &&
"EnumType has no EnumDecl");
7945 DiagnoseUseOfDecl(ED, Loc);
7948 assert(!Underlying.
isNull());
7954 llvm_unreachable(
"unknown unary transform type");
7961 if (RequireCompleteType(Loc, T, diag::err_atomic_specifier_bad_type, 0))
7964 int DisallowedKind = -1;
7979 if (DisallowedKind != -1) {
7980 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.
bool CheckNoCallerSavedRegsAttr(const AttributeList &attr)
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
static void checkNullabilityConsistency(Sema &S, SimplePointerKind pointerKind, SourceLocation pointerLoc, SourceLocation pointerEndLoc=SourceLocation())
Complains about missing nullability if the file containing pointerLoc has other uses of nullability (...
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
Helper for figuring out the default CC for a function declarator type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
bool CheckNoReturnAttr(const AttributeList &attr)
AttributePool & getAttributePool() const
static void HandleExtVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
ParameterABI getABI() const
Return the ABI treatment of this parameter.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
TypeLoc getValueLoc() const
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
unsigned UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
const Type * Ty
The locally-unqualified type.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for literal type diagnostic message.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl *> Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
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.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
A (possibly-)qualified type.
bool isBlockPointerType() const
bool isMemberPointerType() const
void setStarLoc(SourceLocation Loc)
Wrapper for source info for tag types.
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
Distribute an objc_gc type attribute that was written on the declarator.
AttributeList * getNext() const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static const TSS TSS_unsigned
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
QualType BuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
__auto_type (GNU extension)
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
void setNameEndLoc(SourceLocation Loc)
static const TST TST_wchar
#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)
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
void setStarLoc(SourceLocation Loc)
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
NullabilityKind
Describes the nullability of a particular type.
void setExceptionSpecRange(SourceRange R)
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.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TypeLoc getValueLoc() const
bool isRealFloatingType() const
Floating point categories.
void setEmbeddedInDeclarator(bool isInDeclarator)
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isRecordType() const
bool isDecltypeAuto() const
static const TST TST_typeofExpr
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
static const TST TST_char16
Decl - This represents one declaration (or definition), e.g.
static NullabilityKind mapNullabilityAttrKind(AttributeList::Kind kind)
Map a nullability attribute kind to a nullability kind.
TagDecl * getDecl() const
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
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.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier, if any.
A constructor named via a template-id.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
SourceLocation getLParenLoc() const
The base class of the type hierarchy.
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
DiagnosticsEngine & getDiagnostics() const
One instance of this struct is used for each type in a declarator that is parsed. ...
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
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".
const TargetInfo & getTargetInfo() const
The attribute is part of a DeclaratorChunk.
RefQualifierKind RefQualifier
A container of type source information.
bool getHasRegParm() const
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
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.
AttributeList *& getAttrListRef()
An overloaded operator name, e.g., operator+.
bool getSuppressSystemWarnings() const
Wrapper for source info for pointers decayed from arrays and functions.
Abstract base class used for diagnosing integer constant expression violations.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
SourceLocation getEllipsisLoc() const
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
#define NULLABILITY_TYPE_ATTRS_CASELIST
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
bool checkObjCKindOfType(QualType &type, SourceLocation loc)
Check the application of the Objective-C '__kindof' qualifier to the given type.
void setParensRange(SourceRange range)
An identifier, stored as an IdentifierInfo*.
QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
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
bool isArgIdent(unsigned Arg) const
Information about one declarator, including the parsed type information and the identifier.
void removeObjCLifetime()
LangAS getLangASFromTargetAS(unsigned TargetAS)
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location. ...
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
bool isEnumeralType() const
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
const T * getAs() const
Member-template getAs<specific type>'.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Extra information about a function prototype.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Represents a C++17 deduced template specialization type.
The "__interface" keyword.
static const TST TST_interface
static const TST TST_char
A namespace, stored as a NamespaceDecl*.
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 ...
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
TypeLoc getNamedTypeLoc() const
bool isInvalidDecl() const
void setAttrOperandParensRange(SourceRange range)
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
bool hasDefinition() const
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
ParmVarDecl - Represents a parameter to a function.
static bool handleFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
Process an individual function attribute.
OpenCLOptions & getOpenCLOptions()
AttributeList * getList() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
The collection of all-type qualifiers we support.
bool isVariableArrayType() const
bool needsExtraLocalData() const
SourceRange getTypeSpecWidthRange() const
void setParensRange(SourceRange Range)
static const TST TST_unknown_anytype
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type.
Base wrapper for a particular "section" of type source info.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
RecordDecl - Represents a struct/union/class.
SourceLocation getLoc() const
__ptr16, alignas(...), etc.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
TypeSpecifierSign getWrittenSignSpec() const
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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...
static bool hasOuterPointerLikeChunk(const Declarator &D, unsigned endIndex)
Returns true if any of the declarator chunks before endIndex include a level of indirection: array...
SourceLocation getExceptionSpecLocBeg() const
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 ...
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
static const TST TST_decimal32
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Represents a class type in Objective C.
static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State, QualType &T, TypeAttrLocation TAL)
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.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
ArrayRef< QualType > getParamTypes() const
SourceLocation getTypeSpecTypeLoc() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
QualType BuildParenType(QualType T)
Build a paren type including T.
void setBuiltinLoc(SourceLocation Loc)
bool isSpelledAsLValue() const
field_range fields() const
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
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.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
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...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
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...
bool hasAutoTypeSpec() const
bool isReferenceType() const
void setElaboratedKeywordLoc(SourceLocation Loc)
static std::string getPrintableNameForEntity(DeclarationName Entity)
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
static const TST TST_error
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6...
static const TST TST_enum
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type...
SourceLocation getLocStart() const LLVM_READONLY
TypeLoc getNextTypeLoc() const
static const TSW TSW_unspecified
void copy(DependentTemplateSpecializationTypeLoc Loc)
bool hasTagDefinition() const
TSC getTypeSpecComplex() const
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...
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
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
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the 'restrict' qualifier, if any.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
A user-defined literal name, e.g., operator "" _i.
unsigned getTypeQuals() const
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
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 getProducesResult() const
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...
TypeSpecifierWidth getWrittenWidthSpec() const
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 findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
void setNameLoc(SourceLocation Loc)
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TypeSourceInfo *&ReturnTypeInfo)
Represents the results of name lookup.
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 refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static void fixItNullability(Sema &S, DiagnosticBuilder &Diag, SourceLocation PointerLoc, NullabilityKind Nullability)
Creates a fix-it to insert a C-style nullability keyword at pointerLoc, taking into account whitespac...
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t', '\f', '\v', '\n', '\r'.
void setCaretLoc(SourceLocation Loc)
TagKind getTagKind() const
static void spliceAttrOutOfList(AttributeList &attr, AttributeList *&head)
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator, PointerWrappingDeclaratorKind &wrappingKind)
Classify the given declarator, whose type-specified is type, based on what kind of pointer it refers ...
const FileInfo & getFile() const
bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T)
Check if type T corresponding to declaration specifier DS is disabled due to required OpenCL extensio...
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
bool isTypeSpecPipe() const
const Type * getClass() 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"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, QualType &declSpecType)
Given that there are attributes written on the declarator itself, try to distribute any type attribut...
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const clang::PrintingPolicy & getPrintingPolicy() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
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.
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
const Type * getClass() const
void expandBuiltinRange(SourceRange Range)
enum clang::DeclaratorChunk::@198 Kind
TSS getTypeSpecSign() const
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.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
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.
Represents an Objective-C protocol declaration.
#define MS_TYPE_ATTRS_CASELIST
void setUnaligned(bool flag)
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static FileID getNullabilityCompletenessCheckFileID(Sema &S, SourceLocation loc)
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
const LangOptions & getLangOpts() const
SourceLocation getConstSpecLoc() const
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 CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
void setLocalRangeBegin(SourceLocation L)
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
Represents an ObjC class declaration.
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.
void copy(ElaboratedTypeLoc Loc)
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getIncludeLoc() const
SourceRange getSourceRange() const LLVM_READONLY
is ARM Neon polynomial vector
SmallVector< TemplateTypeParmDecl *, 4 > AutoTemplateParams
Store the list of the auto parameters for a generic lambda.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierInfo * getIdentifier() const
CanQualType UnsignedCharTy
void setAttrNameLoc(SourceLocation loc)
const LangOptions & LangOpts
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.
static const TST TST_float
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
bool isExpressionContext() const
Determine whether this declaration appears in a context where an expression could appear...
bool IsStructurallyEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
ExtInfo withCallingConv(CallingConv cc) const
void * getOpaqueData() const
Get the pointer where source information is stored.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
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.
static OpenCLAccessAttr::Spelling getImageAccess(const AttributeList *Attrs)
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
Sema - This implements semantic analysis and AST building for C.
static const TSW TSW_long
CXXRecordDecl * getMostRecentDecl()
static bool handleObjCGCTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type...
A little helper class used to produce diagnostics.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SourceLocation getUnalignedSpecLoc() const
Represents a prototype with parameter type info, e.g.
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl *> protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
static void checkExtParameterInfos(Sema &S, ArrayRef< QualType > paramTypes, const FunctionProtoType::ExtProtoInfo &EPI, llvm::function_ref< SourceLocation(unsigned)> getParamLoc)
Check the extended parameter information.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
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.
bool isEnabled(llvm::StringRef Ext) const
void setSizeExpr(Expr *Size)
A conversion function name, e.g., operator int.
SourceRange getRange() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
TST getTypeSpecType() const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
void setAttrNameLoc(SourceLocation loc)
Scope * getCurScope() const
Retrieve the parser's current scope.
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
void setAttrExprOperand(Expr *e)
unsigned hasStatic
True if this dimension included the 'static' keyword.
Type source information for an attributed type.
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.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
QualType getPointeeType() const
llvm::StringRef getAsString(SyncScope S)
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, ArrayRef< NamedDecl *> DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
const FunctionProtoType * T
Declaration of a template type parameter.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
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.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isObjCRetainableType() const
QualType getTypeOfExprType(Expr *e) const
GCC extension.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
Qualifiers::GC getObjCGCAttr() const
Returns gc attribute of this type.
QualType getParenType(QualType NamedType) const
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
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.
SourceLocation getVolatileSpecLoc() const
QualType BuildAtomicType(QualType T, SourceLocation Loc)
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
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 ...
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 to c...
void completeExprArrayBound(Expr *E)
ObjCLifetime getObjCLifetime() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
SourceLocation getBeginLoc() const
bool isConstexprSpecified() const
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
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.
Represents a C++ template name within the type system.
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.
static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T)
Produce an appropriate diagnostic for a declarator with top-level parentheses.
A namespace alias, stored as a NamespaceAliasDecl*.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
static QualType getDecltypeForExpr(Sema &S, Expr *E)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
CanQualType UnsignedInt128Ty
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
void setNameLoc(SourceLocation Loc)
bool isFunctionOrMethod() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
SourceLocation Loc
Loc - The place where this type was defined.
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...
Qualifiers Quals
The local qualifiers.
void setAttrExprOperand(Expr *e)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
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.
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.
SourceLocation getEnd() const
Compare two source locations.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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].
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
bool isFriendSpecified() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Wraps an identifier and optional source location for the identifier.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
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 getCommaLoc() const
SourceLocation getLocEnd() const LLVM_READONLY
bool isCXX11Attribute() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
static const TSW TSW_short
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
AttributeList * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
CallingConv
CallingConv - Specifies the calling convention that a function uses.
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
bool isFirstDeclarator() const
AttributedType::Kind getAttrKind() const
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
bool hasAttrExprOperand() const
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
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
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
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.
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.
There is no lifetime qualification on this type.
Information about a FileID, basically just the logical file that it represents and include stack info...
void setAttrOperandParensRange(SourceRange range)
const AttributeList * getAttributes() const
is AltiVec 'vector Pixel'
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.
Assigning into this object requires the old value to be released and the new value to be retained...
bool isBuiltinType() const
Helper methods to distinguish type categories.
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.
ExtProtoInfo getExtProtoInfo() const
SCS getStorageClassSpec() const
void setKNRPromoted(bool promoted)
ASTContext & getASTContext() const
SourceLocation getRParenLoc() const
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)
static const TST TST_float16
const ExtParameterInfo * ExtParameterInfos
Encodes a location in the source.
bool isTypeSpecOwned() const
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
static const TST TST_auto_type
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
bool isContextSensitiveKeywordAttribute() const
LangAS getAddressSpace() const
Return the address space of this type.
PointerDeclaratorKind
Describes the kind of a pointer a declarator describes.
Interfaces are the core concept in Objective-C for object oriented design.
FunctionDefinitionKind getFunctionDefinitionKind() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
TagDecl - Represents the declaration of a struct/union/class/enum.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
ASTContext & getASTContext() const LLVM_READONLY
static const TST TST_union
CallingConv getCC() const
IdentifierInfo * getScopeName() const
static void moveAttrFromListToList(AttributeList &attr, AttributeList *&fromList, AttributeList *&toList)
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static const TSS TSS_signed
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
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>::".
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...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
MemberPointerTypeInfo Mem
SimplePointerKind
A simple notion of pointer kinds, which matches up with the various pointer declarators.
QualType getEquivalentType() const
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
Decl * getRepAsDecl() const
static bool isBlockPointer(Expr *Arg)
is AltiVec 'vector bool ...'
SplitQualType getSplitUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isFunctionProtoType() const
static const TST TST_typeofType
void setAmpLoc(SourceLocation Loc)
void setLBracketLoc(SourceLocation Loc)
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
AttributeList *& getAttrListRef()
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 BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
SourceLocation getRAngleLoc() const
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
static bool isVectorSizeTooLarge(unsigned NumElements)
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier, if any.
bool isStaticMember()
Returns true if this declares a static member.
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isVLASupported() const
Whether target supports variable-length arrays.
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
static void recordNullabilitySeen(Sema &S, SourceLocation loc)
Marks that a nullability feature has been used in the file containing loc.
std::string getAsString() const
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;...
Represents a pack expansion of types.
void setLParenLoc(SourceLocation Loc)
StringRef getName() const
Return the actual identifier string.
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...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Base class for declarations which introduce a typedef-name.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
TSW getTypeSpecWidth() const
static const TST TST_decltype_auto
void setClassTInfo(TypeSourceInfo *TI)
TagTypeKind
The kind of a tag type.
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
CanQualType ObjCBuiltinIdTy
Dataflow Directional Tag Classes.
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
static const TSS TSS_unspecified
SourceLocation getTypeSpecWidthLoc() const
ExtInfo getExtInfo() const
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)
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
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
static const TST TST_void
SourceLocation getLocStart() const LLVM_READONLY
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
static const TST TST_int128
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
QualType getUnderlyingType() const
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
CanQualType UnsignedLongLongTy
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.
Expr * getArgAsExpr(unsigned Arg) const
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
bool isBooleanType() const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
LLVM_READONLY bool isIdentifierBody(unsigned char c, bool AllowDollar=false)
Returns true if this is a body character of a C identifier, which is [a-zA-Z0-9_].
SourceLocation getTypeSpecSignLoc() const
SourceLocation getLocEnd() const LLVM_READONLY
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
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.
The maximum supported address space number.
A pointer to member type per C++ 8.3.3 - Pointers to members.
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...
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
bool hasObjCLifetime() const
SplitQualType getSingleStepDesugaredType() const
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
A type that was preceded by the 'template' keyword, stored as a Type*.
static const TST TST_unspecified
IdentifierInfo * getName() const
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
unsigned getNumParams() const
void setNameLoc(SourceLocation Loc)
bool hasAttrEnumOperand() 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".
Syntax
The style used to specify an attribute.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
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...
bool isIncompleteArrayType() const
void setAttrEnumOperandLoc(SourceLocation loc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static const TST TST_decimal128
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
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...
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool isArgExpr(unsigned Arg) const
void setNext(AttributeList *N)
bool isAtomicType() const
bool isFunctionType() const
void setInvalid(bool b=true) const
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.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
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.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
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...
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
SourceLocation getTypeSpecTypeNameLoc() const
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
SourceRange getExceptionSpecRange() const
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
bool isObjectType() const
Determine whether this type is an object type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) 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...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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.
UnqualTypeLoc getUnqualifiedLoc() const
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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 isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
PointerWrappingDeclaratorKind
Describes a declarator chunk wrapping a pointer that marks inference as unexpected.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
unsigned AutoTemplateParameterDepth
If this is a generic lambda, use this as the depth of each 'auto' parameter, during initial AST const...
An attributed type is a type to which a type attribute has been applied.
void setKWLoc(SourceLocation Loc)
unsigned TypeQuals
For now, sema will catch these as invalid.
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SourceLocation getRestrictSpecLoc() const
Represents a C++ struct/union/class.
SourceLocation getEllipsisLoc() const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability, SourceLocation nullabilityLoc, bool isContextSensitive, bool allowArrayTypes)
Check whether a nullability type specifier can be added to the given type.
void setParam(unsigned i, ParmVarDecl *VD)
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.
static const TST TST_float128
void setLParenLoc(SourceLocation Loc)
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static const TST TST_bool
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
bool hasAttrOperand() const
SourceManager & getSourceManager() const
A template-id, e.g., f<int>.
static void HandleAddressSpaceTypeAttribute(QualType &Type, const AttributeList &Attr, Sema &S)
HandleAddressSpaceTypeAttribute - Process an address_space attribute on the specified type...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ParsedType getRepAsType() const
Defines the clang::TargetInfo interface.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
A SourceLocation and its associated SourceManager.
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
SourceLocation getAtomicSpecLoc() const
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
static Qualifiers fromCVRMask(unsigned CVR)
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
static const TSW TSW_longlong
static Decl::Kind getKind(const Decl *D)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
static OpaquePtr make(QualType P)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static void emitNullabilityConsistencyWarning(Sema &S, SimplePointerKind PointerKind, SourceLocation PointerLoc, SourceLocation PointerEndLoc)
A reference to a declared variable, function, enum, etc.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
Represents an extended address space qualifier where the input address space value is dependent...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void copy(TypeLoc other)
Copies the other type loc into this one.
static const TST TST_atomic
bool isPointerType() const
SourceManager & SourceMgr
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
static const TST TST_struct
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.
DeclaratorContext getContext() 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)
static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, const AttributeList *Attrs)
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
void copy(DependentNameTypeLoc Loc)
Expr * getRepAsExpr() const
QualifiedFunctionKind
Kinds of declarator that cannot contain a qualified function type.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
bool hasExplicitCallingConv(QualType &T)
No keyword precedes the qualified type name.
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...
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
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.
static void spliceAttrIntoList(AttributeList &attr, AttributeList *&head)
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
attr::Kind getKind() const
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.
SourceLocation getLocEnd() const LLVM_READONLY
The global specifier '::'. There is no stored value.
bool isPrototypeContext() const
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
Wrapper for source info for pointers.
SourceLocation getBegin() const
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
Wrapper for source info for block pointers.
unsigned size() const
Determine the number of type parameters in this list.
An implicit 'self' parameter.
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
A deduction-guide name (a template-name)
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new 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()
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
SourceRange getTypeofParensRange() const
QualType getPointeeType() const
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...
QualType getType() const
Return the type wrapped by this type source info.
This parameter (which must have pointer type) is a Swift indirect result parameter.
QualType BuildTypeofExprType(Expr *E, SourceLocation Loc)
void setUnderlyingTInfo(TypeSourceInfo *TI) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
AttributeList - Represents a syntactic attribute.
CanQualType UnsignedIntTy
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...
static void fillAttributedTypeLoc(AttributedTypeLoc TL, const AttributeList *attrs, const AttributeList *DeclAttrs=nullptr)
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?