Go to the documentation of this file.
22 #ifndef LLVM_CLANG_SEMA_DECLSPEC_H
23 #define LLVM_CLANG_SEMA_DECLSPEC_H
35 #include "llvm/ADT/SmallVector.h"
36 #include "llvm/Support/Compiler.h"
37 #include "llvm/Support/ErrorHandling.h"
45 class NamespaceAliasDecl;
50 struct TemplateIdAnnotation;
78 return Builder.getRepresentation();
201 assert(R.
isValid() &&
"Must have a valid source range");
202 if (Range.getBegin().isInvalid())
298 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
299 static const TST TST_##ImgType##_t = clang::TST_##ImgType##_t;
300 #include "clang/Basic/OpenCLImageTypes.def"
328 unsigned StorageClassSpec : 3;
329 unsigned ThreadStorageClassSpec : 2;
330 unsigned SCS_extern_in_linkage_spec : 1;
333 unsigned TypeSpecWidth : 2;
334 unsigned TypeSpecComplex : 2;
335 unsigned TypeSpecSign : 2;
336 unsigned TypeSpecType : 6;
337 unsigned TypeAltiVecVector : 1;
338 unsigned TypeAltiVecPixel : 1;
339 unsigned TypeAltiVecBool : 1;
340 unsigned TypeSpecOwned : 1;
341 unsigned TypeSpecPipe : 1;
342 unsigned TypeSpecSat : 1;
343 unsigned ConstrainedAuto : 1;
346 unsigned TypeQualifiers : 5;
349 unsigned FS_inline_specified : 1;
350 unsigned FS_forceinline_specified: 1;
351 unsigned FS_virtual_specified : 1;
352 unsigned FS_noreturn_specified : 1;
355 unsigned Friend_specified : 1;
358 unsigned ConstexprSpecifier : 2;
389 SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
391 SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc;
398 void SaveWrittenBuiltinSpecs();
406 static bool isExprRep(
TST T) {
409 static bool isTemplateIdRep(
TST T) {
413 DeclSpec(
const DeclSpec &) =
delete;
414 void operator=(
const DeclSpec &) =
delete;
425 SCS_extern_in_linkage_spec(
false),
433 FS_forceinline_specified(
false), FS_virtual_specified(
false),
434 FS_noreturn_specified(
false), Friend_specified(
false),
437 Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {}
442 return (
TSCS)ThreadStorageClassSpec;
446 SCS_extern_in_linkage_spec =
Value;
451 return ThreadStorageClassSpecLoc;
457 SCS_extern_in_linkage_spec =
false;
464 TypeSpecOwned =
false;
487 assert(
isTypeRep((
TST) TypeSpecType) &&
"DeclSpec does not store a type");
491 assert(
isDeclRep((
TST) TypeSpecType) &&
"DeclSpec does not store a decl");
495 assert(isExprRep((
TST) TypeSpecType) &&
"DeclSpec does not store an expr");
499 assert(isTemplateIdRep((
TST) TypeSpecType) &&
500 "DeclSpec does not store a template id");
520 isExprRep((
TST)TypeSpecType));
569 return FS_inline_specified | FS_forceinline_specified;
572 return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
576 return FS_explicit_specifier;
587 return FS_explicit_specifier.
getExpr()
588 ?
SourceRange(FS_explicitLoc, FS_explicitCloseParenLoc)
596 FS_inline_specified =
false;
598 FS_forceinline_specified =
false;
600 FS_virtual_specified =
false;
605 FS_noreturn_specified =
false;
653 const char *&PrevSpec,
unsigned &DiagID,
656 const char *&PrevSpec,
unsigned &DiagID);
658 const char *&PrevSpec,
unsigned &DiagID,
663 const char *&PrevSpec,
unsigned &DiagID);
677 unsigned &DiagID,
Decl *Rep,
bool Owned,
685 unsigned &DiagID,
Decl *Rep,
bool Owned,
692 unsigned &DiagID,
Expr *Rep,
695 const char *&PrevSpec,
unsigned &DiagID,
698 const char *&PrevSpec,
unsigned &DiagID,
701 const char *&PrevSpec,
unsigned &DiagID,
704 const char *&PrevSpec,
unsigned &DiagID,
707 const char *&PrevSpec,
unsigned &DiagID,
721 assert(isExprRep((
TST) TypeSpecType));
747 const char *&PrevSpec,
unsigned &DiagID);
844 PropertyAttributes(ObjCPropertyAttribute::
kind_noattr), Nullability(0),
845 GetterName(nullptr), SetterName(nullptr) {}
869 "Objective-C declspec doesn't have nullability");
877 "Objective-C declspec doesn't have nullability");
878 return NullabilityLoc;
885 "Set the nullability declspec or property attribute first");
886 Nullability =
static_cast<unsigned>(
kind);
887 NullabilityLoc = loc;
910 unsigned objcDeclQualifier : 7;
915 unsigned Nullability : 2;
1267 std::unique_ptr<CachedTokens> DefArgTokens =
nullptr)
1381 for (
unsigned I = 0; I <
NumParams; ++I)
1382 Params[I].DefaultArgTokens.reset();
1538 Scope().~CXXScopeSpec();
1610 bool isStatic,
bool isStar,
Expr *NumElts,
1628 ParamInfo *Params,
unsigned NumParams,
1631 bool RefQualifierIsLvalueRef,
1638 unsigned NumExceptions,
1649 DeclSpec *MethodQualifiers =
nullptr);
1716 unsigned NumBindings : 31;
1717 unsigned DeleteBindings : 1;
1723 :
Bindings(nullptr), NumBindings(0), DeleteBindings(
false) {}
1737 DeleteBindings =
false;
1741 return llvm::makeArrayRef(
Bindings, NumBindings);
1826 unsigned InvalidType : 1;
1829 unsigned GroupingParens : 1;
1835 unsigned FunctionDefinition : 2;
1838 unsigned Redeclaration : 1;
1841 unsigned Extension : 1;
1844 unsigned ObjCIvar : 1;
1847 unsigned ObjCWeakProperty : 1;
1850 unsigned InlineStorageUsed : 1;
1853 unsigned HasInitializer : 1;
1867 Expr *TrailingRequiresClause;
1920 GroupingParens(
false), FunctionDefinition(static_cast<
unsigned>(
1923 ObjCWeakProperty(
false), InlineStorageUsed(
false),
1925 DeclarationAttrs(DeclarationAttrs), AsmLabel(nullptr),
1926 TrailingRequiresClause(nullptr),
1927 InventedTemplateParameterList(nullptr) {
1928 assert(llvm::all_of(DeclarationAttrs,
1932 "DeclarationAttrs may only contain [[]] attributes");
1962 return BindingGroup;
1984 Range.setBegin(Loc);
1996 if (Range.getBegin().isInvalid())
1999 Range.setEnd(SR.
getEnd());
2007 BindingGroup.
clear();
2009 for (
unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
2010 DeclTypeInfo[i].destroy();
2011 DeclTypeInfo.clear();
2014 InlineStorageUsed =
false;
2015 HasInitializer =
false;
2017 ObjCWeakProperty =
false;
2059 llvm_unreachable(
"unknown context kind!");
2099 llvm_unreachable(
"unknown context kind!");
2143 llvm_unreachable(
"unknown context kind!");
2200 llvm_unreachable(
"unknown context kind!");
2219 return BindingGroup.
isSet();
2224 return Name.Identifier;
2232 Name.setIdentifier(
Id, IdLoc);
2247 DeclTypeInfo.push_back(TI);
2248 DeclTypeInfo.back().getAttrs().addAll(attrs.begin(), attrs.end());
2258 DeclTypeInfo.push_back(TI);
2266 DeclTypeInfo.insert(DeclTypeInfo.begin(), TI);
2275 assert(i < DeclTypeInfo.size() &&
"Invalid type chunk");
2276 return DeclTypeInfo[i];
2279 assert(i < DeclTypeInfo.size() &&
"Invalid type chunk");
2280 return DeclTypeInfo[i];
2292 assert(!DeclTypeInfo.empty() &&
"No type chunks to drop.");
2293 DeclTypeInfo.front().destroy();
2294 DeclTypeInfo.erase(DeclTypeInfo.begin());
2301 for (
unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2302 if (!DeclTypeInfo[i].isParen())
2303 return &DeclTypeInfo[i];
2312 for (
unsigned i = DeclTypeInfo.size(), i_end = 0; i != i_end; --i) {
2313 if (!DeclTypeInfo[i-1].isParen())
2314 return &DeclTypeInfo[i-1];
2333 for (
unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2334 switch (DeclTypeInfo[i].
Kind) {
2348 llvm_unreachable(
"Invalid type chunk");
2367 return DeclTypeInfo[index].Fun;
2423 llvm_unreachable(
"unknown context kind!");
2466 llvm_unreachable(
"unknown context kind!");
2487 Chunk.Fun.hasTrailingReturnType())
2496 Chunk.Fun.hasTrailingReturnType())
2497 return Chunk.Fun.getTrailingReturnType();
2503 TrailingRequiresClause = TRC;
2510 return TrailingRequiresClause;
2516 return TrailingRequiresClause !=
nullptr;
2521 TemplateParameterLists = TPLs;
2526 return TemplateParameterLists;
2533 InventedTemplateParameterList = Invented;
2540 return InventedTemplateParameterList;
2563 return DeclarationAttrs;
2581 if (AL.isCXX11Attribute())
2582 Ranges.push_back(AL.getRange());
2614 FunctionDefinition =
static_cast<unsigned>(Val);
2673 const char *&PrevSpec);
2694 unsigned Specifiers;
2750 InitCaptureType, ExplicitRange));
2776 #endif // LLVM_CLANG_SEMA_DECLSPEC_H
Store information needed for an explicit specifier.
SourceLocation getVirtualSpecLoc() const
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
bool isOverrideSpecified() const
bool isConstrainedAuto() const
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Represents a C++ unqualified-id that has been parsed.
void setEndLoc(SourceLocation Loc)
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
bool SetTypeQual(TQ T, SourceLocation Loc)
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
Captures information about "declaration specifiers" specific to Objective-C.
SourceLocation RefQualifierLoc
The location of the ref-qualifier, if any.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
void setGroupingParens(bool flag)
SourceLocation getMutableLoc() const
Retrieve the location of the 'mutable' qualifier, if any.
SourceLocation getRestrictSpecLoc() const
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
CXXScopeSpec & getCXXScopeSpec()
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
DeclaratorChunk & getTypeObject(unsigned i)
Information about a template-id annotation token.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
SourceLocation getOverrideLoc() const
Represents a complete lambda introducer.
static const TST TST_unknown_anytype
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
void setBeginLoc(SourceLocation Loc)
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier.
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
void setAsmLabel(Expr *E)
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
static const TST TST_enum
A trivial tuple used to represent a source range.
SourceLocation getSetterNameLoc() const
SourceLocation getFinalLoc() const
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
DeclaratorChunk::ParamInfo InlineParams[16]
InlineParams - This is a local array used for the first function decl chunk to avoid going to the hea...
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
SourceRange getTypeSpecWidthRange() const
Represents a C++ namespace alias.
MemberPointerTypeInfo Mem
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
SourceLocation getExplicitSpecLoc() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
SourceRange getExplicitSpecRange() const
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
bool isInlineSpecified() const
ParsedAttributes & getAttributes()
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
Encodes a location in the source.
static const TST TST_error
SourceLocation getRParenLoc() const
This represents a decl that may have a name.
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getBegin() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, TypeResult Rep, const PrintingPolicy &Policy)
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec,...
SmallVector< LambdaCapture, 4 > Captures
void setObjCQualifiers(ObjCDeclSpec *quals)
Expr * getRepAsExpr() const
SourceLocation ConstQualLoc
The location of the const-qualifier, if any.
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, ExplicitSpecifier ExplicitSpec, SourceLocation CloseParenLoc)
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
OverloadedOperatorKind Operator
The kind of overloaded operator.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
IdentifierInfo * getIdentifier() const
@ EST_None
no exception specification
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ArrayRef< Binding > bindings() const
void setExternInLinkageSpec(bool Value)
DeclSpec(AttributeFactory &attrFactory)
@ EST_Dynamic
throw(T1, T2)
DeclaratorContext getContext() const
void setTypeofParensRange(SourceRange range)
ObjCDeclSpec * getObjCQualifiers() const
bool hasAutoTypeSpec() const
@ IK_Identifier
An identifier.
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
static const char * getSpecifierName(Specifier VS)
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
SourceRange getSourceRange() const LLVM_READONLY
SCS
storage-class-specifier
IdentifierInfo * getGetterName()
FunctionDefinitionKind getFunctionDefinitionKind() const
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool getExtension() const
bool hasExplicitSpecifier() const
static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS, unsigned TypeQuals, SourceLocation StarLoc, SourceLocation EndLoc)
DecompositionDeclarator & operator=(const DecompositionDeclarator &G)=delete
SourceLocation StarLoc
Location of the '*' token.
TSC getTypeSpecComplex() const
FieldDeclarator(const DeclSpec &DS, const ParsedAttributes &DeclarationAttrs)
ParsedAttributes & getAttributes()
@ EST_Unparsed
not parsed yet
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
@ TSCS_thread_local
C++11 thread_local.
SourceLocation ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Represents a C++ nested-name-specifier or a global scope specifier.
Describes how types, statements, expressions, and declarations should be printed.
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
SourceLocation getEllipsisLoc() const
SourceLocation getConstSpecLoc() const
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
AttributePool & getAttributePool() const
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
SourceLocation getTypeSpecComplexLoc() const
char ScopeMem[sizeof(CXXScopeSpec)]
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
AttributeFactory * QualAttrFactory
AtttibuteFactory for the MethodQualifiers.
SourceLocation EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
ParsedType getTrailingReturnType() const
Get the trailing return type appearing (at any level) within this declarator.
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getIdentifierLoc() const
const ParsedAttributesView & getDeclarationAttributes() const
SourceLocation getTypeSpecTypeLoc() const
const DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo() const
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
static const TSCS TSCS_unspecified
SourceLocation getFriendSpecLoc() const
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
ExplicitSpecifier getExplicitSpecifier() const
bool isStaticMember()
Returns true if this declares a static member.
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal)
SourceLocation getEllipsisLoc() const
static const TST TST_float
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isSet() const
Deprecated.
~DecompositionDeclarator()
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required.
static const TST TST_underlyingType
void takeAttributes(ParsedAttributes &attrs)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
static const TST TST_char8
void SetRangeStart(SourceLocation Loc)
bool isObjCWeakProperty() const
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
static const TST TST_accum
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
const DeclaratorChunk * getOutermostNonParenChunk() const
Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chu...
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getCommaLoc() const
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
bool isNoreturnSpecified() const
bool isFinalSpecified() const
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
bool isTypeSpecPipe() const
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
TypeSpecifierSign getTypeSpecSign() const
SourceLocation getVolatileSpecLoc() const
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Specifier getLastSpecifier() const
bool hasGroupingParens() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
SourceLocation getRSquareLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isExternInLinkageSpec() const
ThreadStorageClassSpecifier
Thread storage-class-specifier.
SourceLocation RestrictQualLoc
The location of the restrict-qualifier, if any.
TST getTypeSpecType() const
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
bool isStandardAttributeSyntax() const
The attribute is spelled [[]] in either C or C++ mode, including standard attributes spelled with a k...
SourceLocation getAbstractLoc() const
void UpdateTypeRep(ParsedType Rep)
void UpdateExprRep(Expr *Rep)
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
Expr * getAsmLabel() const
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
NullabilityKind getNullability() const
bool isValid() const
A scope specifier is present, and it refers to a real scope.
static const TST TST_interface
static const TST TST_char
SourceLocation getEnd() const
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
static const TST TST_double
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,...
bool isPrototypeContext() const
SourceLocation getUnalignedSpecLoc() const
static const TST TST_BFloat16
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ParsedType InitCaptureType
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
DeclSpec & getOrCreateMethodQualifiers()
NamedDecl ** DeclsInPrototype
Pointer to a new[]'d array of declarations that need to be available for lookup inside the function b...
Declarator(const DeclSpec &DS, const ParsedAttributesView &DeclarationAttrs, DeclaratorContext C)
DS and DeclarationAttrs must outlive the Declarator.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
const DecompositionDeclarator & getDecompositionDeclarator() const
bool hasConstexprSpecifier() const
void ClearStorageClassSpecs()
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier.
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
SourceLocation getGetterNameLoc() const
static const TST TST_decimal32
bool isFinalSpelledSealed() const
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
static const TST TST_class
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
void addAll(iterator B, iterator E)
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
bool isTypeAltiVecVector() const
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
bool hasTagDefinition() const
static const TST TST_fract
SourceLocation getEndLoc() const LLVM_READONLY
unsigned AccessWrites
The access writes.
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
bool isTypeSpecOwned() const
void setInvalidType(bool Val=true)
ParsedAttr - Represents a syntactic attribute.
An individual capture in a lambda introducer.
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
@ IK_ConstructorName
A constructor name.
void clear()
Reset the contents of this Declarator.
unsigned TypeQuals
For now, sema will catch these as invalid.
const CXXScopeSpec & Scope() const
@ NumObjCPropertyAttrsBits
Number of bits fitting all the property attributes.
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
Append a capture in a lambda introducer.
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
SourceLocation getEndLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
const IdentifierInfo * getGetterName() const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
bool isFriendSpecified() const
LambdaCaptureDefault Default
bool hasInitializer() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
SCS getStorageClassSpec() const
SourceLocation getNoreturnSpecLoc() const
ParsedAttributesView & getAttrs()
bool hasAttributes() const
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
static const TST TST_union
SourceRange getSourceRange() const
SourceRange getExceptionSpecRange() const
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
A C++ nested-name-specifier augmented with source location information.
void setObjCIvar(bool Val=true)
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
void setNullability(SourceLocation loc, NullabilityKind kind)
void SetSourceRange(SourceRange R)
DecompositionDeclarator()
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs)
Sets the template parameter lists that preceded the declarator.
void freeParams()
Reset the parameter list to having zero parameters.
void ClearConstexprSpec()
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getExceptionSpecLocEnd() const
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
SourceLocation getNullabilityLoc() const
SourceRange getSourceRange() const
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
static const TST TST_decimal64
UnqualifiedIdKind
Describes the kind of unqualified-id parsed.
static const TST TST_ibm128
void setRedeclaration(bool Val)
const Expr * getExpr() const
SourceLocation getStorageClassSpecLoc() const
ConstexprSpecKind
Define the kind of constexpr specifier.
void takeAllFrom(ParsedAttributes &Other)
static const TST TST_int128
void setHasInitializer(bool Val=true)
SourceLocation getLSquareLoc() const
Represents a C++ struct/union/class.
SourceLocation TrailingReturnTypeLoc
If HasTrailingReturnType is true, this is the location of the trailing return type.
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
@ IK_TemplateId
A template-id, e.g., f<int>.
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void setRange(SourceRange R)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
unsigned hasStatic
True if this dimension included the 'static' keyword.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
LambdaCaptureKind
The different capture forms in a lambda introducer.
bool isTypeAltiVecPixel() const
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
void setTrailingRequiresClause(Expr *TRC)
Sets a trailing requires clause for this declarator.
SourceLocation getAltiVecLoc() const
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
static const TST TST_bitint
static const TST TST_decimal128
static bool isDeclRep(TST T)
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
const IdentifierInfo * getSetterName() const
bool isSpecified() const
Determine if the declaration had an explicit specifier of any kind.
void setGetterName(IdentifierInfo *name, SourceLocation loc)
SmallVectorImpl< DeclaratorChunk >::const_iterator type_object_iterator
SmallVector< NamedDecl *, 4 > TemplateParams
Store the list of the template parameters for a generic lambda or an abbreviated function template.
bool isModulePrivateSpecified() const
Represents a C++ template name within the type system.
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
SourceLocation LParenLoc
The location of the left parenthesis in the source.
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
ObjCDeclQualifier getObjCDeclQualifier() const
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
static const TST TST_float16
static const TST TST_typename
SourceLocation getTypeSpecTypeNameLoc() const
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Decl - This represents one declaration (or definition), e.g.
bool isFunctionDefinition() const
Base wrapper for a particular "section" of type source info.
bool isTypeAltiVecBool() const
static const TST TST_typeofType
SourceLocation UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
SourceLocation getInlineSpecLoc() const
llvm::iterator_range< type_object_iterator > type_object_range
static const TST TST_half
void setDeductionGuideName(ParsedTemplateTy Template, SourceLocation TemplateLoc)
Specify that this unqualified-id was parsed as a template-name for a deduction-guide.
static const TST TST_decltype_auto
TypeSpecifierWidth getTypeSpecWidth() const
Sema - This implements semantic analysis and AST building for C.
@ IK_DestructorName
A destructor name.
SourceLocation Loc
Loc - The place where this type was defined.
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
void setDecompositionBindings(SourceLocation LSquareLoc, ArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
static const TST TST_decltype
bool isInvalidType() const
SourceLocation getTypeSpecWidthLoc() const
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
ParsedAttributes - A collection of parsed attributes.
ConstexprSpecKind getConstexprSpecifier() const
unsigned AutoTemplateParameterDepth
If this is a generic lambda or abbreviated function template, use this as the depth of each 'auto' pa...
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
void setExtension(bool Val=true)
ParsedSpecifiers
ParsedSpecifiers - Flags to query which specifiers were applied.
One of these records is kept for each identifier that is lexed.
SourceLocation VolatileQualLoc
The location of the volatile-qualifier, if any.
SourceLocation getLParenLoc() const
enum clang::DeclaratorChunk::@211 Kind
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
SourceLocation EllipsisLoc
void setSetterName(IdentifierInfo *name, SourceLocation loc)
static const TST TST_float128
SourceLocation RParenLoc
The location of the right parenthesis in the source.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SourceLocation getTrailingReturnTypeLoc() const
Get the trailing-return-type location for this function declarator.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Decl * getRepAsDecl() const
static const TST TST_void
void setCommaLoc(SourceLocation CL)
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
static const TST TST_bool
static const TST TST_char32
NullabilityKind
Describes the nullability of a particular type.
static const TST TST_unspecified
SourceLocation getPipeLoc() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
void takeAttributesFrom(ParsedAttributes &attrs)
SourceLocation SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new",...
static const TSCS TSCS___thread
SourceLocation DefaultLoc
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceLocation getTypeSpecSatLoc() const
@ TSCS__Thread_local
C11 _Thread_local.
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
ActionResult< ParsedType > TypeResult
ParsedAttributesView AttrList
static const TST TST_atomic
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
DecompositionDeclarator::Binding InlineBindings[16]
static const TST TST_auto_type
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Information about one declarator, including the parsed type information and the identifier.
@ CopyInit
[a = b], [a = {b}]
void forEachCVRUQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each CVRU qual being set.
SourceLocation MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
void DropFirstTypeObject()
void ClearFunctionSpecs()
This little struct is used to capture information about structure field declarators,...
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceRange getTypeofParensRange() const
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const CXXScopeSpec & getTypeSpecScope() const
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
bool isVirtualSpecified() const
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
One instance of this struct is used for each type in a declarator that is parsed.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
@ TSCS___thread
GNU __thread.
SourceLocation getLastLocation() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, std::unique_ptr< CachedTokens > DefArgTokens=nullptr)
bool hasTrailingRequiresClause() const
Determine whether a trailing requires clause was written in this declarator.
static const TST TST_struct
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceLocation ExceptionSpecLocEnd
The end location of the exception specification, if any.
SourceLocation getModulePrivateSpecLoc() const
ThreadStorageClassSpecifier TSCS
TemplateIdAnnotation * getRepAsTemplateId() const
void setObjCWeakProperty(bool Val=true)
static const TST TST_typeofExpr
SourceLocation getEndLoc() const LLVM_READONLY
void AddTypeInfo(const DeclaratorChunk &TI, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
SourceLocation getTypeSpecSignLoc() const
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
unsigned NumExplicitTemplateParams
The number of parameters in the template parameter list that were explicitly specified by the user,...
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
SourceRange ExplicitRange
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
AttributePool & getPool() const
This represents one expression.
IdentifierInfo * getSetterName()
static const TST TST_wchar
bool isEmpty() const
No scope specifier.
void addAttributes(const ParsedAttributesView &AL)
Concatenates two attribute lists.
const ParsedAttributes & getAttributes() const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
SourceRange getRange() const
void SetRangeEnd(SourceLocation Loc)
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
bool hasAttributes() const
hasAttributes - do we contain any attributes?
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
SourceLocation getBeginLoc() const
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the 'restrict' qualifier.
SourceLocation getConstexprSpecLoc() const
Wraps an identifier and optional source location for the identifier.
static const TSCS TSCS__Thread_local
static const TST TST_auto
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
void setEllipsisLoc(SourceLocation EL)
static const TST TST_char16
Represent a C++ namespace.
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
AttributePool & getAttributePool() const
SourceLocation getBeginLoc() const LLVM_READONLY
void UpdateDeclRep(Decl *Rep)
bool SetTypeSpecWidth(TypeSpecifierWidth W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
unsigned kind
All of the diagnostics that can be emitted by the frontend.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getFirstLocation() const
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
bool isFirstDeclarator() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk,...
SourceLocation getAtomicSpecLoc() const
Structure that packs information about the type specifiers that were written in a particular type spe...
bool isTypeSpecSat() const
Captures information about "declaration specifiers".
SourceLocation AtomicQualLoc
The location of the _Atomic-qualifier, if any.
CXXScopeSpec & getTypeSpecScope()
bool isRedeclaration() const
LambdaCaptureInitKind InitKind
static const TSCS TSCS_thread_local
ParsedType getRepAsType() const
bool isExpressionContext() const
Determine whether this declaration appears in a context where an expression could appear.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
Represents a C++11 virt-specifier-seq.
void setImplicitSelfParam(const IdentifierInfo *Id)
Specify that this unqualified-id is an implicit 'self' parameter.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
TypeSpecifierType
Specifies the kind of type.
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
TemplateIdAnnotation * TemplateIdRep
SourceLocation getExceptionSpecLocBeg() const
@ PQ_StorageClassSpecifier
TSCS getThreadStorageClassSpec() const