mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-14 17:06:38 +00:00
[clang-tidy] matchesAnyListedTypeName
support non canonical types (#134869)
This commit is contained in:
parent
3ff634dee8
commit
302bc41410
@ -18,8 +18,9 @@ bool NotIdenticalStatementsPredicate::operator()(
|
||||
}
|
||||
|
||||
MatchesAnyListedTypeNameMatcher::MatchesAnyListedTypeNameMatcher(
|
||||
llvm::ArrayRef<StringRef> NameList)
|
||||
: NameMatchers(NameList.begin(), NameList.end()) {}
|
||||
llvm::ArrayRef<StringRef> NameList, bool CanonicalTypes)
|
||||
: NameMatchers(NameList.begin(), NameList.end()),
|
||||
CanonicalTypes(CanonicalTypes) {}
|
||||
|
||||
MatchesAnyListedTypeNameMatcher::~MatchesAnyListedTypeNameMatcher() = default;
|
||||
|
||||
@ -32,7 +33,7 @@ bool MatchesAnyListedTypeNameMatcher::matches(
|
||||
|
||||
PrintingPolicy PrintingPolicyWithSuppressedTag(
|
||||
Finder->getASTContext().getLangOpts());
|
||||
PrintingPolicyWithSuppressedTag.PrintCanonicalTypes = true;
|
||||
PrintingPolicyWithSuppressedTag.PrintCanonicalTypes = CanonicalTypes;
|
||||
PrintingPolicyWithSuppressedTag.SuppressElaboration = true;
|
||||
PrintingPolicyWithSuppressedTag.SuppressScope = false;
|
||||
PrintingPolicyWithSuppressedTag.SuppressTagKeyword = true;
|
||||
|
@ -172,7 +172,8 @@ AST_MATCHER_P(Stmt, isStatementIdenticalToBoundNode, std::string, ID) {
|
||||
class MatchesAnyListedTypeNameMatcher
|
||||
: public ast_matchers::internal::MatcherInterface<QualType> {
|
||||
public:
|
||||
explicit MatchesAnyListedTypeNameMatcher(llvm::ArrayRef<StringRef> NameList);
|
||||
explicit MatchesAnyListedTypeNameMatcher(llvm::ArrayRef<StringRef> NameList,
|
||||
bool CanonicalTypes);
|
||||
~MatchesAnyListedTypeNameMatcher() override;
|
||||
bool matches(
|
||||
const QualType &Node, ast_matchers::internal::ASTMatchFinder *Finder,
|
||||
@ -180,13 +181,19 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<llvm::Regex> NameMatchers;
|
||||
bool CanonicalTypes;
|
||||
};
|
||||
|
||||
// Returns a matcher that matches QualType against a list of provided regular.
|
||||
inline ::clang::ast_matchers::internal::Matcher<QualType>
|
||||
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList) {
|
||||
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList,
|
||||
bool CanonicalTypes) {
|
||||
return ::clang::ast_matchers::internal::makeMatcher(
|
||||
new MatchesAnyListedTypeNameMatcher(NameList));
|
||||
new MatchesAnyListedTypeNameMatcher(NameList, CanonicalTypes));
|
||||
}
|
||||
inline ::clang::ast_matchers::internal::Matcher<QualType>
|
||||
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList) {
|
||||
return matchesAnyListedTypeName(NameList, true);
|
||||
}
|
||||
|
||||
} // namespace clang::tidy::matchers
|
||||
|
Loading…
x
Reference in New Issue
Block a user