-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] [Tests] Refactor most unit tests to use DRAV instead #115132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: None (Sirraide) ChangesThis pr refactors most tests that use RAV to use DRAV instead; this also has the nice effect of testing both the RAV and DRAV implementations at the same time w/o having to duplicate all of our AST visitor tests. Some tests rely on features that DRAV doesn’t support (mainly post-order traversal), so those haven’t been migrated. At the same time, Patch is 71.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/115132.diff 44 Files Affected:
diff --git a/clang/unittests/AST/EvaluateAsRValueTest.cpp b/clang/unittests/AST/EvaluateAsRValueTest.cpp
index f6261b827671bc..1e17330863f264 100644
--- a/clang/unittests/AST/EvaluateAsRValueTest.cpp
+++ b/clang/unittests/AST/EvaluateAsRValueTest.cpp
@@ -13,7 +13,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Tooling/Tooling.h"
#include "gtest/gtest.h"
#include <map>
@@ -28,8 +28,8 @@ typedef std::map<std::string, bool> VarInfoMap;
/// \brief Records information on variable initializers to a map.
class EvaluateConstantInitializersVisitor
- : public clang::RecursiveASTVisitor<EvaluateConstantInitializersVisitor> {
- public:
+ : public clang::DynamicRecursiveASTVisitor {
+public:
explicit EvaluateConstantInitializersVisitor(VarInfoMap &VarInfo)
: VarInfo(VarInfo) {}
@@ -38,7 +38,7 @@ class EvaluateConstantInitializersVisitor
///
/// For each VarDecl with an initializer this also records in VarInfo
/// whether the initializer could be evaluated as a constant.
- bool VisitVarDecl(const clang::VarDecl *VD) {
+ bool VisitVarDecl(clang::VarDecl *VD) override {
if (const clang::Expr *Init = VD->getInit()) {
clang::Expr::EvalResult Result;
bool WasEvaluated = Init->EvaluateAsRValue(Result, VD->getASTContext());
@@ -109,9 +109,9 @@ TEST(EvaluateAsRValue, FailsGracefullyForUnknownTypes) {
}
class CheckLValueToRValueConversionVisitor
- : public clang::RecursiveASTVisitor<CheckLValueToRValueConversionVisitor> {
+ : public clang::DynamicRecursiveASTVisitor {
public:
- bool VisitDeclRefExpr(const clang::DeclRefExpr *E) {
+ bool VisitDeclRefExpr(clang::DeclRefExpr *E) override {
clang::Expr::EvalResult Result;
E->EvaluateAsRValue(Result, E->getDecl()->getASTContext(), true);
diff --git a/clang/unittests/Analysis/CloneDetectionTest.cpp b/clang/unittests/Analysis/CloneDetectionTest.cpp
index 738f6efd2018d7..d0148a8c28c54e 100644
--- a/clang/unittests/Analysis/CloneDetectionTest.cpp
+++ b/clang/unittests/Analysis/CloneDetectionTest.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Analysis/CloneDetection.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Tooling/Tooling.h"
#include "gtest/gtest.h"
@@ -15,15 +15,14 @@ namespace clang {
namespace analysis {
namespace {
-class CloneDetectionVisitor
- : public RecursiveASTVisitor<CloneDetectionVisitor> {
+class CloneDetectionVisitor : public DynamicRecursiveASTVisitor {
CloneDetector &Detector;
public:
explicit CloneDetectionVisitor(CloneDetector &D) : Detector(D) {}
- bool VisitFunctionDecl(FunctionDecl *D) {
+ bool VisitFunctionDecl(FunctionDecl *D) override {
Detector.analyzeCodeBody(D);
return true;
}
diff --git a/clang/unittests/Frontend/FrontendActionTest.cpp b/clang/unittests/Frontend/FrontendActionTest.cpp
index 818e8cef27e51b..6ce9ba6f6a0888 100644
--- a/clang/unittests/Frontend/FrontendActionTest.cpp
+++ b/clang/unittests/Frontend/FrontendActionTest.cpp
@@ -9,7 +9,7 @@
#include "clang/Frontend/FrontendAction.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Basic/LangStandard.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
@@ -53,7 +53,7 @@ class TestASTFrontendAction : public ASTFrontendAction {
}
private:
- class Visitor : public ASTConsumer, public RecursiveASTVisitor<Visitor> {
+ class Visitor : public ASTConsumer, public DynamicRecursiveASTVisitor {
public:
Visitor(CompilerInstance &CI, bool ActOnEndOfTranslationUnit,
std::vector<std::string> &decl_names) :
@@ -67,7 +67,7 @@ class TestASTFrontendAction : public ASTFrontendAction {
TraverseDecl(context.getTranslationUnitDecl());
}
- virtual bool VisitNamedDecl(NamedDecl *Decl) {
+ bool VisitNamedDecl(NamedDecl *Decl) override {
decl_names_.push_back(Decl->getQualifiedNameAsString());
return true;
}
diff --git a/clang/unittests/Tooling/ASTSelectionTest.cpp b/clang/unittests/Tooling/ASTSelectionTest.cpp
index 113165f68449ca..1897bc15196ec2 100644
--- a/clang/unittests/Tooling/ASTSelectionTest.cpp
+++ b/clang/unittests/Tooling/ASTSelectionTest.cpp
@@ -26,7 +26,7 @@ struct FileLocation {
using FileRange = std::pair<FileLocation, FileLocation>;
-class SelectionFinderVisitor : public TestVisitor<SelectionFinderVisitor> {
+class SelectionFinderVisitor : public TestVisitor {
FileLocation Location;
std::optional<FileRange> SelectionRange;
llvm::function_ref<void(SourceRange SelectionRange,
@@ -42,7 +42,7 @@ class SelectionFinderVisitor : public TestVisitor<SelectionFinderVisitor> {
: Location(Location), SelectionRange(SelectionRange), Consumer(Consumer) {
}
- bool VisitTranslationUnitDecl(const TranslationUnitDecl *TU) {
+ bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) override {
const ASTContext &Context = TU->getASTContext();
const SourceManager &SM = Context.getSourceManager();
diff --git a/clang/unittests/Tooling/CRTPTestVisitor.h b/clang/unittests/Tooling/CRTPTestVisitor.h
new file mode 100644
index 00000000000000..67ae36b2e3ddd9
--- /dev/null
+++ b/clang/unittests/Tooling/CRTPTestVisitor.h
@@ -0,0 +1,42 @@
+//===--- TestVisitor.h ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief Defines a CRTP-based RecursiveASTVisitor helper for tests.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H
+#define LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H
+
+#include "TestVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+
+// CRTP versions of the visitors in TestVisitor.h.
+namespace clang {
+template <typename T>
+class CRTPTestVisitor : public RecursiveASTVisitor<T>,
+ public detail::TestVisitorHelper {
+public:
+ bool shouldVisitTemplateInstantiations() const { return true; }
+ bool shouldVisitImplicitCode() const { return true; }
+
+ void InvokeTraverseDecl(TranslationUnitDecl *D) override {
+ RecursiveASTVisitor<T>::TraverseDecl(D);
+ }
+};
+
+template <typename T>
+class CRTPExpectedLocationVisitor
+ : public CRTPTestVisitor<T>,
+ public detail::ExpectedLocationVisitorHelper {
+ ASTContext *getASTContext() override { return this->Context; }
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_UNITTESTS_TOOLING_CRTPTESTVISITOR_H
diff --git a/clang/unittests/Tooling/CastExprTest.cpp b/clang/unittests/Tooling/CastExprTest.cpp
index eab23a5a98e5d5..e5a8d994bf011b 100644
--- a/clang/unittests/Tooling/CastExprTest.cpp
+++ b/clang/unittests/Tooling/CastExprTest.cpp
@@ -12,17 +12,17 @@ using namespace clang;
namespace {
-struct CastExprVisitor : TestVisitor<CastExprVisitor> {
+struct CastExprVisitor : TestVisitor {
std::function<void(ExplicitCastExpr *)> OnExplicitCast;
std::function<void(CastExpr *)> OnCast;
- bool VisitExplicitCastExpr(ExplicitCastExpr *Expr) {
+ bool VisitExplicitCastExpr(ExplicitCastExpr *Expr) override {
if (OnExplicitCast)
OnExplicitCast(Expr);
return true;
}
- bool VisitCastExpr(CastExpr *Expr) {
+ bool VisitCastExpr(CastExpr *Expr) override {
if (OnCast)
OnCast(Expr);
return true;
diff --git a/clang/unittests/Tooling/CommentHandlerTest.cpp b/clang/unittests/Tooling/CommentHandlerTest.cpp
index 7eb11ccd6ee2d1..edfb72e2ec599b 100644
--- a/clang/unittests/Tooling/CommentHandlerTest.cpp
+++ b/clang/unittests/Tooling/CommentHandlerTest.cpp
@@ -22,12 +22,9 @@ struct Comment {
class CommentVerifier;
typedef std::vector<Comment> CommentList;
-class CommentHandlerVisitor : public TestVisitor<CommentHandlerVisitor>,
- public CommentHandler {
- typedef TestVisitor<CommentHandlerVisitor> base;
-
+class CommentHandlerVisitor : public TestVisitor, public CommentHandler {
public:
- CommentHandlerVisitor() : base(), PP(nullptr), Verified(false) {}
+ CommentHandlerVisitor() : PP(nullptr), Verified(false) {}
~CommentHandlerVisitor() override {
EXPECT_TRUE(Verified) << "CommentVerifier not accessed";
@@ -64,7 +61,7 @@ class CommentHandlerVisitor : public TestVisitor<CommentHandlerVisitor>,
CommentList Comments;
bool Verified;
- class CommentHandlerAction : public base::TestAction {
+ class CommentHandlerAction : public TestAction {
public:
CommentHandlerAction(CommentHandlerVisitor *Visitor)
: TestAction(Visitor) { }
diff --git a/clang/unittests/Tooling/ExecutionTest.cpp b/clang/unittests/Tooling/ExecutionTest.cpp
index 91ab8594f6823d..b0fd7ccb950ff4 100644
--- a/clang/unittests/Tooling/ExecutionTest.cpp
+++ b/clang/unittests/Tooling/ExecutionTest.cpp
@@ -9,7 +9,7 @@
#include "clang/Tooling/Execution.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/DeclCXX.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
@@ -30,12 +30,9 @@ namespace {
// This traverses the AST and outputs function name as key and "1" as value for
// each function declaration.
-class ASTConsumerWithResult
- : public ASTConsumer,
- public RecursiveASTVisitor<ASTConsumerWithResult> {
+class ASTConsumerWithResult : public ASTConsumer,
+ public DynamicRecursiveASTVisitor {
public:
- using ASTVisitor = RecursiveASTVisitor<ASTConsumerWithResult>;
-
explicit ASTConsumerWithResult(ExecutionContext *Context) : Context(Context) {
assert(Context != nullptr);
}
@@ -44,12 +41,12 @@ class ASTConsumerWithResult
TraverseDecl(Context.getTranslationUnitDecl());
}
- bool TraverseFunctionDecl(clang::FunctionDecl *Decl) {
+ bool TraverseFunctionDecl(clang::FunctionDecl *Decl) override {
Context->reportResult(Decl->getNameAsString(),
Context->getRevision() + ":" + Context->getCorpus() +
":" + Context->getCurrentCompilationUnit() +
"/1");
- return ASTVisitor::TraverseFunctionDecl(Decl);
+ return DynamicRecursiveASTVisitor::TraverseFunctionDecl(Decl);
}
private:
diff --git a/clang/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp b/clang/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
index 5d16595aec8014..b167eb4b811755 100644
--- a/clang/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
+++ b/clang/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -44,13 +44,14 @@ class LexicallyOrderedDeclVisitor
llvm::SmallVector<Decl *, 8> TraversalStack;
};
-class DummyMatchVisitor : public ExpectedLocationVisitor<DummyMatchVisitor> {
+class DummyMatchVisitor : public ExpectedLocationVisitor {
bool EmitDeclIndices, EmitStmtIndices;
public:
DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false)
: EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {}
- bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+
+ bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) override {
const ASTContext &Context = TU->getASTContext();
const SourceManager &SM = Context.getSourceManager();
LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices,
diff --git a/clang/unittests/Tooling/LookupTest.cpp b/clang/unittests/Tooling/LookupTest.cpp
index 2cf5ebb2a4cbd0..acd1714a26e071 100644
--- a/clang/unittests/Tooling/LookupTest.cpp
+++ b/clang/unittests/Tooling/LookupTest.cpp
@@ -13,31 +13,31 @@
using namespace clang;
namespace {
-struct GetDeclsVisitor : TestVisitor<GetDeclsVisitor> {
+struct GetDeclsVisitor : TestVisitor {
std::function<void(CallExpr *)> OnCall;
std::function<void(RecordTypeLoc)> OnRecordTypeLoc;
std::function<void(UsingTypeLoc)> OnUsingTypeLoc;
SmallVector<Decl *, 4> DeclStack;
- bool VisitCallExpr(CallExpr *Expr) {
+ bool VisitCallExpr(CallExpr *Expr) override {
if (OnCall)
OnCall(Expr);
return true;
}
- bool VisitRecordTypeLoc(RecordTypeLoc Loc) {
+ bool VisitRecordTypeLoc(RecordTypeLoc Loc) override {
if (OnRecordTypeLoc)
OnRecordTypeLoc(Loc);
return true;
}
- bool VisitUsingTypeLoc(UsingTypeLoc Loc) {
+ bool VisitUsingTypeLoc(UsingTypeLoc Loc) override {
if (OnUsingTypeLoc)
OnUsingTypeLoc(Loc);
return true;
}
- bool TraverseDecl(Decl *D) {
+ bool TraverseDecl(Decl *D) override {
DeclStack.push_back(D);
bool Ret = TestVisitor::TraverseDecl(D);
DeclStack.pop_back();
diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp
index 686d189cf69eb2..5ded64d4fcc8c5 100644
--- a/clang/unittests/Tooling/QualTypeNamesTest.cpp
+++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp
@@ -11,12 +11,12 @@
using namespace clang;
namespace {
-struct TypeNameVisitor : TestVisitor<TypeNameVisitor> {
+struct TypeNameVisitor : TestVisitor {
llvm::StringMap<std::string> ExpectedQualTypeNames;
bool WithGlobalNsPrefix = false;
// ValueDecls are the least-derived decl with both a qualtype and a name.
- bool VisitValueDecl(const ValueDecl *VD) {
+ bool VisitValueDecl(ValueDecl *VD) override {
std::string ExpectedName =
ExpectedQualTypeNames.lookup(VD->getNameAsString());
if (ExpectedName != "") {
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp
index d72a110d37e0fd..eed016e9ee7c24 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp
@@ -12,12 +12,12 @@ using namespace clang;
namespace {
-class VarDeclVisitor : public ExpectedLocationVisitor<VarDeclVisitor> {
+class VarDeclVisitor : public ExpectedLocationVisitor {
public:
- bool VisitVarDecl(VarDecl *Variable) {
- Match(Variable->getNameAsString(), Variable->getBeginLoc());
- return true;
- }
+ bool VisitVarDecl(VarDecl *Variable) override {
+ Match(Variable->getNameAsString(), Variable->getBeginLoc());
+ return true;
+ }
};
TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {
@@ -29,12 +29,11 @@ TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {
VarDeclVisitor::Lang_CXX11));
}
-class ParmVarDeclVisitorForImplicitCode :
- public ExpectedLocationVisitor<ParmVarDeclVisitorForImplicitCode> {
+class ParmVarDeclVisitorForImplicitCode : public ExpectedLocationVisitor {
public:
- bool shouldVisitImplicitCode() const { return true; }
+ ParmVarDeclVisitorForImplicitCode() { ShouldVisitImplicitCode = true; }
- bool VisitParmVarDecl(ParmVarDecl *ParamVar) {
+ bool VisitParmVarDecl(ParmVarDecl *ParamVar) override {
Match(ParamVar->getNameAsString(), ParamVar->getBeginLoc());
return true;
}
@@ -58,10 +57,9 @@ TEST(RecursiveASTVisitor, VisitsParmVarDeclForImplicitCode) {
"void bar(Y a) {Y b = a;}"));
}
-class NamedDeclVisitor
- : public ExpectedLocationVisitor<NamedDeclVisitor> {
+class NamedDeclVisitor : public ExpectedLocationVisitor {
public:
- bool VisitNamedDecl(NamedDecl *Decl) {
+ bool VisitNamedDecl(NamedDecl *Decl) override {
std::string NameWithTemplateArgs;
llvm::raw_string_ostream OS(NameWithTemplateArgs);
Decl->getNameForDiagnostic(OS,
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
index 8ac0604c09110a..481559ed08efdf 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
@@ -11,14 +11,12 @@
//
//===----------------------------------------------------------------------===//
-#include "TestVisitor.h"
+#include "CRTPTestVisitor.h"
using namespace clang;
namespace {
-
-class RecordingVisitor : public TestVisitor<RecordingVisitor> {
-
+class RecordingVisitor : public CRTPTestVisitor<RecordingVisitor> {
bool VisitPostOrder;
public:
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp
index a21186265db6a9..eec628ca396417 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp
@@ -12,9 +12,9 @@ using namespace clang;
namespace {
-class TypeLocVisitor : public ExpectedLocationVisitor<TypeLocVisitor> {
+class TypeLocVisitor : public ExpectedLocationVisitor {
public:
- bool VisitTypeLoc(TypeLoc TypeLocation) {
+ bool VisitTypeLoc(TypeLoc TypeLocation) override {
Match(TypeLocation.getType().getAsString(), TypeLocation.getBeginLoc());
return true;
}
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp
index 022ef8b8322868..7693e77236b0c4 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "TestVisitor.h"
+#include "CRTPTestVisitor.h"
using namespace clang;
@@ -14,7 +14,7 @@ namespace {
// Check to ensure that attributes and expressions within them are being
// visited.
-class AttrVisitor : public ExpectedLocationVisitor<AttrVisitor> {
+class AttrVisitor : public CRTPExpectedLocationVisitor<AttrVisitor> {
public:
bool VisitMemberExpr(MemberExpr *ME) {
Match(ME->getMemberDecl()->getNameAsString(), ME->getBeginLoc());
@@ -30,7 +30,6 @@ class AttrVisitor : public ExpectedLocationVisitor<AttrVisitor> {
}
};
-
TEST(RecursiveASTVisitor, AttributesAreVisited) {
AttrVisitor Visitor;
Visitor.ExpectMatch("Attr", 4, 24);
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
index c11e726fe85528..c1217179768ac2 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -14,10 +14,9 @@ using namespace clang;
namespace {
// Check to ensure that bitfield initializers are visited.
-class BitfieldInitializerVisitor
- : public ExpectedLocationVisitor<BitfieldInitializerVisitor> {
+class BitfieldInitializerVisitor : public ExpectedLocationVisitor {
public:
- bool VisitIntegerLiteral(IntegerLiteral *IL) {
+ bool VisitIntegerLiteral(IntegerLiteral *IL) override {
Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
return true;
}
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
index 1fb192dcda0863..4b0c4c31f2dd2e 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
@@ -12,10 +12,9 @@ using namespace clang;
namespace {
-class CXXBoolLiteralExprVisitor
- : public ExpectedLocationVisitor<CXXBoolLiteralExprVisitor> {
+class CXXBoolLiteralExprVisitor : public ExpectedLocationVisitor {
public:
- bool VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *BE) {
+ bool VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *BE) override {
if (BE->getValue())
Match("true", BE->getLocation());
else
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXMemberCall.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/CXXMemberCall.cpp
index c7b31e06e0e8e9..fe95...
[truncated]
|
CI on Windows seems to be broken trying to check out the branch: > git fetch -v --prune -- origin 0dd745286a124f7142d827810be5185abdc196cf
POST git-upload-pack (112 bytes)
From https://github.com/llvm/llvm-project
* branch 0dd745286a124f7142d827810be5185abdc196cf -> FETCH_HEAD
> git checkout -f 0dd745286a124f7142d827810be5185abdc196cf
error: unable to unlink old 'clang/lib/AST/Decl.cpp': Invalid argument
error: unable to unlink old 'clang/lib/Serialization/ASTReaderDecl.cpp': Invalid argument
HEAD is now at 0dd745286a12 [Tests] Refactor most tests to use the dynamic visitor |
ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though it may make sense to push a noop change to kickstart precommit CI into testing Windows before landing the changes.
…o use DynamicRecursiveASTVisitor (#115144) This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and `StaticAnalysis` to inherit from DRAV instead. This is over half of the visitors that inherit from RAV directly. See also #115132, #110040, #93462 LLVM Compile-Time Tracker link for this branch: https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
This pr refactors most tests that use RAV to use DRAV instead; this also has the nice effect of testing both the RAV and DRAV implementations at the same time w/o having to duplicate all of our AST visitor tests.
Some tests rely on features that DRAV doesn’t support (mainly post-order traversal), so those haven’t been migrated. At the same time,
TestVisitor
is now a DRAV, so I’ve had to introduce a newCTRPTestVisitor
for any tests that need to use RAV directly.