clang API Documentation

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

#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,
  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
 getSourceRange - 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 ()
 clear - Reset the contents of this Declarator.
bool mayOmitIdentifier () const
bool mayHaveIdentifier () 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)
 AddInnermostTypeInfo - Add a new innermost chunk to this declarator.
unsigned getNumTypeObjects () const
const DeclaratorChunkgetTypeObject (unsigned i) const
DeclaratorChunkgetTypeObject (unsigned i)
void DropFirstTypeObject ()
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.
void takeAttributes (ParsedAttributes &attrs, SourceLocation lastLoc)
const AttributeListgetAttributes () const
AttributeListgetAttributes ()
AttributeList *& getAttrListRef ()
bool hasAttributes () const
 hasAttributes - do we contain any attributes?
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
void setRedeclaration (bool Val)
bool isRedeclaration () const

Friends

struct DeclaratorChunk

Detailed Description

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


Member Enumeration Documentation

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

Definition at line 1417 of file DeclSpec.h.


Constructor & Destructor Documentation

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

Definition at line 1497 of file DeclSpec.h.

clang::Declarator::~Declarator ( ) [inline]

Definition at line 1506 of file DeclSpec.h.

References clear().


Member Function Documentation

void clang::Declarator::AddInnermostTypeInfo ( const DeclaratorChunk TI) [inline]

AddInnermostTypeInfo - Add a new innermost chunk to this declarator.

Definition at line 1736 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 1724 of file DeclSpec.h.

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

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

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

clear - Reset the contents of this Declarator.

Reimplemented in clang::ParsingDeclarator.

Definition at line 1570 of file DeclSpec.h.

References clang::CXXScopeSpec::clear(), clang::ParsedAttributes::clear(), clang::UnqualifiedId::clear(), and clang::DeclSpec::getSourceRange().

Referenced by ~Declarator().

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

Definition at line 1755 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 1561 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]
AttributePool& clang::Declarator::getAttributePool ( ) const [inline]
const AttributeList* clang::Declarator::getAttributes ( ) const [inline]
AttributeList* clang::Declarator::getAttributes ( ) [inline]

Definition at line 1856 of file DeclSpec.h.

References clang::ParsedAttributes::getList().

AttributeList*& clang::Declarator::getAttrListRef ( ) [inline]
SourceLocation clang::Declarator::getCommaLoc ( ) const [inline]

Definition at line 1884 of file DeclSpec.h.

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

TheContext clang::Declarator::getContext ( ) const [inline]
const CXXScopeSpec& clang::Declarator::getCXXScopeSpec ( ) const [inline]
CXXScopeSpec& clang::Declarator::getCXXScopeSpec ( ) [inline]

Definition at line 1528 of file DeclSpec.h.

const DeclSpec& clang::Declarator::getDeclSpec ( ) const [inline]
SourceLocation clang::Declarator::getEllipsisLoc ( ) const [inline]
bool clang::Declarator::getExtension ( ) const [inline]

Definition at line 1873 of file DeclSpec.h.

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

Definition at line 1899 of file DeclSpec.h.

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

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

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

Definition at line 1827 of file DeclSpec.h.

References getFunctionTypeInfo().

IdentifierInfo* clang::Declarator::getIdentifier ( ) const [inline]
SourceLocation clang::Declarator::getIdentifierLoc ( ) const [inline]
SourceLocation clang::Declarator::getLocEnd ( ) const [inline]

Definition at line 1544 of file DeclSpec.h.

References clang::SourceRange::getEnd().

SourceLocation clang::Declarator::getLocStart ( ) const [inline]
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 1519 of file DeclSpec.h.

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

UnqualifiedId& clang::Declarator::getName ( ) [inline]
unsigned clang::Declarator::getNumTypeObjects ( ) const [inline]
const SourceRange& clang::Declarator::getSourceRange ( ) const [inline]
const DeclaratorChunk& clang::Declarator::getTypeObject ( unsigned  i) const [inline]
DeclaratorChunk& clang::Declarator::getTypeObject ( unsigned  i) [inline]

Definition at line 1750 of file DeclSpec.h.

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

hasAttributes - do we contain any attributes?

Definition at line 1861 of file DeclSpec.h.

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

bool clang::Declarator::hasEllipsis ( ) const [inline]
bool clang::Declarator::hasGroupingParens ( ) const [inline]

Definition at line 1881 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 1705 of file DeclSpec.h.

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

Referenced by clang::Sema::ActOnParamDeclarator(), and diagnoseMisplacedEllipsis().

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

References clang::DeclaratorChunk::Array, clang::DeclaratorChunk::BlockPointer, clang::DeclaratorChunk::Function, clang::DeclaratorChunk::MemberPointer, clang::DeclaratorChunk::Paren, clang::DeclaratorChunk::Pointer, and clang::DeclaratorChunk::Reference.

bool Declarator::isDeclarationOfFunction ( ) const
bool clang::Declarator::isFirstDeclarator ( ) const [inline]

Definition at line 1883 of file DeclSpec.h.

References clang::SourceLocation::isValid().

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

bool clang::Declarator::isFunctionDeclarator ( unsigned &  idx) const [inline]
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 1811 of file DeclSpec.h.

Referenced by getFunctionTypeInfo().

bool clang::Declarator::isFunctionDefinition ( ) const [inline]
bool clang::Declarator::isInvalidType ( ) const [inline]
bool clang::Declarator::isPastIdentifier ( ) const [inline]

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

Definition at line 1700 of file DeclSpec.h.

References clang::UnqualifiedId::isValid().

bool clang::Declarator::isPrototypeContext ( ) const [inline]
bool clang::Declarator::isRedeclaration ( ) const [inline]
bool clang::Declarator::mayBeFollowedByCXXDirectInit ( ) const [inline]
bool clang::Declarator::mayHaveIdentifier ( ) const [inline]
bool clang::Declarator::mayOmitIdentifier ( ) const [inline]
void clang::Declarator::setAsmLabel ( Expr E) [inline]

Definition at line 1869 of file DeclSpec.h.

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

Definition at line 1885 of file DeclSpec.h.

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

Definition at line 1889 of file DeclSpec.h.

Referenced by diagnoseMisplacedEllipsis(), and GetFullTypeForDeclarator().

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

Definition at line 1872 of file DeclSpec.h.

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

Definition at line 1880 of file DeclSpec.h.

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

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

Definition at line 1549 of file DeclSpec.h.

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

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

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

Definition at line 1554 of file DeclSpec.h.

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

Referenced by AddTypeInfo(), and takeAttributes().

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

Definition at line 1546 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 1848 of file DeclSpec.h.

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


Friends And Related Function Documentation

friend struct DeclaratorChunk [friend]

Definition at line 1494 of file DeclSpec.h.


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