clang
10.0.0git
|
Base wrapper for a particular "section" of type source info. More...
#include "clang/AST/TypeLoc.h"
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 TypeLoc 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 Type * | getTypePtr () 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... | |
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... | |
AutoTypeLoc | getContainedAutoTypeLoc () const |
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this type. 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) |
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.
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 |
|
default |
|
inline |
|
inline |
|
inline |
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition at line 77 of file TypeLoc.h.
Referenced by clang::TemplateDeclInstantiator::adjustForRewrite(), FixInvalidVariablyModifiedTypeLoc(), getBeginLoc(), getEndLoc(), GetTypeSourceInfoForDeclarator(), NeedsInstantiationAsFunctionType(), clang::TypeLocBuilder::push(), clang::TypeLocBuilder::pushTypeSpec(), clang::TreeTransform< Derived >::RebuildQualifiedType(), clang::TemplateDeclInstantiator::SubstFunctionType(), clang::TreeTransform< Derived >::TransformFunctionTypeParam(), clang::TreeTransform< Derived >::TransformFunctionTypeParams(), clang::TreeTransform< Derived >::TransformOverloadExprDecls(), clang::TreeTransform< Derived >::TransformTypeWithDeducedTST(), and clang::TemplateDeclInstantiator::VisitCXXMethodDecl().
void TypeLoc::copy | ( | TypeLoc | other | ) |
Copies the other type loc into this one.
Definition at line 167 of file TypeLoc.cpp.
References Data, getFullDataSize(), getNextTypeLoc(), memcpy(), 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 430 of file TypeLoc.cpp.
References getAs().
Referenced by getNextTypeLoc().
SourceLocation TypeLoc::findNullabilityLoc | ( | ) | const |
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier), if there is one.
Definition at line 419 of file TypeLoc.cpp.
References clang::Attr::getLocation().
|
inline |
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired type.
Definition at line 88 of file TypeLoc.h.
References getAsAdjusted().
Referenced by clang::Sema::ActOnTemplateTypeArgument(), checkAllAtProps(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::checkThisInStaticMemberFunctionExceptionSpec(), clang::Sema::checkThisInStaticMemberFunctionType(), convertTypeTemplateArgumentToTemplate(), clang::Sema::DeduceAutoType(), findExplicitQualifierLoc(), findTypeLocationForBlockDecl(), FixInvalidVariablyModifiedTypeLoc(), getAsAdjusted(), getContainedAutoTypeLoc(), clang::comments::getFunctionTypeLoc(), clang::FunctionDecl::getFunctionTypeLoc(), GetTypeSourceInfoForDeclarator(), clang::BuiltinTypeLoc::getWrittenTypeSpec(), isEnableIf(), IsTailPaddedMemberArray(), clang::comments::lookThroughTypedefOrTypeAliasLocs(), NeedsInstantiationAsFunctionType(), clang::InitializationSequence::Perform(), clang::Sema::SubstFunctionDeclType(), clang::TemplateDeclInstantiator::SubstFunctionType(), clang::Sema::SubstParmVarDecl(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::TreeTransform< Derived >::TransformOverloadExprDecls(), and clang::TreeTransform< Derived >::TransformTypeWithDeducedTST().
|
inline |
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired type.
It will consider type adjustments from a type that was written as a T to another type that is still canonically a T (ignores parens, attributes, elaborated types, etc).
Definition at line 2435 of file TypeLoc.h.
References getAs().
Referenced by clang::TemplateDeclInstantiator::adjustForRewrite(), getAs(), clang::Sema::getReturnTypeLoc(), and implicitObjectParamIsLifetimeBound().
SourceLocation TypeLoc::getBeginLoc | ( | ) | const |
Get the begin source location.
Definition at line 191 of file TypeLoc.cpp.
References castAs(), clang::SourceRange::getBegin(), getLocalSourceRange(), getNextTypeLoc(), getTypeLocClass(), clang::InheritingConcreteTypeLoc< Base, Derived, TypeClass >::getTypePtr(), clang::FunctionProtoType::hasTrailingReturn(), isNull(), and clang::SourceLocation::isValid().
Referenced by clang::Sema::AtomicPropertySetterGetterRules(), clang::Sema::AttachTypeConstraint(), clang::Sema::BuildBuiltinBitCastExpr(), clang::Sema::BuildCXXTypeConstructExpr(), clang::Sema::CheckBaseSpecifier(), CheckConstexprDeclStmt(), clang::Sema::CheckEnumUnderlyingType(), clang::CXXBindTemporaryExpr::Create(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), clang::CXXBaseSpecifier::getBaseTypeLoc(), clang::CXXUnresolvedConstructExpr::getBeginLoc(), clang::DependentNameTypeLoc::getLocalSourceRange(), clang::DependentTemplateSpecializationTypeLoc::getLocalSourceRange(), getOpaqueData(), getSourceRange(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::ASTImporter::Import(), clang::TreeTransform< Derived >::RebuildQualifiedType(), ReplaceWithClasstype(), ReplaceWithInstancetype(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), clang::TreeTransform< Derived >::TransformFunctionProtoType(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::TreeTransform< Derived >::TransformType(), clang::TreeTransform< Derived >::TransformTypeWithDeducedTST(), clang::tooling::RecursiveSymbolVisitor< T >::VisitTypedefTypeLoc(), and clang::tooling::RecursiveSymbolVisitor< T >::VisitTypeLoc().
AutoTypeLoc TypeLoc::getContainedAutoTypeLoc | ( | ) | const |
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this type.
This looks through declarators like pointer types, but not through decltype or typedefs.
Definition at line 681 of file TypeLoc.cpp.
References getAs(), and isNull().
Referenced by getNextTypeLoc(), InventTemplateParameter(), and clang::TemplateDeclInstantiator::VisitCXXMethodDecl().
SourceLocation TypeLoc::getEndLoc | ( | ) | const |
Get the end source location.
Definition at line 228 of file TypeLoc.cpp.
References castAs(), clang::SourceRange::getEnd(), getLocalSourceRange(), getNextTypeLoc(), getTypeLocClass(), clang::InheritingConcreteTypeLoc< Base, Derived, TypeClass >::getTypePtr(), clang::FunctionProtoType::hasTrailingReturn(), clang::Last, Paren, and Pointer.
Referenced by clang::Sema::BuildBuiltinBitCastExpr(), clang::Sema::CheckConversionDeclarator(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), clang::ElaboratedTypeLoc::getLocalSourceRange(), getOpaqueData(), getSourceRange(), clang::ClassTemplateSpecializationDecl::getSourceRange(), clang::DeclaratorDecl::getTypeSpecEndLoc(), ReplaceWithClasstype(), ReplaceWithInstancetype(), clang::Sema::SubstExceptionSpec(), and clang::TreeTransform< Derived >::TransformCXXNamedCastExpr().
|
inline |
Returns the size of the type source info data block.
Definition at line 163 of file TypeLoc.h.
References getFullDataSizeForType(), and getType().
Referenced by copy(), clang::TemplateSpecializationTypeLoc::copy(), clang::AutoTypeLoc::copy(), clang::ElaboratedTypeLoc::copy(), clang::DependentNameTypeLoc::copy(), clang::DependentTemplateSpecializationTypeLoc::copy(), clang::Sema::DeduceTemplateArguments(), GetTypeSourceInfoForDeclarator(), initializeFullCopy(), clang::TypeLocBuilder::pushFullCopy(), clang::Sema::SubstFunctionDeclType(), clang::Sema::SubstType(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), clang::TreeTransform< Derived >::TransformFunctionTypeParam(), clang::TreeTransform< Derived >::TransformOverloadExprDecls(), clang::TreeTransform< Derived >::TransformType(), and clang::TreeTransform< Derived >::TransformTypeWithDeducedTST().
|
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 93 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().
|
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 73 of file TypeLoc.cpp.
References clang::QualType::isNull().
Referenced by clang::ConcreteTypeLoc< UnqualTypeLoc, ReferenceTypeLoc, ReferenceType, PointerLikeLocInfo >::getInnerTypeLoc(), clang::QualifiedTypeLoc::getUnqualifiedLoc(), and operator bool().
|
inline |
Get the local source range.
Definition at line 158 of file TypeLoc.h.
Referenced by clang::Sema::BuildBaseInitializer(), clang::Sema::BuildDelegatingInitializer(), clang::Sema::BuildPseudoDestructorExpr(), clang::Sema::CheckFriendTypeDecl(), clang::AttributedTypeLoc::getAttrAs(), getBeginLoc(), getEndLoc(), clang::TypeOfExprTypeLoc::getUnderlyingExpr(), and clang::PseudoDestructorTypeStorage::PseudoDestructorTypeStorage().
|
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 169 of file TypeLoc.h.
References findExplicitQualifierLoc(), getContainedAutoTypeLoc(), getUnqualifiedLoc(), and IgnoreParens().
Referenced by clang::ASTRecordWriter::AddTypeLoc(), copy(), getBeginLoc(), getEndLoc(), getFullDataSizeForType(), clang::ConcreteTypeLoc< UnqualTypeLoc, ReferenceTypeLoc, ReferenceType, PointerLikeLocInfo >::getInnerTypeLoc(), clang::ConcreteTypeLoc< UnqualTypeLoc, ReferenceTypeLoc, ReferenceType, PointerLikeLocInfo >::getNextTypeLoc(), GetTypeSourceInfoForDeclarator(), clang::TypeLocBuilder::pushFullCopy(), and clang::ASTRecordReader::readTypeLoc().
|
inline |
Get the pointer where source information is stored.
Definition at line 141 of file TypeLoc.h.
References Data, getBeginLoc(), and getEndLoc().
Referenced by clang::NestedNameSpecifierLocBuilder::Extend(), and GetTypeSourceInfoForDeclarator().
|
inline |
Get the full source range.
Definition at line 152 of file TypeLoc.h.
References getBeginLoc(), and getEndLoc().
Referenced by AnalyzeBitFieldAssignment(), clang::Sema::AttachTypeConstraint(), clang::Sema::BuildClassMessage(), clang::Sema::BuildCStyleCastExpr(), clang::Sema::BuildCXXFunctionalCastExpr(), clang::Sema::BuildCXXNew(), clang::Sema::CheckBaseSpecifier(), CheckConstexprDeclStmt(), clang::Sema::CheckConversionDeclarator(), clang::Sema::CheckPackExpansion(), clang::Sema::CheckTemplateArgument(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), findTemplateParameter(), clang::Sema::getPrintable(), clang::FunctionDecl::getReturnTypeSourceRange(), getTypeRange(), clang::Sema::InstantiateMemInitializers(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), and clang::TreeTransform< Derived >::TransformFunctionTypeParam().
|
inline |
Get the type for which this source info wrapper provides information.
Definition at line 132 of file TypeLoc.h.
References clang::QualType::getFromOpaquePtr().
Referenced by clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::Sema::AttachTypeConstraint(), CheckConstexprDeclStmt(), clang::Sema::DeduceAutoType(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), clang::comments::DeclInfo::fill(), findTemplateParameter(), getFullDataSize(), getFullDataSizeForType(), getTypeLocClass(), initializeFullCopy(), clang::TypeLocBuilder::pushFullCopy(), clang::TreeTransform< Derived >::RebuildQualifiedType(), clang::Sema::SubstType(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), clang::TreeTransform< Derived >::TransformExceptionSpec(), clang::TreeTransform< Derived >::TransformFunctionProtoType(), clang::TreeTransform< Derived >::TransformNestedNameSpecifierLoc(), clang::TreeTransform< Derived >::TransformReferenceType(), clang::TreeTransform< Derived >::TransformTemplateSpecializationType(), clang::TransformTypeSpecType(), and clang::tooling::RecursiveSymbolVisitor< T >::VisitTypeLoc().
|
inline |
Definition at line 115 of file TypeLoc.h.
References getType(), clang::Type::getTypeClass(), and Qualified.
Referenced by getBeginLoc(), getEndLoc(), clang::TypeLocBuilder::pushFullCopy(), clang::TreeTransform< Derived >::TransformType(), clang::RecursiveASTVisitor< CallGraph >::TraverseTypeLoc(), and clang::TypeLocVisitor< TypeLocReader >::Visit().
|
inline |
Definition at line 136 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::AutoTypeLoc::getArgLoc(), clang::DependentTemplateSpecializationTypeLoc::getArgLoc(), clang::AttributedTypeLoc::getAttrKind(), clang::AutoTypeLoc::getAutoKeyword(), 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::MacroQualifiedTypeLoc::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::MacroQualifiedTypeLoc::getMacroIdentifier(), clang::AutoTypeLoc::getNamedConcept(), clang::TemplateSpecializationTypeLoc::getNumArgs(), clang::AutoTypeLoc::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::AutoTypeLoc::isConstrained(), clang::AttributedTypeLoc::isQualifier(), clang::BuiltinTypeLoc::needsExtraLocalData(), clang::ElaboratedTypeLoc::setQualifierLoc(), clang::DependentNameTypeLoc::setQualifierLoc(), clang::DependentTemplateSpecializationTypeLoc::setQualifierLoc(), and clang::tooling::RecursiveSymbolVisitor< T >::VisitTypeLoc().
|
inline |
Skips past any qualifiers, if this is qualified.
Definition at line 326 of file TypeLoc.h.
References getUnqualifiedLoc().
Referenced by clang::comments::DeclInfo::fill(), findTypeLocationForBlockDecl(), FixInvalidVariablyModifiedTypeLoc(), clang::comments::getFunctionTypeLoc(), getNextTypeLoc(), clang::QualifiedTypeLoc::getNextTypeLoc(), GetTypeSourceInfoForDeclarator(), getUnqualifiedLoc(), clang::comments::lookThroughTypedefOrTypeAliasLocs(), clang::TreeTransform< Derived >::TransformTypeWithDeducedTST(), and clang::RecursiveASTVisitor< CallGraph >::WalkUpFromUnqualTypeLoc().
|
inline |
Definition at line 1151 of file TypeLoc.h.
Referenced by clang::Sema::CheckEquivalentExceptionSpec(), findTypeLocationForBlockDecl(), clang::FunctionDecl::getFunctionTypeLoc(), getNextTypeLoc(), clang::comments::lookThroughTypedefOrTypeAliasLocs(), NeedsInstantiationAsFunctionType(), clang::Sema::SubstFunctionDeclType(), and clang::TemplateDeclInstantiator::SubstFunctionType().
|
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 196 of file TypeLoc.h.
Referenced by clang::ASTContext::getTrivialTypeSourceInfo().
|
inline |
|
inline |
|
inline |
Definition at line 120 of file TypeLoc.h.
References Ty.
Referenced by clang::ASTRecordWriter::AddTypeLoc(), getBeginLoc(), getContainedAutoTypeLoc(), getFullDataSizeForType(), clang::index::IndexingContext::indexTypeLoc(), clang::index::IndexingContext::indexTypeSourceInfo(), clang::ASTRecordReader::readTypeLoc(), and clang::RecursiveASTVisitor< CallGraph >::TraverseTypeLoc().
|
inlineexplicit |
Definition at line 121 of file TypeLoc.h.
References getFullDataSizeForType(), getLocalAlignmentForType(), and Ty.
|
protected |
Definition at line 63 of file TypeLoc.h.
Referenced by copy(), clang::TemplateSpecializationTypeLoc::copy(), clang::AutoTypeLoc::copy(), clang::ElaboratedTypeLoc::copy(), clang::DependentNameTypeLoc::copy(), clang::DependentTemplateSpecializationTypeLoc::copy(), getOpaqueData(), and clang::QualifiedTypeLoc::getUnqualifiedLoc().
|
protected |
Definition at line 62 of file TypeLoc.h.
Referenced by clang::TypeSourceInfo::getTypeLoc(), clang::UnqualTypeLoc::getTypePtr(), isNull(), and operator bool().