-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[ASTMatchers][NFC] use Matcher<QualType> instead of DynTypedMatcher in TypeLocTypeMatcher
#123450
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
There are no template in
|
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clang Author: Congcong Cai (HerrCai0907) ChangesThere are no template in Full diff: https://github.com/llvm/llvm-project/pull/123450.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 1ff61bae46b1ed..4448e9ccba80d9 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,6 +10,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"
using namespace clang::ast_matchers;
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 1f7b5e7cac8465..55a925bf869091 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1804,7 +1804,7 @@ class LocMatcher : public MatcherInterface<TLoc> {
///
/// Used to implement the \c loc() matcher.
class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
- DynTypedMatcher InnerMatcher;
+ Matcher<QualType> InnerMatcher;
public:
explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher)
@@ -1814,8 +1814,7 @@ class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
BoundNodesTreeBuilder *Builder) const override {
if (!Node)
return false;
- return this->InnerMatcher.matches(DynTypedNode::create(Node.getType()),
- Finder, Builder);
+ return this->InnerMatcher.matches(Node.getType(), Finder, Builder);
}
};
|
|
@llvm/pr-subscribers-clang-tidy Author: Congcong Cai (HerrCai0907) ChangesThere are no template in Full diff: https://github.com/llvm/llvm-project/pull/123450.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 1ff61bae46b1ed..4448e9ccba80d9 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -10,6 +10,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"
using namespace clang::ast_matchers;
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 1f7b5e7cac8465..55a925bf869091 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1804,7 +1804,7 @@ class LocMatcher : public MatcherInterface<TLoc> {
///
/// Used to implement the \c loc() matcher.
class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
- DynTypedMatcher InnerMatcher;
+ Matcher<QualType> InnerMatcher;
public:
explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher)
@@ -1814,8 +1814,7 @@ class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
BoundNodesTreeBuilder *Builder) const override {
if (!Node)
return false;
- return this->InnerMatcher.matches(DynTypedNode::create(Node.getType()),
- Finder, Builder);
+ return this->InnerMatcher.matches(Node.getType(), Finder, Builder);
}
};
|
Matcher<QualType> instead of DynTypedMatcher in TypeLocTypeMatcherMatcher<QualType> instead of DynTypedMatcher in TypeLocTypeMatcher
|
I don't really have enough experience with the AST matcher implementations to provide an authoritative review of this, sorry. I did do some digging in the code history, and found that
The base class has a It's not clear to me whether this change would regress the code size improvement brought by the first change. |
I test the binary size of clang-query before an after this change, there are no change. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12217 Here is the relevant piece of the build log for the reference |
There are no template in
TypeLocTypeMatcher. So we do not need to useDynTypedMatcherwhich can improve performance