返回类型 | 名字 | 参数 |
---|---|---|
Matcher<attr> | attr | Matcher<Attr>... |
匹配属性.
属性
可附加各种不同的语法(包括关键字,C++11
属性,GNU'
的__attribute'''
和MSVC'
的__declspec''
,和''#pragma''等
).也可能是隐含
的.
给定
struct [[nodiscard]] Foo{};void bar(int * __attribute__((nonnull)) );__declspec(noinline) void baz();#pragma omp declare simdint min();
attr()
匹配"nodiscard","nonnull","noinline"
和整个"#pragma"
行.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<CXXBaseSpecifier> | cxxBaseSpecifier | Matcher<CXXBaseSpecifier>... |
匹配类基.
示例匹配公共虚B
.
class B {};class C : public virtual B {};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<CXXCtorInitializer> | cxxCtorInitializer | Matcher<CXXCtorInitializer>... |
匹配构造器初化器
示例匹配i(42)
.
class C {C() : i(42) {}int i;};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | accessSpecDecl | Matcher<AccessSpecDecl>... |
匹配C++
访问限定器声明.
给定
class C {public:int a;};
accessSpecDecl()
匹配'public'
:
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | bindingDecl | Matcher<BindingDecl>... |
匹配绑定声明
示例,匹配foo
和bar
,匹配器=bindingDecl()
auto [foo, bar] = std::make_pair{42, 42};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | blockDecl | Matcher<BlockDecl>... |
匹配块声明.
示例匹配
打印输入
整数的无名块
的声明.
myFunc(^(int p) {printf("%d", p);})
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | classTemplateDecl | Matcher<ClassTemplateDecl>... |
匹配C++
类模板声明.
示例匹配Z
template<class T> class Z {};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | classTemplatePartialSpecializationDecl | Matcher<ClassTemplatePartialSpecializationDecl>... |
匹配C++
类模板部分特化.
给定
template<class T1, class T2, int I>class A {};template<class T, int I>class A<T, T*, I> {};template<>class A<int, int, 1> {};
classTemplatePartialSpecializationDecl()
类TemplatePartialSpecializationDecl()
与A<T,T*,I>
特化匹配,但不匹配A<int,int,1>
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | classTemplateSpecializationDecl | Matcher<ClassTemplateSpecializationDecl>... |
匹配C++
类模板特化.
给定
template<typename T> class A {};template<> class A<double> {};A<int> a;
classTemplateSpecializationDecl()
类模板特化Decl()
匹配特化A<int>
和A<double>
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | conceptDecl | Matcher<ConceptDecl>... |
匹配概念声明.
示例:匹配
整数
template<typename T>concept integral = std::is_integral_v<T>;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxConstructorDecl | Matcher<CXXConstructorDecl>... |
匹配C++
构造器声明.
示例匹配Foo::Foo()
和Foo::Foo(int)
class Foo {public:Foo();Foo(int);int DoSomething();};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxConversionDecl | Matcher<CXXConversionDecl>... |
匹配转换符号声明.
示例匹配符号
.
class X { operator int() const; };
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxDeductionGuideDecl | Matcher<CXXDeductionGuideDecl>... |
匹配用户定义和隐式生成的推导.
示例匹配推导
.
template<typename T>class X { X(int) };X(int) -> X<int>;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxDestructorDecl | Matcher<CXXDestructorDecl>... |
匹配显式C++
析构器声明.
示例匹配Foo::~Foo()
class Foo {public:virtual ~Foo();};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxMethodDecl | Matcher<CXXMethodDecl>... |
匹配方法声明.
示例匹配y
class X { void y(); };
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | cxxRecordDecl | Matcher<CXXRecordDecl>... |
匹配C++
类声明.
示例匹配X,Z
class X;template<class T> class Z {};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | decl | Matcher<Decl>... |
匹配声明.
示例匹配X,C
和C
中的友
声明;
void X();class C {friend X;};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | declaratorDecl | Matcher<DeclaratorDecl>... |
匹配声明符声明(字段,变量,函数)和非类型模板参数声明.
给定
class X { int y; };
declaratorDecl()
匹配int y
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | decompositionDecl | Matcher<DecompositionDecl>... |
匹配分解声明.
示例,匹配foo
和bar
声明节点,但不匹配
数.
(匹配器=declStmt(has(decompositionDecl())))
)
int number = 42;auto [foo, bar] = std::make_pair{42, 42};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | enumConstantDecl | Matcher<EnumConstantDecl>... |
匹配枚举常量.
示例匹配A,B,C
enum X {A, B, C};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | enumDecl | Matcher<EnumDecl>... |
匹配枚举声明.
示例匹配X
enum X {A, B, C};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | fieldDecl | Matcher<FieldDecl>... |
匹配字段声明.
给定
class X { int m; };
fieldDecl()
字段匹配'm'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | friendDecl | Matcher<FriendDecl>... |
匹配友声明.
给定
class X { friend void foo(); };
friendDecl()
匹配friend void foo()
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | functionDecl | Matcher<functionDecl>... |
匹配函数声明.
示例匹配f
void f();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | functionTemplateDecl | Matcher<FunctionTemplateDecl>... |
匹配C++
函数模板声明.
示例匹配f
template<class T> void f(T t) {}
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | indirectFieldDecl | Matcher<IndirectFieldDecl>... |
匹配间接字段声明.
给定
struct X { struct { int a; }; };
indirectFieldDecl()
匹配'a'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | labelDecl | Matcher<LabelDecl>... |
匹配标签的声明.
给定
goto FOO;
FOO:bar();
labelDecl()
匹配'FOO:'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | linkageSpecDecl | Matcher<LinkageSpecDecl>... |
匹配链接规范的声明.
给定
extern "C" {}
linkageSpecDecl()
匹配"extern"C"{}"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | namedDecl | Matcher<NamedDecl>... |
匹配命名声明.
示例匹配X,S
,匿名i
联类型和U
;
typedef int X;struct S {union {int i;} U;};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | namespaceAliasDecl | Matcher<NamespaceAliasDecl>... |
匹配名字空间别名的声明.
给定
namespace test {}namespace alias = ::test;
namespaceAliasDecl()
匹配"alias
名字空间",但不匹配"测试
名字空间"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | namespaceDecl | Matcher<NamespaceDecl>... |
匹配名字空间的声明.
给定
namespace {}namespace test {}
namespaceDecl()
匹配"namespace{}"
和"namespace test{}"
,
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | nonTypeTemplateParmDecl | Matcher<NonTypeTemplateParmDecl>... |
匹配非类型模板参数声明.
给定
template <typename T, int N> struct C {};
nonTypeTemplateParmDecl()
匹配"N"
,但不匹配"T"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | parmVarDecl | Matcher<ParmVarDecl>... |
匹配参数变量声明.
给定
void f(int x);
parmVarDecl()
参数匹配int x
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | recordDecl | Matcher<RecordDecl>... |
匹配类,结构和联声明.
示例匹配X,Z,U
和S
.
class X;template<class T> class Z {};struct S {};union U {};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | staticAssertDecl | Matcher<StaticAssertDecl>... |
匹配C++static_assert
声明.
例:在
struct S {int x;};static_assert(sizeof(S) == sizeof(int));
中,staticAssertDecl()
匹配static_assert(sizeof(S)==sizeof(int))
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | tagDecl | Matcher<TagDecl>... |
匹配标记声明.
示例匹配X,Z,U,S,E
class X;template<class T> class Z {};struct S {};union U {};enum E {A, B, C};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | templateTemplateParmDecl | Matcher<TemplateTemplateParmDecl>... |
匹配模板模板参数声明.
给定
template <template <typename> class Z, int N> struct C {};
templateTypeParmDecl()
匹配"Z"
,但不匹配"N"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | templateTypeParmDecl | Matcher<TemplateTypeParmDecl>... |
匹配模板类型参数声明.
给定
template <typename T, int N> struct C {};
templateTypeParmDecl()
匹配"T"
,但不匹配"N"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | translationUnitDecl | Matcher<TranslationUnitDecl>... |
匹配顶部声明环境.
给定
int X;namespace NS {int Y;} //`NS`名字空间
decl(hasDeclContext(translationUnitDecl()))
匹配"int X"
,但不匹配"int Y"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | typeAliasDecl | Matcher<TypeAliasDecl>... |
匹配类型别名声明.
给定
typedef int X;using Y = int;
typeAliasDecl()
,匹配"using Y=int"
,但不匹配"typedef int X"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | typeAliasTemplateDecl | Matcher<TypeAliasTemplateDecl>... |
匹配类型别名模板声明.
typeAliasTemplateDecl()
匹配
template <typename T>using Y = X<T>;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | typedefDecl | Matcher<TypedefDecl>... |
匹配typedef
声明.
给定
typedef int X;using Y = int;
typedefDecl()
型匹配"typedef int X"
,但不匹配"using Y=int"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | typedefNameDecl | Matcher<TypedefNameDecl>... |
匹配typedef
名声明.
给定
typedef int X;using Y = int;
typedefNameDecl()
型,匹配"typedef int X"
和"using Y=int"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | unresolvedUsingTypenameDecl | Matcher<UnresolvedUsingTypenameDecl>... |
匹配未解析的包含型名的用型名声明
给定
template <typename T>struct Base { typedef T Foo; };template<typename T>struct S : private Base<T> {using typename Base<T>::Foo;};
unresolvedUsingTypenameDecl()
匹配using Base<T>::Foo
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | unresolvedUsingValueDecl | Matcher<UnresolvedUsingValueDecl>... |
匹配未解析用值声明.
给定
template<typename X>class C : private X {using X::x;};
unresolvedUsingValueDecl()
匹配using X::x
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | usingDecl | Matcher<UsingDecl>... |
匹配用声明.
给定
namespace X { int x; }using X::x;
usingDecl()
,匹配用 X::x
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | usingDirectiveDecl | Matcher<UsingDirectiveDecl>... |
匹配用名字空间声明.
给定
namespace X { int x; }using namespace X;
usingDirectiveDecl()
匹配用 名字空间 X
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | usingEnumDecl | Matcher<UsingEnumDecl>... |
匹配using-enum
声明.
给定
namespace X { enum x {...}; }using enum X::x;
usingEnumDecl()
,匹配用 枚举 X::x
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | valueDecl | Matcher<ValueDecl>... |
匹配值声明.
示例匹配A,B,C
和F
enum X { A, B, C };void F();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Decl> | varDecl | Matcher<VarDecl>... |
匹配变量声明.
注意:这不匹配
,Clang
中的"字段"
声明的成员变量
.
示例匹配
int a;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<λCapture> | λCapture | Matcher<λCapture>... |
匹配λ
抓.
给定
int main() {int x;auto f = [x](){};auto g = [x = 1](){};}
在'λExpr(hasAnyCapture(λCapture()))'
匹配器中,'λCapture()'
匹配'x'
和'x=1'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<NestedNameSpecifierLoc> | nestedNameSpecifierLoc | Matcher<NestedNameSpecifierLoc>... |
与nestedNameSpecifier
相同,但匹配NestedNameSpecifierLoc
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<NestedNameSpecifier> | nestedNameSpecifier | Matcher<NestedNameSpecifier>... |
匹配嵌套名限定器.
给定
namespace ns {struct A { static void f(); };void A::f() {}void g() { A::f(); }}ns::A a;
nestedNameSpecifier()
匹配"ns::"
和两个"A::"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<OMPClause> | ompDefaultClause | Matcher<OMPDefaultClause>... |
匹配OpenMP
的default
子句.
给定
#pragma omp parallel default(none)#pragma omp parallel default(shared)#pragma omp parallel default(private)#pragma omp parallel default(firstprivate)#pragma omp parallel
''ompDefaultClause()''
匹配''default(none)'',''default(shared)'',``''default(private)''
和''default(firstprivate)''
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<QualType> | qualType | Matcher<QualType>... |
匹配clangAST
中的QualTypes
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | addrLabelExpr | Matcher<AddrLabelExpr>... |
匹配label
语句(GNU
扩展名)的地址.
给定
FOO: bar();void *ptr = &&FOO;goto *bar;
addrLabelExpr()
匹配'&&FOO'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | arrayInitIndexExpr | Matcher<ArrayInitIndexExpr>... |
arrayInitIndexExpr
由两个子式
组成:一个预先计算一次的公共式(源数组)
,及对每个数组元素
运行一次的每元素初化器
.在每元素初化器
中,可通过ArrayInitIndexExpr
取当前索引
.
给定
void testStructBinding() {int a[2] = {1, 2};auto [x, y] = a;}
arrayInitIndexExpr()
匹配,在"a"
数组上的隐式迭代的数组索引
,来复制每个元素
到匿名数组
,来支持结构化绑定"[x,y]"
元素.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | arrayInitLoopExpr | Matcher<ArrayInitLoopExpr>... |
匹配多个环境中初化数组元素的循环:
1,在有数组成员
的类的隐式复制/移动
构造器中
2,λ式
按值抓数组时
3,分解
声明分解
数组时
给定
void testλCapture() {int a[10];auto Lam1 = [a]() {return;};}
在表示按值抓的"a"
数组的λ
对象中,arrayInitLoopExpr()
匹配初化隐式数组字段
的隐式循环
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | arraySubscriptExpr | Matcher<ArraySubscriptExpr>... |
匹配数组下标式.
给定
int i = a[1];
arraySubscriptExpr()
匹配"a[1]"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | asmStmt | Matcher<AsmStmt>... |
匹配asm
语句.
int i = 100;__asm("mov al, 2");
asmStmt()
匹配'__asm("moval,2")'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | atomicExpr | Matcher<AtomicExpr>... |
匹配原子内置.
示例匹配__atomic_load_n(ptr,1)
void foo() { int *ptr; __atomic_load_n(ptr, 1); }
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | binaryConditionalOperator | Matcher<BinaryConditionalOperator>... |
匹配二元条件符号式(GNU扩展).
示例匹配a:b
(a : b) + 42;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | binaryOperator | Matcher<BinaryOperator>... |
匹配二元符号式.
示例匹配a||b
!(a || b)
另见binaryOperation()
匹配器以取更通用
匹配.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | blockExpr | Matcher<BlockExpr>... |
匹配块引用.
示例:匹配"^{}"
:
void f() { ^{}(); }
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | breakStmt | Matcher<BreakStmt>... |
匹配中断语句.
给定
while (true) { break; }
breakStmt()
匹配"break"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cStyleCastExpr | Matcher<CStyleCastExpr>... |
匹配C风格转换式.
int i = (int) 2.2f;
示例:匹配(int)2.2f
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | callExpr | Matcher<CallExpr>... |
匹配调用式.
示例匹配x.y()
和y()
X x;x.y();y();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | caseStmt | Matcher<CaseStmt>... |
匹配switch
语句中的case
语句.
给定
switch(a) { case 42: break; default: break; }
caseStmt()
匹配'case42:'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | castExpr | Matcher<CastExpr>... |
匹配Clang
的AST
的转换节点.
示例:castExpr()
匹配以下各项
:
(int) 3;const_cast<Expr *>(SubExpr);char c = 0;
但不匹配
int i = (0);int k = 0;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | characterLiteral | Matcher<CharacterLiteral>... |
匹配符字面(也匹配wchar_t
).
但,不匹配十六进制
编码的符(如0x1234
,它是IntegerLiteral
),
示例匹配'a',L'a'
char ch = 'a';wchar_t chw = L'a';
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | chooseExpr | Matcher<ChooseExpr>... |
匹配GNU__builtin_choose_expr
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | coawaitExpr | Matcher<CoawaitExpr>... |
匹配co_await
式.
给定
co_await 1;
coawaitExpr()
匹配'co_await 1'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | compoundLiteralExpr | Matcher<CompoundLiteralExpr>... |
匹配复合(即非标量)字面
示例匹配:{1},(1,2)
int array[4] = {1};vector int myvec = (vector int)(1, 2);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | compoundStmt | Matcher<CompoundStmt>... |
匹配复合语句.
示例匹配'for(;;)
中的'{}'
和'{{}}'{{}}'
.
for (;;) {{}}
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | conditionalOperator | Matcher<ConditionalOperator>... |
匹配条件符号式.
示例,匹配a?b:c
(a ? b : c) + 42
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | constantExpr | Matcher<ConstantExpr>... |
匹配常量式包装器.
示例匹配case
语句中的常量
:
(匹配器=constantExpr()
)
switch (a) {case 37: break;}
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | continueStmt | Matcher<ContinueStmt>... |
匹配继续语句.
给定
while (true) { continue; }
continueStmt()
匹配"继续(continue)"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | convertVectorExpr | Matcher<ConvertVectorExpr>... |
匹配内置函数__builtin_convertvector
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | coreturnStmt | Matcher<CoreturnStmt>... |
匹配co_return
语句.
给定
while (true) { co_return; }
coreturnStmt()
匹配'co_return'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | coroutineBodyStmt | Matcher<CoroutineBodyStmt>... |
匹配协程体语句.
coroutineBodyStmt()
匹配下面协程
:
generator<int> gen() {co_return;}
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | coyieldExpr | Matcher<CoyieldExpr>... |
匹配co_yield
式.
给定
co_yield 1;
coyieldExpr()
匹配'co_yield1'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cudaKernelCallExpr | Matcher<CUDAKernelCallExpr>... |
匹配CUDA
内核调用式.
示例匹配,
kernel<<<i,j>>>();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxBindTemporaryExpr | Matcher<CXXBindTemporaryExpr>... |
匹配创建临时的节点.
示例匹配FunctionTakesString(GetStringByValue()
)
(匹配器=cxxBindTemporaryExpr()
)
FunctionTakesString(GetStringByValue());FunctionTakesStringByPointer(GetStringPointer());
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxBoolLiteral | Matcher<CXXBoolLiteralExpr>... |
匹配bool
字面.
示例匹配true
,真
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxCatchStmt | Matcher<CXXCatchStmt>... |
匹配catch
语句.
try {} catch(int i) {}
cxxCatchStmt()
匹配'catch(int i)'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxConstCastExpr | Matcher<CXXConstCastExpr>... |
匹配const_cast
式.
示例:匹配const_cast<int*>(&r)
int n = 42;const int &r(n);int* p = const_cast<int*>(&r);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxConstructExpr | Matcher<CXXConstructExpr>... |
匹配构造器调用式(包括隐式调用).
示例在f
的参数中,匹配string(ptr,n)
和ptr
,(匹配器=cxxConstructExpr()
)
void f(const string &a, const string &b);char *ptr;int n;f(string(ptr, n), ptr);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxDefaultArgExpr | Matcher<CXXDefaultArgExpr>... |
匹配调用点上的默认参数值.
示例匹配,在f(42)
调用式中,插入的第二个
参数的默认值的CXXDefaultArgExpr
占位符.
(匹配器=cxxDefaultArgExpr()
)
void f(int x, int y = 0);f(42);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxDeleteExpr | Matcher<CXX>... |
匹配删除式.
给定
delete X;
cxxDeleteExpr()
匹配delete X
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxDependentScopeMemberExpr | Matcher<CXXDependentScopeMemberExpr>... |
匹配无法解析实际引用
成员的成员式
因为,给定基式
或成员名
是依赖
的.
给定
template <class T> void f() { T t; t.g(); }
cxxDependentScopeMemberExpr()
匹配t.g
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxDynamicCastExpr | Matcher<CXXDynamicCastExpr>... |
匹配dynamic_cast
式.
例:
在
struct B { virtual ~B() {} }; struct D : B {};B b;D* p = dynamic_cast<D*>(&b);
中,cxxDynamicCastExpr()
匹配dynamic_cast<D*>(&b);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxFoldExpr | Matcher<CXXFoldExpr>... |
匹配C++17
个折叠式.
示例匹配'(0+...+args)'
:
template <typename... Args>auto sum(Args... args) {return (0 + ... + args);}
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxForRangeStmt | Matcher<CXXForRangeStmt>... |
匹配基于区间的for
语句.
cxxForRangeStmt()
匹配'for(auto a:i)'
int i[] = {1, 2, 3}; for (auto a : i);for(int j = 0; j < 5; ++j);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxFunctionalCastExpr | Matcher<CXXFunctionalCastExpr>... |
匹配函数转换式
示例:匹配Foo(bar);
Foo f = bar;Foo g = (Foo) bar;Foo h = Foo(bar);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxMemberCallExpr | Matcher<CXXMemberCallExpr>... |
匹配成员调用式.
示例匹配x.y()
X x;x.y();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxNewExpr | Matcher<CXXNewExpr>... |
匹配新式.
给定
new X;
cxxNewExpr()
匹配"新 X"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxNoexceptExpr | Matcher<CXXNoexceptExpr>... |
匹配noexcept
式.
给定
bool a() noexcept;bool b() noexcept(true);bool c() noexcept(false);bool d() noexcept(noexcept(a()));bool e = noexcept(b()) || noexcept(c());
cxxNoexceptExpr()
匹配'noexcept(a())','noexcept(b())'
和'noexcept(c())'
.
不匹配a,b,c
或d
声明中的noexcept
限定器.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxNullPtrLiteralExpr | Matcher<CXXNullPtrLiteralExpr>... |
匹配nullptr
字面.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxOperatorCallExpr | Matcher<CXXOperatorCallExpr>... |
匹配重载的符号调用.
注意,如果未重载符号
,则不会匹配.相反,请使用binaryOperator
匹配器.
目前,不匹配new delete
等符号.
待办
:找出不匹配
原因
示例同时匹配符号<<((o<<b),c)
和符号<<(o,b)
.
(匹配器=cxxOperatorCallExpr()
)
ostream &operator<< (ostream &out, int i) { };ostream &o; int b = 1, c = 1;o << b << c;
另见binaryOperation()
匹配器,了解匹配此AST
节点更通用
二元用法.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxReinterpretCastExpr | Matcher<CXXReinterpretCastExpr>... |
匹配reinterpret_cast
式.
用has()
可匹配源式
或目标类型
,但hasDestinationType()
更具体,更可读.
void* p = reinterpret_cast<char*>(&p);
中,匹配reinterpret_cast<char*>(&p)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxRewrittenBinaryOperator | Matcher<CXXRewrittenBinaryOperator>... |
匹配重写的二元符号
示例匹配"<"
的用法:
#include <compare>struct HasSpaceshipMem {int a;constexpr auto operator<=>(const HasSpaceshipMem&) const = default;};void compare() {HasSpaceshipMem hs1, hs2;if (hs1 < hs2)return;}
另见binaryOperation()
匹配器以取此AST
节点更通用
匹配.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxStaticCastExpr | Matcher<CXXStaticCastExpr>... |
匹配C++static_cast
式.
另见:hasDestinationType
见:reinterpretCast
例:在
long eight(static_cast<long>(8));
中,cxxStaticCastExpr()
匹配
static_cast<long>(8)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxStdInitializerListExpr | Matcher<CXXStdInitializerListExpr>... |
匹配C++
初化器列表式.
给定
std::vector<int> a({ 1, 2, 3 });std::vector<int> b = { 4, 5 };int c[] = { 6, 7 };std::pair<int, int> d = { 8, 9 };
cxxStdInitializerListExpr()
匹配"{1,2,3}"
和"{4,5}"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxTemporaryObjectExpr | Matcher<CXXTemporaryObjectExpr>... |
匹配有N!=1
个参数的函数转换式
示例:匹配Foo(bar,bar)
Foo h = Foo(bar, bar);
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxThisExpr | Matcher<CXXThisExpr>... |
匹配隐式和显式此式.
示例与"return i"
中隐式的this
式匹配.
(匹配器=cxxThisExpr()
)
struct foo {int i;int f() { return i; }
};
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxThrowExpr | Matcher<CXXThrowExpr>... |
匹配抛式.
try { throw 5; } catch(int i) {}
cxxThrowExpr()
匹配'throw 5'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxTryStmt | Matcher<CXXTryStmt>... |
匹配try
语句.
try {} catch(int i) {}
cxxTryStmt()
匹配'try{}'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | cxxUnresolvedConstructExpr | Matcher<CXXUnresolvedConstructExpr>... |
匹配未解析的构造器调用式.
示例匹配f
的return
语句中的T(t)
.(匹配器=cxxUnresolvedConstructExpr()
)
template <typename T>void f(const T& t) { return T(t); }
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | declRefExpr | Matcher<DeclRefExpr>... |
匹配引用声明的式.
bool x;if (x) {}
示例匹配if(x)
中的x
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | declStmt | Matcher<DeclStmt>... |
匹配声明语句.
给定
int a;
declStmt()
匹配'int a'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | defaultStmt | Matcher<DefaultStmt>... |
匹配switch
语句中的默认语句.
给定
switch(a) { case 42: break; default: break; }
defaultStmt()
匹配'default:'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | dependentCoawaitExpr | Matcher<DependentCoawaitExpr>... |
匹配promise
类型依赖的co_await
式
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | designatedInitExpr | Matcher<DesignatedInitExpr>... |
匹配C99
指定的初化器式[C996.7.8]
.
示例:匹配{[2].y=1.0,[0].x=1.0}
point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | doStmt | Matcher<DoStmt>... |
匹配do
语句.
给定
do {} while (true);
doStmt()
匹配'do{}while(true)'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | explicitCastExpr | Matcher<ExplicitCastExpr>... |
匹配显式转换式.
匹配用户代码
中编写的转换式
,无论它是C风格
转换,函数式
转换或关键字
转换.不匹配隐式转化
.
注意:选择"explicitCast"
名字,是为了匹配Clang
,因为Clang
使用"转换"
来表示隐式转换
及实际转换式
.
另见:hasDestinationType
.
示例:匹配所有以下五个转换
:
int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))
但不匹配:
long ell = 42;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | expr | Matcher<Expr>... |
匹配式.
示例匹配x()
void f() { x(); }
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | exprWithCleanups | Matcher<ExprWithCleanups>... |
匹配引入要在子式求值尾运行的清理式
const std::string str = std::string();
示例匹配std::string()
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | fixedPointLiteral | Matcher<FixedPointLiteral>... |
匹配固定点字面
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | floatLiteral | Matcher<FloatingLiteral>... |
匹配所有大小/编码的浮点字面,如
1.0,1.0f,1.0L
和1e10
.不匹配隐式转换
,如
float a = 10;
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | forStmt | Matcher<ForStmt>... |
匹配for语句.
for (;;) {}int i[] = {1, 2, 3}; for (auto a : i);
示例匹配'for(;;){}'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | genericSelectionExpr | Matcher<GenericSelectionExpr>... |
匹配C11_Generic
式.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | gnuNullExpr | Matcher<GNUNullExpr>... |
匹配GNU__null
式.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | gotoStmt | Matcher<GotoStmt>... |
匹配goto
语句.
给定
goto FOO;FOO: bar();
gotoStmt()
匹配'goto FOO'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | ifStmt | Matcher<IfStmt>... |
匹配if
语句.
if (x) {}
示例匹配'if(x){}'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | imaginaryLiteral | Matcher<ImaginaryLiteral>... |
匹配基于整数和浮点数
的虚数字面和浮点字面,如:1i,1.0i
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | implicitCastExpr | Matcher<ImplicitCastExpr>... |
匹配Clang
的AST
的隐式转换节点.
这匹配包括消除
函数调用返回值,及转换类型
等许多不同的位置
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | implicitValueInitExpr | Matcher<ImplicitValueInitExpr>... |
匹配initlist
式的隐式初化器.
给定
point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
implicitValueInitExpr()
匹配"[0].y"
(隐式)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | initListExpr | Matcher<InitListExpr>... |
匹配initlist
式.
给定
int a[] = { 1, 2 };struct B { int x, y; };B b = { 5, 6 };
initListExpr()
,匹配"{1,2}"
和"{5,6}"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | integerLiteral | Matcher<IntegerLiteral>... |
匹配所有大小/编码的整数字面,如1,1L,0x1
和1U.
不匹配符编码
的整数(如L'a'
).
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | labelStmt | Matcher<LabelStmt>... |
匹配label
语句.
给定
goto FOO;
FOO: bar();
labelStmt()
匹配'FOO:'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | λExpr | Matcher<λExpr>... |
匹配λ
式.
[&](){return 5;}
示例匹配[&](){return 5;}
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | materializeTemporaryExpr | Matcher<MaterializeTemporaryExpr>... |
匹配具体化临时对象的节点.
示例:给定
struct T {void func();};T f();void g(T);
materializeTemporaryExpr()
匹配"f()"
.
T u(f());g(f());f().func();
但不匹配
f();
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | memberExpr | Matcher<MemberExpr>... |
匹配成员式.
给定
class Y {void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }int a; static int b;};
memberExpr()
匹配this->x,x,y.x,a,this->b
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | nullStmt | Matcher<NullStmt>... |
匹配null
语句.
foo();;
nullStmt()
匹配第二个";"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | ompExecutableDirective | Matcher<OMPExecutableDirective>... |
匹配"#pragma omp"
可执行指令.
给定
#pragma omp parallel#pragma omp parallel default(none)#pragma omp taskyield
''ompExecutableDirective()''
匹配''ompparallel'',
,''ompparalleldefault(none)''
和''omptaskyield''.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | opaqueValueExpr | Matcher<OpaqueValueExpr>... |
匹配不透明的值式.用作引用另一个式
的帮手,可在如BinaryConditionalOperators
中满足.
(a : c) + 42;
示例匹配'a'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | parenExpr | Matcher<ParenExpr>... |
匹配式中使用的括号.
int foo() { return 1; }int a = (foo() + 1);
示例匹配(foo()+1)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | parenListExpr | Matcher<ParenListExpr>... |
匹配parenlist
式.
ParenListExprs
没有预定义类型
,用来后期分析
.在最终的AST
中,可在模板声明
中遇见它们.
给定
template<typename T> class X {void f() {X x(*this);int a = 0, b = 1; int i = (a, b);}};
parenListExpr()
匹配"*this"
,但不匹配(a,b)
,因为(a,b)
有预定义类型
,且是ParenExpr
,而不是ParenListExpr
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | predefinedExpr | Matcher<PredefinedExpr>... |
匹配预定义的标识式[C996.4.2.2]
.
printf("%s", __func__);
示例:匹配__func__
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | returnStmt | Matcher<ReturnStmt>... |
匹配return
语句.
给定
return 1;
returnStmt()
匹配'return 1'
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | stmt | Matcher<Stmt>... |
匹配语句.
给定
{ ++a; }
stmt()
匹配'{++a;}'
和'++a'
复合语句.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | stmtExpr | Matcher<StmtExpr>... |
匹配语句式(GNU扩展).
int C = ({ int X = 4; X; });
匹配示例:({int X=4;X;})
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | stringLiteral | Matcher<StringLiteral>... |
匹配串字面(也匹配宽串字面).
char *s = "abcd";wchar_t *ws = L"abcd";
示例匹配"abcd",L"abcd"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | substNonTypeTemplateParmExpr | Matcher<SubstNonTypeTemplateParmExpr>... |
匹配非类型模板参数的替换.
给定
template <int N>struct A { static const int n = N; };struct B : public A<42> {};
substNonTypeTemplateParmExpr()
匹配"static const int n=N;"
右侧的"N"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | switchCase | Matcher<SwitchCase>... |
匹配switch
语句中的case
和default
语句.
给定
switch(a) { case 42: break; default: break; }
switchCase()
匹配'case42:'
和'default:'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | switchStmt | Matcher<SwitchStmt>... |
匹配switch
语句.
给定
switch(a) { case 42: break; default: break; }
switchStmt()
匹配'switch(a)'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | unaryExprOrTypeTraitExpr | Matcher<UnaryExprOrTypeTraitExpr>... |
匹配sizeof(C99),alignof(C++11)
和vec_step(OpenCL)
给定
Foo x = bar;int y = sizeof(x) + alignof(x);
unaryExprOrTypeTraitExpr()
匹配sizeof(x)
和alignof(x)
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | unaryOperator | Matcher<UnaryOperator>... |
匹配一元符号式.
!a || b
示例匹配!a
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | unresolvedLookupExpr | Matcher<UnresolvedLookupExpr>... |
匹配解析过程中可查找名字的引用,但不能解析为具体的声明.
给定
template<typename T>T foo() { T a; return a; }template<typename T>void bar() {foo<T>();}
unresolvedLookupExpr()
匹配foo<T>()
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | unresolvedMemberExpr | Matcher<UnresolvedMemberExpr>... |
匹配未解析的成员式.
给定
struct X {template <class T> void f();void g();};template <class T> void h() { X x; x.f<T>(); x.g(); }
unresolvedMemberExpr()
匹配x.f<T>
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | userDefinedLiteral | Matcher<UserDefinedLiteral>... |
匹配用户定义的字面符号调用.
匹配示例:"foo"_suffix
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Stmt> | whileStmt | Matcher<WhileStmt>... |
匹配while
语句.
给定
while (true) {}
whileStmt()
匹配'while(true){}'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TemplateArgumentLoc> | templateArgumentLoc | Matcher<TemplateArgumentLoc>... |
匹配模板参数(包含位置信息).
给定
template <typename T> struct C {};C<int> c;
templateArgumentLoc()
匹配C<int>
中的"int"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TemplateArgument> | templateArgument | Matcher<TemplateArgument>... |
匹配模板参数.
给定
template <typename T> struct C {};C<int> c;
模板参数(templateArgument)()
匹配C<int>
中的"int"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TemplateName> | templateName | Matcher<TemplateName>... |
匹配模板名.
给定
template <typename T> class X { };X<int> xi;
templateName()
匹配X<int>
中的"X"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | elaboratedTypeLoc | Matcher<ElaboratedTypeLoc>... |
匹配C或C++
精心设计的"TypeLoc"
.
给定
struct s {};struct s ss;
elaboratedTypeLoc()
匹配'ss'
变量声明的'TypeLoc'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | pointerTypeLoc | Matcher<PointerTypeLoc>... |
匹配指针"TypeLoc"
.
给定
int* x;
pointerTypeLoc()
匹配'int*'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | qualifiedTypeLoc | Matcher<QualifiedTypeLoc>... |
匹配clangAST
中的"QualifiedTypeLoc"
.
给定
const int x = 0;
qualifiedTypeLoc()
匹配'const int'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | referenceTypeLoc | Matcher<ReferenceTypeLoc>... |
匹配引用"TypeLoc"
.
给定
int x = 3;int& l = x;int&& r = 3;
referenceTypeLoc()
匹配'int&'
和'int&&'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | templateSpecializationTypeLoc | Matcher<TemplateSpecializationTypeLoc>... |
匹配模板特化"TypeLoc".
给定
template <typename T> class C {};C<char> var;
varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
匹配'C<char>var'
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<TypeLoc> | typeLoc | Matcher<TypeLoc>... |
匹配clangAST
中的TypeLocs
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | arrayType | Matcher<ArrayType>... |
匹配各种数组.
给定
int a[] = { 2, 3 };int b[4];void f() { int c[a[0]]; }
arrayType()
匹配"int a[]","int b[4]"
和"int c[a[0]]";
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | atomicType | Matcher<AtomicType>... |
匹配原子类型.
给定
_Atomic(int) i;
atomicType()
匹配"_Atomic(int)i"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | autoType | Matcher<AutoType>... |
匹配表示C++11
自动类型的类型节点.
给定:
auto n = 4;int v[] = { 2, 3 }for (auto i : v) { }
autoType()
函数匹配"auto n"
和"auto i"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | blockPointerType | Matcher<BlockPointerType>... |
匹配块指针类型,即按"void (^)(int)"
表示
被指
总是要求是FunctionType
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | builtinType | Matcher<BuiltinType>... |
匹配内置类型.
给定
struct A {};A a;int b;float c;bool d;
内置类型(builtinType)()
匹配"int b","float c"
和"bool d"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | complexType | Matcher<ComplexType>... |
匹配C99
复杂类型.
给定
_Complex float f;
complexType()
匹配"_Complex float f"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | constantArrayType | Matcher<ConstantArrayType>... |
匹配带指定常量大小的C数组.
给定
void() {int a[2];int b[] = { 2, 3 };int c[b[0]];}
constantArrayType()
匹配"int a[2]"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | decayedType | Matcher<DecayedType>... |
匹配降级类型
void f(int i[]) {i[1] = 0;}
示例
,在f
的声明中匹配i[]
.
(匹配器=valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
(匹配器=expr(hasType(decayedType(hasDecayedType(pointerType())))))
示例匹配i[1]
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | decltypeType | Matcher<DecltypeType>... |
匹配表示C++11decltype(<expr>)
类型的类型节点.
给定:
short i = 1;int j = 42;decltype(i + j) result = i + j;
decltypeType()
匹配"decltype(i+j)"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | deducedTemplateSpecializationType | Matcher<DeducedTemplateSpecializationType>... |
匹配C++17
推导的模板特化类型,如推导类模板类型.
给定
template <typename T>class C { public: C(T); };C c(123);
deducedTemplateSpecializationType()
匹配,在c变量
中声明的类型
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | dependentSizedArrayType | Matcher<DependentSizedArrayType>... |
匹配大小与值相关的式的C++
数组.
给定
template<typename T, int Size>class array {T data[Size];};
dependentSizedArrayType()
匹配"Tdata[Size]"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | dependentSizedExtVectorType | Matcher<DependentSizedExtVectorType>... |
匹配类型或大小相关的C++
扩展向量类型
给定
template<typename T, int Size>class vector {typedef T __attribute__((ext_vector_type(Size))) type;};
dependentSizedExtVectorType()
,匹配"T __attribute__((ext_vector_type(Size))))"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | elaboratedType | Matcher<ElaboratedType>... |
匹配用详细类型关键字或全名.
给定
namespace N {namespace M {class D {};}}class C {};class C c;N::M::D d;
elaboratedType()
匹配c
和d
变量声明类型
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | enumType | Matcher<EnumType>... |
匹配枚举类型.
给定
enum C { Green };enum class S { Red };C c;S s;
enumType()
匹配c
和s
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | functionProtoType | Matcher<FunctionProtoType>... |
匹配FunctionProtoType
节点.
给定
int (*f)(int);void g();
functionProtoType()
匹配"int(*f)(int)"
和C++
模式下的"g"
类型.
在C模式下,因为不包含原型
,不匹配"g"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | functionType | Matcher<FunctionType>... |
匹配FunctionType
节点.
给定
int (*f)(int);void g();
函数类型(functionType)()
匹配"int(*f)(int)"
和"g"
的类型.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | incompleteArrayType | Matcher<IncompleteArrayType>... |
匹配未指定大小的C数组.
给定
int a[] = { 2, 3 };int b[42];void f(int c[]) { int d[a[0]]; };
incompleteArrayType()
匹配"int a[]"
和"int c[]"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | injectedClassNameType | Matcher<InjectedClassNameType>... |
匹配注入的类名类型.
template <typename T> struct S {void f(S s);void g(S<T> s);};
示例匹配S s
,但不匹配S<T>s
.
(匹配器=parmVarDecl(hasType(injectedClassNameType())))
)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | lValueReferenceType | Matcher<LValueReferenceType>... |
匹配左值引用类型.
给定:
int *a;int &b = *a;int &&c = 1;auto &d = b;auto &&e = c;auto &&f = 2;int g = 5;
lValueReferenceType()
匹配b,d
和e
的类型.因为按引用
折叠规则推导为int&
,因此匹配e
类型.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | macroQualifiedType | Matcher<MacroQualifiedType>... |
通过宏应用限定符时,匹配限定符.
给定
#define CDECL __attribute__((cdecl))typedef void (CDECL *X)();typedef void (__attribute__((cdecl)) *Y)();
macroQualifiedType()
匹配X
的typedef
声明的类型,但不匹配Y
的.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | memberPointerType | Matcher<MemberPointerType>... |
匹配成员指针类型.
给定
struct A { int i; }A::* ptr = A::i;
memberPointerType()
,匹配"A::*ptr"
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | parenType | Matcher<ParenType>... |
匹配ParenType
节点.
给定
int (*ptr_to_array)[4];int *array_of_ptrs[4];
varDecl(hasType(pointsTo(parenType())))
匹配ptr_to_array
但不匹配array_of_ptrs
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | pointerType | Matcher<PointerType>... |
匹配指针类型,但不匹配Objective-C
对象指针类型.
给定
int *a;int &b = *a;int c = 5;@interface Foo@endFoo *f;
pointerType()
匹配"int*a"
,但不匹配"Foo*f"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | rValueReferenceType | Matcher<RValueReferenceType>... |
匹配右值引用类型.
给定:
int *a;int &b = *a;int &&c = 1;auto &d = b;auto &&e = c;auto &&f = 2;int g = 5;
rValueReferenceType()
与c和f
类型匹配.e
按引用折叠规则
推导为int&
,因此不匹配
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | recordType | Matcher<RecordType>... |
匹配记录类型(如结构,类).
给定
class C {};struct S {};C c;S s;
recordType()
与c
和s
变量声明类型匹配
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | referenceType | Matcher<ReferenceType>... |
匹配左值和右值引用类型.
给定
int *a;int &b = *a;int &&c = 1;auto &d = b;auto &&e = c;auto &&f = 2;int g = 5;
referenceType()
匹配b,c,d,e
和f
类型.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | substTemplateTypeParmType | Matcher<SubstTemplateTypeParmType>... |
匹配表示替换模板类型参数
类型结果的类型.
给定
template <typename T>void F(T t) {int i = 1 + t;}
substTemplateTypeParmType()
与"t"
的类型匹配,但与"1"
不匹配
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | tagType | Matcher<TagType>... |
匹配标记类型(记录和枚举类型).
给定
enum E {};class C {};E e;C c;
tagType()
与e
和c
变量声明类型匹配
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | templateSpecializationType | Matcher<TemplateSpecializationType>... |
匹配模板特化类型.
给定
template <typename T>class C { };template class C<int>; //`AB`C<char> var; //
templateSpecializationType()
匹配A
中的显式实例化
和B
中变量声明的类型
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | templateTypeParmType | Matcher<TemplateTypeParmType>... |
匹配模板类型参数类型.
template <typename T> void f(int i);
示例匹配T
,但不匹配int
.(匹配器=templateTypeParmType()
)
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | type | Matcher<Type>... |
匹配clangAST
中的类型.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | typedefType | Matcher<TypedefType>... |
匹配typedef
类型.
给定
typedef int X;
typedefType()
型匹配"typedef int X"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | unaryTransformType | Matcher<UnaryTransformType>... |
匹配表示一元类型转换的类型节点.
给定:
typedef __underlying_type(T) type;
unaryTransformType()
匹配"__underlying_type(T)"
.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | usingType | Matcher<UsingType>... |
匹配通过using
声明指定的类型.
给定
namespace a { struct S {}; }using a::S;S s;
usingType()
匹配s变量声明
的类型.
返回类型 | 名字 | 参数 |
---|---|---|
Matcher<Type> | variableArrayType | Matcher<VariableArrayType>... |
匹配指定大小不为整数常量式
的C数组.
给定
void f() {int a[] = { 2, 3 }int b[42];int c[a[0]];}
variableArrayType()
匹配"int c[a[0]]"
.