clang 23.0.0git
clang::Declarator Class Reference

Information about one declarator, including the parsed type information and the identifier. More...

#include "clang/Sema/DeclSpec.h"

Inheritance diagram for clang::Declarator:
[legend]

Public Types

typedef SmallVectorImpl< DeclaratorChunk >::const_iterator type_object_iterator
typedef llvm::iterator_range< type_object_iteratortype_object_range

Public Member Functions

 Declarator (const DeclSpec &DS, const ParsedAttributesView &DeclarationAttrs, DeclaratorContext C)
 DS and DeclarationAttrs must outlive the Declarator.
 ~Declarator ()
const DeclSpecgetDeclSpec () const
 getDeclSpec - Return the declaration-specifier that this declarator was declared with.
DeclSpecgetMutableDeclSpec ()
 getMutableDeclSpec - Return a non-const version of the DeclSpec.
AttributePoolgetAttributePool () const
const CXXScopeSpecgetCXXScopeSpec () const
 getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part of the declarator-id.
CXXScopeSpecgetCXXScopeSpec ()
UnqualifiedIdgetName ()
 Retrieve the name specified by this declarator.
const DecompositionDeclaratorgetDecompositionDeclarator () const
DeclaratorContext getContext () const
bool isPrototypeContext () const
SourceRange getSourceRange () const LLVM_READONLY
 Get the source range that spans this declarator.
SourceLocation getBeginLoc () const LLVM_READONLY
SourceLocation getEndLoc () const LLVM_READONLY
void SetSourceRange (SourceRange R)
void SetRangeBegin (SourceLocation Loc)
 SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.
void SetRangeEnd (SourceLocation Loc)
 SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
void ExtendWithDeclSpec (const DeclSpec &DS)
 ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
void clear ()
 Reset the contents of this Declarator.
bool mayOmitIdentifier () const
 mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
bool mayHaveIdentifier () const
 mayHaveIdentifier - Return true if the identifier is either optional or required.
bool mayHaveDecompositionDeclarator () const
 Return true if the context permits a C++17 decomposition declarator.
bool mayBeFollowedByCXXDirectInit () const
 mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initializer, e.g.
bool isPastIdentifier () const
 isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
bool hasName () const
 hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentifier()) or some kind of special C++ name (constructor, destructor, etc.), or a structured binding (which is not exactly a name, but occupies the same position).
bool isDecompositionDeclarator () const
 Return whether this declarator is a decomposition declarator.
const IdentifierInfogetIdentifier () const
SourceLocation getIdentifierLoc () const
void SetIdentifier (const IdentifierInfo *Id, SourceLocation IdLoc)
 Set the name of this declarator to be the given identifier.
