Skip to content

Commit

Permalink
[clang][test] remove unused run overload in BoundNodesCallback
Browse files Browse the repository at this point in the history
The overload that did not take the additional `ASTContext *` argument is
unnecessary when the context could simply be commented out, as it is
always passed to `run` from `VerifyMatcher::run`.
This patch removes the single-argument overload in favor of having a
single overload.
  • Loading branch information
5chmidti committed Jul 12, 2024
1 parent 1383ace commit 26d5b03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 0 additions & 2 deletions clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,8 +2030,6 @@ TEST_P(ASTMatchersTest,
template <typename T>
class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
public:
bool run(const BoundNodes *Nodes) override { return false; }

bool run(const BoundNodes *Nodes, ASTContext *Context) override {
const T *Node = Nodes->getNodeAs<T>("");
return verify(*Nodes, *Context, Node);
Expand Down
7 changes: 1 addition & 6 deletions clang/unittests/ASTMatchers/ASTMatchersTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ using clang::tooling::runToolOnCodeWithArgs;
class BoundNodesCallback {
public:
virtual ~BoundNodesCallback() {}
virtual bool run(const BoundNodes *BoundNodes) = 0;
virtual bool run(const BoundNodes *BoundNodes, ASTContext *Context) = 0;
virtual void onEndOfTranslationUnit() {}
};
Expand Down Expand Up @@ -403,7 +402,7 @@ template <typename T> class VerifyIdIsBoundTo : public BoundNodesCallback {
EXPECT_EQ("", Name);
}

bool run(const BoundNodes *Nodes) override {
bool run(const BoundNodes *Nodes, ASTContext * /*Context*/) override {
const BoundNodes::IDToNodeMap &M = Nodes->getMap();
if (Nodes->getNodeAs<T>(Id)) {
++Count;
Expand All @@ -426,10 +425,6 @@ template <typename T> class VerifyIdIsBoundTo : public BoundNodesCallback {
return false;
}

bool run(const BoundNodes *Nodes, ASTContext *Context) override {
return run(Nodes);
}

private:
const std::string Id;
const int ExpectedCount;
Expand Down
15 changes: 4 additions & 11 deletions clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5641,7 +5641,6 @@ TEST(HasParent, MatchesAllParents) {
TEST(HasParent, NoDuplicateParents) {
class HasDuplicateParents : public BoundNodesCallback {
public:
bool run(const BoundNodes *Nodes) override { return false; }
bool run(const BoundNodes *Nodes, ASTContext *Context) override {
const Stmt *Node = Nodes->getNodeAs<Stmt>("node");
std::set<const void *> Parents;
Expand Down Expand Up @@ -5850,16 +5849,14 @@ template <typename T> class VerifyMatchOnNode : public BoundNodesCallback {
public:
VerifyMatchOnNode(StringRef Id, const internal::Matcher<T> &InnerMatcher,
StringRef InnerId)
: Id(Id), InnerMatcher(InnerMatcher), InnerId(InnerId) {
}

bool run(const BoundNodes *Nodes) override { return false; }
: Id(Id), InnerMatcher(InnerMatcher), InnerId(InnerId) {}

bool run(const BoundNodes *Nodes, ASTContext *Context) override {
const T *Node = Nodes->getNodeAs<T>(Id);
return selectFirst<T>(InnerId, match(InnerMatcher, *Node, *Context)) !=
nullptr;
nullptr;
}

private:
std::string Id;
internal::Matcher<T> InnerMatcher;
Expand Down Expand Up @@ -6053,7 +6050,7 @@ namespace {
class ForCallablePreservesBindingWithMultipleParentsTestCallback
: public BoundNodesCallback {
public:
bool run(const BoundNodes *BoundNodes) override {
bool run(const BoundNodes *BoundNodes, ASTContext *Context) override {
FunctionDecl const *FunDecl =
BoundNodes->getNodeAs<FunctionDecl>("funDecl");
// Validate test assumptions. This would be expressed as ASSERT_* in
Expand Down Expand Up @@ -6090,10 +6087,6 @@ class ForCallablePreservesBindingWithMultipleParentsTestCallback
return true;
}

bool run(const BoundNodes *BoundNodes, ASTContext *Context) override {
return run(BoundNodes);
}

private:
void ExpectCorrectResult(StringRef LogInfo,
ArrayRef<BoundNodes> Results) const {
Expand Down

0 comments on commit 26d5b03

Please sign in to comment.