Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/AST/ASTNodeTraverser.h
Show All 17 Lines | |||||
#include "clang/AST/ASTTypeTraits.h" | #include "clang/AST/ASTTypeTraits.h" | ||||
#include "clang/AST/AttrVisitor.h" | #include "clang/AST/AttrVisitor.h" | ||||
#include "clang/AST/CommentVisitor.h" | #include "clang/AST/CommentVisitor.h" | ||||
#include "clang/AST/DeclVisitor.h" | #include "clang/AST/DeclVisitor.h" | ||||
#include "clang/AST/LocInfoType.h" | #include "clang/AST/LocInfoType.h" | ||||
#include "clang/AST/StmtVisitor.h" | #include "clang/AST/StmtVisitor.h" | ||||
#include "clang/AST/TemplateArgumentVisitor.h" | #include "clang/AST/TemplateArgumentVisitor.h" | ||||
#include "clang/AST/Type.h" | #include "clang/AST/Type.h" | ||||
#include "clang/AST/TypeLocVisitor.h" | |||||
#include "clang/AST/TypeVisitor.h" | #include "clang/AST/TypeVisitor.h" | ||||
namespace clang { | namespace clang { | ||||
class APValue; | class APValue; | ||||
/** | /** | ||||
Show All 9 Lines | struct { | ||||
void Visit(const comments::Comment *C, const comments::FullComment *FC); | void Visit(const comments::Comment *C, const comments::FullComment *FC); | ||||
void Visit(const Attr *A); | void Visit(const Attr *A); | ||||
void Visit(const TemplateArgument &TA, SourceRange R = {}, | void Visit(const TemplateArgument &TA, SourceRange R = {}, | ||||
const Decl *From = nullptr, StringRef Label = {}); | const Decl *From = nullptr, StringRef Label = {}); | ||||
void Visit(const Stmt *Node); | void Visit(const Stmt *Node); | ||||
void Visit(const Type *T); | void Visit(const Type *T); | ||||
void Visit(QualType T); | void Visit(QualType T); | ||||
void Visit(TypeLoc TL); | |||||
void Visit(const Decl *D); | void Visit(const Decl *D); | ||||
void Visit(const CXXCtorInitializer *Init); | void Visit(const CXXCtorInitializer *Init); | ||||
void Visit(const OMPClause *C); | void Visit(const OMPClause *C); | ||||
void Visit(const BlockDecl::Capture &C); | void Visit(const BlockDecl::Capture &C); | ||||
void Visit(const GenericSelectionExpr::ConstAssociation &A); | void Visit(const GenericSelectionExpr::ConstAssociation &A); | ||||
void Visit(const concepts::Requirement *R); | void Visit(const concepts::Requirement *R); | ||||
void Visit(const APValue &Value, QualType Ty); | void Visit(const APValue &Value, QualType Ty); | ||||
}; | }; | ||||
*/ | */ | ||||
template <typename Derived, typename NodeDelegateType> | template <typename Derived, typename NodeDelegateType> | ||||
class ASTNodeTraverser | class ASTNodeTraverser | ||||
: public ConstDeclVisitor<Derived>, | : public ConstDeclVisitor<Derived>, | ||||
public ConstStmtVisitor<Derived>, | public ConstStmtVisitor<Derived>, | ||||
public comments::ConstCommentVisitor<Derived, void, | public comments::ConstCommentVisitor<Derived, void, | ||||
const comments::FullComment *>, | const comments::FullComment *>, | ||||
public TypeVisitor<Derived>, | public TypeVisitor<Derived>, | ||||
public TypeLocVisitor<Derived>, | |||||
public ConstAttrVisitor<Derived>, | public ConstAttrVisitor<Derived>, | ||||
public ConstTemplateArgumentVisitor<Derived> { | public ConstTemplateArgumentVisitor<Derived> { | ||||
/// Indicates whether we should trigger deserialization of nodes that had | /// Indicates whether we should trigger deserialization of nodes that had | ||||
/// not already been loaded. | /// not already been loaded. | ||||
bool Deserialize = false; | bool Deserialize = false; | ||||
TraversalKind Traversal = TraversalKind::TK_AsIs; | TraversalKind Traversal = TraversalKind::TK_AsIs; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | getNodeDelegate().AddChild([=] { | ||||
QualType SingleStepDesugar = | QualType SingleStepDesugar = | ||||
T->getLocallyUnqualifiedSingleStepDesugaredType(); | T->getLocallyUnqualifiedSingleStepDesugaredType(); | ||||
if (SingleStepDesugar != QualType(T, 0)) | if (SingleStepDesugar != QualType(T, 0)) | ||||
Visit(SingleStepDesugar); | Visit(SingleStepDesugar); | ||||
}); | }); | ||||
} | } | ||||
void Visit(TypeLoc TL) { | |||||
getNodeDelegate().AddChild([=] { | |||||
getNodeDelegate().Visit(TL); | |||||
TypeLocVisitor<Derived>::Visit(TL); | |||||
}); | |||||
} | |||||
void Visit(const Attr *A) { | void Visit(const Attr *A) { | ||||
getNodeDelegate().AddChild([=] { | getNodeDelegate().AddChild([=] { | ||||
getNodeDelegate().Visit(A); | getNodeDelegate().Visit(A); | ||||
ConstAttrVisitor<Derived>::Visit(A); | ConstAttrVisitor<Derived>::Visit(A); | ||||
}); | }); | ||||
} | } | ||||
void Visit(const CXXCtorInitializer *Init) { | void Visit(const CXXCtorInitializer *Init) { | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | void Visit(const DynTypedNode &N) { | ||||
if (const auto *D = N.get<Decl>()) | if (const auto *D = N.get<Decl>()) | ||||
Visit(D); | Visit(D); | ||||
else if (const auto *S = N.get<Stmt>()) | else if (const auto *S = N.get<Stmt>()) | ||||
Visit(S); | Visit(S); | ||||
else if (const auto *QT = N.get<QualType>()) | else if (const auto *QT = N.get<QualType>()) | ||||
Visit(*QT); | Visit(*QT); | ||||
else if (const auto *T = N.get<Type>()) | else if (const auto *T = N.get<Type>()) | ||||
Visit(T); | Visit(T); | ||||
else if (const auto *TL = N.get<TypeLoc>()) | |||||
Visit(*TL); | |||||
else if (const auto *C = N.get<CXXCtorInitializer>()) | else if (const auto *C = N.get<CXXCtorInitializer>()) | ||||
Visit(C); | Visit(C); | ||||
else if (const auto *C = N.get<OMPClause>()) | else if (const auto *C = N.get<OMPClause>()) | ||||
Visit(C); | Visit(C); | ||||
else if (const auto *T = N.get<TemplateArgument>()) | else if (const auto *T = N.get<TemplateArgument>()) | ||||
Visit(*T); | Visit(*T); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | public: | ||||
void VisitAdjustedType(const AdjustedType *T) { Visit(T->getOriginalType()); } | void VisitAdjustedType(const AdjustedType *T) { Visit(T->getOriginalType()); } | ||||
void VisitPackExpansionType(const PackExpansionType *T) { | void VisitPackExpansionType(const PackExpansionType *T) { | ||||
if (!T->isSugared()) | if (!T->isSugared()) | ||||
Visit(T->getPattern()); | Visit(T->getPattern()); | ||||
} | } | ||||
// FIXME: ElaboratedType, DependentNameType, | // FIXME: ElaboratedType, DependentNameType, | ||||
// DependentTemplateSpecializationType, ObjCObjectType | // DependentTemplateSpecializationType, ObjCObjectType | ||||
void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { | |||||
Visit(TL.getUnqualifiedLoc()); | |||||
} | |||||
void VisitComplexTypeLoc(ComplexTypeLoc TL) { Visit(TL.getType()); } | |||||
void VisitPointerTypeLoc(PointerTypeLoc TL) { Visit(TL.getPointeeLoc()); } | |||||
void VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) { | |||||
Visit(TL.getPointeeLoc()); | |||||
} | |||||
void VisitReferenceTypeLoc(ReferenceTypeLoc TL) { Visit(TL.getPointeeLoc()); } | |||||
void VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) { | |||||
Visit(TL.getClass()); | |||||
Visit(TL.getPointeeLoc()); | |||||
} | |||||
void VisitArrayTypeLoc(ArrayTypeLoc TL) { Visit(TL.getElementLoc()); } | |||||
void VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) { | |||||
VisitArrayTypeLoc(TL); | |||||
} | |||||
void VisitDependentSizedArrayTypeLoc(DependentSizedArrayTypeLoc TL) { | |||||
VisitArrayTypeLoc(TL); | |||||
} | |||||
void VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) { | |||||
Visit(TL.getElementLoc()); | |||||
} | |||||
void VisitVectorTypeLoc(VectorTypeLoc TL) { Visit(TL.getElementLoc()); } | |||||
void VisitFunctionTypeLoc(FunctionTypeLoc TL) { Visit(TL.getReturnLoc()); } | |||||
void VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) { | |||||
VisitFunctionTypeLoc(TL); | |||||
// FIXME: Parameter TypeLocs | |||||
} | |||||
void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) { | |||||
Visit(TL.getUnderlyingExpr()); | |||||
} | |||||
void VisitDecltypeTypeLoc(const DecltypeTypeLoc TL) { | |||||
Visit(TL.getUnderlyingExpr()); | |||||
} | |||||
void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) { | |||||
// FIXME: Transformed TypeLoc | |||||
} | |||||
void VisitAttributedTypeLoc(AttributedTypeLoc TL) { | |||||
// FIXME: AttrKind | |||||
Visit(TL.getModifiedLoc()); | |||||
} | |||||
void VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) { | |||||
Visit(TL.getWrappedLoc()); | |||||
} | |||||
void VisitSubstTemplateTypeParmTypeLoc(SubstTemplateTypeParmTypeLoc TL) { | |||||
// FIXME: Replaced Parameter | |||||
} | |||||
void | |||||
VisitSubstTemplateTypeParmPackTypeLoc(SubstTemplateTypeParmPackTypeLoc TL) { | |||||
// FIXME: Replaced Parameter, Argument Pack | |||||
} | |||||
void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { | |||||
// FIXME: Arguments | |||||
} | |||||
void VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) { | |||||
Visit(TL.getPointeeLoc()); | |||||
} | |||||
void VisitAtomicTypeLoc(AtomicTypeLoc TL) { Visit(TL.getValueLoc()); } | |||||
void VisitPipeTypeLoc(PipeTypeLoc TL) { Visit(TL.getValueLoc()); } | |||||
void VisitAdjustedTypeLoc(AdjustedTypeLoc TL) { Visit(TL.getOriginalLoc()); } | |||||
void VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) { | |||||
Visit(TL.getPatternLoc()); | |||||
} | |||||
void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { | |||||
Visit(TL.getNamedTypeLoc()); | |||||
} | |||||
// FIXME: DependentNameTypeLoc, DependentTemplateSpecializationTypeLoc, | |||||
// ObjCObjectTypeLoc | |||||
void VisitTypedefDecl(const TypedefDecl *D) { Visit(D->getUnderlyingType()); } | void VisitTypedefDecl(const TypedefDecl *D) { Visit(D->getUnderlyingType()); } | ||||
void VisitEnumConstantDecl(const EnumConstantDecl *D) { | void VisitEnumConstantDecl(const EnumConstantDecl *D) { | ||||
if (const Expr *Init = D->getInitExpr()) | if (const Expr *Init = D->getInitExpr()) | ||||
Visit(Init); | Visit(Init); | ||||
} | } | ||||
void VisitFunctionDecl(const FunctionDecl *D) { | void VisitFunctionDecl(const FunctionDecl *D) { | ||||
▲ Show 20 Lines • Show All 394 Lines • Show Last 20 Lines |