clang  3.9.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
clang::TypeLoc Class Reference

Base wrapper for a particular "section" of type source info. More...

#include <TypeLoc.h>

Inheritance diagram for clang::TypeLoc:
[legend]
Collaboration diagram for clang::TypeLoc:
[legend]

Public Types

enum  TypeLocClass { Qualified }
 The kinds of TypeLocs. More...
 

Public Member Functions

template<typename T >
castAs () const
 Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type. More...
 
template<typename T >
getAs () const
 Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired type. More...
 
 TypeLoc ()
 
 TypeLoc (QualType ty, void *opaqueData)
 
 TypeLoc (const Type *ty, void *opaqueData)
 
TypeLocClass getTypeLocClass () const
 
bool isNull () const
 
 operator bool () const
 
QualType getType () const
 Get the type for which this source info wrapper provides information. More...
 
const TypegetTypePtr () const
 
void * getOpaqueData () const
 Get the pointer where source information is stored. More...
 
SourceLocation getBeginLoc () const
 Get the begin source location. More...
 
SourceLocation getEndLoc () const
 Get the end source location. More...
 
SourceRange getSourceRange () const LLVM_READONLY
 Get the full source range. More...
 
SourceLocation getLocStart () const LLVM_READONLY
 
SourceLocation getLocEnd () const LLVM_READONLY
 
SourceRange getLocalSourceRange () const
 Get the local source range. More...
 
unsigned getFullDataSize () const
 Returns the size of the type source info data block. More...
 
TypeLoc getNextTypeLoc () const
 Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next TypeLoc is for "int". More...
 
UnqualTypeLoc getUnqualifiedLoc () const
 Skips past any qualifiers, if this is qualified. More...
 
TypeLoc IgnoreParens () const
 
TypeLoc findExplicitQualifierLoc () const
 Find a type with the location of an explicit type qualifier. More...
 
void initialize (ASTContext &Context, SourceLocation Loc) const
 Initializes this to state that every location in this type is the given location. More...
 
void initializeFullCopy (TypeLoc Other)
 Initializes this by copying its information from another TypeLoc of the same type. More...
 
void initializeFullCopy (TypeLoc Other, unsigned Size)
 Initializes this by copying its information from another TypeLoc of the same type. More...
 
void copy (TypeLoc other)
 Copies the other type loc into this one. More...
 
SourceLocation findNullabilityLoc () const
 Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier), if there is one. More...
 

Static Public Member Functions

static unsigned getFullDataSizeForType (QualType Ty)
 Returns the size of type source info data block for the given type. More...
 
static unsigned getLocalAlignmentForType (QualType Ty)
 Returns the alignment of type source info data block for the given type. More...
 

Protected Attributes

const void * Ty
 
void * Data
 

Friends

bool operator== (const TypeLoc &LHS, const TypeLoc &RHS)
 
bool operator!= (const TypeLoc &LHS, const TypeLoc &RHS)
 

Detailed Description

Base wrapper for a particular "section" of type source info.

A client should use the TypeLoc subclasses through castAs()/getAs() in order to get at the actual information.

Definition at line 40 of file TypeLoc.h.

Member Enumeration Documentation

The kinds of TypeLocs.

Equivalent to the Type::TypeClass enum, except it also defines a Qualified enum that corresponds to the QualifiedLoc class.

Enumerator
Qualified 

Definition at line 76 of file TypeLoc.h.

Constructor & Destructor Documentation

clang::TypeLoc::TypeLoc ( )
inline

Definition at line 84 of file TypeLoc.h.

Referenced by findExplicitQualifierLoc(), getEndLoc(), and getLocalAlignmentForType().

clang::TypeLoc::TypeLoc ( QualType  ty,
void *  opaqueData 
)
inline

Definition at line 85 of file TypeLoc.h.

clang::TypeLoc::TypeLoc ( const Type ty,
void *  opaqueData 
)
inline

Definition at line 87 of file TypeLoc.h.

Member Function Documentation

template<typename T >
T clang::TypeLoc::castAs ( ) const
inline
void TypeLoc::copy ( TypeLoc  other)

Copies the other type loc into this one.

Definition at line 146 of file TypeLoc.cpp.

References Data, getFullDataSize(), getNextTypeLoc(), getType(), and TypeLocMaxDataAlign.

Referenced by initializeFullCopy().

TypeLoc TypeLoc::findExplicitQualifierLoc ( ) const

Find a type with the location of an explicit type qualifier.

The result, if non-null, will be one of: QualifiedTypeLoc AtomicTypeLoc AttributedTypeLoc, for those type attributes that behave as qualifiers

Definition at line 371 of file TypeLoc.cpp.

References getAs(), IgnoreParens(), and TypeLoc().

Referenced by clang::Sema::actOnObjCTypeParam(), and applyObjCTypeArgs().

SourceLocation TypeLoc::findNullabilityLoc ( ) const

Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier), if there is one.

Definition at line 360 of file TypeLoc.cpp.

References clang::AttributedType::attr_nonnull, clang::AttributedType::attr_null_unspecified, and clang::AttributedType::attr_nullable.

template<typename T >
T clang::TypeLoc::getAs ( ) const
inline
SourceLocation TypeLoc::getBeginLoc ( ) const

Get the begin source location.

Definition at line 170 of file TypeLoc.cpp.

