Skip to content

Commit e9cb878

Browse files
committed
rm not needed typeofstr match kind
1 parent 72cf581 commit e9cb878

File tree

3 files changed

+11
-34
lines changed

3 files changed

+11
-34
lines changed

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,10 +1588,10 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
15881588
///
15891589
/// The matcher \matcher{cxxDeductionGuideDecl()}
15901590
/// matches the written deduction guide
1591-
/// \match{type=typeofstr$auto (int) -> X<int>},
1592-
/// the implicit copy deduction guide \match{type=typeofstr$auto (int) -> X<T>}
1591+
/// \match{type=typestr$auto (int) -> X<int>},
1592+
/// the implicit copy deduction guide \match{type=typestr$auto (int) -> X<T>}
15931593
/// and the implicitly declared deduction guide
1594-
/// \match{type=typeofstr$auto (X<T>) -> X<T>}.
1594+
/// \match{type=typestr$auto (X<T>) -> X<T>}.
15951595
extern const internal::VariadicDynCastAllOfMatcher<Decl, CXXDeductionGuideDecl>
15961596
cxxDeductionGuideDecl;
15971597

@@ -10116,7 +10116,7 @@ AST_MATCHER(CXXConstructorDecl, isDelegatingConstructor) {
1011610116
/// The matcher \matcher{cxxDeductionGuideDecl(isExplicit())}
1011710117
/// matches the deduction guide \match{explicit S(double) -> S<false>},
1011810118
/// the implicit copy deduction candiate
10119-
/// \match{type=typeofstr$auto (double) -> S<b>} and
10119+
/// \match{type=typestr$auto (double) -> S<b>} and
1012010120
/// the implicitly generated deduction guide for \match{explicit(true) S(char)},
1012110121
/// but does not match \nomatch{S(int) -> S<true>}.
1012210122
AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(
@@ -10156,7 +10156,7 @@ AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(
1015610156
/// The matcher
1015710157
/// \matcher{cxxDeductionGuideDecl(hasExplicitSpecifier(declRefExpr()))}
1015810158
/// matches the implicitly generated deduction guide
10159-
/// \match{type=typeofstr$auto (float) -> S<b>} of the constructor
10159+
/// \match{type=typestr$auto (float) -> S<b>} of the constructor
1016010160
/// \c{explicit(b) S(float)}.
1016110161
AST_MATCHER_P(FunctionDecl, hasExplicitSpecifier, internal::Matcher<Expr>,
1016210162
InnerMatcher) {

clang/unittests/ASTMatchers/ASTMatchersTest.h

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ enum class MatchKind {
596596
Code,
597597
Name,
598598
TypeStr,
599-
TypeOfStr,
600599
};
601600

602601
inline llvm::StringRef toString(const MatchKind Kind) {
@@ -607,8 +606,6 @@ inline llvm::StringRef toString(const MatchKind Kind) {
607606
return "Name";
608607
case MatchKind::TypeStr:
609608
return "TypeStr";
610-
case MatchKind::TypeOfStr:
611-
return "TypeOfStr";
612609
}
613610
llvm_unreachable("Unhandled MatchKind");
614611
}
@@ -651,8 +648,6 @@ template <typename T> class VerifyBoundNodeMatch : public BoundNodesCallback {
651648
return getNameText(Node, EmitFailures);
652649
case MatchKind::TypeStr:
653650
return getTypeStrText(Node, EmitFailures);
654-
case MatchKind::TypeOfStr:
655-
return getTypeOfStrText(Node, EmitFailures);
656651
}
657652
}
658653

@@ -695,27 +690,14 @@ template <typename T> class VerifyBoundNodeMatch : public BoundNodesCallback {
695690
getTypeStrText(const U *const Node, const bool EmitFailures = true) {
696691
if constexpr (std::is_base_of_v<Type, U>)
697692
return QualType(Node, 0).getAsString();
698-
if constexpr (std::is_base_of_v<Decl, U>)
693+
if constexpr (std::is_base_of_v<Decl, U>) {
699694
if (const auto *const TDecl = llvm::dyn_cast<TypeDecl>(Node))
700695
return getTypeStrText(TDecl->getTypeForDecl());
701-
702-
if (EmitFailures)
703-
ADD_FAILURE() << "Match kind is 'TypeStr', but node of type 'U' is "
704-
"not handled.";
705-
return std::nullopt;
706-
}
707-
708-
template <typename U>
709-
static std::optional<std::string>
710-
getTypeOfStrText(const U *const Node, const bool EmitFailures = true) {
711-
if constexpr (std::is_base_of_v<Decl, U>) {
712696
if (const auto *const VDecl = llvm::dyn_cast<ValueDecl>(Node))
713697
return VDecl->getType().getAsString();
714-
} else if constexpr (std::is_base_of_v<Expr, U>)
715-
return Node->getType().getAsString();
716-
698+
}
717699
if (EmitFailures)
718-
ADD_FAILURE() << "Match kind is 'TypeOfStr', but node of type 'U' is "
700+
ADD_FAILURE() << "Match kind is 'TypeStr', but node of type 'U' is "
719701
"not handled.";
720702
return std::nullopt;
721703
}
@@ -823,8 +805,8 @@ template <typename T> class VerifyBoundNodeMatch : public BoundNodesCallback {
823805
static std::string getPossibleMatchStrings(const T *Node,
824806
const ASTContext &Context) {
825807
std::string MatchStrings{"\n"};
826-
for (const auto Kind : {MatchKind::Code, MatchKind::Name,
827-
MatchKind::TypeStr, MatchKind::TypeOfStr})
808+
for (const auto Kind :
809+
{MatchKind::Code, MatchKind::Name, MatchKind::TypeStr})
828810
MatchStrings +=
829811
llvm::formatv("\tMatchKind: {0}: '{1}',\n", toString(Kind),
830812
Match::getMatchText(Node, Context, Kind, false)

clang/utils/generate_ast_matcher_doc_tests.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,12 @@ class MatchType(Enum):
496496
Name: Use the name of the matched node to check if it matches
497497
TypeStr: Use the string representation of the matched type to check if
498498
it matches
499-
TypeOfStr: Use the string representation of the type of a matched node
500-
to check if it matches
501499
"""
502500

503501
Invalid = 0
504502
Code = 1
505503
Name = 2
506504
TypeStr = 3
507-
TypeOfStr = 4
508505

509506

510507
def get_match_type(match: Match) -> MatchType:
@@ -515,9 +512,7 @@ def get_match_type(match: Match) -> MatchType:
515512
return MatchType.Code
516513
if match_type == "typestr":
517514
return MatchType.TypeStr
518-
if match_type == "typeofstr":
519-
return MatchType.TypeOfStr
520-
print(f"match {match} has an invalid match type, tags: {match.tags}")
515+
print(f"match {match} has an invalid match type: {match_type}")
521516
statistics["match_type_invalid"] += 1
522517
return MatchType.Invalid
523518

0 commit comments

Comments
 (0)