Skip to content

Commit c928045

Browse files
committed
add missing comments on some matchers on the number of matches generated
1 parent e84f21a commit c928045

File tree

1 file changed

+55
-60
lines changed

1 file changed

+55
-60
lines changed

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ AST_POLYMORPHIC_MATCHER(isProtected,
811811
/// matches \match{struct Derived1 : private Base {}} and
812812
/// \match{class Derived2 : Base {}}, with
813813
/// \matcher{type=sub$cxxBaseSpecifier(isPrivate())} matching
814-
/// \match{sub=base;count=2$Base}.
814+
/// \match{sub=base;count=2$Base} each time.
815815
AST_POLYMORPHIC_MATCHER(isPrivate,
816816
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl,
817817
CXXBaseSpecifier)) {
@@ -1224,7 +1224,7 @@ AST_MATCHER_P_OVERLOAD(Expr, ignoringParens, internal::Matcher<Expr>,
12241224
/// The matcher \matcher{expr(isInstantiationDependent())}
12251225
/// matches \match{sizeof(T() + T())},
12261226
/// \match{(T() + T())},
1227-
/// \match{T() + T()} and \match{count=2$T()}.
1227+
/// \match{T() + T()} and two time \match{count=2$T()}.
12281228
AST_MATCHER(Expr, isInstantiationDependent) {
12291229
return Node.isInstantiationDependent();
12301230
}
@@ -2372,8 +2372,9 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBindTemporaryExpr>
23722372
/// \compile_args{-std=c++}
23732373
/// The matcher \matcher{materializeTemporaryExpr()} matches
23742374
/// \match{std=c++14-or-earlier;count=3$f()} three times before C++17 and it
2375-
/// matches \match{std=c++17-or-later$f()} time with C++17 and later, but
2376-
/// it does not match the \nomatch{f()} in the last line in any version.
2375+
/// matches \match{std=c++17-or-later$f()} one time with C++17 and later for
2376+
/// \c f().func() , but it does not match the \nomatch{f()} in the last line in
2377+
/// any version.
23772378
extern const internal::VariadicDynCastAllOfMatcher<Stmt,
23782379
MaterializeTemporaryExpr>
23792380
materializeTemporaryExpr;
@@ -4665,8 +4666,10 @@ AST_MATCHER(CXXRecordDecl, isLambda) {
46654666
/// \endcode
46664667
/// \compile_args{-std=c++}
46674668
/// The matcher \matcher{cxxRecordDecl(has(cxxRecordDecl(hasName("X"))))}
4668-
/// matches \match{count=3$class X {}} three times,
4669-
/// and \match{count=2$class Y { class X {}; }} two times.
4669+
/// matches \match{count=3$class X {}} three times for the definitions of \c X
4670+
/// that contain the implicit class declarations of \c X ,
4671+
/// and \match{count=2$class Y { class X {}; }} two times for the two different
4672+
/// definitions of \c Y that contain \c X .
46704673
///
46714674
/// ChildT must be an AST base type.
46724675
///
@@ -4698,8 +4701,10 @@ extern const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher> has;
46984701
/// \compile_args{-std=c++}
46994702
/// The matcher
47004703
/// \matcher{cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))}
4701-
/// matches \match{count=3$class X {}}, \match{count=2$class Y { class X {}; }}
4702-
/// and \match{class Z { class Y { class X {}; }; }}.
4704+
/// matches \match{count=3$class X {}} three times for the definitions of \c X
4705+
/// that contain the implicit class declarations of \c X ,
4706+
/// \match{count=2$class Y { class X {}; }} two times for the declaration of
4707+
/// \c X they contain, and \match{class Z { class Y { class X {}; }; }}.
47034708
///
47044709
/// DescendantT must be an AST base type.
47054710
///
@@ -4887,13 +4892,12 @@ extern const internal::ArgumentAdaptingMatcherFunc<
48874892
///
48884893
/// Given
48894894
/// \code
4890-
/// class X {};
4891-
/// class Y {};
4895+
/// int x;
4896+
/// int y = 0;
48924897
/// \endcode
48934898
/// \compile_args{-std=c++}
4894-
/// The matcher \matcher{cxxRecordDecl(unless(hasName("X")))}
4895-
/// matches \match{type=name;count=2$Y} twice, once for the definition
4896-
/// and once for the implicit class declaration.
4899+
/// The matcher \matcher{varDecl(unless(hasInitializer(expr())))}
4900+
/// matches \match{int x}, but not \nomatch{int y = 0}.
48974901
///
48984902
/// Usable as: Any Matcher
48994903
extern const internal::VariadicOperatorMatcherFunc<1, 1> unless;
@@ -7801,7 +7805,7 @@ AST_POLYMORPHIC_MATCHER_P(hasUnaryOperand,
78017805
/// \matcher{opaqueValueExpr(hasSourceExpression(
78027806
/// implicitCastExpr(has(
78037807
/// implicitCastExpr(has(declRefExpr()))))))}
7804-
/// matches \match{count=2$b} twice, for the conditiona and the true expression.
7808+
/// matches \match{count=2$b} twice, for the condition and the true expression.
78057809
AST_POLYMORPHIC_MATCHER_P(hasSourceExpression,
78067810
AST_POLYMORPHIC_SUPPORTED_TYPES(CastExpr,
78077811
OpaqueValueExpr),
@@ -7864,17 +7868,14 @@ AST_MATCHER_P(ImplicitCastExpr, hasImplicitDestinationType,
78647868
///
78657869
/// Example matches S, but not C, U or E.
78667870
/// \code
7867-
/// struct S {};
7868-
/// class C {};
7869-
/// union U {};
7870-
/// enum E { Ok };
7871+
/// struct S;
7872+
/// class C;
7873+
/// union U;
7874+
/// enum E;
78717875
/// \endcode
78727876
/// \compile_args{-std=c++}
7873-
/// The matcher \matcher{tagDecl(isStruct())}
7874-
/// matches \match{type=typestr;count=2$struct S},
7875-
/// but does not match \nomatch{type=typestr;count=2$class C},
7876-
/// \nomatch{type=typestr;count=2$union U}
7877-
/// or \nomatch{type=typestr;count=2$enum E}.
7877+
/// The matcher \matcher{tagDecl(isStruct())} matches \match{struct S},
7878+
/// but does not match \nomatch{class C}, \nomatch{union U} or \nomatch{enum E}.
78787879
AST_MATCHER(TagDecl, isStruct) {
78797880
return Node.isStruct();
78807881
}
@@ -7883,17 +7884,14 @@ AST_MATCHER(TagDecl, isStruct) {
78837884
///
78847885
/// Given
78857886
/// \code
7886-
/// struct S {};
7887-
/// class C {};
7888-
/// union U {};
7889-
/// enum E { Ok };
7887+
/// struct S;
7888+
/// class C;
7889+
/// union U;
7890+
/// enum E;
78907891
/// \endcode
78917892
/// \compile_args{-std=c++}
7892-
/// The matcher \matcher{tagDecl(isUnion())}
7893-
/// matches \match{type=typestr;count=2$union U},
7894-
/// does not match \nomatch{type=typestr;count=2$struct S},
7895-
/// \nomatch{type=typestr;count=2$class C}
7896-
/// or \nomatch{type=typestr;count=2$enum E}.
7893+
/// The matcher \matcher{tagDecl(isUnion())} matches \match{union U}, but does
7894+
/// not match \nomatch{struct S}, \nomatch{class C} or \nomatch{enum E}.
78977895
AST_MATCHER(TagDecl, isUnion) {
78987896
return Node.isUnion();
78997897
}
@@ -7902,17 +7900,14 @@ AST_MATCHER(TagDecl, isUnion) {
79027900
///
79037901
/// Given
79047902
/// \code
7905-
/// struct S {};
7906-
/// class C {};
7907-
/// union U {};
7908-
/// enum E { Ok };
7903+
/// struct S;
7904+
/// class C;
7905+
/// union U;
7906+
/// enum E;
79097907
/// \endcode
79107908
/// \compile_args{-std=c++}
7911-
/// The matcher \matcher{tagDecl(isClass())}
7912-
/// matches \match{type=typestr;count=2$class C},
7913-
/// but does not match \nomatch{type=typestr;count=2$struct S},
7914-
/// \nomatch{type=typestr;count=2$union U}
7915-
/// or \nomatch{type=typestr;count=2$enum E}.
7909+
/// The matcher \matcher{tagDecl(isClass())} matches \match{class C}, but does
7910+
/// not match \nomatch{struct S}, \nomatch{union U} or \nomatch{enum E}.
79167911
AST_MATCHER(TagDecl, isClass) {
79177912
return Node.isClass();
79187913
}
@@ -7921,16 +7916,14 @@ AST_MATCHER(TagDecl, isClass) {
79217916
///
79227917
/// Given
79237918
/// \code
7924-
/// struct S {};
7925-
/// class C {};
7926-
/// union U {};
7927-
/// enum E { Ok };
7919+
/// struct S;
7920+
/// class C;
7921+
/// union U;
7922+
/// enum E;
79287923
/// \endcode
79297924
/// \compile_args{-std=c++}
7930-
/// The matcher \matcher{tagDecl(isEnum())}
7931-
/// matches \match{count=1$enum E { Ok }},
7932-
/// but does not match \nomatch{count=2$struct S {}},
7933-
/// \nomatch{count=2$class C {}} or \nomatch{count=2$union U {}}.
7925+
/// The matcher \matcher{tagDecl(isEnum())} matches \match{enum E}, but does not
7926+
/// match \nomatch{struct S}, \nomatch{class C} or \nomatch{union U}.
79347927
AST_MATCHER(TagDecl, isEnum) {
79357928
return Node.isEnum();
79367929
}
@@ -9415,7 +9408,7 @@ extern const AstTypeMatcher<LValueReferenceType> lValueReferenceType;
94159408
///
94169409
/// The matcher \matcher{rValueReferenceType()} matches the type
94179410
/// \match{type=typestr$int &&} of \c c and the type
9418-
/// \match{type=typestr;count=2$auto &&} of \c f.
9411+
/// \match{type=typestr;count=2$auto &&} of \c e and \c f.
94199412
extern const AstTypeMatcher<RValueReferenceType> rValueReferenceType;
94209413

94219414
/// Narrows PointerType (and similar) matchers to those where the
@@ -9552,7 +9545,7 @@ extern const AstTypeMatcher<UnaryTransformType> unaryTransformType;
95529545
/// declaration of \c s.
95539546
/// Both of these types are matched three times, once for the type of the
95549547
/// variable, once for the definition of the class, and once for the type of the
9555-
/// injected class name.
9548+
/// implicit class declaration.
95569549
extern const AstTypeMatcher<RecordType> recordType;
95579550

95589551
/// Matches tag types (record and enum types).
@@ -9571,7 +9564,7 @@ extern const AstTypeMatcher<RecordType> recordType;
95719564
/// \match{type=typestr$enum E} of variable \c e and the type
95729565
/// \match{type=typestr;count=3;std=c++$class C} three times, once for the type
95739566
/// of the variable \c c , once for the type of the class definition and once of
9574-
/// the type in the injected class name.
9567+
/// the type in the implicit class declaration.
95759568
extern const AstTypeMatcher<TagType> tagType;
95769569

95779570
/// Matches types specified with an elaborated type keyword or with a
@@ -9594,10 +9587,10 @@ extern const AstTypeMatcher<TagType> tagType;
95949587
/// The matcher \matcher{elaboratedType()} matches the type
95959588
/// \match{type=typestr;count=3$C} three times. Once for the type of the
95969589
/// variable \c c, once for the type of the class definition and once for the
9597-
/// type in the injected class name. For \c{class D}, it matches
9590+
/// type in the implicit class declaration. For \c{class D}, it matches
95989591
/// \match{type=typestr$N::M::D} of variable \c d and its class definition and
9599-
/// injected class name
9600-
/// \match{type=typestr;count=2$D} one time respectively.
9592+
/// implicit class declaration \match{type=typestr;count=2$D} one time
9593+
/// respectively.
96019594
extern const AstTypeMatcher<ElaboratedType> elaboratedType;
96029595

96039596
/// Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
@@ -9737,7 +9730,8 @@ extern const AstTypeMatcher<InjectedClassNameType> injectedClassNameType;
97379730
/// matches \match{int i[]} in declaration of \c{f}.
97389731
/// The matcher
97399732
/// \matcher{expr(hasType(decayedType(hasDecayedType(pointerType()))))}
9740-
/// matches \match{count=2$i} in \c{i[1]}.
9733+
/// matches \match{count=2$i} twice, once for the \c DeclRefExpr and oncde for
9734+
/// the cast from an l- to an r-value in \c{i[1]}.
97419735
///
97429736
extern const AstTypeMatcher<DecayedType> decayedType;
97439737

@@ -9810,7 +9804,8 @@ extern const internal::VariadicAllOfMatcher<NestedNameSpecifier>
98109804
/// \compile_args{-std=c++}
98119805
///
98129806
/// The matcher \matcher{nestedNameSpecifierLoc()} matches
9813-
/// \match{count=2$A::} twice, and \match{ns::} once.
9807+
/// \match{count=2$A::} twice for the spellings in \c A::f() and \c ns::A ,
9808+
/// and \match{ns::} once.
98149809
extern const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc>
98159810
nestedNameSpecifierLoc;
98169811

@@ -9830,7 +9825,7 @@ extern const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc>
98309825
///
98319826
/// The matcher \matcher{nestedNameSpecifierLoc(loc(specifiesType(
98329827
/// hasDeclaration(namedDecl(hasName("A"))))))} matches \match{count=2$A::}
9833-
/// twice.
9828+
/// twice for the spellings in \c A::f() and \c ns::A .
98349829
AST_MATCHER_FUNCTION_P_OVERLOAD(
98359830
internal::BindableMatcher<NestedNameSpecifierLoc>, loc,
98369831
internal::Matcher<NestedNameSpecifier>, InnerMatcher, 1) {
@@ -9994,8 +9989,8 @@ AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type*, Other, 2) {
99949989
/// \matcher{switchStmt(forEachSwitchCase(caseStmt().bind("c")))}
99959990
/// matches four times, matching
99969991
/// \match{count=2$switch (1) { case 1: case 2: default: switch (2) { case 3:
9997-
/// case 4: ; } }} and
9998-
/// \match{count=2$switch (2) { case 3: case 4: ; }}, with
9992+
/// case 4: ; } }} twice and
9993+
/// \match{count=2$switch (2) { case 3: case 4: ; }} twice, with
99999994
/// \matcher{type=sub$caseStmt()} matching each of \match{sub=c$case 1:},
100009995
/// \match{sub=c$case 2:}, \match{sub=c$case 3:}
100019996
/// and \match{sub=c$case 4:}.

0 commit comments

Comments
 (0)