Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clang-tools-extra/clang-tidy/utils/Matchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions clang-tools-extra/clang-tidy/utils/Matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,28 @@ 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,
ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override;

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
Expand Down
Loading