clang API Documentation

Public Types | Public Member Functions | Friends
clang::Declarator Class Reference

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

#include <DeclSpec.h>

Inheritance diagram for clang::Declarator:
Inheritance graph
[legend]

List of all members.

Public Types

enum  TheContext {
  FileContext, PrototypeContext, ObjCResultContext, ObjCParameterContext,
  KNRTypeListContext, TypeNameContext, MemberContext, BlockContext,
  ForContext, ConditionContext, TemplateParamContext, CXXNewContext,
  CXXCatchContext, ObjCCatchContext, BlockLiteralContext, LambdaExprContext,
  LambdaExprParameterContext, ConversionIdContext, TrailingReturnContext, TemplateTypeArgContext,
  AliasDeclContext, AliasTemplateContext
}

Public Member Functions

 Declarator (const DeclSpec &ds, TheContext C)
 ~Declarator ()
const DeclSpecgetDeclSpec () const
DeclSpecgetMutableDeclSpec ()
AttributePoolgetAttributePool () const
const CXXScopeSpecgetCXXScopeSpec () const
CXXScopeSpecgetCXXScopeSpec ()
UnqualifiedIdgetName ()
 Retrieve the name specified by this declarator.
TheContext getContext () const
bool isPrototypeContext () const
const SourceRangegetSourceRange () const LLVM_READONLY
 Get the source range that spans this declarator.
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
void SetSourceRange (SourceRange R)
void SetRangeBegin (SourceLocation Loc)
void SetRangeEnd (SourceLocation Loc)
 SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
void ExtendWithDeclSpec (const DeclSpec &DS)
void clear ()
 Reset the contents of this Declarator.
bool mayOmitIdentifier () const
bool mayHaveIdentifier () const
bool diagnoseIdentifier () const
bool mayBeFollowedByCXXDirectInit () const
bool isPastIdentifier () const
bool hasName () const
IdentifierInfogetIdentifier () const
SourceLocation getIdentifierLoc () const
void SetIdentifier (IdentifierInfo *Id, SourceLocation IdLoc)
 Set the name of this declarator to be the given identifier.
void AddTypeInfo (const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
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
DeclaratorChunkgetTypeObject (unsigned i)
void DropFirstTypeObject ()
const DeclaratorChunkgetInnermostNonParenChunk () const
const DeclaratorChunkgetOutermostNonParenChunk () const
bool isArrayOfUnknownBound () const
bool isFunctionDeclarator (unsigned &idx) const
bool isFunctionDeclarator () const
DeclaratorChunk::FunctionTypeInfogetFunctionTypeInfo ()
const
DeclaratorChunk::FunctionTypeInfo
getFunctionTypeInfo () const
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 isFunctionDeclaratorAFunctionDeclaration () const
 Return true if a function declarator at this position would be a function declaration.
void takeAttributes (ParsedAttributes &attrs, SourceLocation lastLoc)
const AttributeListgetAttributes () const
AttributeListgetAttributes ()
AttributeList *& getAttrListRef ()
bool hasAttributes () const
 hasAttributes - do we contain any attributes?
void getCXX11AttributeRanges (SmallVectorImpl< SourceRange > &Ranges)
 Return a source range list of C++11 attributes associated with the declarator.
void setAsmLabel (Expr *E)
ExprgetAsmLabel () const
void setExtension (bool Val=true)
bool getExtension () 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)
void setFunctionDefinitionKind (FunctionDefinitionKind Val)
bool isFunctionDefinition () const
FunctionDefinitionKind getFunctionDefinitionKind () const
bool isFirstDeclarationOfMember ()
 Returns true if this declares a real member and not a friend.
bool isStaticMember ()
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 1540 of file DeclSpec.h.


Member Enumeration Documentation

Enumerator:
FileContext 
PrototypeContext 
ObjCResultContext 
ObjCParameterContext 
KNRTypeListContext 
TypeNameContext 
MemberContext 
BlockContext 
ForContext 
ConditionContext 
TemplateParamContext 
CXXNewContext 
CXXCatchContext 
ObjCCatchContext 
BlockLiteralContext 
LambdaExprContext 
LambdaExprParameterContext 
ConversionIdContext 
TrailingReturnContext 
TemplateTypeArgContext 
AliasDeclContext 
AliasTemplateContext 

Definition at line 1542 of file DeclSpec.h.


Constructor & Destructor Documentation

clang::Declarator::Declarator ( const DeclSpec ds,
TheContext  C 
) [inline]

Definition at line 1623 of file DeclSpec.h.

Definition at line 1632 of file DeclSpec.h.

References clear().


Member Function Documentation

Add a new innermost chunk to this declarator.

Definition at line 1901 of file DeclSpec.h.

Referenced by maybeSynthesizeBlockSignature().

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.

Definition at line 1889 of file DeclSpec.h.

References getAttributePool(), clang::ParsedAttributes::getList(), clang::ParsedAttributes::getPool(), clang::SourceLocation::isInvalid(), SetRangeEnd(), and clang::AttributePool::takeAllFrom().

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

void clang::Declarator::clear ( ) [inline]

Definition at line 1919 of file DeclSpec.h.

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

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 1687 of file DeclSpec.h.

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

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

Definition at line 2077 of file DeclSpec.h.

References clang::ParsedAttributes::getList().

Definition at line 2116 of file DeclSpec.h.

Referenced by warnAboutAmbiguousFunction().

