clang  6.0.0svn
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 "clang/AST/TypeLoc.h"

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

Public Types

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

Public Member Functions

 TypeLoc ()=default
 
 TypeLoc (QualType ty, void *opaqueData)
 
 TypeLoc (const Type *ty, void *opaqueData)
 
template<typename T >
T castAs () const
 Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type. More...
 
template<typename T >
T getAs () const
 Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired type. More...
 
template<typename T >
T getAsAdjusted () const
 Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desired type. More...
 
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 = nullptr
 
void * Data = nullptr
 

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 56 of file TypeLoc.h.

Member Enumeration Documentation

◆ TypeLocClass

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 105 of file TypeLoc.h.

Constructor & Destructor Documentation

◆ TypeLoc() [1/3]

clang::TypeLoc::TypeLoc ( )
default

◆ TypeLoc() [2/3]

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

Definition at line 65 of file TypeLoc.h.

◆ TypeLoc() [3/3]

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

Definition at line 67 of file TypeLoc.h.

Member Function Documentation

◆ castAs()

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

◆ copy()

void TypeLoc::copy ( TypeLoc  other)

Copies the other type loc into this one.

Definition at line 166 of file TypeLoc.cpp.

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

Referenced by initializeFullCopy().

◆ findExplicitQualifierLoc()

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 391 of file TypeLoc.cpp.

References getAs().

Referenced by getNextTypeLoc().

◆ findNullabilityLoc()

SourceLocation TypeLoc::findNullabilityLoc ( ) const

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

Definition at line 380 of file TypeLoc.cpp.

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

◆ getAs()

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

◆ getAsAdjusted()

template<typename T >
T clang::TypeLoc::getAsAdjusted ( ) const
inline

Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desired type.

It will consider type adjustments from a type that wad written as a T to another type that is still canonically a T (ignores parens, attributes, elaborated types, etc).

Definition at line 2344 of file TypeLoc.h.

References getAs(), and clang::T.

Referenced by getAs().

◆ getBeginLoc()

SourceLocation TypeLoc::getBeginLoc ( ) const

◆ getEndLoc()

SourceLocation TypeLoc::getEndLoc ( ) const

◆ getFullDataSize()

unsigned clang::TypeLoc::getFullDataSize ( ) const
inline

◆ getFullDataSizeForType()

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 92 of file TypeLoc.cpp.

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

Referenced by clang::ASTContext::adjustExceptionSpec(), clang::ASTContext::CreateTypeSourceInfo(), getFullDataSize(), operator bool(), and clang::TypeLocBuilder::pushFullCopy().

◆ getLocalAlignmentForType()

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 72 of file TypeLoc.cpp.

References clang::QualType::isNull().

Referenced by clang::ConcreteTypeLoc< UnqualTypeLoc, ReferenceTypeLoc, ReferenceType, PointerLikeLocInfo >::getInnerTypeLoc(), clang::QualifiedTypeLoc::getUnqualifiedLoc(), and operator bool().

◆ getLocalSourceRange()

SourceRange clang::TypeLoc::getLocalSourceRange ( ) const
inline

◆ getLocEnd()

SourceLocation clang::TypeLoc::getLocEnd ( ) const
inline

Definition at line 155 of file TypeLoc.h.

References getEndLoc().

Referenced by clang::Sema::CheckConversionDeclarator(), and clang::Sema::SubstExceptionSpec().

◆ getLocStart()

SourceLocation clang::TypeLoc::getLocStart ( ) const
inline

Definition at line 154 of file TypeLoc.h.

References getBeginLoc().

Referenced by clang::CXXBaseSpecifier::getBaseTypeLoc(), and clang::ASTImporter::Import().

◆ getNextTypeLoc()

TypeLoc clang::TypeLoc::getNextTypeLoc ( ) const
inline

◆ getOpaqueData()

void* clang::TypeLoc::getOpaqueData ( ) const
inline

Get the pointer where source information is stored.

Definition at line 139 of file TypeLoc.h.

References Data, getBeginLoc(), and getEndLoc().

Referenced by clang::NestedNameSpecifierLocBuilder::Extend().

◆ getSourceRange()

SourceRange clang::TypeLoc::getSourceRange ( ) const
inline

◆ getType()

QualType clang::TypeLoc::getType ( ) const
inline

◆ getTypeLocClass()

TypeLocClass clang::TypeLoc::getTypeLocClass ( ) const
inline

◆ getTypePtr()