References castAs(), clang::SourceRange::getBegin(), getLocalSourceRange(), getNextTypeLoc(), getTypeLocClass(), clang::InheritingConcreteTypeLoc< Base, Derived, TypeClass >::getTypePtr(), clang::FunctionProtoType::hasTrailingReturn(), isNull(), clang::SourceLocation::isValid(), and Qualified.

Referenced by clang::Sema::ActOnAliasDeclaration(), clang::Sema::ActOnMethodDeclaration(), clang::Sema::ActOnObjCForCollectionStmt(), clang::Sema::actOnObjCTypeParam(), clang::Sema::ActOnTag(), clang::Sema::AtomicPropertySetterGetterRules(), clang::Sema::BuildCXXNew(), clang::Sema::BuildCXXTypeConstructExpr(), clang::Sema::BuildVAArgExpr(), clang::Sema::CheckBaseSpecifier(), CheckConstexprDeclStmt(), clang::Sema::CheckEnumUnderlyingType(), clang::Sema::deduceVarTypeFromInitializer(), clang::CXXScopeSpec::Extend(), clang::TemplateTypeParmDecl::getDefaultArgumentLoc(), clang::DependentNameTypeLoc::getLocalSourceRange(), clang::DependentTemplateSpecializationTypeLoc::getLocalSourceRange(), getLocStart(), clang::CXXUnresolvedConstructExpr::getLocStart(), getSourceRange(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::ASTReader::ReadNestedNameSpecifierLoc(), clang::TreeTransform< Derived >::RebuildCXXPseudoDestructorExpr(), ReplaceWithClasstype(), ReplaceWithInstancetype(), clang::TreeTransform< Derived >::TransformFunctionProtoType(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), and clang::TreeTransform< Derived >::TransformType().

SourceLocation TypeLoc::getEndLoc ( ) const
unsigned clang::TypeLoc::getFullDataSize ( ) const
inline
unsigned TypeLoc::getFullDataSizeForType ( QualType  Ty)
static

Returns the size of type source info data block for the given type.

Returns the size of the type source info data block.

Definition at line 76 of file TypeLoc.cpp.

References getLocalAlignmentForType(), getNextTypeLoc(), getType(), isNull(), and max().

Referenced by clang::ASTContext::adjustExceptionSpec(), clang::ASTContext::CreateTypeSourceInfo(), and getFullDataSize().

unsigned TypeLoc::getLocalAlignmentForType ( QualType  Ty)
static

Returns the alignment of type source info data block for the given type.

Returns the alignment of the type source info data block.

Definition at line 58 of file TypeLoc.cpp.

References clang::QualType::isNull(), and TypeLoc().

Referenced by getFullDataSizeForType(), and clang::QualifiedTypeLoc::getUnqualifiedLoc().

SourceRange clang::TypeLoc::getLocalSourceRange ( ) const
inline
SourceLocation clang::TypeLoc::getLocEnd ( ) const
inline
SourceLocation clang::TypeLoc::getLocStart ( ) const
inline
TypeLoc clang::TypeLoc::getNextTypeLoc ( ) const
inline

Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next TypeLoc is for "int".

Definition at line 145 of file TypeLoc.h.

Referenced by clang::ASTRecordWriter::AddTypeLoc(), copy(), getBeginLoc(), getEndLoc(), getFullDataSizeForType(), clang::Sema::GetTypeSourceInfoForDeclarator(), and clang::TypeLocBuilder::pushFullCopy().

void* clang::TypeLoc::getOpaqueData ( ) const
inline
SourceRange clang::TypeLoc::getSourceRange ( ) const
inline
QualType clang::TypeLoc::getType ( ) const
inline
TypeLocClass clang::TypeLoc::getTypeLocClass ( ) const
inline
const Type* clang::TypeLoc::getTypePtr ( ) const
inline
UnqualTypeLoc clang::TypeLoc::getUnqualifiedLoc ( ) const
inline
TypeLoc clang::TypeLoc::IgnoreParens ( ) const
inline
void clang::TypeLoc::initialize ( ASTContext Context,
SourceLocation  Loc 
) const
inline

Initializes this to state that every location in this type is the given location.

This method exists to provide a simple transition for code that relies on location-less types.

Definition at line 167 of file TypeLoc.h.

Referenced by clang::ASTContext::getTrivialTypeSourceInfo().

void clang::TypeLoc::initializeFullCopy ( TypeLoc  Other)
inline

Initializes this by copying its information from another TypeLoc of the same type.

Definition at line 173 of file TypeLoc.h.

References copy(), and getType().

Referenced by clang::Sema::ActOnBlockArguments(), and FixInvalidVariablyModifiedTypeLoc().

void clang::TypeLoc::initializeFullCopy ( TypeLoc  Other,
unsigned  Size 
)
inline

Initializes this by copying its information from another TypeLoc of the same type.

The given size must be the full data size.

Definition at line 181 of file TypeLoc.h.

References copy(), getFullDataSize(), and getType().

bool clang::TypeLoc::isNull ( ) const
inline
clang::TypeLoc::operator bool ( ) const
inlineexplicit

Definition at line 96 of file TypeLoc.h.

References Ty.

Friends And Related Function Documentation

bool operator!= ( const TypeLoc LHS,
const TypeLoc RHS 
)
friend

Definition at line 194 of file TypeLoc.h.

bool operator== ( const TypeLoc LHS,
const TypeLoc RHS 
)
friend

Definition at line 190 of file TypeLoc.h.

Member Data Documentation

void* clang::TypeLoc::Data
protected
const void* clang::TypeLoc::Ty
protected

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