34 #include "llvm/ADT/SmallPtrSet.h"
35 #include "llvm/ADT/SmallString.h"
36 #include "llvm/Support/ErrorHandling.h"
38 using namespace clang;
68 bool useExpansionLoc =
true;
70 case AttributeList::AT_ObjCGC: WhichType =
TDS_Pointer;
break;
75 useExpansionLoc =
false;
85 if (useExpansionLoc && loc.
isMacroID() && II) {
86 if (II->
isStr(
"strong")) {
88 }
else if (II->
isStr(
"weak")) {
93 S.
Diag(loc, diag::warn_type_attribute_wrong_type) << name << WhichType
99 #define OBJC_POINTER_TYPE_ATTRS_CASELIST \
100 case AttributeList::AT_ObjCGC: \
101 case AttributeList::AT_ObjCOwnership
104 #define FUNCTION_TYPE_ATTRS_CASELIST \
105 case AttributeList::AT_NoReturn: \
106 case AttributeList::AT_CDecl: \
107 case AttributeList::AT_FastCall: \
108 case AttributeList::AT_StdCall: \
109 case AttributeList::AT_ThisCall: \
110 case AttributeList::AT_Pascal: \
111 case AttributeList::AT_VectorCall: \
112 case AttributeList::AT_MSABI: \
113 case AttributeList::AT_SysVABI: \
114 case AttributeList::AT_Regparm: \
115 case AttributeList::AT_Pcs: \
116 case AttributeList::AT_IntelOclBicc
119 #define MS_TYPE_ATTRS_CASELIST \
120 case AttributeList::AT_Ptr32: \
121 case AttributeList::AT_Ptr64: \
122 case AttributeList::AT_SPtr: \
123 case AttributeList::AT_UPtr
126 #define NULLABILITY_TYPE_ATTRS_CASELIST \
127 case AttributeList::AT_TypeNonNull: \
128 case AttributeList::AT_TypeNullable: \
129 case AttributeList::AT_TypeNullUnspecified
134 class TypeProcessingState {
160 : sema(sema), declarator(declarator),
162 trivial(
true), hasSavedAttrs(
false) {}
164 Sema &getSema()
const {
172 bool isProcessingDeclSpec()
const {
176 unsigned getCurrentChunkIndex()
const {
180 void setCurrentChunkIndex(
unsigned idx) {
186 if (isProcessingDeclSpec())
187 return getMutableDeclSpec().getAttributes().getListRef();
192 void saveDeclSpecAttrs() {
194 if (hasSavedAttrs)
return;
196 DeclSpec &spec = getMutableDeclSpec();
199 savedAttrs.push_back(attr);
200 trivial &= savedAttrs.empty();
201 hasSavedAttrs =
true;
207 ignoredTypeAttrs.push_back(&attr);
213 for (
auto *
Attr : ignoredTypeAttrs)
217 ~TypeProcessingState() {
220 restoreDeclSpecAttrs();
224 DeclSpec &getMutableDeclSpec()
const {
228 void restoreDeclSpecAttrs() {
229 assert(hasSavedAttrs);
231 if (savedAttrs.empty()) {
232 getMutableDeclSpec().getAttributes().set(
nullptr);
236 getMutableDeclSpec().getAttributes().set(savedAttrs[0]);
237 for (
unsigned i = 0, e = savedAttrs.size() - 1; i != e; ++i)
238 savedAttrs[i]->setNext(savedAttrs[i+1]);
239 savedAttrs.back()->setNext(
nullptr);
257 assert(cur && cur->
getNext() &&
"ran out of attrs?");
303 if (attr.
getKind() == AttributeList::AT_ObjCGC)
305 assert(attr.
getKind() == AttributeList::AT_ObjCOwnership);
320 bool onlyBlockPointers) {
326 for (; i != 0; --i) {
328 switch (fnChunk.
Kind) {
344 for (--i; i != 0; --i) {
346 switch (ptrChunk.
Kind) {
356 if (onlyBlockPointers)
365 llvm_unreachable(
"bad declarator chunk kind");
371 llvm_unreachable(
"bad declarator chunk kind");
389 Declarator &declarator = state.getDeclarator();
392 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
394 switch (chunk.
Kind) {
400 if (state.isProcessingDeclSpec() &&
401 attr.
getKind() == AttributeList::AT_ObjCOwnership)
404 if (!destChunk) destChunk = &chunk;
417 if (state.isProcessingDeclSpec() &&
418 attr.
getKind() == AttributeList::AT_ObjCOwnership) {
423 dest->getAttrListRef());
447 Declarator &declarator = state.getDeclarator();
451 unsigned innermost = -1U;
452 bool considerDeclSpec =
true;
455 switch (chunk.
Kind) {
469 considerDeclSpec =
false;
477 if (considerDeclSpec) {
482 state.saveDeclSpecAttrs();
491 if (innermost != -1U) {
499 state.addIgnoredTypeAttr(attr);
509 Declarator &declarator = state.getDeclarator();
513 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
515 switch (chunk.
Kind) {
543 Declarator &declarator = state.getDeclarator();
563 state.saveDeclSpecAttrs();
570 state.getDeclarator().getAttrListRef());
576 state.getCurrentAttrListRef(),
582 state.addIgnoredTypeAttr(attr);
591 Declarator &declarator = state.getDeclarator();
602 state.addIgnoredTypeAttr(attr);
617 assert(state.getDeclarator().getAttributes() &&
"declarator has no attrs!");
625 if (attr->isCXX11Attribute())
628 switch (attr->getKind()) {
633 case AttributeList::AT_NSReturnsRetained:
634 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
650 case AttributeList::AT_ObjCKindOf:
656 }
while ((attr = next));
663 Declarator &declarator = state.getDeclarator();
713 loc, loc, declarator));
728 typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
732 if (!(RemoveTQs & Qual.first))
736 if (TypeQuals & Qual.first)
737 S.
Diag(Qual.second, DiagID)
742 TypeQuals &= ~Qual.first;
750 bool failOnError =
false) {
753 if (!objcObjectType || !objcObjectType->getInterface()) {
754 S.
Diag(loc, diag::err_objc_type_args_non_class)
767 S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
778 if (objcObjectType->isSpecialized()) {
779 S.
Diag(loc, diag::err_objc_type_args_specialized_class)
791 unsigned numTypeParams = typeParams->
size();
792 bool anyPackExpansions =
false;
793 for (
unsigned i = 0, n = typeArgs.size(); i != n; ++i) {
801 bool diagnosed =
false;
804 rangeToRemove = attr.getLocalSourceRange();
805 if (attr.getTypePtr()->getImmediateNullability()) {
806 typeArg = attr.
getTypePtr()->getModifiedType();
807 S.
Diag(attr.getLocStart(),
808 diag::err_objc_type_arg_explicit_nullability)
815 S.
Diag(qual.getLocStart(), diag::err_objc_type_arg_qualified)
824 finalTypeArgs.push_back(typeArg);
827 anyPackExpansions =
true;
831 if (!anyPackExpansions) {
832 if (i < numTypeParams) {
833 typeParam = typeParams->
begin()[i];
836 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
857 assert(anyPackExpansions &&
"Too many arguments?");
866 if (typeArgObjC->isObjCIdType()) {
869 if (boundObjC->isObjCIdType())
878 diag::err_objc_type_arg_does_not_match_bound)
895 assert(anyPackExpansions &&
"Too many arguments?");
906 diag::err_objc_type_arg_does_not_match_bound)
924 diag::err_objc_type_arg_not_id_compatible)
935 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
936 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
937 << (typeArgs.size() < typeParams->
size())
959 bool failOnError =
false) {
966 objT->getTypeArgsAsWritten(),
968 objT->isKindOfTypeAsWritten());
984 objPtr->isKindOfType());
989 if (
type->isObjCClassType()) {
991 type = ctx.getObjCObjectType(ctx.ObjCBuiltinClassTy, { }, protocols,
993 return ctx.getObjCObjectPointerType(type);
996 S.
Diag(loc, diag::err_invalid_protocol_qualifiers)
1016 if (!TypeArgs.empty()) {
1021 if (FailOnError && Result.
isNull())
1025 if (!Protocols.empty()) {
1030 ProtocolLocs.data(),
1032 if (FailOnError && Result.
isNull())
1059 auto ObjCObjectTL = ObjCObjectPointerTL.getPointeeLoc()
1069 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
1070 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
1071 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
1072 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
1075 return CreateParsedType(Result, ResultTInfo);
1100 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
1104 ActualTypeArgInfos.clear();
1108 assert(TypeArgInfo &&
"No type source info?");
1109 ActualTypeArgInfos.push_back(TypeArgInfo);
1115 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
1119 ProtocolLocs, ProtocolRAngleLoc,
1134 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
1140 if (ObjCObjectTL.getNumTypeArgs() > 0) {
1141 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
1143 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
1144 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
1145 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
1152 if (ObjCObjectTL.getNumProtocols() > 0) {
1153 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
1154 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
1155 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
1156 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
1157 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
1164 ObjCObjectTL.setHasBaseTypeAsWritten(
true);
1165 if (ObjCObjectTL.getType() == T)
1166 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
1168 ObjCObjectTL.getBaseLoc().initialize(
Context, Loc);
1184 Sema &S = state.getSema();
1185 Declarator &declarator = state.getDeclarator();
1205 "Unknown TSS value");
1219 "Unknown TSS value");
1228 "Unknown TSS value");
1233 "Unknown TSS value");
1263 S.
Diag(DeclLoc, diag::ext_missing_declspec)
1273 S.
Diag(DeclLoc, diag::err_missing_type_specifier)
1281 S.
Diag(DeclLoc, diag::err_missing_actual_pipe_type)
1285 S.
Diag(DeclLoc, diag::ext_missing_type_specifier)
1305 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1324 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
1353 << Result <<
"cl_khr_fp64";
1362 Result = Context.
IntTy;
1373 Result = Context.
IntTy;
1396 "Can't handle qualifiers on typedef names yet!");
1398 if (Result.isNull()) {
1402 StringRef TypeName = Result.getBaseTypeIdentifier()->getName();
1404 llvm::StringSwitch<bool>(TypeName)
1405 .Cases(
"atomic_int",
"atomic_uint",
"atomic_float",
1406 "atomic_flag",
true)
1410 << Result <<
"cl_khr_int64_base_atomics";
1416 << Result <<
"cl_khr_int64_extended_atomics";
1420 !TypeName.compare(
"atomic_double")) {
1422 << Result <<
"cl_khr_fp64";
1426 (Result->isImage2dMSAAT() || Result->isImage2dArrayMSAAT() ||
1427 Result->isImage2dArrayMSAATDepth() ||
1428 Result->isImage2dMSAATDepth())) {
1430 << Result <<
"cl_khr_gl_msaa_sharing";
1441 assert(!Result.isNull() &&
"Didn't get a type for typeof?");
1442 if (!Result->isDependentType())
1450 assert(E &&
"Didn't get an expression for typeof?");
1453 if (Result.isNull()) {
1454 Result = Context.
IntTy;
1461 assert(E &&
"Didn't get an expression for decltype?");
1464 if (Result.isNull()) {
1465 Result = Context.
IntTy;
1472 assert(!Result.isNull() &&
"Didn't get a type for __underlying_type?");
1476 if (Result.isNull()) {
1477 Result = Context.
IntTy;
1490 assert(LSI &&
"No LambdaScopeInfo on the stack!");
1493 const bool IsParameterPack = declarator.
hasEllipsis();
1507 TemplateParameterDepth,
1508 AutoParameterPosition,
1509 nullptr,
false, IsParameterPack);
1534 assert(!Result.isNull() &&
"Didn't get a type for _Atomic?");
1536 if (Result.isNull()) {
1537 Result = Context.
IntTy;
1543 Result = Context.
IntTy;
1555 assert(typeSize > 0 &&
"type size for vector must be greater than 0 bits");
1590 if (TypeQuals &&
Result->isFunctionType()) {
1594 ? diag::warn_typecheck_function_qualifiers_ignored
1595 : diag::warn_typecheck_function_qualifiers_unspecified);
1608 if (TypeQuals &&
Result->isReferenceType()) {
1610 S, DS, TypeQuals, Result,
1612 diag::warn_typecheck_reference_qualifiers);
1619 && TypeQuals &
Result.getCVRQualifiers()) {
1638 declarator.setInvalidType(
true);
1643 assert(!
Result.isNull() &&
"This function should not return a null type");
1662 unsigned DiagID = 0;
1678 DiagID = diag::err_typecheck_invalid_restrict_invalid_pointee;
1682 DiagID = diag::err_typecheck_invalid_restrict_not_pointer;
1696 unsigned CVRA,
const DeclSpec *DS) {
1701 unsigned CVR = CVRA & ~
DeclSpec::TQ_atomic;
1775 diag::err_arc_indirect_no_ownership, type, isReference));
1777 S.
Diag(loc, diag::err_arc_indirect_no_ownership) << type << isReference;
1781 assert(implicitLifetime &&
"didn't infer any lifetime!");
1835 S.
Diag(Loc, diag::err_compound_qualified_function_type)
1858 Diag(Loc, diag::err_illegal_decl_pointer_to_reference)
1893 "Unresolved overloaded function type");
1921 Diag(Loc, diag::err_reference_to_void);
1966 S.
Diag(Loc, diag::ext_vla_folded_to_constant) << SR;
1991 Expr *ArraySize,
unsigned Quals,
2008 Diag(Loc, diag::err_illegal_decl_array_of_references)
2014 Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
2019 diag::err_array_of_abstract_type))
2026 if (!MPTy->getClass()->isDependentType())
2033 diag::err_illegal_decl_array_incomplete_type))
2038 Diag(Loc, diag::err_illegal_decl_array_of_functions)
2046 if (EltTy->getDecl()->hasFlexibleArrayMember())
2047 Diag(Loc, diag::ext_flexible_array_in_array) << T;
2049 Diag(Loc, diag::err_objc_array_of_interfaces) << T;
2057 ArraySize = Result.
get();
2061 if (ArraySize && !ArraySize->
isRValue()) {
2066 ArraySize = Result.
get();
2074 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2075 << ArraySize->
getType() << ArraySize->getSourceRange();
2094 Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
2095 << ArraySize->
getType() << ArraySize->getSourceRange();
2106 if (ConstVal.isSigned() && ConstVal.isNegative()) {
2108 Diag(ArraySize->getLocStart(), diag::err_decl_negative_array_size)
2111 Diag(ArraySize->getLocStart(), diag::err_typecheck_negative_array_size)
2112 << ArraySize->getSourceRange();
2115 if (ConstVal == 0) {
2118 Diag(ArraySize->getLocStart(),
2120 : diag::ext_typecheck_zero_array_size)
2121 << ArraySize->getSourceRange();
2124 Diag(ArraySize->getLocStart(),
2125 diag::warn_typecheck_zero_static_array_size)
2126 << ArraySize->getSourceRange();
2132 unsigned ActiveSizeBits
2135 Diag(ArraySize->getLocStart(), diag::err_array_too_large)
2136 << ConstVal.toString(10)
2137 << ArraySize->getSourceRange();
2147 Diag(Loc, diag::err_opencl_vla);
2157 Diag(Loc, diag::err_vla_non_pod) << BaseT;
2162 Diag(Loc, diag::err_vla_in_sfinae);
2167 Diag(Loc, diag::ext_vla);
2171 : diag::ext_c99_array_usage) << ASM;
2176 Diag(Loc, diag::warn_vla_used);
2191 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
2196 llvm::APSInt vecSize(32);
2198 Diag(AttrLoc, diag::err_attribute_argument_type)
2200 << ArraySize->getSourceRange();
2206 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue());
2208 if (vectorSize == 0) {
2209 Diag(AttrLoc, diag::err_attribute_zero_size)
2210 << ArraySize->getSourceRange();
2215 Diag(AttrLoc, diag::err_attribute_size_too_large)
2216 << ArraySize->getSourceRange();
2228 Diag(Loc, diag::err_func_returning_array_function)
2235 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 1 <<
2243 Diag(Loc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T;
2254 bool Invalid =
false;
2258 for (
unsigned Idx = 0, Cnt = ParamTypes.size(); Idx < Cnt; ++Idx) {
2262 Diag(Loc, diag::err_param_with_void_type);
2266 Diag(Loc, diag::err_parameters_retval_cannot_have_fp16_type) << 0 <<
2271 ParamTypes[Idx] = ParamType;
2295 Diag(Loc, diag::err_distant_exception_spec);
2302 Diag(Loc, diag::err_illegal_decl_mempointer_to_reference)
2308 Diag(Loc, diag::err_illegal_decl_mempointer_to_void)
2314 Diag(Loc, diag::err_mempointer_in_nonclass_type) << Class;
2344 Diag(Loc, diag::err_nonfunction_block_type);
2357 if (TInfo) *TInfo =
nullptr;
2362 if (
const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
2363 QT = LIT->getType();
2364 DI = LIT->getTypeSourceInfo();
2367 if (TInfo) *TInfo = DI;
2373 unsigned chunkIndex);
2380 Sema &S = state.getSema();
2381 Declarator &declarator = state.getDeclarator();
2387 unsigned outermostPointerIndex = 0;
2388 bool isBlockPointer =
false;
2389 unsigned numPointers = 0;
2391 unsigned chunkIndex = i;
2393 switch (chunk.
Kind) {
2403 outermostPointerIndex = chunkIndex;
2411 if (numPointers != 1)
return;
2413 outermostPointerIndex = chunkIndex;
2414 isBlockPointer =
true;
2431 if (numPointers == 1) {
2449 }
else if (numPointers == 2) {
2463 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
2467 outermostPointerIndex);
2488 }
const QualKinds[4] = {
2496 unsigned NumQuals = 0;
2501 for (
unsigned I = 0;
I != 4; ++
I) {
2502 if (Quals & QualKinds[
I].Mask) {
2503 if (!QualStr.empty()) QualStr +=
' ';
2504 QualStr += QualKinds[
I].Name;
2520 << QualStr << NumQuals << FixIts[0] << FixIts[1] << FixIts[2] << FixIts[3];
2526 unsigned FunctionChunkIndex) {
2536 for (
unsigned OuterChunkIndex = FunctionChunkIndex + 1,
2538 OuterChunkIndex !=
End; ++OuterChunkIndex) {
2540 switch (OuterChunk.
Kind) {
2547 diag::warn_qual_return_type,
2572 llvm_unreachable(
"unknown declarator chunk kind");
2594 Sema &SemaRef = state.getSema();
2597 ReturnTypeInfo =
nullptr;
2600 TagDecl *OwnedTagDecl =
nullptr;
2644 llvm_unreachable(
"Can't specify a type specifier in lambda grammar");
2661 switch (cast<TagDecl>(SemaRef.
CurContext)->getTagKind()) {
2662 case TTK_Enum: llvm_unreachable(
"unhandled tag kind");
2664 case TTK_Union: Error = Cxx ? 3 : 4;
break;
2724 bool HaveTrailing =
false;
2734 unsigned chunkIndex = e - i - 1;
2735 state.setCurrentChunkIndex(chunkIndex);
2740 HaveTrailing =
true;
2758 default: llvm_unreachable(
"unknown auto TypeSpecType");
2760 SemaRef.
Diag(AutoRange.
getBegin(), diag::err_auto_not_allowed)
2761 << Keyword << Error << AutoRange;
2764 }
else if (!HaveTrailing) {
2768 diag::warn_cxx98_compat_auto_type_specifier)
2777 unsigned DiagID = 0;
2782 llvm_unreachable(
"parser should not have allowed this");
2797 DiagID = diag::err_type_defined_in_alias_template;
2806 DiagID = diag::err_type_defined_in_type_specifier;
2815 DiagID = diag::err_type_defined_in_param_type;
2821 DiagID = diag::err_type_defined_in_condition;
2832 assert(!T.
isNull() &&
"This function should not return a null type");
2841 assert(FTI.
isAmbiguous &&
"no direct-initializer / function ambiguity");
2872 FTI.
NumParams ? diag::warn_parens_disambiguated_as_function_declaration
2873 : diag::warn_empty_parens_are_function_decl)
2884 if (
Comma.getFileID() !=
Name.getFileID() ||
2885 Comma.getSpellingLineNumber() !=
Name.getSpellingLineNumber()) {
2904 S.
Diag(B, diag::note_additional_parens_for_variable_declaration)
2919 S.
Diag(DeclType.
Loc, diag::note_empty_parens_default_ctor)
2924 if (Init.empty() && S.
LangOpts.CPlusPlus11)
2927 S.
Diag(DeclType.
Loc, diag::note_empty_parens_zero_initialize)
2940 unsigned ChunkIndex) {
2943 bool IsCXXInstanceMethod =
false;
2949 unsigned I = ChunkIndex;
2950 bool FoundNonParen =
false;
2951 while (I && !FoundNonParen) {
2954 FoundNonParen =
true;
2957 if (FoundNonParen) {
2960 IsCXXInstanceMethod =
2965 IsCXXInstanceMethod =
true;
2972 IsCXXInstanceMethod =
2980 IsCXXInstanceMethod);
2989 if (
Attr->
getKind() == AttributeList::AT_OpenCLKernel) {
3010 switch (nullability) {
3012 if (!Ident__Nonnull)
3014 return Ident__Nonnull;
3017 if (!Ident__Nullable)
3019 return Ident__Nullable;
3022 if (!Ident__Null_unspecified)
3024 return Ident__Null_unspecified;
3026 llvm_unreachable(
"Unknown nullability kind.");
3034 return Ident_NSError;
3042 if (attr->getKind() == AttributeList::AT_TypeNonNull ||
3043 attr->getKind() == AttributeList::AT_TypeNullable ||
3044 attr->getKind() == AttributeList::AT_TypeNullUnspecified)
3061 MaybePointerToCFRef,
3065 NSErrorPointerPointer,
3076 unsigned numNormalPointers = 0;
3080 return PointerDeclaratorKind::NonPointer;
3085 switch (chunk.
Kind) {
3093 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3094 : PointerDeclaratorKind::SingleLevelPointer;
3101 ++numNormalPointers;
3102 if (numNormalPointers > 2)
3103 return PointerDeclaratorKind::MultiLevelPointer;
3109 unsigned numTypeSpecifierPointers = 0;
3113 ++numNormalPointers;
3115 if (numNormalPointers > 2)
3116 return PointerDeclaratorKind::MultiLevelPointer;
3119 ++numTypeSpecifierPointers;
3125 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3126 : PointerDeclaratorKind::SingleLevelPointer;
3131 return numNormalPointers > 0 ? PointerDeclaratorKind::MultiLevelPointer
3132 : PointerDeclaratorKind::SingleLevelPointer;
3137 ++numNormalPointers;
3138 ++numTypeSpecifierPointers;
3141 if (
auto objcClassDecl = objcObjectPtr->getInterfaceDecl()) {
3143 numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3144 return PointerDeclaratorKind::NSErrorPointerPointer;
3153 if (objcClass->getInterface()->getIdentifier() == S.
getNSErrorIdent()) {
3154 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
3155 return PointerDeclaratorKind::NSErrorPointerPointer;;
3162 if (numNormalPointers == 0)
3163 return PointerDeclaratorKind::NonPointer;
3168 bool isCFError =
false;
3176 if (
auto bridgeAttr = recordDecl->
getAttr<ObjCBridgeAttr>()) {
3186 if (isCFError && numNormalPointers == 2 && numTypeSpecifierPointers < 2) {
3187 return PointerDeclaratorKind::CFErrorRefPointer;
3196 switch (numNormalPointers) {
3198 return PointerDeclaratorKind::NonPointer;
3201 return PointerDeclaratorKind::SingleLevelPointer;
3204 return PointerDeclaratorKind::MaybePointerToCFRef;
3207 return PointerDeclaratorKind::MultiLevelPointer;
3216 if (ctx->isFunctionOrMethod())
3219 if (ctx->isFileContext())
3230 bool invalid =
false;
3232 if (invalid || !sloc.
isFile())
3252 Sema &S = state.getSema();
3268 fileNullability.
PointerKind =
static_cast<unsigned>(pointerKind);
3275 S.
Diag(pointerLoc, diag::warn_nullability_missing)
3276 <<
static_cast<unsigned>(pointerKind);
3286 Sema &S = state.getSema();
3296 bool IsTypedefName =
3309 if (AT->isDecltypeAuto()) {
3311 unsigned Index =
E -
I - 1;
3313 unsigned DiagId = diag::err_decltype_auto_compound_type;
3314 unsigned DiagKind = 0;
3315 switch (DeclChunk.
Kind) {
3323 DiagId = diag::err_decltype_auto_function_declarator_not_declaration;
3341 S.
Diag(DeclChunk.
Loc, DiagId) << DiagKind;
3350 bool inferNullabilityCS =
false;
3351 bool inferNullabilityInnerOnly =
false;
3352 bool inferNullabilityInnerOnlyComplete =
false;
3355 bool inAssumeNonNullRegion =
false;
3357 inAssumeNonNullRegion =
true;
3367 S.
Diag(fileNullability.
PointerLoc, diag::warn_nullability_missing)
3368 <<
static_cast<unsigned>(fileNullability.
PointerKind);
3386 } complainAboutMissingNullability = CAMN_No;
3387 unsigned NumPointersRemaining = 0;
3389 if (IsTypedefName) {
3393 complainAboutMissingNullability = CAMN_InnerPointers;
3396 ++NumPointersRemaining;
3401 switch (chunk.
Kind) {
3409 ++NumPointersRemaining;
3417 ++NumPointersRemaining;
3423 switch (
auto context = state.getDeclarator().getContext()) {
3428 isFunctionOrMethod =
true;
3433 complainAboutMissingNullability = CAMN_No;
3438 if (state.getDeclarator().isObjCWeakProperty() && inAssumeNonNullRegion) {
3447 complainAboutMissingNullability = CAMN_Yes;
3451 case PointerDeclaratorKind::NonPointer:
3452 case PointerDeclaratorKind::MultiLevelPointer:
3456 case PointerDeclaratorKind::SingleLevelPointer:
3458 if (inAssumeNonNullRegion) {
3465 case PointerDeclaratorKind::CFErrorRefPointer:
3466 case PointerDeclaratorKind::NSErrorPointerPointer:
3469 if (isFunctionOrMethod && inAssumeNonNullRegion)
3473 case PointerDeclaratorKind::MaybePointerToCFRef:
3474 if (isFunctionOrMethod) {
3478 auto hasCFReturnsAttr = [](
const AttributeList *NextAttr) ->
bool {
3480 if (NextAttr->getKind() == AttributeList::AT_CFReturnsRetained ||
3481 NextAttr->getKind() == AttributeList::AT_CFReturnsNotRetained)
3483 NextAttr = NextAttr->getNext();
3489 hasCFReturnsAttr(InnermostChunk->getAttrs()) ||
3492 inferNullabilityInnerOnly =
true;
3501 complainAboutMissingNullability = CAMN_Yes;
3529 if (NumPointersRemaining > 0)
3530 --NumPointersRemaining;
3537 if (inferNullability && !inferNullabilityInnerOnlyComplete) {
3541 AttributeList *nullabilityAttr = state.getDeclarator().getAttributePool()
3547 nullptr, 0, syntax);
3551 if (inferNullabilityCS) {
3552 state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
3556 if (inferNullabilityInnerOnly)
3557 inferNullabilityInnerOnlyComplete =
true;
3558 return nullabilityAttr;
3563 switch (complainAboutMissingNullability) {
3567 case CAMN_InnerPointers:
3568 if (NumPointersRemaining == 0)
3584 pointerKind = SimplePointerKind::BlockPointer;
3586 pointerKind = SimplePointerKind::MemberPointer;
3588 if (
auto *attr = inferPointerNullability(
3593 attr->setUsedAsTypeAttr();
3601 unsigned chunkIndex = e - i - 1;
3602 state.setCurrentChunkIndex(chunkIndex);
3605 switch (DeclType.
Kind) {
3611 if (!LangOpts.Blocks)
3612 S.
Diag(DeclType.
Loc, diag::err_blocks_disable);
3615 inferPointerNullability(SimplePointerKind::BlockPointer,
3632 inferPointerNullability(SimplePointerKind::Pointer, DeclType.
Loc,
3681 S.
Diag(DeclType.
Loc, diag::err_array_star_outside_prototype);
3692 S.
Diag(DeclType.
Loc, diag::err_array_static_outside_prototype) <<
3703 unsigned x = chunkIndex;
3715 S.
Diag(DeclType.
Loc, diag::err_array_static_not_outermost) <<
3736 S.
Diag(DeclType.
Loc, diag::err_illegal_decl_array_of_auto)
3763 ? diag::err_auto_missing_trailing_return
3764 : diag::err_deduced_return_type);
3769 if (isa<ParenType>(T)) {
3771 diag::err_trailing_return_in_parens)
3775 (T.hasQualifiers() || !isa<AutoType>(T) ||
3778 diag::err_trailing_return_without_auto)
3793 if ((T->isArrayType() || T->isFunctionType()) &&
3795 unsigned diagID = diag::err_func_returning_array_function;
3798 if (chunkIndex == 0 &&
3800 diagID = diag::err_block_returning_array_function;
3801 S.
Diag(DeclType.
Loc, diagID) << T->isFunctionType() << T;
3808 if (T->isHalfType()) {
3816 diag::err_parameters_retval_cannot_have_fp16_type) << 1;
3823 if (T->isObjCObjectType()) {
3832 S.
Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value)
3850 if ((T.getCVRQualifiers() || T->isAtomicType()) &&
3852 (T->isDependentType() || T->isRecordType()))) {
3853 if (T->isVoidType() && !S.
getLangOpts().CPlusPlus &&
3858 S.
Diag(DeclType.
Loc, diag::err_func_returning_qualified_void) << T;
3866 if (T.getQualifiers().hasObjCLifetime()) {
3872 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
3873 AttrLoc =
Attr->getLoc();
3882 if (
Attr->
getKind() == AttributeList::AT_ObjCOwnership) {
3883 AttrLoc =
Attr->getLoc();
3896 S.
Diag(AttrLoc, diag::warn_arc_lifetime_result_type)
3897 << T.getQualifiers().getObjCLifetime();
3913 diag::err_exception_spec_in_typedef)
3932 bool Overloadable =
false;
3934 Attrs; Attrs = Attrs->
getNext()) {
3935 if (Attrs->getKind() == AttributeList::AT_Overloadable) {
3936 Overloadable =
true;
3949 diag::err_ident_list_in_fn_declaration);
3971 ConsumedParameters.reserve(FTI.
NumParams);
3972 bool HasAnyConsumedParameters =
false;
3974 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
3977 assert(!ParamTy.isNull() &&
"Couldn't parse type?");
3982 if (ParamTy->isVoidType()) {
3987 S.
Diag(DeclType.
Loc, diag::err_void_only_param);
3988 ParamTy = Context.
IntTy;
3993 ParamTy = Context.
IntTy;
3997 if (ParamTy.hasQualifiers())
3998 S.
Diag(DeclType.
Loc, diag::err_void_param_qualified);
4003 }
else if (ParamTy->isHalfType()) {
4009 diag::err_opencl_half_param) << ParamTy;
4015 diag::err_parameters_retval_cannot_have_fp16_type) << 0;
4019 if (ParamTy->isPromotableIntegerType()) {
4023 if (BTy->getKind() == BuiltinType::Float) {
4030 if (LangOpts.ObjCAutoRefCount) {
4031 bool Consumed = Param->
hasAttr<NSConsumedAttr>();
4032 ConsumedParameters.push_back(Consumed);
4033 HasAnyConsumedParameters |= Consumed;
4036 ParamTys.push_back(ParamTy);
4039 if (HasAnyConsumedParameters)
4045 Expr *NoexceptExpr =
nullptr;
4051 DynamicExceptions.reserve(N);
4052 DynamicExceptionRanges.reserve(N);
4053 for (
unsigned I = 0;
I != N; ++
I) {
4064 DynamicExceptionRanges,
4080 inferPointerNullability(SimplePointerKind::MemberPointer,
4100 llvm_unreachable(
"Nested-name-specifier must name a type");
4110 if (NNSPrefix && isa<TemplateSpecializationType>(NNS->
getAsType()))
4116 diag::err_illegal_decl_mempointer_in_nonclass)
4147 const_cast<AttributeList *>(DeclType.
getAttrs()));
4150 assert(!T.
isNull() &&
"T must not be null after this point");
4154 assert(FnTy &&
"Why oh why is there not a FunctionProtoType here?");
4171 FreeFunction = (DC && !DC->
isRecord());
4190 if (IsQualifiedFunction &&
4210 if (!RemovalLocs.empty()) {
4211 std::sort(RemovalLocs.begin(), RemovalLocs.end(),
4213 RemovalRange =
SourceRange(RemovalLocs.front(), RemovalLocs.back());
4214 Loc = RemovalLocs.front();
4218 S.
Diag(Loc, diag::err_invalid_qualified_function_type)
4243 state.diagnoseIgnoredTypeAttrs(T);
4273 diag::err_function_parameter_pack_without_parameter_packs)
4293 LangOpts.CPlusPlus11
4294 ? diag::warn_cxx98_compat_variadic_templates
4295 : diag::ext_variadic_templates);
4320 diag::err_ellipsis_in_declarator_not_parameter);
4326 assert(!T.
isNull() &&
"T must not be null at the end of this function");
4342 TypeProcessingState state(*
this, D);
4366 unsigned chunkIndex) {
4367 Sema &S = state.getSema();
4374 if (attr->getKind() == AttributeList::AT_ObjCOwnership)
4377 const char *attrStr =
nullptr;
4378 switch (ownership) {
4407 Sema &S = state.getSema();
4411 bool hasIndirection =
false;
4414 switch (chunk.
Kind) {
4423 hasIndirection =
true;
4456 TypeProcessingState state(*
this, D);
4474 return AttributeList::AT_AddressSpace;
4476 return AttributeList::AT_Regparm;
4478 return AttributeList::AT_VectorSize;
4480 return AttributeList::AT_NeonVectorType;
4482 return AttributeList::AT_NeonPolyVectorType;
4484 return AttributeList::AT_ObjCGC;
4487 return AttributeList::AT_ObjCOwnership;
4489 return AttributeList::AT_NoReturn;
4491 return AttributeList::AT_CDecl;
4493 return AttributeList::AT_FastCall;
4495 return AttributeList::AT_StdCall;
4497 return AttributeList::AT_ThisCall;
4499 return AttributeList::AT_Pascal;
4501 return AttributeList::AT_VectorCall;
4504 return AttributeList::AT_Pcs;
4506 return AttributeList::AT_IntelOclBicc;
4508 return AttributeList::AT_MSABI;
4510 return AttributeList::AT_SysVABI;
4512 return AttributeList::AT_Ptr32;
4514 return AttributeList::AT_Ptr64;
4516 return AttributeList::AT_SPtr;
4518 return AttributeList::AT_UPtr;
4520 return AttributeList::AT_TypeNonNull;
4522 return AttributeList::AT_TypeNullable;
4524 return AttributeList::AT_TypeNullUnspecified;
4526 return AttributeList::AT_ObjCKindOf;
4528 llvm_unreachable(
"unexpected attribute kind!");
4535 assert((attrs || DeclAttrs) &&
4536 "no type attributes in the expected location!");
4540 while (attrs && attrs->
getKind() != parsedKind)
4545 while (DeclAttrs && (!DeclAttrs->isCXX11Attribute() ||
4546 DeclAttrs->getKind() != parsedKind))
4547 DeclAttrs = DeclAttrs->
getNext();
4551 assert(attrs &&
"no matching type attribute in expected location!");
4553 TL.setAttrNameLoc(attrs->
getLoc());
4555 assert(attrs->
isArgExpr(0) &&
"mismatched attribute operand kind");
4559 "unexpected attribute operand kind");
4572 class TypeSpecLocFiller :
public TypeLocVisitor<TypeSpecLocFiller> {
4578 : Context(Context), DS(DS) {}
4582 Visit(TL.getModifiedLoc());
4694 void VisitDependentTemplateSpecializationTypeLoc(
4733 void VisitTypeLoc(
TypeLoc TL) {
4739 class DeclaratorLocFiller :
public TypeLocVisitor<DeclaratorLocFiller> {
4745 : Context(Context), Chunk(Chunk) {}
4748 llvm_unreachable(
"qualified type locs not expected here!");
4751 llvm_unreachable(
"decayed type locs not expected here!");
4784 assert(isa<DependentNameType>(ClsTy) &&
"Unexpected TypeLoc");
4795 if (isa<ElaboratedType>(ClsTy)) {
4810 llvm_unreachable(
"Nested-name-specifier must name a type");
4825 assert(!Chunk.Ref.LValueRef);
4832 TL.
setSizeExpr(static_cast<Expr*>(Chunk.Arr.NumElts));
4842 for (
unsigned i = 0, e = TL.
getNumParams(), tpi = 0; i != e; ++i) {
4858 void VisitTypeLoc(
TypeLoc TL) {
4859 llvm_unreachable(
"unsupported TypeLoc kind in declarator!");
4866 switch (Chunk.
Kind) {
4871 llvm_unreachable(
"cannot be _Atomic qualified");
4904 if (isa<PackExpansionType>(T)) {
4932 if (ReturnTypeInfo) {
4952 "LocInfoType's TypeClass conflicts with an existing Type class");
4958 llvm_unreachable(
"LocInfoType leaked into the type system; an opaque TypeTy*"
4959 " was used directly instead of getting the QualType through"
4960 " GetTypeFromParser");
4967 "Type name should have no identifier!");
5013 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_multiple_qualifiers);
5021 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_function_type);
5027 if (Attr.
getKind() == AttributeList::AT_AddressSpace) {
5030 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5036 llvm::APSInt addrSpace(32);
5039 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
5041 << ASArgExpr->getSourceRange();
5047 if (addrSpace.isSigned()) {
5048 if (addrSpace.isNegative()) {
5049 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_negative)
5050 << ASArgExpr->getSourceRange();
5054 addrSpace.setIsSigned(
false);
5056 llvm::APSInt max(addrSpace.getBitWidth());
5058 if (addrSpace > max) {
5059 S.
Diag(Attr.
getLoc(), diag::err_attribute_address_space_too_high)
5064 ASIdx =
static_cast<unsigned>(addrSpace.getZExtValue());
5068 case AttributeList::AT_OpenCLGlobalAddressSpace:
5070 case AttributeList::AT_OpenCLLocalAddressSpace:
5072 case AttributeList::AT_OpenCLConstantAddressSpace:
5074 case AttributeList::AT_OpenCLGenericAddressSpace:
5077 assert(Attr.
getKind() == AttributeList::AT_OpenCLPrivateAddressSpace);
5094 if (
const AttributedType *attr = dyn_cast<AttributedType>(type)) {
5098 type = attr->getModifiedType();
5101 }
else if (
const ParenType *paren = dyn_cast<ParenType>(type)) {
5102 type = paren->getInnerType();
5122 bool NonObjCPointer =
false;
5132 NonObjCPointer =
true;
5139 if (state.isProcessingDeclSpec()) {
5147 Sema &S = state.getSema();
5153 S.
Diag(AttrLoc, diag::err_attribute_argument_type)
5161 if (II->
isStr(
"none"))
5163 else if (II->
isStr(
"strong"))
5165 else if (II->
isStr(
"weak"))
5167 else if (II->
isStr(
"autoreleasing"))
5170 S.
Diag(AttrLoc, diag::warn_attribute_type_not_supported)
5191 S.
Diag(AttrLoc, diag::err_attr_objc_ownership_redundant)
5198 if (previousLifetime != lifetime) {
5210 if (NonObjCPointer) {
5220 S.
Diag(AttrLoc, diag::warn_type_attribute_wrong_type) << name
5244 if (!NonObjCPointer)
5259 diagnostic,
type, 0));
5261 S.
Diag(loc, diagnostic);
5270 unsigned diagnostic =
5271 (S.
getLangOpts().ObjCWeakRuntime ? diag::err_arc_weak_disabled
5272 : diag::err_arc_weak_no_runtime);
5275 diagnoseOrDelay(S, AttrLoc, diagnostic, type);
5287 if (Class->isArcWeakrefUnavailable()) {
5288 S.
Diag(AttrLoc, diag::err_arc_unsupported_weak_class);
5289 S.
Diag(ObjT->getInterfaceDecl()->getLocation(),
5290 diag::note_class_declared);
5306 Sema &S = state.getSema();
5315 S.
Diag(attr.
getLoc(), diag::err_attribute_multiple_objc_gc);
5322 S.
Diag(attr.
getLoc(), diag::err_attribute_argument_type)
5329 S.
Diag(attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
5336 if (II->
isStr(
"weak"))
5338 else if (II->
isStr(
"strong"))
5341 S.
Diag(attr.
getLoc(), diag::warn_attribute_type_not_supported)
5369 struct FunctionTypeUnwrapper {
5383 FunctionTypeUnwrapper(
Sema &S,
QualType T) : Original(T) {
5386 if (isa<FunctionType>(Ty)) {
5387 Fn = cast<FunctionType>(Ty);
5389 }
else if (isa<ParenType>(Ty)) {
5390 T = cast<ParenType>(Ty)->getInnerType();
5391 Stack.push_back(Parens);
5392 }
else if (isa<PointerType>(Ty)) {
5393 T = cast<PointerType>(Ty)->getPointeeType();
5394 Stack.push_back(Pointer);
5395 }
else if (isa<BlockPointerType>(Ty)) {
5396 T = cast<BlockPointerType>(Ty)->getPointeeType();
5397 Stack.push_back(BlockPointer);
5398 }
else if (isa<MemberPointerType>(Ty)) {
5399 T = cast<MemberPointerType>(Ty)->getPointeeType();
5400 Stack.push_back(MemberPointer);
5401 }
else if (isa<ReferenceType>(Ty)) {
5402 T = cast<ReferenceType>(Ty)->getPointeeType();
5403 Stack.push_back(Reference);
5417 bool isFunctionType()
const {
return (Fn !=
nullptr); }
5422 if (New ==
get())
return Original;
5425 return wrap(S.
Context, Original, 0);
5430 if (I ==
Stack.size())
5439 return wrap(C, SplitOld.
Ty, I);
5446 switch (static_cast<WrapKind>(
Stack[I++])) {
5453 QualType New = wrap(C, cast<ParenType>(Old)->getInnerType(), I);
5458 QualType New = wrap(C, cast<PointerType>(Old)->getPointeeType(), I);
5462 case BlockPointer: {
5463 QualType New = wrap(C, cast<BlockPointerType>(Old)->getPointeeType(),I);
5467 case MemberPointer: {
5476 if (isa<LValueReferenceType>(OldRef))
5483 llvm_unreachable(
"unknown wrapping kind");
5491 Sema &S = State.getSema();
5502 S.
Diag(Attr.
getLoc(), diag::warn_duplicate_attribute_exact)
5510 Kind == AttributeList::AT_Ptr64) ||
5512 Kind == AttributeList::AT_Ptr32)) {
5513 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5514 <<
"'__ptr32'" <<
"'__ptr64'";
5517 Kind == AttributeList::AT_UPtr) ||
5519 Kind == AttributeList::AT_SPtr)) {
5520 S.
Diag(Attr.
getLoc(), diag::err_attributes_are_not_compatible)
5521 <<
"'__sptr'" <<
"'__uptr'";
5531 if (!isa<PointerType>(Desugared)) {
5533 S.
Diag(Attr.
getLoc(), diag::err_attribute_no_member_pointers)
5536 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
5543 default: llvm_unreachable(
"Unknown attribute kind");
5557 bool isContextSensitive) {
5568 <<
static_cast<unsigned>(fileNullability.
PointerKind);
5577 while (
auto attributed = dyn_cast<AttributedType>(desugared.
getTypePtr())) {
5579 if (
auto existingNullability = attributed->getImmediateNullability()) {
5581 if (nullability == *existingNullability) {
5582 Diag(nullabilityLoc, diag::warn_nullability_duplicate)
5590 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5596 desugared = attributed->getModifiedType();
5604 if (nullability != *existingNullability) {
5605 Diag(nullabilityLoc, diag::err_nullability_conflicting)
5613 if (
auto typedefNullability
5615 if (*typedefNullability == *existingNullability) {
5628 Diag(nullabilityLoc, diag::err_nullability_nonpointer)
5635 if (isContextSensitive) {
5641 Diag(nullabilityLoc, diag::err_nullability_cs_multilevel)
5644 Diag(nullabilityLoc, diag::note_nullability_type_specifier)
5668 Diag(loc, diag::err_objc_kindof_nonobject)
5676 objType->getTypeArgsAsWritten(),
5677 objType->getProtocols(),
5700 case AttributeList::AT_TypeNonNull:
5703 case AttributeList::AT_TypeNullable:
5706 case AttributeList::AT_TypeNullUnspecified:
5710 llvm_unreachable(
"not a nullability attribute kind");
5723 Declarator &declarator = state.getDeclarator();
5726 auto moveToChunk = [&](
DeclaratorChunk &chunk,
bool inFunction) ->
bool {
5739 PK_MemberFunctionPointer,
5744 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
5746 auto diag = state.getSema().Diag(attr.
getLoc(),
5747 diag::warn_nullability_declspec)
5751 << static_cast<unsigned>(pointerKind);
5757 state.getSema().getPreprocessor()
5758 .getLocForEndOfToken(chunk.
Loc),
5769 for (
unsigned i = state.getCurrentChunkIndex(); i != 0; --i) {
5771 switch (chunk.
Kind) {
5775 return moveToChunk(chunk,
false);
5787 return moveToChunk(*dest,
true);
5806 llvm_unreachable(
"not a calling convention attribute");
5807 case AttributeList::AT_CDecl:
5809 case AttributeList::AT_FastCall:
5811 case AttributeList::AT_StdCall:
5813 case AttributeList::AT_ThisCall:
5815 case AttributeList::AT_Pascal:
5817 case AttributeList::AT_VectorCall:
5819 case AttributeList::AT_Pcs: {
5825 Str = cast<StringLiteral>(Attr.
getArgAsExpr(0))->getString();
5828 return llvm::StringSwitch<AttributedType::Kind>(Str)
5832 case AttributeList::AT_IntelOclBicc:
5834 case AttributeList::AT_MSABI:
5836 case AttributeList::AT_SysVABI:
5839 llvm_unreachable(
"unexpected attribute kind!");
5847 Sema &S = state.getSema();
5849 FunctionTypeUnwrapper unwrapped(S, type);
5851 if (attr.
getKind() == AttributeList::AT_NoReturn) {
5856 if (!unwrapped.isFunctionType())
5867 if (attr.
getKind() == AttributeList::AT_NSReturnsRetained) {
5869 "ns_returns_retained treated as type attribute in non-ARC");
5873 if (!unwrapped.isFunctionType())
5877 = unwrapped.get()->getExtInfo().withProducesResult(
true);
5882 if (attr.
getKind() == AttributeList::AT_Regparm) {
5888 if (!unwrapped.isFunctionType())
5895 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5903 unwrapped.get()->getExtInfo().withRegParm(value);
5909 if (!unwrapped.isFunctionType())
return false;
5925 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5937 unsigned DiagID = diag::err_cconv_varargs;
5941 DiagID = diag::warn_cconv_varargs;
5951 S.
Diag(attr.
getLoc(), diag::err_attributes_are_not_compatible)
5970 if (AT->isCallingConv())
5972 R = AT->getModifiedType().IgnoreParens();
5979 FunctionTypeUnwrapper Unwrapped(*
this, T);
5981 bool IsVariadic = (isa<FunctionProtoType>(FT) &&
5982 cast<FunctionProtoType>(FT)->isVariadic());
5995 Diag(Loc, diag::warn_cconv_structors)
6005 if (CurCC != DefaultCC || DefaultCC == ToCC)
6013 QualType Wrapped = Unwrapped.wrap(*
this, FT);
6028 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6034 llvm::APSInt vecSize(32);
6037 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6039 << sizeExpr->getSourceRange();
6047 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6053 unsigned vectorSize =
static_cast<unsigned>(vecSize.getZExtValue() * 8);
6056 if (vectorSize % typeSize) {
6057 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_size)
6058 << sizeExpr->getSourceRange();
6063 S.
Diag(Attr.
getLoc(), diag::err_attribute_size_too_large)
6064 << sizeExpr->getSourceRange();
6068 if (vectorSize == 0) {
6069 S.
Diag(Attr.
getLoc(), diag::err_attribute_zero_size)
6070 << sizeExpr->getSourceRange();
6088 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6107 sizeExpr = Size.
get();
6128 bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
6129 Triple.getArch() == llvm::Triple::aarch64_be;
6131 if (IsPolyUnsigned) {
6133 return BTy->
getKind() == BuiltinType::UChar ||
6134 BTy->
getKind() == BuiltinType::UShort ||
6135 BTy->
getKind() == BuiltinType::ULong ||
6136 BTy->
getKind() == BuiltinType::ULongLong;
6139 return BTy->
getKind() == BuiltinType::SChar ||
6140 BTy->
getKind() == BuiltinType::Short;
6146 bool Is64Bit = Triple.getArch() == llvm::Triple::aarch64 ||
6147 Triple.getArch() == llvm::Triple::aarch64_be;
6149 if (Is64Bit && BTy->
getKind() == BuiltinType::Double)
6152 return BTy->
getKind() == BuiltinType::SChar ||
6153 BTy->
getKind() == BuiltinType::UChar ||
6154 BTy->
getKind() == BuiltinType::Short ||
6155 BTy->
getKind() == BuiltinType::UShort ||
6156 BTy->
getKind() == BuiltinType::Int ||
6157 BTy->
getKind() == BuiltinType::UInt ||
6158 BTy->
getKind() == BuiltinType::Long ||
6159 BTy->
getKind() == BuiltinType::ULong ||
6160 BTy->
getKind() == BuiltinType::LongLong ||
6161 BTy->
getKind() == BuiltinType::ULongLong ||
6162 BTy->
getKind() == BuiltinType::Float ||
6163 BTy->
getKind() == BuiltinType::Half;
6184 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
6191 llvm::APSInt numEltsInt(32);
6194 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
6196 << numEltsExpr->getSourceRange();
6202 S.
Diag(Attr.
getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
6209 unsigned numElts =
static_cast<unsigned>(numEltsInt.getZExtValue());
6210 unsigned vecSize = typeSize * numElts;
6211 if (vecSize != 64 && vecSize != 128) {
6212 S.
Diag(Attr.
getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType;
6227 bool hasOpenCLAddressSpace =
false;
6243 state.getSema().Diag(attr.
getLoc(),
6244 diag::warn_cxx11_gnu_attribute_on_type)
6261 state.getSema().Diag(attr.
getLoc(), diag::err_attribute_not_type_attr)
6269 state.getSema().Diag(attr.
getLoc(),
6270 diag::warn_unknown_attribute_ignored)
6277 case AttributeList::AT_MayAlias:
6282 case AttributeList::AT_OpenCLPrivateAddressSpace:
6283 case AttributeList::AT_OpenCLGlobalAddressSpace:
6284 case AttributeList::AT_OpenCLLocalAddressSpace:
6285 case AttributeList::AT_OpenCLConstantAddressSpace:
6286 case AttributeList::AT_OpenCLGenericAddressSpace:
6287 case AttributeList::AT_AddressSpace:
6290 hasOpenCLAddressSpace =
true;
6297 case AttributeList::AT_VectorSize:
6301 case AttributeList::AT_ExtVectorType:
6305 case AttributeList::AT_NeonVectorType:
6310 case AttributeList::AT_NeonPolyVectorType:
6315 case AttributeList::AT_OpenCLImageAccess:
6333 if (state.getSema().checkNullabilityTypeSpecifier(
6345 case AttributeList::AT_ObjCKindOf:
6353 state.getSema().Diag(attr.
getLoc(),
6354 diag::err_objc_kindof_wrong_position)
6357 state.getDeclarator().getDeclSpec().getLocStart(),
"__kindof ");
6362 if (state.getSema().checkObjCKindOfType(type, attr.
getLoc()))
6367 case AttributeList::AT_NSReturnsRetained:
6368 if (!state.getSema().getLangOpts().ObjCAutoRefCount)
6396 if (state.getSema().getLangOpts().OpenCLVersion >= 200 &&
6400 if (state.getCurrentChunkIndex() > 0 &&
6403 type = state.getSema().Context.getAddrSpaceQualType(
6405 }
else if (state.getCurrentChunkIndex() == 0 &&
6410 type = state.getSema().Context.getAddrSpaceQualType(
6412 else if (state.getCurrentChunkIndex() == 0 &&
6415 type = state.getSema().Context.getAddrSpaceQualType(
6422 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
6427 Var->getMemberSpecializationInfo()) {
6429 if (MSInfo->getPointOfInstantiation().isInvalid()) {
6430 MSInfo->setPointOfInstantiation(PointOfInstantiation);
6435 L->StaticDataMemberInstantiated(Var);
6439 cast<VarTemplateSpecializationDecl>(Var);
6520 if (RequireCompleteTypeImpl(Loc, T, &Diagnoser))
6523 if (!Tag->getDecl()->isCompleteDefinitionRequired()) {
6524 Tag->getDecl()->setCompleteDefinitionRequired();
6541 bool OnlyNeedComplete) {
6548 if (isa<TagDecl>(D) && cast<TagDecl>(D)->isBeingDefined()) {
6552 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6553 if (
auto *Pattern = RD->getTemplateInstantiationPattern())
6555 D = RD->getDefinition();
6556 }
else if (
auto *ED = dyn_cast<EnumDecl>(D)) {
6557 while (
auto *NewED = ED->getInstantiatedFromMemberEnum())
6559 if (OnlyNeedComplete && ED->isFixed()) {
6563 *Suggested =
nullptr;
6564 for (
auto *Redecl : ED->redecls()) {
6567 if (Redecl->isThisDeclarationADefinition() ||
6568 (Redecl->isCanonicalDecl() && !*Suggested))
6569 *Suggested = Redecl;
6573 D = ED->getDefinition();
6575 assert(D &&
"missing definition for pattern of instantiated definition");
6584 Source->CompleteRedeclChain(D);
6594 if (!RD->
hasAttr<MSInheritanceAttr>()) {
6595 MSInheritanceAttr::Spelling IM;
6602 IM = MSInheritanceAttr::Keyword_single_inheritance;
6605 IM = MSInheritanceAttr::Keyword_multiple_inheritance;
6608 IM = MSInheritanceAttr::Keyword_unspecified_inheritance;
6612 RD->
addAttr(MSInheritanceAttr::CreateImplicit(
6624 TypeDiagnoser *Diagnoser) {
6637 if (!MPTy->getClass()->isDependentType()) {
6657 return !TreatAsComplete;
6688 Source->CompleteType(Tag->
getDecl());
6690 Source->CompleteType(IFace->getDecl());
6695 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
6705 MaybeTemplate = Array->getElementType();
6707 bool Instantiated =
false;
6708 bool Diagnosed =
false;
6710 = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
6711 if (ClassTemplateSpec->getSpecializationKind() ==
TSK_Undeclared) {
6715 Instantiated =
true;
6718 = dyn_cast<CXXRecordDecl>(Record->getDecl())) {
6720 if (!Rec->isBeingDefined() && Pattern) {
6722 assert(MSI &&
"Missing member specialization information?");
6730 Instantiated =
true;
6738 if (Diagnoser && Diagnosed)
6744 return RequireCompleteTypeImpl(Loc, T, Diagnoser);
6752 if (Ident___float128 &&
6754 Diag(Loc, diag::err_typecheck_decl_incomplete_type___float128);
6758 Diagnoser->diagnose(*
this, Loc, T);
6765 : diag::note_forward_declaration)
6769 if (IFace && !IFace->getDecl()->isInvalidDecl())
6770 Diag(IFace->getDecl()->getLocation(), diag::note_forward_class);
6796 default: llvm_unreachable(
"Invalid tag kind for literal type diagnostic!");
6851 for (
const auto &I : RD->
vbases())
6852 Diag(I.getLocStart(), diag::note_constexpr_virtual_base_here)
6853 << I.getSourceRange();
6856 Diag(RD->
getLocation(), diag::note_non_literal_no_constexpr_ctors) << RD;
6858 for (
const auto &I : RD->
bases()) {
6859 if (!I.getType()->isLiteralType(
Context)) {
6860 Diag(I.getLocStart(),
6861 diag::note_non_literal_base_class)
6862 << RD << I.getType() << I.getSourceRange();
6866 for (
const auto *I : RD->
fields()) {
6867 if (!I->getType()->isLiteralType(
Context) ||
6868 I->getType().isVolatileQualified()) {
6869 Diag(I->getLocation(), diag::note_non_literal_field)
6870 << RD << I << I->getType()
6871 << I->getType().isVolatileQualified();
6879 assert(Dtor &&
"class has literal fields and bases but no dtor?");
6884 diag::note_non_literal_user_provided_dtor :
6885 diag::note_non_literal_nontrivial_dtor) << RD;
6921 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
6948 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl()))
6949 return VD->getType();
6950 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
6951 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()))
6952 return FD->getType();
6953 }
else if (
const ObjCIvarRefExpr *IR = dyn_cast<ObjCIvarRefExpr>(E)) {
6954 return IR->getDecl()->getType();
6956 if (PR->isExplicitProperty())
6957 return PR->getExplicitProperty()->getType();
6958 }
else if (
auto *PE = dyn_cast<PredefinedExpr>(E)) {
6959 return PE->getType();
6969 using namespace sema;
6971 if (isa<ParenExpr>(E)) {
6973 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
7001 bool AsUnevaluated) {
7010 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
7022 Diag(Loc, diag::err_only_enums_have_underlying_types);
7031 Diag(Loc, diag::err_underlying_type_of_incomplete_enum) << BaseType;
7032 Diag(FwdDecl->
getLocation(), diag::note_forward_declaration) << FwdDecl;
7037 assert(ED &&
"EnumType has no EnumDecl");
7042 assert(!Underlying.
isNull());
7048 llvm_unreachable(
"unknown unary transform type");
7058 int DisallowedKind = -1;
7073 if (DisallowedKind != -1) {
7074 Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Abstract class used to diagnose incomplete types.
static QualType applyObjCProtocolQualifiers(Sema &S, SourceLocation loc, SourceRange range, QualType type, ArrayRef< ObjCProtocolDecl * > protocols, const SourceLocation *protocolLocs, bool failOnError=false)
Apply Objective-C protocol qualifiers to the given type.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
static CallingConv getCCForDeclaratorChunk(Sema &S, Declarator &D, const DeclaratorChunk::FunctionTypeInfo &FTI, unsigned ChunkIndex)
Helper for figuring out the default CC for a function declarator type.
bool CheckNoReturnAttr(const AttributeList &attr)
unsigned getAddressSpace() const
Return the address space of this type.
static void HandleExtVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
Process the OpenCL-like ext_vector_type attribute when it occurs on a type.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType) const
Defines the clang::ASTContext interface.
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
SourceLocation getEnd() const
static bool handleObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
const Type * Ty
The locally-unqualified type.
IdKind getKind() const
Determine what kind of name we have.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for literal type diagnostic message.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
Scope * getCurScope() const
Retrieve the parser's current scope.
static bool isOmittedBlockReturnType(const Declarator &D)
isOmittedBlockReturnType - Return true if this declarator is missing a return type because this is a ...
no exception specification
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
This is a discriminated union of FileInfo and ExpansionInfo.
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getRestrictSpecLoc() const
A (possibly-)qualified type.
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
void setStarLoc(SourceLocation Loc)
SourceLocation getConstSpecLoc() const
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
Wrapper for source info for tag types.
ExtInfo withCallingConv(CallingConv cc) const
TSW getTypeSpecWidth() const
static void distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
Distribute an objc_gc type attribute that was written on the declarator.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static const TSS TSS_unsigned
bool isMemberPointerType() const
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
TheContext getContext() const
QualType BuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
__auto_type (GNU extension)
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
void setNameEndLoc(SourceLocation Loc)
static const TST TST_wchar
Decl * getRepAsDecl() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
void setKWLoc(SourceLocation Loc)
The attribute is immediately after the declaration's name.
void setRParenLoc(SourceLocation Loc)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
void setStarLoc(SourceLocation Loc)
NullabilityKind
Describes the nullability of a particular type.
FunctionType - C99 6.7.5.3 - Function Declarators.
TypeLoc getNamedTypeLoc() const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool canHaveNullability() const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type or a dependent type that could instantiate to any kind of pointer type.
void setEmbeddedInDeclarator(bool isInDeclarator)
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Qualifiers::GC getObjCGCAttr() const
Returns gc attribute of this type.
A conversion function name, e.g., operator int.
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
bool isRecordType() const
static const TST TST_typeofExpr
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
static const TST TST_char16
static NullabilityKind mapNullabilityAttrKind(AttributeList::Kind kind)
Map a nullability attribute kind to a nullability kind.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
bool isTypeAltiVecBool() const
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
AttributePool & getAttributePool() const
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Defines the C++ template declaration subclasses.
static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, AttributeList *attrs)
Represents a C++11 auto or C++14 decltype(auto) type.
bool isEnumeralType() const
QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
SCS getStorageClassSpec() const
bool hasDefinition() const
FunctionDefinitionKind getFunctionDefinitionKind() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
QualType getPointeeType() const
The base class of the type hierarchy.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator)
Classify the given declarator, whose type-specified is type, based on what kind of pointer it refers ...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
One instance of this struct is used for each type in a declarator that is parsed. ...
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Wrapper for source info for typedefs.
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk)
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
bool isDecltypeAuto() const
The attribute is part of a DeclaratorChunk.
bool isBooleanType() const
RefQualifierKind RefQualifier
A container of type source information.
static void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS, unsigned &TypeQuals, QualType TypeSoFar, unsigned RemoveTQs, unsigned DiagID)
static void transferARCOwnership(TypeProcessingState &state, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Used for transferring ownership in casts resulting in l-values.
bool getHasRegParm() const
AttributeList *& getAttrListRef()
bool isBlockPointerType() const
Wrapper for source info for pointers decayed from arrays and functions.
bool hasAttrEnumOperand() const
Abstract base class used for diagnosing integer constant expression violations.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
TypeLoc getNextTypeLoc() const
bool isSpelledAsLValue() const
QualType getPipeType(QualType T) const
Return pipe type for the specified type.
#define NULLABILITY_TYPE_ATTRS_CASELIST
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr)
bool checkObjCKindOfType(QualType &type, SourceLocation loc)
Check the application of the Objective-C '__kindof' qualifier to the given type.
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
void setParensRange(SourceRange range)
SourceLocation getIncludeLoc() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
An identifier, stored as an IdentifierInfo*.
SourceLocation getCommaLoc() const
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static DeclaratorChunk * maybeMovePastReturnType(Declarator &declarator, unsigned i, bool onlyBlockPointers)
Given the index of a declarator chunk, check whether that chunk directly specifies the return type of...
static const TST TST_underlyingType
Information about one declarator, including the parsed type information and the identifier.
void removeObjCLifetime()
DiagnosticsEngine & Diags
Wrapper for source info for member pointers.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
ObjCLifetime getObjCLifetime() const
bool hasAttrExprOperand() const
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
SourceLocation getEllipsisLoc() const
Extra information about a function prototype.
CallingConv getCallConv() const
std::string getAsString() const
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Represents a variable template specialization, which refers to a variable template with a given set o...
static const TST TST_interface
static const TST TST_char
A namespace, stored as a NamespaceDecl*.
Describes how types, statements, expressions, and declarations should be printed. ...
bool hasAttrOperand() const
unsigned size() const
Determine the number of type parameters in this list.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isArgIdent(unsigned Arg) const
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
static bool handleFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
Process an individual function attribute.
OpenCLOptions & getOpenCLOptions()
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs, typeofs, etc., as well as any qualifiers.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
The collection of all-type qualifiers we support.
void setParensRange(SourceRange Range)
static const TST TST_unknown_anytype
SourceLocation getPragmaAssumeNonNullLoc() const
The location of the currently-active #pragma clang assume_nonnull begin.
Base wrapper for a particular "section" of type source info.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
RecordDecl - Represents a struct/union/class.
__ptr16, alignas(...), etc.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
void setLocalRangeEnd(SourceLocation L)
static bool checkQualifiedFunction(Sema &S, QualType T, SourceLocation Loc, QualifiedFunctionKind QFK)
Check whether the type T is a qualified function type, and if it is, diagnose that it cannot be conta...
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
static void distributeFunctionTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
A function type attribute was written somewhere in a declaration other than on the declarator itself ...
static const TST TST_decimal32
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Represents a class type in Objective C.
AttributeList * getList() const
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an AttributeList as an argument...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the 'restrict' qualifier, if any.
bool isTypeSpecPipe() const
ArrayRef< QualType > getParamTypes() const
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
QualType BuildParenType(QualType T)
Build a paren type including T.
void setBuiltinLoc(SourceLocation Loc)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
SourceLocation getTypeSpecSignLoc() const
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
TSS getTypeSpecSign() const
void setRBracketLoc(SourceLocation Loc)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isReferenceType() const
static bool distributeNullabilityTypeAttr(TypeProcessingState &state, QualType type, AttributeList &attr)
Distribute a nullability type attribute that cannot be applied to the type specifier to a pointer...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
static const TST TST_class
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
bool isAnyPointerType() const
static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
handleObjCOwnershipTypeAttr - Process an objc_ownership attribute on the specified type...
unsigned TypeQuals
The type qualifiers: const/volatile/restrict.
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
static const TST TST_double
static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, QualType type)
diagnoseBadTypeAttribute - Diagnoses a type attribute which doesn't apply to the given type...
void setElaboratedKeywordLoc(SourceLocation Loc)
static std::string getPrintableNameForEntity(DeclarationName Entity)
TagKind getTagKind() const
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
TypeLoc getValueLoc() const
virtual bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, QualType T)
Produces a diagnostic note if the external source contains a complete definition for T...
static const TST TST_enum
QualType getTypeOfType(QualType t) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes...
static void maybeSynthesizeBlockSignature(TypeProcessingState &state, QualType declSpecType)
Add a synthetic '()' to a block-literal declarator if it is required, given the return type...
SourceLocation getTypeSpecTypeLoc() const
SourceLocation getLocStart() const LLVM_READONLY
static const TSW TSW_unspecified
void copy(DependentTemplateSpecializationTypeLoc Loc)
static unsigned getNumAddressingBits(ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
Wrapper of type source information for a type with no direct qualifiers.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
virtual void HandleTagDeclRequiredDefinition(const TagDecl *D)
This callback is invoked the first time each TagDecl is required to be complete.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
llvm::BumpPtrAllocator BumpAlloc
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Values of this type can be null.
static void inferARCWriteback(TypeProcessingState &state, QualType &declSpecType)
Given that this is the declaration of a parameter under ARC, attempt to infer attributes and such for...
bool hasStatic
True if this dimension included the 'static' keyword.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly...
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
QualType getParenType(QualType NamedType) const
void setNameLoc(SourceLocation Loc)
static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, TypeSourceInfo *&ReturnTypeInfo)
Represents the results of name lookup.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > typedefDecl
Matches typedef declarations.
const TargetInfo & getTargetInfo() const
static void HandleVectorSizeAttr(QualType &CurType, const AttributeList &Attr, Sema &S)
HandleVectorSizeAttribute - this attribute is only applicable to integral and float scalars...
An lvalue ref-qualifier was provided (&).
unsigned ConstQualLoc
The location of the const-qualifier, if any.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
void setCaretLoc(SourceLocation Loc)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static void spliceAttrOutOfList(AttributeList &attr, AttributeList *&head)
SourceLocation getRAngleLoc() const
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
QualType getReturnType() const
Wrapper for source info for functions.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
static bool hasDirectOwnershipQualifier(QualType type)
Does this type have a "direct" ownership qualifier? That is, is it written like "__strong id"...
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, QualType &declSpecType)
Given that there are attributes written on the declarator itself, try to distribute any type attribut...
field_range fields() const
SplitQualType getSplitUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
void addCVRQualifiers(unsigned mask)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
TypeDecl - Represents a declaration of a type.
An implicit 'self' parameter.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
bool needsExtraLocalData() const
RecordDecl * getDecl() const
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
Scope - A scope is a transient data structure that is used while parsing the program.
Wrapper for source info for ObjC interfaces.
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
Represents an Objective-C protocol declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
#define MS_TYPE_ATTRS_CASELIST
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
static FileID getNullabilityCompletenessCheckFileID(Sema &S, SourceLocation loc)
void setLocalRangeBegin(SourceLocation L)
static void transferARCOwnershipToDeclSpec(Sema &S, QualType &declSpecTy, Qualifiers::ObjCLifetime ownership)
Represents an ObjC class declaration.
void copy(ElaboratedTypeLoc Loc)
SourceLocation getLocStart() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
void setInvalid(bool b=true) const
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
unsigned getNumParams() const
SmallVector< TemplateTypeParmDecl *, 4 > AutoTemplateParams
Store the list of the auto parameters for a generic lambda.
CanQualType UnsignedCharTy
const LangOptions & LangOpts
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
static std::string getFunctionQualifiersAsString(const FunctionProtoType *FnTy)
uint8_t PointerKind
Which kind of pointer declarator we saw.
This object can be modified without requiring retains or releases.
SourceRange getRange() const
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
DiagnosticsEngine & getDiagnostics() const
static const TST TST_float
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void setUnderlyingTInfo(TypeSourceInfo *TI) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
AttributedType::Kind getAttrKind() const
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
SourceRange getTypeofParensRange() const
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
static const TSW TSW_long
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
CXXRecordDecl * getMostRecentDecl()
static bool handleObjCGCTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType &type)
handleObjCGCTypeAttr - Process the attribute((objc_gc)) type attribute on the specified type...
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
TST getTypeSpecType() const
Represents a prototype with parameter type info, e.g.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
ArraySizeModifier
Capture whether this is a normal array (e.g.
std::vector< bool > & Stack
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/atomic.
void addObjCLifetime(ObjCLifetime type)
static QualType ConvertDeclSpecToType(TypeProcessingState &state)
Convert the specified declspec to the appropriate type object.
void setSizeExpr(Expr *Size)
bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability, SourceLocation nullabilityLoc, bool isContextSensitive)
Check whether a nullability type specifier can be added to the given type.
unsigned NumExceptions
NumExceptions - This is the number of types in the dynamic-exception- decl, if the function has one...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location. ...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
bool isRealFloatingType() const
Floating point categories.
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C object pointer type.
SourceLocation getLParenLoc() const
bool isKindOfType() const
Whether this is a "__kindof" type.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier, if any.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Type source information for an attributed type.
const Type * getTypeForDecl() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
StringRef getName() const
Return the actual identifier string.
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
SourceLocation getAtomicSpecLoc() const
void * getOpaqueData() const
Get the pointer where source information is stored.
SourceLocation getTypeSpecComplexLoc() const
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
Declaration of a template type parameter.
TypeSpecifierWidth getWrittenWidthSpec() const
bool isFunctionDefinition() const
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isAtomicType() const
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
QualType BuildAtomicType(QualType T, SourceLocation Loc)
bool isVariableArrayType() const
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ExtProtoInfo getExtProtoInfo() const
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void HandleNeonVectorTypeAttr(QualType &CurType, const AttributeList &Attr, Sema &S, VectorType::VectorKind VecKind)
HandleNeonVectorTypeAttr - The "neon_vector_type" and "neon_polyvector_type" attributes are used ...
void completeExprArrayBound(Expr *E)
SourceLocation getVolatileSpecLoc() const
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
const bool * ConsumedParameters
static const TST TST_decimal64
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isObjCIdType() const
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
static QualType getDecltypeForExpr(Sema &S, Expr *E)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
bool isConstexprSpecified() const
CanQualType UnsignedInt128Ty
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
void setNameLoc(SourceLocation Loc)
ASTMutationListener * getASTMutationListener() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation Loc
Loc - The place where this type was defined.
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier, if any.
void setHasBaseTypeAsWritten(bool HasBaseType)
void setEllipsisLoc(SourceLocation EL)
static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
A function type attribute was written in the decl spec.
void setPointOfInstantiation(SourceLocation Loc)
static QualType inferARCLifetimeForPointee(Sema &S, QualType type, SourceLocation loc, bool isReference)
Given that we're building a pointer or reference to the given.
TypeSourceInfo * GetTypeSourceInfoForDeclarator(Declarator &D, QualType T, TypeSourceInfo *ReturnTypeInfo)
Create and instantiate a TypeSourceInfo with type source information.
Compare two source locations.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
static const TST TST_half
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Wraps an identifier and optional source location for the identifier.
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA)
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
A type, stored as a Type*.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
static const TSW TSW_short
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
AttributeList * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
CallingConv
CallingConv - Specifies the calling convention that a function uses.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
const clang::PrintingPolicy & getPrintingPolicy() const
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool isObjectType() const
Determine whether this type is an object type.
bool hasObjCLifetime() const
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
bool getSuppressSystemWarnings() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void setStarLoc(SourceLocation Loc)
static const TST TST_char32
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
void setTypeofLoc(SourceLocation Loc)
Context-sensitive version of a keyword attribute.
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
bool isPrototypeContext() const
static void diagnoseRedundantReturnTypeQualifiers(Sema &S, QualType RetTy, Declarator &D, unsigned FunctionChunkIndex)
Wrapper for source info for arrays.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
There is no lifetime qualification on this type.
Information about a FileID, basically just the logical file that it represents and include stack info...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void setAttrOperandParensRange(SourceRange range)
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
TypeLoc getValueLoc() const
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
The attribute is in the decl-specifier-seq.
enum clang::DeclaratorChunk::@183 Kind
void setKNRPromoted(bool promoted)
static bool distributeFunctionTypeAttrToInnermost(TypeProcessingState &state, AttributeList &attr, AttributeList *&attrList, QualType &declSpecType)
Try to distribute a function type attribute to the innermost function chunk or type.
static bool isPermittedNeonBaseType(QualType &Ty, VectorType::VectorKind VecKind, Sema &S)
Encodes a location in the source.
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static const TST TST_auto_type
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
PointerDeclaratorKind
Describes the kind of a pointer a declarator describes.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Interfaces are the core concept in Objective-C for object oriented design.
The maximum supported address space number.
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, Qualifiers::ObjCLifetime ownership, unsigned chunkIndex)
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
static const TST TST_union
ParsedType getRepAsType() const
static void moveAttrFromListToList(AttributeList &attr, AttributeList *&fromList, AttributeList *&toList)
TSC getTypeSpecComplex() const
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
static const TSS TSS_signed
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
No ref-qualifier was provided.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T)
Retrieve a version of the type 'T' that is elaborated by Keyword and qualified by the nested-name-spe...
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
bool isInvalid() const
An error occurred during parsing of the scope specifier.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
MemberPointerTypeInfo Mem
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
static QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type, ArrayRef< TypeSourceInfo * > typeArgs, SourceRange typeArgsRange, bool failOnError=false)
Apply Objective-C type arguments to the given type.
SimplePointerKind
A simple notion of pointer kinds, which matches up with the various pointer declarators.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
const FileInfo & getFile() const
is AltiVec 'vector bool ...'
static const TST TST_typeofType
SourceLocation getBegin() const
void setAmpLoc(SourceLocation Loc)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
bool isArgExpr(unsigned Arg) const
void setLBracketLoc(SourceLocation Loc)
AttributeList *& getAttrListRef()
IdentifierInfo * getScopeName() const
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/_Atomic.
static bool isVectorSizeTooLarge(unsigned NumElements)
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool isStaticMember()
Returns true if this declares a static member.
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
SourceLocation getExceptionSpecLocBeg() const
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
bool isFunctionProtoType() const
A constructor named via a template-id.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a pack expansion of types.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool containsPlaceholderType() const
void setLParenLoc(SourceLocation Loc)
void setTypeArgsLAngleLoc(SourceLocation Loc)
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
CanQualType UnsignedShortTy
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Base class for declarations which introduce a typedef-name.
attr::Kind getKind() const
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static const TST TST_decltype_auto
void setClassTInfo(TypeSourceInfo *TI)
TagTypeKind
The kind of a tag type.
CanQualType ObjCBuiltinIdTy
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/_Atomic.
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
static const TSS TSS_unspecified
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void setAmpAmpLoc(SourceLocation Loc)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
static const TST TST_decltype
static const TST TST_auto
bool isFriendSpecified() const
static const TST TST_void
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
SourceLocation getLocStart() const LLVM_READONLY
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
SourceLocation getTypeSpecTypeNameLoc() const
static const TST TST_int128
bool isInvalidDecl() const
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType getEquivalentType() const
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
CanQualType UnsignedLongLongTy
static void checkNullabilityConsistency(TypeProcessingState &state, SimplePointerKind pointerKind, SourceLocation pointerLoc)
Check for consistent use of nullability.
bool hasTagDefinition() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
std::pair< SourceLocation, SourceLocation > getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Expr * getArgAsExpr(unsigned Arg) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
SourceLocation getLocEnd() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
EnumDecl - Represents an enum.
#define FUNCTION_TYPE_ATTRS_CASELIST
static bool isArraySizeVLA(Sema &S, Expr *ArraySize, llvm::APSInt &SizeVal)
Check whether the specified array size makes the array type a VLA.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A type that was preceded by the 'template' keyword, stored as a Type*.
static const TST TST_unspecified
bool isFirstDeclarator() const
void setNameLoc(SourceLocation Loc)
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
Syntax
The style used to specify an attribute.
bool isObjCObjectType() const
void setAttrEnumOperandLoc(SourceLocation loc)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
TypeSpecifierSign getWrittenSignSpec() const
bool isTriviallyCopyableType(ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
IdentifierInfo * getName() const
static const TST TST_decimal128
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
unsigned getTypeQuals() const
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
#define OBJC_POINTER_TYPE_ATTRS_CASELIST
CanQualType UnsignedLongTy
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
void setNext(AttributeList *N)
UnqualTypeLoc getUnqualifiedLoc() const
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, bool NeedDefinition, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool isFunctionType() const
QualType BuildPipeType(QualType T, SourceLocation Loc)
Build a Pipe type.
static const TST TST_typename
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Base for LValueReferenceType and RValueReferenceType.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void copy(TemplateSpecializationTypeLoc Loc)
Copy the location information from the given info.
Wraps an ObjCPointerType with source location information.
unsigned AtomicQualLoc
The location of the _Atomic-qualifier, if any.
SourceLocation getLoc() const
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
A template-id, e.g., f<int>.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
QualType getPointeeType() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, DeclaratorChunk &DeclType, QualType RT)
Produce an appropriate diagnostic for an ambiguity between a function declarator and a C++ direct-ini...
IdentifierInfo * getIdentifier() const
TypeDecl * getFloat128StubType() const
Retrieve the declaration for a 128-bit float stub type.
static bool hasNullabilityAttr(const AttributeList *attrs)
Check whether there is a nullability attribute of any kind in the given attribute list...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
Describes whether we've seen any nullability information for the given file.
bool CheckRegparmAttr(const AttributeList &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
bool isCXX11Attribute() const
const Type * getClass() const
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
bool isContextSensitiveKeywordAttribute() const
unsigned AutoTemplateParameterDepth
If this is a generic lambda, use this as the depth of each 'auto' parameter, during initial AST const...
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
QualType getTypeOfExprType(Expr *e) const
GCC extension.
An attributed type is a type to which a type attribute has been applied.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
void setKWLoc(SourceLocation Loc)
unsigned TypeQuals
For now, sema will catch these as invalid.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
Captures information about "declaration specifiers".
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
SourceLocation getIdentifierLoc() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation())
A user-defined literal name, e.g., operator "" _i.
bool isObjCObjectPointerType() const
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
void setParam(unsigned i, ParmVarDecl *VD)
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
Provides information a specialization of a member of a class template, which may be a member function...
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
void setLParenLoc(SourceLocation Loc)
static const TST TST_bool
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
static void assignInheritanceModel(Sema &S, CXXRecordDecl *RD)
Locks in the inheritance model for the given class and all of its bases.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
SourceLocation getRParenLoc() const
static void HandleAddressSpaceTypeAttribute(QualType &Type, const AttributeList &Attr, Sema &S)
HandleAddressSpaceTypeAttribute - Process an address_space attribute on the specified type...
bool isTypeSpecOwned() const
Defines the clang::TargetInfo interface.
SourceLocation getTypeSpecWidthLoc() const
bool isStar
True if this dimension was [*]. In this case, NumElts is null.
A SourceLocation and its associated SourceManager.
static Qualifiers fromCVRMask(unsigned CVR)
static const TSW TSW_longlong
TagDecl * getDecl() const
bool isIncompleteArrayType() const
static OpaquePtr make(QualTypeP)
bool isTypeAltiVecVector() const
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool isSet() const
Deprecated.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
void copy(TypeLoc other)
Copies the other type loc into this one.
static const TST TST_atomic
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
bool hasQualifiers() const
Determine whether this type has any qualifiers.
SourceManager & SourceMgr
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
static const TST TST_struct
SplitQualType getSingleStepDesugaredType() const
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false)
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
AttributeList * getNext() const
static StringRef getNameForCallConv(CallingConv CC)
Wrapper for source info for builtin types.
An l-value expression is a reference to an object with independent storage.
void setRParenLoc(SourceLocation Loc)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
void copy(DependentNameTypeLoc Loc)
QualifiedFunctionKind
Kinds of declarator that cannot contain a qualified function type.
bool hasExplicitCallingConv(QualType &T)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
No keyword precedes the qualified type name.
bool isConstQualified() const
Determine whether this type is const-qualified.
TypeAttrLocation
The location of a type attribute.
static void distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, AttributeList &attr, QualType &declSpecType)
A function type attribute was written on the declarator.
const Type * getClass() const
static void spliceAttrIntoList(AttributeList &attr, AttributeList *&head)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static TypeSourceInfo * GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo)
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
The global specifier '::'. There is no stored value.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
void setType(QualType newType)
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Wrapper for source info for block pointers.
bool isTypeAltiVecPixel() const
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static AttributeList::Kind getAttrListKind(AttributedType::Kind kind)
Map an AttributedType::Kind to an AttributeList::Kind.
A class which abstracts out some details necessary for making a call.
AttributeList *& getListRef()
Returns a reference to the attribute list.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
static void distributeObjCPointerTypeAttr(TypeProcessingState &state, AttributeList &attr, QualType type)
Given that an objc_gc attribute was written somewhere on a declaration other than on the declarator i...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
QualType BuildTypeofExprType(Expr *E, SourceLocation Loc)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
CanQualType UnsignedIntTy
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static void fillAttributedTypeLoc(AttributedTypeLoc TL, const AttributeList *attrs, const AttributeList *DeclAttrs=nullptr)
bool isPointerType() const
SourceLocation getEllipsisLoc() const
const AttributeList * getAttributes() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?