const Type* clang::TypeLoc::getTypePtr ( ) const
inline

Definition at line 134 of file TypeLoc.h.

References clang::QualType::getFromOpaquePtr(), and clang::QualType::getTypePtr().

Referenced by clang::DEF_TRAVERSE_TYPE(), clang::NestedNameSpecifierLocBuilder::Extend(), clang::TemplateSpecializationTypeLoc::getArgLoc(), clang::DependentTemplateSpecializationTypeLoc::getArgLoc(), clang::AttributedTypeLoc::getAttrKind(), clang::MemberPointerTypeLoc::getClass(), clang::InjectedClassNameTypeLoc::getDecl(), clang::UnresolvedUsingTypeLoc::getDecl(), clang::TagTypeLoc::getDecl(), clang::RecordTypeLoc::getDecl(), clang::EnumTypeLoc::getDecl(), clang::TemplateTypeParmTypeLoc::getDecl(), clang::ObjCTypeParamTypeLoc::getDecl(), clang::ObjCInterfaceTypeLoc::getIFaceDecl(), clang::AttributedTypeLoc::getInnerType(), clang::ObjCObjectTypeLoc::getInnerType(), clang::ParenTypeLoc::getInnerType(), clang::AdjustedTypeLoc::getInnerType(), clang::PointerLikeTypeLoc< ObjCObjectPointerTypeLoc, ObjCObjectPointerType >::getInnerType(), clang::ReferenceTypeLoc::getInnerType(), clang::FunctionTypeLoc::getInnerType(), clang::ArrayTypeLoc::getInnerType(), clang::DependentAddressSpaceTypeLoc::getInnerType(), clang::ElaboratedTypeLoc::getInnerType(), clang::PackExpansionTypeLoc::getInnerType(), clang::AtomicTypeLoc::getInnerType(), clang::PipeTypeLoc::getInnerType(), clang::TemplateSpecializationTypeLoc::getNumArgs(), clang::DependentTemplateSpecializationTypeLoc::getNumArgs(), clang::FunctionTypeLoc::getNumParams(), clang::ObjCTypeParamTypeLoc::getNumProtocols(), clang::ObjCObjectTypeLoc::getNumProtocols(), clang::ObjCObjectTypeLoc::getNumTypeArgs(), clang::ObjCTypeParamTypeLoc::getProtocol(), clang::ObjCObjectTypeLoc::getProtocol(), clang::ElaboratedTypeLoc::getQualifierLoc(), clang::DependentNameTypeLoc::getQualifierLoc(), clang::DependentTemplateSpecializationTypeLoc::getQualifierLoc(), clang::TypedefTypeLoc::getTypedefNameDecl(), clang::UnqualTypeLoc::getTypeLocClass(), clang::TypeOfExprTypeLoc::getUnderlyingExpr(), clang::DecltypeTypeLoc::getUnderlyingExpr(), clang::TypeOfTypeLoc::getUnderlyingType(), clang::QualifiedTypeLoc::getUnqualifiedLoc(), clang::AttributedTypeLoc::isQualifier(), clang::BuiltinTypeLoc::needsExtraLocalData(), clang::ElaboratedTypeLoc::setQualifierLoc(), clang::DependentNameTypeLoc::setQualifierLoc(), and clang::DependentTemplateSpecializationTypeLoc::setQualifierLoc().

◆ getUnqualifiedLoc()

UnqualTypeLoc clang::TypeLoc::getUnqualifiedLoc ( ) const
inline

◆ IgnoreParens()

TypeLoc clang::TypeLoc::IgnoreParens ( ) const
inline

◆ initialize()

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 191 of file TypeLoc.h.

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

◆ initializeFullCopy() [1/2]

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

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

Definition at line 197 of file TypeLoc.h.

References copy(), and getType().

Referenced by FixInvalidVariablyModifiedTypeLoc().

◆ initializeFullCopy() [2/2]

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 205 of file TypeLoc.h.

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

◆ isNull()

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

◆ operator bool()

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

Definition at line 119 of file TypeLoc.h.

References getFullDataSizeForType(), getLocalAlignmentForType(), and Ty.

Friends And Related Function Documentation

◆ operator!=

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

Definition at line 218 of file TypeLoc.h.

◆ operator==

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

Definition at line 214 of file TypeLoc.h.

Member Data Documentation

◆ Data

void* clang::TypeLoc::Data = nullptr
protected

◆ Ty

const void* clang::TypeLoc::Ty = nullptr
protected

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