From f877913ea661edfce597d77f10b9f2d4c8215b43 Mon Sep 17 00:00:00 2001 From: Sirraide Date: Tue, 28 Jan 2025 02:20:33 +0100 Subject: [PATCH] Revert "[Clang] [NFC] Introduce `ConstDynamicRecursiveASTVisitor` (#122991)" This reverts commit eeefa72f7c7287a3aa26f6278b9669eb76e8d1be. --- .../clang/AST/DynamicRecursiveASTVisitor.h | 114 +++----- clang/lib/AST/DynamicRecursiveASTVisitor.cpp | 251 ++++++++++++------ .../WebKit/RawPtrRefMemberChecker.cpp | 6 +- 3 files changed, 210 insertions(+), 161 deletions(-) diff --git a/clang/include/clang/AST/DynamicRecursiveASTVisitor.h b/clang/include/clang/AST/DynamicRecursiveASTVisitor.h index 4e0ba568263bf..4382d20990829 100644 --- a/clang/include/clang/AST/DynamicRecursiveASTVisitor.h +++ b/clang/include/clang/AST/DynamicRecursiveASTVisitor.h @@ -52,11 +52,7 @@ class ASTContext; /// WalkUpFromX or post-order traversal). /// /// \see RecursiveASTVisitor. -template class DynamicRecursiveASTVisitorBase { -protected: - template - using MaybeConst = std::conditional_t; - +class DynamicRecursiveASTVisitor { public: /// Whether this visitor should recurse into template instantiations. bool ShouldVisitTemplateInstantiations = false; @@ -72,29 +68,28 @@ template class DynamicRecursiveASTVisitorBase { bool ShouldVisitLambdaBody = true; protected: - DynamicRecursiveASTVisitorBase() = default; - DynamicRecursiveASTVisitorBase(DynamicRecursiveASTVisitorBase &&) = default; - DynamicRecursiveASTVisitorBase(const DynamicRecursiveASTVisitorBase &) = - default; - DynamicRecursiveASTVisitorBase & - operator=(DynamicRecursiveASTVisitorBase &&) = default; - DynamicRecursiveASTVisitorBase & - operator=(const DynamicRecursiveASTVisitorBase &) = default; + DynamicRecursiveASTVisitor() = default; + DynamicRecursiveASTVisitor(DynamicRecursiveASTVisitor &&) = default; + DynamicRecursiveASTVisitor(const DynamicRecursiveASTVisitor &) = default; + DynamicRecursiveASTVisitor & + operator=(DynamicRecursiveASTVisitor &&) = default; + DynamicRecursiveASTVisitor & + operator=(const DynamicRecursiveASTVisitor &) = default; public: virtual void anchor(); - virtual ~DynamicRecursiveASTVisitorBase() = default; + virtual ~DynamicRecursiveASTVisitor() = default; /// Recursively visits an entire AST, starting from the TranslationUnitDecl. /// \returns false if visitation was terminated early. - virtual bool TraverseAST(MaybeConst &AST); + virtual bool TraverseAST(ASTContext &AST); /// Recursively visit an attribute, by dispatching to /// Traverse*Attr() based on the argument's dynamic type. /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is a Null type location). - virtual bool TraverseAttr(MaybeConst *At); + virtual bool TraverseAttr(Attr *At); /// Recursively visit a constructor initializer. This /// automatically dispatches to another visitor for the initializer @@ -102,8 +97,7 @@ template class DynamicRecursiveASTVisitorBase { /// be overridden for clients that need access to the name. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool - TraverseConstructorInitializer(MaybeConst *Init); + virtual bool TraverseConstructorInitializer(CXXCtorInitializer *Init); /// Recursively visit a base specifier. This can be overridden by a /// subclass. @@ -116,7 +110,7 @@ template class DynamicRecursiveASTVisitorBase { /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is NULL). - virtual bool TraverseDecl(MaybeConst *D); + virtual bool TraverseDecl(Decl *D); /// Recursively visit a name with its location information. /// @@ -127,15 +121,13 @@ template class DynamicRecursiveASTVisitorBase { /// will be used to initialize the capture. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool TraverseLambdaCapture(MaybeConst *LE, - const LambdaCapture *C, - MaybeConst *Init); + virtual bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, + Expr *Init); /// Recursively visit a C++ nested-name-specifier. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool - TraverseNestedNameSpecifier(MaybeConst *NNS); + virtual bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); /// Recursively visit a C++ nested-name-specifier with location /// information. @@ -148,7 +140,7 @@ template class DynamicRecursiveASTVisitorBase { /// /// \returns false if the visitation was terminated early, true /// otherwise (including when the argument is nullptr). - virtual bool TraverseStmt(MaybeConst *S); + virtual bool TraverseStmt(Stmt *S); /// Recursively visit a template argument and dispatch to the /// appropriate method for the argument type. @@ -198,51 +190,41 @@ template class DynamicRecursiveASTVisitorBase { /// Traverse a concept (requirement). virtual bool TraverseTypeConstraint(const TypeConstraint *C); - virtual bool TraverseConceptRequirement(MaybeConst *R); - - virtual bool - TraverseConceptTypeRequirement(MaybeConst *R); - - virtual bool - TraverseConceptExprRequirement(MaybeConst *R); - - virtual bool - TraverseConceptNestedRequirement(MaybeConst *R); - - virtual bool TraverseConceptReference(MaybeConst *CR); - virtual bool VisitConceptReference(MaybeConst *CR) { - return true; - } + virtual bool TraverseConceptRequirement(concepts::Requirement *R); + virtual bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R); + virtual bool TraverseConceptExprRequirement(concepts::ExprRequirement *R); + virtual bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R); + virtual bool TraverseConceptReference(ConceptReference *CR); + virtual bool VisitConceptReference(ConceptReference *CR) { return true; } /// Visit a node. - virtual bool VisitAttr(MaybeConst *A) { return true; } - virtual bool VisitDecl(MaybeConst *D) { return true; } - virtual bool VisitStmt(MaybeConst *S) { return true; } - virtual bool VisitType(MaybeConst *T) { return true; } + virtual bool VisitAttr(Attr *A) { return true; } + virtual bool VisitDecl(Decl *D) { return true; } + virtual bool VisitStmt(Stmt *S) { return true; } + virtual bool VisitType(Type *T) { return true; } virtual bool VisitTypeLoc(TypeLoc TL) { return true; } /// Walk up from a node. - bool WalkUpFromDecl(MaybeConst *D) { return VisitDecl(D); } - bool WalkUpFromStmt(MaybeConst *S) { return VisitStmt(S); } - bool WalkUpFromType(MaybeConst *T) { return VisitType(T); } + bool WalkUpFromDecl(Decl *D) { return VisitDecl(D); } + bool WalkUpFromStmt(Stmt *S) { return VisitStmt(S); } + bool WalkUpFromType(Type *T) { return VisitType(T); } bool WalkUpFromTypeLoc(TypeLoc TL) { return VisitTypeLoc(TL); } /// Invoked before visiting a statement or expression via data recursion. /// /// \returns false to skip visiting the node, true otherwise. - virtual bool dataTraverseStmtPre(MaybeConst *S) { return true; } + virtual bool dataTraverseStmtPre(Stmt *S) { return true; } /// Invoked after visiting a statement or expression via data recursion. /// This is not invoked if the previously invoked \c dataTraverseStmtPre /// returned false. /// /// \returns false if the visitation was terminated early, true otherwise. - virtual bool dataTraverseStmtPost(MaybeConst *S) { return true; } - virtual bool dataTraverseNode(MaybeConst *S); + virtual bool dataTraverseStmtPost(Stmt *S) { return true; } + virtual bool dataTraverseNode(Stmt *S); #define DEF_TRAVERSE_TMPL_INST(kind) \ - virtual bool TraverseTemplateInstantiations( \ - MaybeConst *D); + virtual bool TraverseTemplateInstantiations(kind##TemplateDecl *D); DEF_TRAVERSE_TMPL_INST(Class) DEF_TRAVERSE_TMPL_INST(Var) DEF_TRAVERSE_TMPL_INST(Function) @@ -250,34 +232,32 @@ template class DynamicRecursiveASTVisitorBase { // Decls. #define ABSTRACT_DECL(DECL) -#define DECL(CLASS, BASE) \ - virtual bool Traverse##CLASS##Decl(MaybeConst *D); +#define DECL(CLASS, BASE) virtual bool Traverse##CLASS##Decl(CLASS##Decl *D); #include "clang/AST/DeclNodes.inc" #define DECL(CLASS, BASE) \ - bool WalkUpFrom##CLASS##Decl(MaybeConst *D); \ - virtual bool Visit##CLASS##Decl(MaybeConst *D) { return true; } + bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D); \ + virtual bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; } #include "clang/AST/DeclNodes.inc" // Stmts. #define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) virtual bool Traverse##CLASS(MaybeConst *S); +#define STMT(CLASS, PARENT) virtual bool Traverse##CLASS(CLASS *S); #include "clang/AST/StmtNodes.inc" #define STMT(CLASS, PARENT) \ - bool WalkUpFrom##CLASS(MaybeConst *S); \ - virtual bool Visit##CLASS(MaybeConst *S) { return true; } + bool WalkUpFrom##CLASS(CLASS *S); \ + virtual bool Visit##CLASS(CLASS *S) { return true; } #include "clang/AST/StmtNodes.inc" // Types. #define ABSTRACT_TYPE(CLASS, BASE) -#define TYPE(CLASS, BASE) \ - virtual bool Traverse##CLASS##Type(MaybeConst *T); +#define TYPE(CLASS, BASE) virtual bool Traverse##CLASS##Type(CLASS##Type *T); #include "clang/AST/TypeNodes.inc" #define TYPE(CLASS, BASE) \ - bool WalkUpFrom##CLASS##Type(MaybeConst *T); \ - virtual bool Visit##CLASS##Type(MaybeConst *T) { return true; } + bool WalkUpFrom##CLASS##Type(CLASS##Type *T); \ + virtual bool Visit##CLASS##Type(CLASS##Type *T) { return true; } #include "clang/AST/TypeNodes.inc" // TypeLocs. @@ -291,14 +271,6 @@ template class DynamicRecursiveASTVisitorBase { virtual bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; } #include "clang/AST/TypeLocNodes.def" }; - -extern template class DynamicRecursiveASTVisitorBase; -extern template class DynamicRecursiveASTVisitorBase; - -using DynamicRecursiveASTVisitor = - DynamicRecursiveASTVisitorBase; -using ConstDynamicRecursiveASTVisitor = - DynamicRecursiveASTVisitorBase; } // namespace clang #endif // LLVM_CLANG_AST_DYNAMIC_RECURSIVE_AST_VISITOR_H diff --git a/clang/lib/AST/DynamicRecursiveASTVisitor.cpp b/clang/lib/AST/DynamicRecursiveASTVisitor.cpp index 9cc0ee60c05f6..8cfabd9f3e93f 100644 --- a/clang/lib/AST/DynamicRecursiveASTVisitor.cpp +++ b/clang/lib/AST/DynamicRecursiveASTVisitor.cpp @@ -89,9 +89,9 @@ using namespace clang; // // End result: RAV::TraverseCallExpr() is executed, namespace { -template struct Impl : RecursiveASTVisitor> { - DynamicRecursiveASTVisitorBase &Visitor; - Impl(DynamicRecursiveASTVisitorBase &Visitor) : Visitor(Visitor) {} +struct Impl : RecursiveASTVisitor { + DynamicRecursiveASTVisitor &Visitor; + Impl(DynamicRecursiveASTVisitor &Visitor) : Visitor(Visitor) {} bool shouldVisitTemplateInstantiations() const { return Visitor.ShouldVisitTemplateInstantiations; @@ -189,10 +189,8 @@ template struct Impl : RecursiveASTVisitor> { // TraverseStmt() always passes in a queue, so we have no choice but to // accept it as a parameter here. - bool dataTraverseNode( - Stmt *S, - typename RecursiveASTVisitor::DataRecursionQueue * = nullptr) { - // But since we don't support postorder traversal, we don't need it, so + bool dataTraverseNode(Stmt *S, DataRecursionQueue * = nullptr) { + // But since don't support postorder traversal, we don't need it, so // simply discard it here. This way, derived classes don't need to worry // about including it as a parameter that they never use. return Visitor.dataTraverseNode(S); @@ -268,108 +266,187 @@ template struct Impl : RecursiveASTVisitor> { }; } // namespace -template void DynamicRecursiveASTVisitorBase::anchor() {} - -// Helper macros to forward a call to the base implementation since that -// ends up getting very verbose otherwise. - -// This calls the RecursiveASTVisitor implementation of the same function, -// stripping any 'const' that the DRAV implementation may have added since -// the RAV implementation largely doesn't use 'const'. -#define FORWARD_TO_BASE(Function, Type, RefOrPointer) \ - template \ - bool DynamicRecursiveASTVisitorBase::Function( \ - MaybeConst RefOrPointer Param) { \ - return Impl(*this) \ - .template RecursiveASTVisitor>::Function( \ - const_cast(Param)); \ - } - -// Same as 'FORWARD_TO_BASE', but doesn't change the parameter type in any way. -#define FORWARD_TO_BASE_EXACT(Function, Type) \ - template \ - bool DynamicRecursiveASTVisitorBase::Function(Type Param) { \ - return Impl(*this) \ - .template RecursiveASTVisitor>::Function(Param); \ - } - -FORWARD_TO_BASE(TraverseAST, ASTContext, &) -FORWARD_TO_BASE(TraverseAttr, Attr, *) -FORWARD_TO_BASE(TraverseConstructorInitializer, CXXCtorInitializer, *) -FORWARD_TO_BASE(TraverseDecl, Decl, *) -FORWARD_TO_BASE(TraverseStmt, Stmt, *) -FORWARD_TO_BASE(TraverseNestedNameSpecifier, NestedNameSpecifier, *) -FORWARD_TO_BASE(TraverseTemplateInstantiations, ClassTemplateDecl, *) -FORWARD_TO_BASE(TraverseTemplateInstantiations, VarTemplateDecl, *) -FORWARD_TO_BASE(TraverseTemplateInstantiations, FunctionTemplateDecl, *) -FORWARD_TO_BASE(TraverseConceptRequirement, concepts::Requirement, *) -FORWARD_TO_BASE(TraverseConceptTypeRequirement, concepts::TypeRequirement, *) -FORWARD_TO_BASE(TraverseConceptExprRequirement, concepts::ExprRequirement, *) -FORWARD_TO_BASE(TraverseConceptReference, ConceptReference, *) -FORWARD_TO_BASE(TraverseConceptNestedRequirement, - concepts::NestedRequirement, *) - -FORWARD_TO_BASE_EXACT(TraverseCXXBaseSpecifier, const CXXBaseSpecifier &) -FORWARD_TO_BASE_EXACT(TraverseDeclarationNameInfo, DeclarationNameInfo) -FORWARD_TO_BASE_EXACT(TraverseTemplateArgument, const TemplateArgument &) -FORWARD_TO_BASE_EXACT(TraverseTemplateArguments, ArrayRef) -FORWARD_TO_BASE_EXACT(TraverseTemplateArgumentLoc, const TemplateArgumentLoc &) -FORWARD_TO_BASE_EXACT(TraverseTemplateName, TemplateName) -FORWARD_TO_BASE_EXACT(TraverseType, QualType) -FORWARD_TO_BASE_EXACT(TraverseTypeLoc, TypeLoc) -FORWARD_TO_BASE_EXACT(TraverseTypeConstraint, const TypeConstraint *) -FORWARD_TO_BASE_EXACT(TraverseObjCProtocolLoc, ObjCProtocolLoc) -FORWARD_TO_BASE_EXACT(TraverseNestedNameSpecifierLoc, NestedNameSpecifierLoc) - -template -bool DynamicRecursiveASTVisitorBase::TraverseLambdaCapture( - MaybeConst *LE, const LambdaCapture *C, - MaybeConst *Init) { - return Impl(*this) - .template RecursiveASTVisitor>::TraverseLambdaCapture( - const_cast(LE), C, const_cast(Init)); +void DynamicRecursiveASTVisitor::anchor() {} + +bool DynamicRecursiveASTVisitor::TraverseAST(ASTContext &AST) { + return Impl(*this).RecursiveASTVisitor::TraverseAST(AST); +} + +bool DynamicRecursiveASTVisitor::TraverseAttr(Attr *At) { + return Impl(*this).RecursiveASTVisitor::TraverseAttr(At); +} + +bool DynamicRecursiveASTVisitor::TraverseConstructorInitializer( + CXXCtorInitializer *Init) { + return Impl(*this).RecursiveASTVisitor::TraverseConstructorInitializer( + Init); +} + +bool DynamicRecursiveASTVisitor::TraverseDecl(Decl *D) { + return Impl(*this).RecursiveASTVisitor::TraverseDecl(D); +} + +bool DynamicRecursiveASTVisitor::TraverseLambdaCapture(LambdaExpr *LE, + const LambdaCapture *C, + Expr *Init) { + return Impl(*this).RecursiveASTVisitor::TraverseLambdaCapture(LE, C, + Init); +} + +bool DynamicRecursiveASTVisitor::TraverseStmt(Stmt *S) { + return Impl(*this).RecursiveASTVisitor::TraverseStmt(S); +} + +bool DynamicRecursiveASTVisitor::TraverseTemplateArgument( + const TemplateArgument &Arg) { + return Impl(*this).RecursiveASTVisitor::TraverseTemplateArgument(Arg); +} + +bool DynamicRecursiveASTVisitor::TraverseTemplateArguments( + ArrayRef Args) { + return Impl(*this).RecursiveASTVisitor::TraverseTemplateArguments(Args); +} + +bool DynamicRecursiveASTVisitor::TraverseTemplateArgumentLoc( + const TemplateArgumentLoc &ArgLoc) { + return Impl(*this).RecursiveASTVisitor::TraverseTemplateArgumentLoc( + ArgLoc); +} + +bool DynamicRecursiveASTVisitor::TraverseTemplateName(TemplateName Template) { + return Impl(*this).RecursiveASTVisitor::TraverseTemplateName(Template); +} + +bool DynamicRecursiveASTVisitor::TraverseType(QualType T) { + return Impl(*this).RecursiveASTVisitor::TraverseType(T); +} + +bool DynamicRecursiveASTVisitor::TraverseTypeLoc(TypeLoc TL) { + return Impl(*this).RecursiveASTVisitor::TraverseTypeLoc(TL); +} + +bool DynamicRecursiveASTVisitor::TraverseTypeConstraint( + const TypeConstraint *C) { + return Impl(*this).RecursiveASTVisitor::TraverseTypeConstraint(C); +} +bool DynamicRecursiveASTVisitor::TraverseObjCProtocolLoc( + ObjCProtocolLoc ProtocolLoc) { + return Impl(*this).RecursiveASTVisitor::TraverseObjCProtocolLoc( + ProtocolLoc); +} + +bool DynamicRecursiveASTVisitor::TraverseConceptRequirement( + concepts::Requirement *R) { + return Impl(*this).RecursiveASTVisitor::TraverseConceptRequirement(R); +} +bool DynamicRecursiveASTVisitor::TraverseConceptTypeRequirement( + concepts::TypeRequirement *R) { + return Impl(*this).RecursiveASTVisitor::TraverseConceptTypeRequirement( + R); +} +bool DynamicRecursiveASTVisitor::TraverseConceptExprRequirement( + concepts::ExprRequirement *R) { + return Impl(*this).RecursiveASTVisitor::TraverseConceptExprRequirement( + R); +} +bool DynamicRecursiveASTVisitor::TraverseConceptNestedRequirement( + concepts::NestedRequirement *R) { + return Impl(*this) + .RecursiveASTVisitor::TraverseConceptNestedRequirement(R); +} + +bool DynamicRecursiveASTVisitor::TraverseConceptReference( + ConceptReference *CR) { + return Impl(*this).RecursiveASTVisitor::TraverseConceptReference(CR); +} + +bool DynamicRecursiveASTVisitor::TraverseCXXBaseSpecifier( + const CXXBaseSpecifier &Base) { + return Impl(*this).RecursiveASTVisitor::TraverseCXXBaseSpecifier(Base); +} + +bool DynamicRecursiveASTVisitor::TraverseDeclarationNameInfo( + DeclarationNameInfo NameInfo) { + return Impl(*this).RecursiveASTVisitor::TraverseDeclarationNameInfo( + NameInfo); +} + +bool DynamicRecursiveASTVisitor::TraverseNestedNameSpecifier( + NestedNameSpecifier *NNS) { + return Impl(*this).RecursiveASTVisitor::TraverseNestedNameSpecifier( + NNS); +} + +bool DynamicRecursiveASTVisitor::TraverseNestedNameSpecifierLoc( + NestedNameSpecifierLoc NNS) { + return Impl(*this).RecursiveASTVisitor::TraverseNestedNameSpecifierLoc( + NNS); } -template -bool DynamicRecursiveASTVisitorBase::dataTraverseNode( - MaybeConst *S) { - return Impl(*this) - .template RecursiveASTVisitor>::dataTraverseNode( - const_cast(S), nullptr); +bool DynamicRecursiveASTVisitor::dataTraverseNode(Stmt *S) { + return Impl(*this).RecursiveASTVisitor::dataTraverseNode(S, nullptr); } +#define DEF_TRAVERSE_TMPL_INST(kind) \ + bool DynamicRecursiveASTVisitor::TraverseTemplateInstantiations( \ + kind##TemplateDecl *D) { \ + return Impl(*this) \ + .RecursiveASTVisitor::TraverseTemplateInstantiations(D); \ + } +DEF_TRAVERSE_TMPL_INST(Class) +DEF_TRAVERSE_TMPL_INST(Var) +DEF_TRAVERSE_TMPL_INST(Function) +#undef DEF_TRAVERSE_TMPL_INST + // Declare Traverse*() for and friends all concrete Decl classes. #define ABSTRACT_DECL(DECL) #define DECL(CLASS, BASE) \ - FORWARD_TO_BASE(Traverse##CLASS##Decl, CLASS##Decl, *) \ - FORWARD_TO_BASE(WalkUpFrom##CLASS##Decl, CLASS##Decl, *) + bool DynamicRecursiveASTVisitor::Traverse##CLASS##Decl(CLASS##Decl *D) { \ + return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##Decl(D); \ + } \ + bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \ + return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##Decl(D); \ + } #include "clang/AST/DeclNodes.inc" // Declare Traverse*() and friends for all concrete Stmt classes. #define ABSTRACT_STMT(STMT) -#define STMT(CLASS, PARENT) FORWARD_TO_BASE(Traverse##CLASS, CLASS, *) +#define STMT(CLASS, PARENT) \ + bool DynamicRecursiveASTVisitor::Traverse##CLASS(CLASS *S) { \ + return Impl(*this).RecursiveASTVisitor::Traverse##CLASS(S); \ + } #include "clang/AST/StmtNodes.inc" -#define STMT(CLASS, PARENT) FORWARD_TO_BASE(WalkUpFrom##CLASS, CLASS, *) +#define STMT(CLASS, PARENT) \ + bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS(CLASS *S) { \ + return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS(S); \ + } #include "clang/AST/StmtNodes.inc" -// Declare Traverse*() and friends for all concrete Type classes. +// Declare Traverse*() and friends for all concrete Typeclasses. #define ABSTRACT_TYPE(CLASS, BASE) #define TYPE(CLASS, BASE) \ - FORWARD_TO_BASE(Traverse##CLASS##Type, CLASS##Type, *) \ - FORWARD_TO_BASE(WalkUpFrom##CLASS##Type, CLASS##Type, *) + bool DynamicRecursiveASTVisitor::Traverse##CLASS##Type(CLASS##Type *T) { \ + return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##Type(T); \ + } \ + bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Type(CLASS##Type *T) { \ + return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##Type(T); \ + } #include "clang/AST/TypeNodes.inc" #define ABSTRACT_TYPELOC(CLASS, BASE) #define TYPELOC(CLASS, BASE) \ - FORWARD_TO_BASE_EXACT(Traverse##CLASS##TypeLoc, CLASS##TypeLoc) + bool DynamicRecursiveASTVisitor::Traverse##CLASS##TypeLoc( \ + CLASS##TypeLoc TL) { \ + return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##TypeLoc( \ + TL); \ + } #include "clang/AST/TypeLocNodes.def" #define TYPELOC(CLASS, BASE) \ - FORWARD_TO_BASE_EXACT(WalkUpFrom##CLASS##TypeLoc, CLASS##TypeLoc) + bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##TypeLoc( \ + CLASS##TypeLoc TL) { \ + return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##TypeLoc( \ + TL); \ + } #include "clang/AST/TypeLocNodes.def" - -namespace clang { -template class DynamicRecursiveASTVisitorBase; -template class DynamicRecursiveASTVisitorBase; -} // namespace clang diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp index 79f88553feb95..d7e5ebee9a9b4 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp @@ -48,7 +48,7 @@ class RawPtrRefMemberChecker // The calls to checkAST* from AnalysisConsumer don't // visit template instantiations or lambda classes. We // want to visit those, so we make our own RecursiveASTVisitor. - struct LocalVisitor : ConstDynamicRecursiveASTVisitor { + struct LocalVisitor : DynamicRecursiveASTVisitor { const RawPtrRefMemberChecker *Checker; explicit LocalVisitor(const RawPtrRefMemberChecker *Checker) : Checker(Checker) { @@ -57,14 +57,14 @@ class RawPtrRefMemberChecker ShouldVisitImplicitCode = false; } - bool VisitRecordDecl(const RecordDecl *RD) override { + bool VisitRecordDecl(RecordDecl *RD) override { Checker->visitRecordDecl(RD); return true; } }; LocalVisitor visitor(this); - visitor.TraverseDecl(TUD); + visitor.TraverseDecl(const_cast(TUD)); } void visitRecordDecl(const RecordDecl *RD) const {