void setDecompositionBindings (SourceLocation LSquareLoc, MutableArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
 Set the decomposition bindings for this declarator.
void AddTypeInfo (const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
 AddTypeInfo - Add a chunk to this declarator.
void AddTypeInfo (const DeclaratorChunk &TI, AttributePool &OtherPool, SourceLocation EndLoc)
 AddTypeInfo - Add a chunk to this declarator.
void AddTypeInfo (const DeclaratorChunk &TI, SourceLocation EndLoc)
 AddTypeInfo - Add a chunk to this declarator.
void AddInnermostTypeInfo (const DeclaratorChunk &TI)
 Add a new innermost chunk to this declarator.
unsigned getNumTypeObjects () const
 Return the number of types applied to this declarator.
const DeclaratorChunkgetTypeObject (unsigned i) const
 Return the specified TypeInfo from this declarator.
DeclaratorChunkgetTypeObject (unsigned i)
type_object_range type_objects () const
 Returns the range of type objects, from the identifier outwards.
void DropFirstTypeObject ()
const DeclaratorChunkgetInnermostNonParenChunk () const
 Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk, or null if there are no non-parens chunks.
const DeclaratorChunkgetOutermostNonParenChunk () const
 Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chunk, or null if there are no non-parens chunks.
bool isArrayOfUnknownBound () const
 isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of unknown bound (looking through parentheses).
bool isFunctionDeclarator (unsigned &idx) const
 isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking through parentheses).
bool isFunctionDeclarator () const
 isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if the identifier is a function declarator (looking through parentheses).
DeclaratorChunk::FunctionTypeInfogetFunctionTypeInfo ()
 getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
const DeclaratorChunk::FunctionTypeInfogetFunctionTypeInfo () const
 getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
bool isDeclarationOfFunction () const
 Determine whether the declaration that will be produced from this declaration will be a function.
bool isFunctionDeclarationContext () const
 Return true if this declaration appears in a context where a function declarator would be a function declaration.
bool isExpressionContext () const
 Determine whether this declaration appears in a context where an expression could appear.
bool isFunctionDeclaratorAFunctionDeclaration () const
 Return true if a function declarator at this position would be a function declaration.
bool hasTrailingReturnType () const
 Determine whether a trailing return type was written (at any level) within this declarator.
ParsedType getTrailingReturnType () const
 Get the trailing return type appearing (at any level) within this declarator.
void setTrailingRequiresClause (Expr *TRC)
 Sets a trailing requires clause for this declarator.
ExprgetTrailingRequiresClause ()
 Sets a trailing requires clause for this declarator.
bool hasTrailingRequiresClause () const
 Determine whether a trailing requires clause was written in this declarator.
void setTemplateParameterLists (ArrayRef< TemplateParameterList * > TPLs)
 Sets the template parameter lists that preceded the declarator.
ArrayRef< TemplateParameterList * > getTemplateParameterLists () const
 The template parameter lists that preceded the declarator.
void setInventedTemplateParameterList (TemplateParameterList *Invented)
 Sets the template parameter list generated from the explicit template parameters along with any invented template parameters from placeholder-typed parameters.
TemplateParameterListgetInventedTemplateParameterList () const
 The template parameter list generated from the explicit template parameters along with any invented template parameters from placeholder-typed parameters, if there were any such parameters.
void takeAttributesAppending (ParsedAttributes &attrs)
 takeAttributesAppending - Takes attributes from the given ParsedAttributes set and add them to this declarator.
const ParsedAttributesgetAttributes () const
ParsedAttributesgetAttributes ()
const ParsedAttributesViewgetDeclarationAttributes () const
bool hasAttributes () const
 hasAttributes - do we contain any attributes?
void setAsmLabel (Expr *E)
ExprgetAsmLabel () const
void setExtension (bool Val=true)
bool getExtension () const
void setObjCIvar (bool Val=true)
bool isObjCIvar () const
void setObjCWeakProperty (bool Val=true)
bool isObjCWeakProperty () const
void setInvalidType (bool Val=true)
bool isInvalidType () const
void setGroupingParens (bool flag)
bool hasGroupingParens () const
bool isFirstDeclarator () const
SourceLocation getCommaLoc () const
void setCommaLoc (SourceLocation CL)
bool hasEllipsis () const
SourceLocation getEllipsisLoc () const
void setEllipsisLoc (SourceLocation EL)
bool hasPackIndexing () const
ExprgetPackIndexingExpr () const
void setPackIndexingExpr (Expr *PI)
void setFunctionDefinitionKind (FunctionDefinitionKind Val)
bool isFunctionDefinition () const
FunctionDefinitionKind getFunctionDefinitionKind () const
void setHasInitializer (bool Val=true)
bool hasInitializer () const
bool isFirstDeclarationOfMember ()
 Returns true if this declares a real member and not a friend.
bool isStaticMember ()
 Returns true if this declares a static member.
bool isExplicitObjectMemberFunction ()
bool isCtorOrDtor ()
 Returns true if this declares a constructor or a destructor.
void setRedeclaration (bool Val)
bool isRedeclaration () const

Friends

struct DeclaratorChunk

Detailed Description

Information about one declarator, including the parsed type information and the identifier.

When the declarator is fully formed, this is turned into the appropriate Decl object.

Declarators come in two types: normal declarators and abstract declarators. Abstract declarators are used when parsing types, and don't have an identifier. Normal declarators do have ID's.

Instances of this class should be a transient object that lives on the stack, not objects that are allocated in large quantities on the heap.

Definition at line 1942 of file DeclSpec.h.

Member Typedef Documentation

◆ type_object_iterator

Definition at line 2449 of file DeclSpec.h.

◆ type_object_range

Definition at line 2450 of file DeclSpec.h.

Constructor & Destructor Documentation

◆ Declarator()

clang::Declarator::Declarator ( const DeclSpec & DS,
const ParsedAttributesView & DeclarationAttrs,
DeclaratorContext C )
inline

DS and DeclarationAttrs must outlive the Declarator.

In particular, take care not to pass temporary objects for these parameters.

DeclarationAttrs contains [[]] attributes from the attribute-specifier-seq at the beginning of a declaration, which appertain to the declared entity itself. Attributes with other syntax (e.g. GNU) should not be placed in this attribute list; if they occur at the beginning of a declaration, they apply to the DeclSpec and should be attached to that instead.

Here is an example of an attribute associated with a declaration:

[[deprecated]] int x, y;

This attribute appertains to all of the entities declared in the declaration, i.e. x and y in this case.

Definition at line 2064 of file DeclSpec.h.

References clang::C, clang::Declaration, false, getAttributePool(), getSourceRange(), clang::AttributeCommonInfo::isRegularKeywordAttribute(), clang::AttributeCommonInfo::isStandardAttributeSyntax(), clang::nullptr, and clang::TST_error.

Referenced by getFunctionTypeInfo(), and clang::ParsingDeclarator::ParsingDeclarator().

◆ ~Declarator()

clang::Declarator::~Declarator ( )
inline

Definition at line 2084 of file DeclSpec.h.

References clear().

Member Function Documentation

◆ AddInnermostTypeInfo()

void clang::Declarator::AddInnermostTypeInfo ( const DeclaratorChunk & TI)
inline

Add a new innermost chunk to this declarator.

Definition at line 2431 of file DeclSpec.h.

References DeclaratorChunk.

Referenced by maybeSynthesizeBlockSignature().

◆ AddTypeInfo() [1/3]

void clang::Declarator::AddTypeInfo ( const DeclaratorChunk & TI,
AttributePool & OtherPool,
SourceLocation EndLoc )
inline

AddTypeInfo - Add a chunk to this declarator.

Also extend the range to EndLoc, which should be the last token of the chunk. This overload is for copying a 'chunk' from another declarator, so it takes the pool that the other Declarator owns so that it can 'take' the attributes from it.

Definition at line 2409 of file DeclSpec.h.

References DeclaratorChunk, getAttributePool(), clang::SourceLocation::isInvalid(), SetRangeEnd(), and clang::AttributePool::takeFrom().

◆ AddTypeInfo() [2/3]

void clang::Declarator::AddTypeInfo ( const DeclaratorChunk & TI,
ParsedAttributes && attrs,
SourceLocation EndLoc )
inline

AddTypeInfo - Add a chunk to this declarator.

Also extend the range to EndLoc, which should be the last token of the chunk. This function takes attrs by R-Value reference because it takes ownership of those attributes from the parameter.

Definition at line 2395 of file DeclSpec.h.

References DeclaratorChunk, getAttributePool(), clang::SourceLocation::isInvalid(), SetRangeEnd(), and clang::AttributePool::takeAllFrom().

Referenced by clang::Sema::ActOnCXXForRangeIdentifier(), clang::SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(), and clang::Sema::ImplicitlyDefineFunction().

◆ AddTypeInfo() [3/3]

void clang::Declarator::AddTypeInfo ( const DeclaratorChunk & TI,
SourceLocation EndLoc )
inline

AddTypeInfo - Add a chunk to this declarator.

Also extend the range to EndLoc, which should be the last token of the chunk.

Definition at line 2420 of file DeclSpec.h.

References clang::DeclaratorChunk::AttrList, DeclaratorChunk, clang::ParsedAttributesView::empty(), clang::SourceLocation::isInvalid(), and SetRangeEnd().

◆ clear()

void clang::Declarator::clear ( )
inline

Reset the contents of this Declarator.

Definition at line 2152 of file DeclSpec.h.

Referenced by clang::ParsingDeclarator::clear(), and ~Declarator().

◆ DropFirstTypeObject()

void clang::Declarator::DropFirstTypeObject ( )
inline

Definition at line 2457 of file DeclSpec.h.

Referenced by clang::Sema::ActOnCXXNew().

◆ ExtendWithDeclSpec()

void clang::Declarator::ExtendWithDeclSpec ( const DeclSpec & DS)
inline

ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.

Adopts the range start if the current range start is invalid.

Definition at line 2143 of file DeclSpec.h.

References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::SourceLocation::isInvalid(), and clang::SourceRange::setBegin().

◆ getAsmLabel()

Expr * clang::Declarator::getAsmLabel ( ) const
inline

◆ getAttributePool()

AttributePool & clang::Declarator::getAttributePool ( ) const
inline

◆ getAttributes() [1/2]

ParsedAttributes & clang::Declarator::getAttributes ( )
inline

Definition at line 2726 of file DeclSpec.h.

◆ getAttributes() [2/2]

◆ getBeginLoc()

◆ getCommaLoc()

SourceLocation clang::Declarator::getCommaLoc ( ) const
inline

Definition at line 2764 of file DeclSpec.h.

Referenced by warnAboutAmbiguousFunction().

◆ getContext()

◆ getCXXScopeSpec() [1/2]

CXXScopeSpec & clang::Declarator::getCXXScopeSpec ( )
inline

Definition at line 2105 of file DeclSpec.h.

◆ getCXXScopeSpec() [2/2]

◆ getDeclarationAttributes()

◆ getDeclSpec()

const DeclSpec & clang::Declarator::getDeclSpec ( ) const
inline

getDeclSpec - Return the declaration-specifier that this declarator was declared with.

Definition at line 2089 of file DeclSpec.h.

Referenced by clang::Sema::ActOnCXXConditionDeclaration(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnCXXNew(), clang::Sema::ActOnDecompositionDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::SemaObjC::ActOnIvar(), clang::Sema::ActOnNonTypeTemplateParameter(), clang::SemaObjC::ActOnObjCExceptionDecl(), clang::Sema::ActOnParamDeclarator(), clang::SemaOpenMP::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnTypedefDeclarator(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::canDelayFunctionBody(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckExplicitObjectMemberFunction(), clang::Sema::CheckFieldDecl(), checkOmittedBlockReturnType(), clang::Sema::checkUnusedDeclAttributes(), clang::Sema::containsUnexpandedParameterPacks(), CreateNewFunctionDecl(), diagnoseRedundantReturnTypeQualifiers(), getCCForDeclaratorChunk(), clang::ParsingDeclarator::getDeclSpec(), GetDeclSpecTypeForDeclarator(), GetFullTypeForDeclarator(), getFunctionStorageClass(), getLambdaType(), GetTypeSourceInfoForDeclarator(), clang::Sema::HandleDeclarator(), clang::Sema::HandleField(), clang::Sema::HandleMSProperty(), hasAttributes(), hasParsedAttr(), InventTemplateParameter(), clang::Sema::isDeclaratorFunctionLike(), isFirstDeclarationOfMember(), isFunctionDeclarationContext(), isOmittedBlockReturnType(), isStaticMember(), mayBeFollowedByCXXDirectInit(), clang::Sema::ParseTypedefDecl(), clang::Sema::ProcessDeclAttributes(), takeDeclAttributes(), warnAboutAmbiguousFunction(), and warnAboutRedundantParens().

◆ getDecompositionDeclarator()

const DecompositionDeclarator & clang::Declarator::getDecompositionDeclarator ( ) const
inline

◆ getEllipsisLoc()

SourceLocation clang::Declarator::getEllipsisLoc ( ) const
inline

◆ getEndLoc()

◆ getExtension()

bool clang::Declarator::getExtension ( ) const
inline

Definition at line 2747 of file DeclSpec.h.

◆ getFunctionDefinitionKind()

FunctionDefinitionKind clang::Declarator::getFunctionDefinitionKind ( ) const
inline

◆ getFunctionTypeInfo() [1/2]

◆ getFunctionTypeInfo() [2/2]

const DeclaratorChunk::FunctionTypeInfo & clang::Declarator::getFunctionTypeInfo ( ) const
inline

getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).

Definition at line 2538 of file DeclSpec.h.

References Declarator(), and getFunctionTypeInfo().

◆ getIdentifier()

◆ getIdentifierLoc()

◆ getInnermostNonParenChunk()

const DeclaratorChunk * clang::Declarator::getInnermostNonParenChunk ( ) const
inline

Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk, or null if there are no non-parens chunks.

Definition at line 2466 of file DeclSpec.h.

References DeclaratorChunk.

Referenced by GetFullTypeForDeclarator(), and isArrayOfUnknownBound().

◆ getInventedTemplateParameterList()

TemplateParameterList * clang::Declarator::getInventedTemplateParameterList ( ) const
inline

The template parameter list generated from the explicit template parameters along with any invented template parameters from placeholder-typed parameters, if there were any such parameters.

Definition at line 2705 of file DeclSpec.h.

Referenced by clang::Sema::ActOnFunctionDeclarator().

◆ getMutableDeclSpec()

DeclSpec & clang::Declarator::getMutableDeclSpec ( )
inline

getMutableDeclSpec - Return a non-const version of the DeclSpec.

This should be used with extreme care: declspecs can often be shared between multiple declarators, so mutating the DeclSpec affects all of the Declarators. This should only be done when the declspec is known to not be shared or when in error recovery etc.

Definition at line 2096 of file DeclSpec.h.

Referenced by clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::SemaObjC::ActOnObjCExceptionDecl(), clang::Sema::ActOnParamDeclarator(), addContextSensitiveTypeNullability(), clang::Sema::CheckDeductionGuideDeclarator(), checkOmittedBlockReturnType(), ConvertDeclSpecToType(), CreateNewFunctionDecl(), distributeObjCPointerTypeAttrFromDeclarator(), GetDeclSpecTypeForDeclarator(), GetFullTypeForDeclarator(), getFunctionStorageClass(), RebuildDeclaratorInCurrentInstantiation(), and takeDeclAttributes().

◆ getName()

◆ getNumTypeObjects()

◆ getOutermostNonParenChunk()

const DeclaratorChunk * clang::Declarator::getOutermostNonParenChunk ( ) const
inline

Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chunk, or null if there are no non-parens chunks.

Definition at line 2477 of file DeclSpec.h.

References DeclaratorChunk.

◆ getPackIndexingExpr()

Expr * clang::Declarator::getPackIndexingExpr ( ) const
inline

Definition at line 2772 of file DeclSpec.h.

◆ getSourceRange()

◆ getTemplateParameterLists()

ArrayRef< TemplateParameterList * > clang::Declarator::getTemplateParameterLists ( ) const
inline

The template parameter lists that preceded the declarator.

Definition at line 2691 of file DeclSpec.h.

Referenced by clang::Sema::ActOnFinishFunctionDeclarationDeclarator(), clang::Sema::ActOnStartFunctionDeclarationDeclarator(), and isStaticMember().

◆ getTrailingRequiresClause()

Expr * clang::Declarator::getTrailingRequiresClause ( )
inline

Sets a trailing requires clause for this declarator.

Definition at line 2675 of file DeclSpec.h.

Referenced by clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::containsUnexpandedParameterPacks(), and CreateNewFunctionDecl().

◆ getTrailingReturnType()

ParsedType clang::Declarator::getTrailingReturnType ( ) const
inline

Get the trailing return type appearing (at any level) within this declarator.

Definition at line 2659 of file DeclSpec.h.

References clang::DeclaratorChunk::Function, and type_objects().

Referenced by GetDeclSpecTypeForDeclarator().

◆ getTypeObject() [1/2]

DeclaratorChunk & clang::Declarator::getTypeObject ( unsigned i)
inline

Definition at line 2444 of file DeclSpec.h.

References DeclaratorChunk.

◆ getTypeObject() [2/2]

◆ hasAttributes()

bool clang::Declarator::hasAttributes ( ) const
inline

hasAttributes - do we contain any attributes?

Definition at line 2733 of file DeclSpec.h.

References getAttributes(), getDeclarationAttributes(), getDeclSpec(), getNumTypeObjects(), getTypeObject(), and hasAttributes().

Referenced by hasAttributes().

◆ hasEllipsis()

bool clang::Declarator::hasEllipsis ( ) const
inline

◆ hasGroupingParens()

bool clang::Declarator::hasGroupingParens ( ) const
inline

◆ hasInitializer()

bool clang::Declarator::hasInitializer ( ) const
inline

Definition at line 2788 of file DeclSpec.h.

Referenced by clang::Sema::ActOnVariableDeclarator().

◆ hasName()

bool clang::Declarator::hasName ( ) const
inline

hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentifier()) or some kind of special C++ name (constructor, destructor, etc.), or a structured binding (which is not exactly a name, but occupies the same position).

Definition at line 2362 of file DeclSpec.h.

References clang::IK_Identifier, and isDecompositionDeclarator().

Referenced by setDecompositionBindings().

◆ hasPackIndexing()

bool clang::Declarator::hasPackIndexing ( ) const
inline

Definition at line 2771 of file DeclSpec.h.

◆ hasTrailingRequiresClause()

bool clang::Declarator::hasTrailingRequiresClause ( ) const
inline

Determine whether a trailing requires clause was written in this declarator.

Definition at line 2681 of file DeclSpec.h.

◆ hasTrailingReturnType()

bool clang::Declarator::hasTrailingReturnType ( ) const
inline

Determine whether a trailing return type was written (at any level) within this declarator.

Definition at line 2650 of file DeclSpec.h.

References clang::DeclaratorChunk::Function, and type_objects().

Referenced by GetDeclSpecTypeForDeclarator().

◆ isArrayOfUnknownBound()

bool clang::Declarator::isArrayOfUnknownBound ( ) const
inline

isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of unknown bound (looking through parentheses).

Definition at line 2488 of file DeclSpec.h.

References clang::DeclaratorChunk::Arr, clang::DeclaratorChunk::Array, DeclaratorChunk, getInnermostNonParenChunk(), clang::DeclaratorChunk::Kind, and clang::DeclaratorChunk::ArrayTypeInfo::NumElts.

◆ isCtorOrDtor()

bool Declarator::isCtorOrDtor ( )

◆ isDeclarationOfFunction()

bool Declarator::isDeclarationOfFunction ( ) const

Determine whether the declaration that will be produced from this declaration will be a function.

A declaration can declare a function even if the declarator itself isn't a function declarator, if the type specifier refers to a function type. This routine checks for both cases.

Definition at line 296 of file DeclSpec.cpp.

References clang::DeclaratorChunk::Array, clang::DeclaratorChunk::BlockPointer, clang::DeclaratorChunk::Function, clang::Type::isFunctionType(), clang::QualType::isNull(), clang::DeclaratorChunk::MemberPointer, clang::DeclaratorChunk::Paren, clang::DeclaratorChunk::Pipe, clang::DeclaratorChunk::Pointer, clang::DeclaratorChunk::Reference, clang::TST_Accum, clang::TST_atomic, clang::TST_auto, clang::TST_auto_type, clang::TST_BFloat16, clang::TST_bitint, clang::TST_bool, clang::TST_char, clang::TST_char16, clang::TST_char32, clang::TST_char8, clang::TST_class, clang::TST_decimal128, clang::TST_decimal32, clang::TST_decimal64, clang::TST_decltype, clang::TST_decltype_auto, clang::TST_double, clang::TST_enum, clang::TST_error, clang::TST_float, clang::TST_float128, clang::TST_Float16, clang::TST_Fract, clang::TST_half, clang::TST_ibm128, clang::TST_int, clang::TST_int128, clang::TST_interface, clang::TST_struct, clang::TST_typename, clang::TST_typename_pack_indexing, clang::TST_typeof_unqualExpr, clang::TST_typeof_unqualType, clang::TST_typeofExpr, clang::TST_typeofType, clang::TST_union, clang::TST_unknown_anytype, clang::TST_unspecified, clang::TST_void, and clang::TST_wchar.

Referenced by clang::Sema::ActOnCXXMemberDeclarator(), and isStaticMember().

◆ isDecompositionDeclarator()

bool clang::Declarator::isDecompositionDeclarator ( ) const
inline

Return whether this declarator is a decomposition declarator.

Definition at line 2368 of file DeclSpec.h.

Referenced by clang::Sema::ActOnDecompositionDeclarator(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::HandleDeclarator(), clang::Sema::HandleField(), and hasName().

◆ isExplicitObjectMemberFunction()

◆ isExpressionContext()

◆ isFirstDeclarationOfMember()

bool clang::Declarator::isFirstDeclarationOfMember ( )
inline

Returns true if this declares a real member and not a friend.

Definition at line 2791 of file DeclSpec.h.

References getContext(), getDeclSpec(), clang::DeclSpec::isFriendSpecified(), and clang::Member.

Referenced by clang::Sema::ActOnFunctionDeclarator(), and getCCForDeclaratorChunk().

◆ isFirstDeclarator()

bool clang::Declarator::isFirstDeclarator ( ) const
inline

◆ isFunctionDeclarationContext()

◆ isFunctionDeclarator() [1/2]

bool clang::Declarator::isFunctionDeclarator ( ) const
inline

isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if the identifier is a function declarator (looking through parentheses).

Definition at line 2522 of file DeclSpec.h.

References isFunctionDeclarator().

Referenced by getFunctionTypeInfo(), isExplicitObjectMemberFunction(), and isFunctionDeclarator().

◆ isFunctionDeclarator() [2/2]

◆ isFunctionDeclaratorAFunctionDeclaration()

bool clang::Declarator::isFunctionDeclaratorAFunctionDeclaration ( ) const
inline

Return true if a function declarator at this position would be a function declaration.

Definition at line 2637 of file DeclSpec.h.

References getNumTypeObjects(), getTypeObject(), isFunctionDeclarationContext(), and clang::DeclaratorChunk::Paren.

◆ isFunctionDefinition()

◆ isInvalidType()

◆ isObjCIvar()

bool clang::Declarator::isObjCIvar ( ) const
inline

Definition at line 2750 of file DeclSpec.h.

◆ isObjCWeakProperty()

bool clang::Declarator::isObjCWeakProperty ( ) const
inline

Definition at line 2753 of file DeclSpec.h.

◆ isPastIdentifier()

bool clang::Declarator::isPastIdentifier ( ) const
inline

isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.

(This may happen even if we haven't actually parsed a name, perhaps because this context doesn't require one.)

Definition at line 2356 of file DeclSpec.h.

◆ isPrototypeContext()

bool clang::Declarator::isPrototypeContext ( ) const
inline

◆ isRedeclaration()

◆ isStaticMember()

◆ mayBeFollowedByCXXDirectInit()

◆ mayHaveDecompositionDeclarator()

◆ mayHaveIdentifier()

◆ mayOmitIdentifier()

◆ setAsmLabel()

void clang::Declarator::setAsmLabel ( Expr * E)
inline

Definition at line 2743 of file DeclSpec.h.

◆ setCommaLoc()

void clang::Declarator::setCommaLoc ( SourceLocation CL)
inline

Definition at line 2765 of file DeclSpec.h.

◆ setDecompositionBindings()

void Declarator::setDecompositionBindings ( SourceLocation LSquareLoc,
MutableArrayRef< DecompositionDeclarator::Binding > Bindings,
SourceLocation RSquareLoc )

Set the decomposition bindings for this declarator.

Definition at line 265 of file DeclSpec.cpp.

References hasName(), InlineBindings, and SetIdentifier().

◆ setEllipsisLoc()

void clang::Declarator::setEllipsisLoc ( SourceLocation EL)
inline

Definition at line 2769 of file DeclSpec.h.

Referenced by GetFullTypeForDeclarator().

◆ setExtension()

void clang::Declarator::setExtension ( bool Val = true)
inline

Definition at line 2746 of file DeclSpec.h.

◆ setFunctionDefinitionKind()

◆ setGroupingParens()

void clang::Declarator::setGroupingParens ( bool flag)
inline

Definition at line 2760 of file DeclSpec.h.

◆ setHasInitializer()

void clang::Declarator::setHasInitializer ( bool Val = true)
inline

Definition at line 2787 of file DeclSpec.h.

◆ SetIdentifier()

◆ setInvalidType()

◆ setInventedTemplateParameterList()

void clang::Declarator::setInventedTemplateParameterList ( TemplateParameterList * Invented)
inline

Sets the template parameter list generated from the explicit template parameters along with any invented template parameters from placeholder-typed parameters.

Definition at line 2698 of file DeclSpec.h.

Referenced by clang::Sema::ActOnFinishFunctionDeclarationDeclarator().

◆ setObjCIvar()

void clang::Declarator::setObjCIvar ( bool Val = true)
inline

Definition at line 2749 of file DeclSpec.h.

◆ setObjCWeakProperty()

void clang::Declarator::setObjCWeakProperty ( bool Val = true)
inline

Definition at line 2752 of file DeclSpec.h.

Referenced by clang::SemaObjC::ActOnProperty().

◆ setPackIndexingExpr()

void clang::Declarator::setPackIndexingExpr ( Expr * PI)
inline

Definition at line 2773 of file DeclSpec.h.

◆ SetRangeBegin()

void clang::Declarator::SetRangeBegin ( SourceLocation Loc)
inline

SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.

Definition at line 2131 of file DeclSpec.h.

References clang::SourceLocation::isInvalid().

◆ SetRangeEnd()

void clang::Declarator::SetRangeEnd ( SourceLocation Loc)
inline

SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.

Definition at line 2136 of file DeclSpec.h.

References clang::SourceLocation::isInvalid().

Referenced by AddTypeInfo(), AddTypeInfo(), AddTypeInfo(), setTrailingRequiresClause(), and takeAttributesAppending().

◆ setRedeclaration()

void clang::Declarator::setRedeclaration ( bool Val)
inline

◆ SetSourceRange()

void clang::Declarator::SetSourceRange ( SourceRange R)
inline

Definition at line 2128 of file DeclSpec.h.

◆ setTemplateParameterLists()

void clang::Declarator::setTemplateParameterLists ( ArrayRef< TemplateParameterList * > TPLs)
inline

Sets the template parameter lists that preceded the declarator.

Definition at line 2686 of file DeclSpec.h.

◆ setTrailingRequiresClause()

void clang::Declarator::setTrailingRequiresClause ( Expr * TRC)
inline

Sets a trailing requires clause for this declarator.

Definition at line 2668 of file DeclSpec.h.

References clang::Stmt::getEndLoc(), and SetRangeEnd().

◆ takeAttributesAppending()

void clang::Declarator::takeAttributesAppending ( ParsedAttributes & attrs)
inline

takeAttributesAppending - Takes attributes from the given ParsedAttributes set and add them to this declarator.

These examples both add 3 attributes to "var": short int var attribute((aligned(16),common,deprecated)); short int x, attribute((aligned(16)) var attribute((common,deprecated));

Also extends the range of the declarator.

Definition at line 2718 of file DeclSpec.h.

References clang::SourceRange::getEnd(), clang::SourceLocation::isValid(), clang::ParsedAttributesView::Range, and SetRangeEnd().

Referenced by clang::Sema::ActOnCXXForRangeIdentifier().

◆ type_objects()

type_object_range clang::Declarator::type_objects ( ) const
inline

◆ DeclaratorChunk

Member Data Documentation

◆ InlineBindings

DecompositionDeclarator::Binding clang::Declarator::InlineBindings[16]

Definition at line 2030 of file DeclSpec.h.

Referenced by setDecompositionBindings().

◆ InlineParams

DeclaratorChunk::ParamInfo clang::Declarator::InlineParams[16]

InlineParams - This is a local array used for the first function decl chunk to avoid going to the heap for the common case when we have one function chunk in the declarator.

Definition at line 2029 of file DeclSpec.h.

Referenced by clang::DeclaratorChunk::getFunction().


The documentation for this class was generated from the following files: