Skip to content

Commit 51de627

Browse files
committed
[clang][test] remove unused run overload in BoundNodesCallback
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.
1 parent 1383ace commit 51de627

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,8 +2030,6 @@ TEST_P(ASTMatchersTest,
20302030
template <typename T>
20312031
class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
20322032
public:
2033-
bool run(const BoundNodes *Nodes) override { return false; }
2034-
20352033
bool run(const BoundNodes *Nodes, ASTContext *Context) override {
20362034
const T *Node = Nodes->getNodeAs<T>("");
20372035
return verify(*Nodes, *Context, Node);

clang/unittests/ASTMatchers/ASTMatchersTest.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ using clang::tooling::runToolOnCodeWithArgs;
2828
class BoundNodesCallback {
2929
public:
3030
virtual ~BoundNodesCallback() {}
31-
virtual bool run(const BoundNodes *BoundNodes) = 0;
3231
virtual bool run(const BoundNodes *BoundNodes, ASTContext *Context) = 0;
3332
virtual void onEndOfTranslationUnit() {}
3433
};
@@ -403,7 +402,7 @@ template <typename T> class VerifyIdIsBoundTo : public BoundNodesCallback {
403402
EXPECT_EQ("", Name);
404403
}
405404

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

429-
bool run(const BoundNodes *Nodes, ASTContext *Context) override {
430-
return run(Nodes);
431-
}
432-
433428
private:
434429
const std::string Id;
435430
const int ExpectedCount;

clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5641,7 +5641,6 @@ TEST(HasParent, MatchesAllParents) {
56415641
TEST(HasParent, NoDuplicateParents) {
56425642
class HasDuplicateParents : public BoundNodesCallback {
56435643
public:
5644-
bool run(const BoundNodes *Nodes) override { return false; }
56455644
bool run(const BoundNodes *Nodes, ASTContext *Context) override {
56465645
const Stmt *Node = Nodes->getNodeAs<Stmt>("node");
56475646
std::set<const void *> Parents;
@@ -5850,16 +5849,14 @@ template <typename T> class VerifyMatchOnNode : public BoundNodesCallback {
58505849
public:
58515850
VerifyMatchOnNode(StringRef Id, const internal::Matcher<T> &InnerMatcher,
58525851
StringRef InnerId)
5853-
: Id(Id), InnerMatcher(InnerMatcher), InnerId(InnerId) {
5854-
}
5855-
5856-
bool run(const BoundNodes *Nodes) override { return false; }
5852+
: Id(Id), InnerMatcher(InnerMatcher), InnerId(InnerId) {}
58575853

58585854
bool run(const BoundNodes *Nodes, ASTContext *Context) override {
58595855
const T *Node = Nodes->getNodeAs<T>(Id);
58605856
return selectFirst<T>(InnerId, match(InnerMatcher, *Node, *Context)) !=
5861-
nullptr;
5857+
nullptr;
58625858
}
5859+
58635860
private:
58645861
std::string Id;
58655862
internal::Matcher<T> InnerMatcher;

0 commit comments

Comments
 (0)