clang
9.0.0
|
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 | IgnoreMacroDefinitions () const |
Strips MacroDefinitionTypeLocs from a type location. More... | |
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) |
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 75 of file TypeLoc.h.
References t.
Referenced by 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 165 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 419 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 408 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 86 of file TypeLoc.h.
References getAsAdjusted(), and t.
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(), clang::FunctionDecl::getExceptionSpecSourceRange(), clang::comments::getFunctionTypeLoc(), clang::FunctionDecl::getReturnTypeSourceRange(), 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 2317 of file TypeLoc.h.
References getAs().
Referenced by getAs(), clang::Sema::getReturnTypeLoc(), and implicitObjectParamIsLifetimeBound().
SourceLocation TypeLoc::getBeginLoc | ( | ) | const |
Get the begin source location.
Definition at line 189 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::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(), and clang::tooling::RecursiveSymbolVisitor< T >::VisitTypeLoc().
SourceLocation TypeLoc::getEndLoc | ( | ) | const |
Get the end source location.
Definition at line 226 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(), ReplaceWithClasstype(), ReplaceWithInstancetype(), clang::Sema::SubstExceptionSpec(), and clang::TreeTransform< Derived >::TransformCXXNamedCastExpr().
|
inline |
Returns the size of the type source info data block.
Definition at line 161 of file TypeLoc.h.
References getFullDataSizeForType(), and getType().
Referenced by copy(), clang::TemplateSpecializationTypeLoc::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 91 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 71 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 156 of file TypeLoc.h.
Referenced by clang::Sema::BuildBaseInitializer(), clang::Sema::BuildDelegatingInitializer(), clang::Sema::BuildPseudoDestructorExpr(), clang::Sema::CheckFriendTypeDecl(), 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 167 of file TypeLoc.h.
References findExplicitQualifierLoc(), getUnqualifiedLoc(), IgnoreMacroDefinitions(), 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::ASTReader::ReadTypeLoc().
|
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(), and GetTypeSourceInfoForDeclarator().
|
inline |
Get the full source range.
Definition at line 150 of file TypeLoc.h.
References getBeginLoc(), and getEndLoc().
Referenced by AnalyzeBitFieldAssignment(), 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 130 of file TypeLoc.h.
References clang::QualType::getFromOpaquePtr().
Referenced by clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), CheckConstexprDeclStmt(), clang::Sema::DeduceAutoType(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), clang::deduceOpenCLPointeeAddrSpace(), 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 113 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 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::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::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().
|
inline |
Skips past any qualifiers, if this is qualified.
Definition at line 322 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().
TypeLoc clang::TypeLoc::IgnoreMacroDefinitions | ( | ) | const |
Strips MacroDefinitionTypeLocs from a type location.
Referenced by getNextTypeLoc().
|
inline |
Definition at line 1162 of file TypeLoc.h.
Referenced by clang::Sema::CheckEquivalentExceptionSpec(), findTypeLocationForBlockDecl(), clang::FunctionDecl::getExceptionSpecSourceRange(), getNextTypeLoc(), clang::FunctionDecl::getReturnTypeSourceRange(), 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 192 of file TypeLoc.h.
Referenced by clang::ASTContext::getTrivialTypeSourceInfo().
|
inline |
|
inline |
|
inline |
Definition at line 118 of file TypeLoc.h.
References Ty.
Referenced by clang::ASTRecordWriter::AddTypeLoc(), getBeginLoc(), getFullDataSizeForType(), clang::index::IndexingContext::indexTypeLoc(), clang::index::IndexingContext::indexTypeSourceInfo(), clang::ASTReader::ReadTypeLoc(), and clang::RecursiveASTVisitor< CallGraph >::TraverseTypeLoc().
|
inlineexplicit |
Definition at line 119 of file TypeLoc.h.
References getFullDataSizeForType(), getLocalAlignmentForType(), and Ty.
|
protected |
Definition at line 61 of file TypeLoc.h.
Referenced by copy(), clang::TemplateSpecializationTypeLoc::copy(), clang::ElaboratedTypeLoc::copy(), clang::DependentNameTypeLoc::copy(), clang::DependentTemplateSpecializationTypeLoc::copy(), getOpaqueData(), and clang::QualifiedTypeLoc::getUnqualifiedLoc().
|
protected |
Definition at line 60 of file TypeLoc.h.
Referenced by clang::TypeSourceInfo::getTypeLoc(), clang::UnqualTypeLoc::getTypePtr(), isNull(), and operator bool().