void clang::Declarator::getCXX11AttributeRanges ( SmallVectorImpl< SourceRange > &  Ranges) [inline]

Return a source range list of C++11 attributes associated with the declarator.

Definition at line 2092 of file DeclSpec.h.

References clang::ParsedAttributes::getList(), clang::AttributeList::getNext(), clang::AttributeList::getRange(), and clang::AttributeList::isCXX11Attribute().

Definition at line 1653 of file DeclSpec.h.

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

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

Reimplemented in clang::ParsingDeclarator.

Definition at line 1637 of file DeclSpec.h.

Referenced by clang::Sema::ActOnCXXConditionDeclaration(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnCXXNew(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnIvar(), clang::Sema::ActOnObjCExceptionDecl(), clang::Sema::ActOnParamDeclarator(), clang::Sema::ActOnTypedefDeclarator(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::canDelayFunctionBody(), clang::Sema::CheckConstructorDeclarator(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckDestructorDeclarator(), clang::Sema::CheckFieldDecl(), clang::Sema::checkUnusedDeclAttributes(), clang::Sema::containsUnexpandedParameterPacks(), ConvertDeclSpecToType(), CreateNewFunctionDecl(), diagnoseRedundantReturnTypeQualifiers(), getCCForDeclaratorChunk(), GetDeclSpecTypeForDeclarator(), GetFullTypeForDeclarator(), getFunctionStorageClass(), clang::Sema::GetTypeSourceInfoForDeclarator(), clang::Sema::HandleDeclarator(), clang::Sema::HandleField(), clang::Sema::HandleMSProperty(), hasAttributes(), hasParsedAttr(), isFirstDeclarationOfMember(), isFunctionDeclarationContext(), isOmittedBlockReturnType(), isStaticMember(), mayBeFollowedByCXXDirectInit(), clang::Sema::ParseTypedefDecl(), clang::Sema::ProcessDeclAttributes(), takeDeclAttributes(), and warnAboutAmbiguousFunction().

Definition at line 2105 of file DeclSpec.h.

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

Definition at line 1999 of file DeclSpec.h.

References getFunctionTypeInfo().

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 1928 of file DeclSpec.h.

Referenced by isArrayOfUnknownBound().

Definition at line 1670 of file DeclSpec.h.

References clang::SourceRange::getEnd().

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

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 1644 of file DeclSpec.h.

Referenced by clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnObjCExceptionDecl(), clang::Sema::ActOnParamDeclarator(), distributeObjCPointerTypeAttrFromDeclarator(), and RebuildDeclaratorInCurrentInstantiation().

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 1939 of file DeclSpec.h.

Definition at line 1914 of file DeclSpec.h.

hasAttributes - do we contain any attributes?

Definition at line 2082 of file DeclSpec.h.

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

Definition at line 2113 of file DeclSpec.h.

Referenced by mayBeFollowedByCXXDirectInit().

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.).

Definition at line 1870 of file DeclSpec.h.

References clang::UnqualifiedId::getKind(), clang::UnqualifiedId::Identifier, and clang::UnqualifiedId::IK_Identifier.

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

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

Definition at line 1950 of file DeclSpec.h.

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

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

Definition at line 2136 of file DeclSpec.h.

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

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

Definition at line 2115 of file DeclSpec.h.

References clang::SourceLocation::isValid().

Referenced by warnAboutAmbiguousFunction().

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 1983 of file DeclSpec.h.

Referenced by getFunctionTypeInfo().

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

Definition at line 2049 of file DeclSpec.h.

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

isPastIdentifier - Return true if we have parsed beyond the point where the

Definition at line 1865 of file DeclSpec.h.

References clang::UnqualifiedId::isValid().

Returns true if this declares a static member. This cannot be called on a declarator outside of a MemberContext because we won't know until redeclaration time if the decl is static.

Definition at line 345 of file DeclSpec.cpp.

References getContext(), getDeclSpec(), getName(), clang::DeclSpec::getStorageClassSpec(), clang::CXXMethodDecl::isStaticOverloadedOperator(), MemberContext, and clang::DeclSpec::SCS_static.

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

void clang::Declarator::setAsmLabel ( Expr E) [inline]

Definition at line 2101 of file DeclSpec.h.

Definition at line 2117 of file DeclSpec.h.

Definition at line 2121 of file DeclSpec.h.

Referenced by GetFullTypeForDeclarator().

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

Definition at line 2104 of file DeclSpec.h.

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

Definition at line 2112 of file DeclSpec.h.

void clang::Declarator::SetIdentifier ( IdentifierInfo Id,
SourceLocation  IdLoc 
) [inline]
void clang::Declarator::setInvalidType ( bool  Val = true) [inline]

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

Definition at line 1675 of file DeclSpec.h.

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

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

Definition at line 1680 of file DeclSpec.h.

References clang::SourceLocation::isInvalid(), and clang::SourceRange::setEnd().

Referenced by AddTypeInfo(), and takeAttributes().

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

Definition at line 1672 of file DeclSpec.h.

void clang::Declarator::takeAttributes ( ParsedAttributes attrs,
SourceLocation  lastLoc 
) [inline]

takeAttributes - Takes attributes from the given parsed-attributes 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 2069 of file DeclSpec.h.

References clang::SourceLocation::isInvalid(), SetRangeEnd(), and clang::ParsedAttributes::takeAllFrom().

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


Friends And Related Function Documentation

friend struct DeclaratorChunk [friend]

Definition at line 1620 of file DeclSpec.h.


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