srcML v1.0.0 C++ Documentation

Base Elements XML Element Subelements
comment <comment type="block|line" format="javadoc|doxygen">
escape <escape char="0xXX">
literal <literal type="number|char|string|boolean|complex|null">
name <name> <name>, <operator>
Statements XML Element Subelements
block <block> <block_content>
break statement <break>
case statement <case> <expr>
continue statement <continue>
default statement <default>
do while statement <do> <block> <condition>
empty statement <empty_stmt>
expr_stmt <expr_stmt> <expr>
for statement <for> <control> <block>
forever <forever> <expr_stmt>, <block>
goto statement <goto> <name>
if statement <if_stmt> <if> <else> <if type="elseif">
label <label> <name>
return statement <return> <expr>
switch statement <switch> <condition> <case> <block>
while statement <while> <condition> <block>
Statement Subelements XML Element Subelements
block_content <block_content>
capture <capture> <argument>
condition <condition> <expr>
control <control> <init> <condition> <incr>
else <else> <block>
else if <else type="elsif> <condition> <block>
expression <expr> <name>, <operator>, <call>, <ternary>
if <if> <condition> <block>
incr <incr> <expr>
then <then> <expr>
type <type> <specifier>, <name>
Specifiers XML Element Subelements
auto specifier <specifier>
auto type <name>
const <specifier>
constexpr <specifier>
default specifier <specifier>
delete specifier <specifier>
explicit <specifier>
extern block <extern> <literal>, <function_decl>, <decl_stmt>, <block>
extern specifier <specifier>
final <specifier>
friend <friend>
inline <specifier>
mutable <specifier>
override <specifier>
r-value reference <ref_qualifier>
register <specifier>
restrict <specifier>
static <specifier>
template specifier <specifier>
thread_local <specifier>
virtual <specifier>
volatile <specifier>
Declarations, Definitions, and Initializations XML Element Subelements
abstract function declaration <literal type="number">
array declaration <decl> <name>, <index>
array initialization <init> <block>
bitfield <range> <expr>
default function parameters <init> <expr>
explicit conversion operator declaration <function_decl type="operator"> <type> <name> <parameter_list>
explicit conversion operator definition <function type="operator"> <type> <name> <parameter_list> <block>
function declaration <function_decl> <type> <name> <parameter_list>
function definition <function> <type> <name> <parameter_list> <block>
implicit conversion operator declaration <function_decl type="operator"> <name> <parameter_list>
implicit conversion operator definition <function type="operator"> <name> <parameter_list> <block>
lambda functions <lambda> <capture> <parameter_list> <type> <block>
namespace <namespace> <name> <block>
operator overloading declaration <function_decl type="operator"> <type> <name> <parameter_list>
operator overloading definition <function type="operator"> <type> <name> <parameter_list> <block>
pointer declaration <modifier>
reference declaration <modifier>
rvalue reference <modifier>
typedef <typedef> <type> <name> <function_decl>
uniform initialization syntax <call> <block>
using <using> <name>
variable declaration <decl> <name> <init>
variable declaration statement <decl_stmt> <decl>
Classes, Structs, Unions, and Enums XML Element Subelements
class declaration <class_decl> <name>
class definition <class> <name> <super_list> <block>
constructor <constructor> <name> <parameter_list> <member_list> <block>
constructor declaration <constructor_decl> <specifier> <name> <parameter_list>
destructor <destructor> <name>
destructor declaration <destructor_decl> <name>
enum class <enum type="class">
enum class declaration <enum_decl type="class">
enum declaration <enum_decl> <name>
enum declaration <enum_decl> <name>
enum definition <enum> <name> <block>
inheritance list <super_list> <super>
private access specifier <private>
private default access specifier <private type="default">
private inheritance specifier <specifier>
protected access specifier <protected>
protected inheritance specifier <specifier>
public access specifier <public>
public default access specifier <public type="default">
public inheritance specifier <specifier>
struct declaration <struct_decl> <name>
struct definition <struct> <name> <super> <block>
struct initialization <decl_stmt> <decl>, <init>, <block>
union declaration <union_decl> <name>
union definition <union> <name> <block>
Expressions XML Element Subelements
array index <index> <expr>
delete <operator>
dereference member access <expr> <name>, <operator>
function call <call> <name> <argument_list>
member access <expr> <name>, <operator>
new <operator>
ternary operator <ternary> <condition> <then> <else>
this <name>
Other XML Element Subelements
alignas <alignas> <argument_list>
alignof <alignof> <argument_list>
asm <asm>
attribute <attribute> <expr>
cast: const_cast <cast type="const"> <argument_list>
cast: dynamic_cast <cast type="dynamic"> <argument_list>
cast: reinterpret_cast <cast type="reinterpret"> <argument_list>
cast: static_cast <cast type="static"> <argument_list>
decltype <decltype> <argument_list>
noexcept <noexcept> <argument_list>
sizeof <sizeof> <argument_list>, <name>
sizeof... <sizeof type="pack"> <argument_list>, <name>
static_assert <assert type="static"> <argument_list>
typeid <typeid> <argument_list>
Templates XML Element Subelements
class type specifier <typename>
template <template> <parameter_list>, <parameter>, <typename>
template parameter pack <modifier>
template parameters <parameter_list> <param>
typename <typename>
Exceptions XML Element Subelements
catch <catch> <parameter_list>
function try-catch <try> <catch>, <block>, <member_list>
throw <throw> <expr>
try <try> <block> <catch>
OpenMP XML Element Subelements
omp:argument <omp:argument> <omp:expr>
omp:argument_list <omp:argument_list> <omp:argument>
omp:clause <omp:clause> <omp:name> <omp:argument_list>
omp:directive <omp:directive> <omp:name> <omp:clause>
omp:expr <omp:expr>
omp:name <omp:name>

abstract function declaration


Element

  • <literal type="number">

XPath Query

  • abstract function declarations

    //src:function_decl[src:literal = 0]

Example

struct Foo {
	virtual void dump() const = 0;
};
<struct>struct <name>Foo</name> <block>{<public type="default">
	<function_decl><type><specifier>virtual</specifier> <name>void</name></type> <name>dump</name><parameter_list>()</parameter_list> <specifier>const</specifier> = <literal type="number">0</literal>;</function_decl>
</public>}</block>;</struct>

alignas


Element

  • <alignas>

Subelement

  • <argument_list>

XPath Query

  • uses of alignas

    //src:alignas

Example

alignas(MyType);
<decl_stmt><decl><type><alignas>alignas<argument_list>(<argument><expr><name>MyType</name></expr></argument>)</argument_list></alignas></type></decl>;</decl_stmt>

alignof


Element

  • <alignof>

Subelement

  • <argument_list>

XPath Query

  • uses of alignof

    //src:alignof

Example

alignof(T);
<expr_stmt><expr><alignof>alignof<argument_list>(<argument><expr><name>T</name></expr></argument>)</argument_list></alignof></expr>;</expr_stmt>

asm


Element

  • <asm>

XPath Query

  • uses of asm

    //src:asm

Examples

asm("movl %ebx, %eax");
<asm>asm("movl %ebx, %eax");</asm>
__asm__("movl %ebx, %eax");
<asm>__asm__("movl %ebx, %eax");</asm>
__asm { __asm mov al, 2  __asm mov dx, 0xD007 __asm out dx, al }
<asm>__asm { <asm>__asm mov al, 2</asm>  <asm>__asm mov dx, 0xD007</asm> <asm>__asm out dx, al</asm> }</asm>

attribute


Element

  • <attribute>

Subelement

  • <expr>

XPath Queries

  • attributes

    //src:attribute
  • noreturn functions

    //src:function[src:attribute/src:expr/src:name='noreturn']

Examples

[[noreturn]] void std::exit() { }
<function><attribute>[[<expr><name>noreturn</name></expr>]]</attribute> <type><name>void</name></type> <name><name>std</name><operator>::</operator><name>exit</name></name><parameter_list>()</parameter_list> <block>{<block_content> </block_content>}</block></function>
[[noreturn]]
<attribute>[[<expr><name>noreturn</name></expr>]]</attribute>

auto specifier


Element

  • <specifier>

XPath Query

  • auto variables

    //src:decl[src:type/src:specifier='auto']

Example

auto int x;
<decl_stmt><decl><type><specifier>auto</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>

auto type


Element

  • <name>

XPath Query

  • variable declarations with auto as their type

    //src:decl[src:type/src:name='auto']

Examples

auto temp() -> int { }
<function><type><name>auto</name></type> <name>temp</name><parameter_list>()</parameter_list> -&gt; <type><name>int</name></type> <block>{<block_content> </block_content>}</block></function>
auto i = 5;
<decl_stmt><decl><type><name>auto</name></type> <name>i</name> <init>= <expr><literal type="number">5</literal></expr></init></decl>;</decl_stmt>

bitfield


Element

  • <range>

Subelement

  • <expr>

XPath Query

  • bitfield declarations

    //src:decl[src:range]

Example

struct mybitfields
{
    int a : 5;
} test;
<struct>struct <name>mybitfields</name>
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>a</name> <range>: <expr><literal type="number">5</literal></expr></range></decl>;</decl_stmt>
}</block> <decl><name>test</name></decl>;</struct>

block


Element

  • <block>

Subelement

  • <block_content>

XPath Queries

  • blocks

    //src:block
  • variable declarations in a block

    //src:block//src:decl_stmt
  • top-level variable declarations in a block

    //src:block/src:block_content/src:decl_stmt

Example

 {
    line[i] = x;
    x++;
    i--;
}
 <block>{<block_content>
    <expr_stmt><expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name>x</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>x</name><operator>++</operator></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block>

block_content


Element

  • <block_content>

XPath Queries

  • block contents

    //src:block_content
  • declaration block_contents

    //src:decl/src:block/src:block_content
  • function block_contents

    //src:function/src:block/src:block_content

capture


Element

  • <capture>

Subelement

  • <argument>

XPath Queries

  • lambda captures

    //src:capture
  • capture arguments

    //src:capture/src:argument
  • empty captures

    //src:capture[not(src:argument)]
  • captures with this argument

    //src:capture[src:argument/src:name='this']

Example

[](){};

[state](){};

[state,count](){};

[=](){};

[&state](){};

[this](){};

[&state, this](){};
<expr_stmt><expr><lambda><capture>[]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><name>state</name></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><name>state</name></argument>,<argument><name>count</name></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><modifier>=</modifier></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><modifier>&amp;</modifier><name>state</name></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><name>this</name></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

<expr_stmt><expr><lambda><capture>[<argument><modifier>&amp;</modifier><name>state</name></argument>, <argument><name>this</name></argument>]</capture><parameter_list>()</parameter_list><block>{<block_content/>}</block></lambda></expr>;</expr_stmt>

case statement


Element

  • <case>

Subelement

  • <expr>

XPath Queries

  • case labels

    //src:case
  • case labels that use SATURDAY

    //src:case[.//src:name = 'SATURDAY']
  • switch statements with a case that uses SATURDAY

    //src:switch[src:block/src:block_content/src:case//src:name='SATURDAY']

Example

case SATURDAY:
<case>case <expr><name>SATURDAY</name></expr>:</case>

cast: const_cast


Element

  • <cast type="const">

Subelement

  • <argument_list>

XPath Query

  • uses of const_cast

    //src:cast[src:type='const']

Example

const_cast<int const&>(*x);
<expr_stmt><expr><cast type="const">const_cast<argument_list type="generic">&lt;<argument><expr><name>int</name> <specifier>const</specifier><operator>&amp;</operator></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><operator>*</operator><name>x</name></expr></argument>)</argument_list></cast></expr>;</expr_stmt>

cast: dynamic_cast


Element

  • <cast type="dynamic">

Subelement

  • <argument_list>

XPath Query

  • uses of dynamic_cast

    //src:cast[src:type='dynamic']

Example

dynamic_cast<Square*>(boxPtr);
<expr_stmt><expr><cast type="dynamic">dynamic_cast<argument_list type="generic">&lt;<argument><expr><name>Square</name><operator>*</operator></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><name>boxPtr</name></expr></argument>)</argument_list></cast></expr>;</expr_stmt>

cast: reinterpret_cast


Element

  • <cast type="reinterpret">

Subelement

  • <argument_list>

XPath Query

  • uses of reinterpret_cast

    //src:cast[src:type='reinterpret']

Example

reinterpret_cast<double>(number);
<expr_stmt><expr><cast type="reinterpret">reinterpret_cast<argument_list type="generic">&lt;<argument><expr><name>double</name></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><name>number</name></expr></argument>)</argument_list></cast></expr>;</expr_stmt>

cast: static_cast


Element

  • <cast type="static">

Subelement

  • <argument_list>

XPath Query

  • uses of static_cast

    //src:cast[src:type='static']

Example

static_cast<node*>(ptr);
<expr_stmt><expr><cast type="static">static_cast<argument_list type="generic">&lt;<argument><expr><name>node</name><operator>*</operator></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><name>ptr</name></expr></argument>)</argument_list></cast></expr>;</expr_stmt>

class declaration


Element

  • <class_decl>

Subelement

  • <name>

XPath Query

  • class declarations

    //src:class_decl

Example

class Foo;
<class_decl>class <name>Foo</name>;</class_decl>

class definition


Element

  • <class>

Subelements

  • <name>
  • <super_list>
  • <block>

XPath Queries

  • class definitions

    //src:class
  • classes with the name foo

    //src:class[src:name='foo']
  • function definitions in classes

    //src:class//src:function
  • function declarations in classes

    //src:class//src:function_decl

Examples

class Foo { };
<class>class <name>Foo</name> <block>{<private type="default"> </private>}</block>;</class>
class Foo
	:public bar
{ };
<class>class <name>Foo</name>
	<super_list>:<super><specifier>public</specifier> <name>bar</name></super></super_list>
<block>{<private type="default"> </private>}</block>;</class>
class Foo {
	Foo() { }
};
<class>class <name>Foo</name> <block>{<private type="default">
	<constructor><name>Foo</name><parameter_list>()</parameter_list> <block>{<block_content> </block_content>}</block></constructor>
</private>}</block>;</class>
class Foo {
	foo();
}
<class>class <name>Foo</name> <block>{<private type="default">
	<macro><name>foo</name><argument_list>()</argument_list></macro><empty_stmt>;</empty_stmt>
</private>}</block><decl/></class>
class Foo {
	~Foo() { }
};
<class>class <name>Foo</name> <block>{<private type="default">
	<destructor><name>~Foo</name><parameter_list>()</parameter_list> <block>{<block_content> </block_content>}</block></destructor>
</private>}</block>;</class>
class Foo {
	~Foo();
}
<class>class <name>Foo</name> <block>{<private type="default">
	<destructor_decl><name>~Foo</name><parameter_list>()</parameter_list>;</destructor_decl>
</private>}</block><decl/></class>

class type specifier


Element

  • <typename>

XPath Query

  • classes which use class within instead of typename in at least one template parameter

    //src:class[src:template/src:parameter_list/src:parameter/src:type='class']

Example

template<class T>
class Foo { };
<class><template>template<parameter_list>&lt;<parameter><type><name>class</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
class <name>Foo</name> <block>{<private type="default"> </private>}</block>;</class>

comment


Element

  • <comment type="block|line" format="javadoc|doxygen">

XPath Queries

  • comments

    //src:comment
  • block comments

    //src:comment[@type='block']
  • line comments

    //src:comment[@type='line']
  • javadoc comments

    //src:comment[@format='javadoc']
  • doxygen comments

    //src:comment[@format='doxygen']
  • line Javadoc comments

    //src:comment[@type='line'][@format='javadoc']

condition


Element

  • <condition>

Subelement

  • <expr>

XPath Queries

  • conditions, including ternary conditions

    //src:condition
  • condition expressions

    //src:condition/src:expr
  • if conditions

    //src:if/src:condition
  • while conditions

    //src:while/src:condition
  • do while conditions

    //src:do/src:condition
  • ternary conditions

    //src:do/src:condition

const


Element

  • <specifier>

XPath Queries

  • const variables

    //src:decl[src:type/src:specifier='const']
  • const function declarations

    //src:function_decl[src:specifier='const']
  • function declarations with a const return type

    //src:function_decl[src:type/src:specifier='const']

Examples

const int x;
const X y;
<decl_stmt><decl><type><specifier>const</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>
<decl_stmt><decl><type><specifier>const</specifier> <name>X</name></type> <name>y</name></decl>;</decl_stmt>
int const x;
X const y;
<decl_stmt><decl><type><name>int</name> <specifier>const</specifier></type> <name>x</name></decl>;</decl_stmt>
<decl_stmt><decl><type><name>X</name> <specifier>const</specifier></type> <name>y</name></decl>;</decl_stmt>
int foo() const;
<function_decl><type><name>int</name></type> <name>foo</name><parameter_list>()</parameter_list> <specifier>const</specifier>;</function_decl>

constructor


Element

  • <constructor>

Subelements

  • <name>
  • <parameter_list>
  • <member_list>
  • <block>

XPath Queries

  • constructors

    //src:constuctor
  • constructors with no parameters

    //src:constuctor[not(src:parameter_list/src:parameter)]
  • possible default constructors, including constructors with all default parameters

    //src:constructor[src:parameter_list[not(src:parameter)] or (count(src:parameter_list/src:parameter) = count(src:parameter_list/src:parameter/src:decl/src:init))]
  • possible copy constructors, including those which are not defined with the body of class and those with default parameters

    //src:constructor[ (src:name | src:name/src:name[last()]) = (src:parameter_list/src:parameter[1]/src:decl/src:type/src:name | src:parameter_list/src:parameter[1]/src:decl/src:type/src:name[last()])][( (count(src:parameter_list/src:parameter) - 1) = count(src:parameter_list/src:parameter/src:decl/src:init))]

Examples

class Foo{
	Foo()
		:x(5)
	{ }
};
<class>class <name>Foo</name><block>{<private type="default">
	<constructor><name>Foo</name><parameter_list>()</parameter_list>
		<member_init_list>:<call><name>x</name><argument_list>(<argument><expr><literal type="number">5</literal></expr></argument>)</argument_list></call>
	</member_init_list><block>{<block_content> </block_content>}</block></constructor>
</private>}</block>;</class>
Foo::Foo()
	:x(5)
{ }
<constructor><name><name>Foo</name><operator>::</operator><name>Foo</name></name><parameter_list>()</parameter_list>
	<member_init_list>:<call><name>x</name><argument_list>(<argument><expr><literal type="number">5</literal></expr></argument>)</argument_list></call>
</member_init_list><block>{<block_content> </block_content>}</block></constructor>
foo::foo(foo x) { }
<constructor><name><name>foo</name><operator>::</operator><name>foo</name></name><parameter_list>(<parameter><decl><type><name>foo</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></constructor>
bar::bar(bar const& other) { }
<constructor><name><name>bar</name><operator>::</operator><name>bar</name></name><parameter_list>(<parameter><decl><type><name>bar</name> <specifier>const</specifier><modifier>&amp;</modifier></type> <name>other</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></constructor>

constructor declaration


Element

  • <constructor_decl>

Subelements

  • <specifier>
  • <name>
  • <parameter_list>

XPath Query

  • constructor declarations

    //src:constructor_decl

Example

class Foo {
	Foo();
};
<class>class <name>Foo</name> <block>{<private type="default">
	<constructor_decl><name>Foo</name><parameter_list>()</parameter_list>;</constructor_decl>
</private>}</block>;</class>

control


Element

  • <control>

Subelements

  • <init>
  • <condition>
  • <incr>

XPath Query

  • initialization, condition, and increment of for loops

    //src:control

default function parameters


Element

  • <init>

Subelement

  • <expr>

XPath Query

  • function declarations with default parameters

    //src:function_decl[src:parameter_list/src:parameter/src:decl/src:init]

Example

void point(int x = 3, int y = 4);
<function_decl><type><name>void</name></type> <name>point</name><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name> <init>= <expr><literal type="number">3</literal></expr></init></decl></parameter>, <parameter><decl><type><name>int</name></type> <name>y</name> <init>= <expr><literal type="number">4</literal></expr></init></decl></parameter>)</parameter_list>;</function_decl>

default specifier


Element

  • <specifier>

XPath Queries

  • constructors which explicitly use the compiler provided implementation

    //src:constructor_decl[src:specifier='default']
  • functions which explicitly use the compiler provided implementation

    //src:function_decl[src:specifier='default']

Example

class Foo {
	Foo() = default;
};
<class>class <name>Foo</name> <block>{<private type="default">
	<constructor_decl><name>Foo</name><parameter_list>()</parameter_list> = <specifier>default</specifier>;</constructor_decl>
</private>}</block>;</class>

default statement


Element

  • <default>

XPath Queries

  • default labels

    //src:default
  • switch statements with a default label

    //src:switch[src:block/src:block_content/src:default]

Example

default:
<default>default:</default>

delete


Element

  • <operator>

XPath Queries

  • expressions which call delete

    //src:expr[src:operator='delete']
  • expressions which call array delete

    //src:expr[src:operator='delete'][src:index]

Examples

Regular delete

delete x;
<expr_stmt><expr><operator>delete</operator> <name>x</name></expr>;</expr_stmt>

Array delete

delete [] x;
<expr_stmt><expr><operator>delete</operator> <index>[]</index> <name>x</name></expr>;</expr_stmt>

delete specifier


Element

  • <specifier>

XPath Query

  • deleted function declarations

    //src:function_decl[src:specifier='delete']

Example

void dump() = delete;
<function_decl><type><name>void</name></type> <name>dump</name><parameter_list>()</parameter_list> = <specifier>delete</specifier>;</function_decl>

dereference member access


Element

  • <expr>

Subelements

  • <name>
  • <operator>

XPath Query

  • uses of the -> operator

    //src:operator[.='->']

Example

 t->tm_sec;
 <expr_stmt><expr><name><name>t</name><operator>-&gt;</operator><name>tm_sec</name></name></expr>;</expr_stmt>

destructor declaration


Element

  • <destructor_decl>

Subelement

  • <name>

XPath Query

  • destructor declarations

    //src:destructor_decl

Example

class Foo {
	~Foo();
};
<class>class <name>Foo</name> <block>{<private type="default">
	<destructor_decl><name>~Foo</name><parameter_list>()</parameter_list>;</destructor_decl>
</private>}</block>;</class>

else


Element

  • <else>

Subelement

  • <block>

XPath Query

  • all elses

    //src:else

else if


Element

  • <else type="elsif>

Subelements

  • <condition>
  • <block>

XPath Query

  • all else ifs

    //src:else[type="elsif"]

empty statement


Element

  • <empty_stmt>

XPath Query

  • empty statements

    //src:empty_stmt

Example

;
<empty_stmt>;</empty_stmt>

enum class


Element

  • <enum type="class">

XPath Query

  • enum class definitions

    //src:enum[src:type='class']

Example

enum class Color {RED, GREEN, BLUE};
<enum type="class">enum class <name>Color</name> <block>{<decl><name>RED</name></decl>, <decl><name>GREEN</name></decl>, <decl><name>BLUE</name></decl>}</block>;</enum>

enum class declaration


Element

  • <enum_decl type="class">

XPath Query

  • enum class declarations

    //src:enum_decl[src:type='class']

enum declaration


Element

  • <enum_decl>

Subelement

  • <name>

XPath Queries

  • enum declarations

    //src:enum_decl
  • names of enums declarations

    //src:enum_decl/src:name

Examples

enum DAY {
    sunday = 0,
    monday,
    tuesday,
    wednesday,
    thursday,
    friday,
    saturday,
};
<enum>enum <name>DAY</name> <block>{
    <decl><name>sunday</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>,
    <decl><name>monday</name></decl>,
    <decl><name>tuesday</name></decl>,
    <decl><name>wednesday</name></decl>,
    <decl><name>thursday</name></decl>,
    <decl><name>friday</name></decl>,
    <decl><name>saturday</name></decl>,
}</block>;</enum>
enum { yes, no } response;
<enum>enum <block>{ <decl><name>yes</name></decl>, <decl><name>no</name></decl> }</block> <decl><name>response</name></decl>;</enum>

enum declaration


Element

  • <enum_decl>

Subelement

  • <name>

XPath Query

  • enum declarations

    //src:enum_decl

Example

enum DAY;
<enum_decl>enum <name>DAY</name>;</enum_decl>

enum definition


Element

  • <enum>

Subelements

  • <name>
  • <block>

XPath Queries

  • enum definitions

    //src:enum
  • names of members of enums

    //src:enum/src:block/src:decl/src:name

Examples

enum DAY {
    sunday = 0,
    monday,
    tuesday,
    wednesday,
    thursday,
    friday,
    saturday,
};
<enum>enum <name>DAY</name> <block>{
    <decl><name>sunday</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>,
    <decl><name>monday</name></decl>,
    <decl><name>tuesday</name></decl>,
    <decl><name>wednesday</name></decl>,
    <decl><name>thursday</name></decl>,
    <decl><name>friday</name></decl>,
    <decl><name>saturday</name></decl>,
}</block>;</enum>
enum { yes, no } response;
<enum>enum <block>{ <decl><name>yes</name></decl>, <decl><name>no</name></decl> }</block> <decl><name>response</name></decl>;</enum>

escape


Element

  • <escape char="0xXX">

explicit


Element

  • <specifier>

XPath Query

  • explicit constructor declarations

    //src:constructor_decl[src:specifier='explicit']

Example

class Foo{ 
	explicit Foo(X const& x);
};
<class>class <name>Foo</name><block>{<private type="default"> 
	<constructor_decl><specifier>explicit</specifier> <name>Foo</name><parameter_list>(<parameter><decl><type><name>X</name> <specifier>const</specifier><modifier>&amp;</modifier></type> <name>x</name></decl></parameter>)</parameter_list>;</constructor_decl>
</private>}</block>;</class>

explicit conversion operator declaration


Element

  • <function_decl type="operator">

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Query

  • explicit conversion operator declarations

    //src:function_decl[src:type='operator'][src:type/src:specifier='explicit']

Example

explicit operator int*() const;
<function_decl type="operator"><type><specifier>explicit</specifier></type> <name>operator <name>int</name><modifier>*</modifier></name><parameter_list>()</parameter_list> <specifier>const</specifier>;</function_decl>

explicit conversion operator definition


Element

  • <function type="operator">

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Query

  • explicit conversion operator overloads

    //src:function[src:type='operator'][src:type/src:specifier='explicit']

Example

explicit operator int*() const { return nullptr; }
<function type="operator"><type><specifier>explicit</specifier></type> <name>operator <name>int</name><modifier>*</modifier></name><parameter_list>()</parameter_list> <specifier>const</specifier> <block>{<block_content> <return>return <expr><literal type="null">nullptr</literal></expr>;</return> </block_content>}</block></function>

expr_stmt


Element

  • <expr_stmt>

Subelement

  • <expr>

expression


Element

  • <expr>

Subelements

  • <name>
  • <operator>
  • <call>
  • <ternary>

XPath Query

  • expressions

    //src:expr

extern block


Element

  • <extern>

Subelements

  • <literal>
  • <function_decl>
  • <decl_stmt>
  • <block>

XPath Query

  • extern blocks

    //src:extern

Examples

extern function with linkage specifier

extern "C" void foo();
<extern>extern <literal type="string">"C"</literal> <function_decl><type><name>void</name></type> <name>foo</name><parameter_list>()</parameter_list>;</function_decl></extern>

extern structure with linkage specifier

extern "C" struct Z X;
<extern>extern <literal type="string">"C"</literal> <decl_stmt><decl><type><name><name>struct</name> <name>Z</name></name></type> <name>X</name></decl>;</decl_stmt></extern>

extern variable with linkage specifier

extern "C" int X;
<extern>extern <literal type="string">"C"</literal> <decl_stmt><decl><type><name>int</name></type> <name>X</name></decl>;</decl_stmt></extern>

extern block with linkage specifier

extern "C" { }
<extern>extern <literal type="string">"C"</literal> <block>{<block_content> </block_content>}</block></extern>

extern specifier


Element

  • <specifier>

XPath Queries

  • extern variables

    //src:decl[src:type/src:specifier='extern']
  • extern function declarations

    //src:function_decl[src:type/src:specifier='extern']

Examples

external variable

extern int X;
<decl_stmt><decl><type><specifier>extern</specifier> <name>int</name></type> <name>X</name></decl>;</decl_stmt>

external structure

extern struct Z X;
<decl_stmt><decl><type><specifier>extern</specifier> <name><name>struct</name> <name>Z</name></name></type> <name>X</name></decl>;</decl_stmt>

external function

extern void foo();
<function_decl><type><specifier>extern</specifier> <name>void</name></type> <name>foo</name><parameter_list>()</parameter_list>;</function_decl>

final


Element

  • <specifier>

XPath Queries

  • final function declarations

    //src:function_decl[src:specifier='final']
  • final class definitions

    //src:class[src:specifier='final']

Examples

virtual void foo() final;
<function_decl><type><specifier>virtual</specifier> <name>void</name></type> <name>foo</name><parameter_list>()</parameter_list> <specifier>final</specifier>;</function_decl>
class X final { };
<class>class <name>X</name> <specifier>final</specifier> <block>{<private type="default"> </private>}</block>;</class>

for statement


Element

  • <for>

Subelements

  • <control>
  • <block>

XPath Queries

  • for loops

    //src:for
  • for-loop initialization statements

    //src:for/src:control/src:init
  • for-loop conditions

    //src:for/src:control/src:condition
  • for-loop increments

    //src:for/src:control/src:incr
  • for loops that declare a variable with a single character name (e.g. x, i or y)

    //src:for[string-length(src:control/src:init/src:decl/src:name) = 1]
  • for loops with post-increment in the increment expression

    //src:for[src:control/src:incr/src:expr//following-sibling::src:operator= '++']
  • range-based for loops

    //src:for[src:control//src:range]

Examples

for( ;; ) { }
<for>for<control>( <init>;</init><condition>;</condition> <incr/>)</control> <block>{<block_content> </block_content>}</block></for>
for (i = 0; i < max; i++ ) 
{
  if ( line[i] == ' ' )
  {
      space++;
  }
  if ( line[i] == '\t' )
  {
      tab++;
  }
}
<for>for <control>(<init><expr><name>i</name> <operator>=</operator> <literal type="number">0</literal></expr>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <name>max</name></expr>;</condition> <incr><expr><name>i</name><operator>++</operator></expr></incr> )</control> 
<block>{<block_content>
  <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">' '</literal></expr> )</condition>
  <block>{<block_content>
      <expr_stmt><expr><name>space</name><operator>++</operator></expr>;</expr_stmt>
  </block_content>}</block></if></if_stmt>
  <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">'\t'</literal></expr> )</condition>
  <block>{<block_content>
      <expr_stmt><expr><name>tab</name><operator>++</operator></expr>;</expr_stmt>
  </block_content>}</block></if></if_stmt>
</block_content>}</block></for>
for(int i =0; i < 10;++i)
	a += x[i];
<for>for<control>(<init><decl><type><name>int</name></type> <name>i</name> <init>=<expr><literal type="number">0</literal></expr></init></decl>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <literal type="number">10</literal></expr>;</condition><incr><expr><operator>++</operator><name>i</name></expr></incr>)</control><block type="pseudo"><block_content>
	<expr_stmt><expr><name>a</name> <operator>+=</operator> <name><name>x</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt></block_content></block></for>
for (int i : v)
    std::cout << i << ' ';
<for>for <control>(<init><decl><type><name>int</name></type> <name>i</name> <range>: <expr><name>v</name></expr></range></decl></init>)</control><block type="pseudo"><block_content>
    <expr_stmt><expr><name><name>std</name><operator>::</operator><name>cout</name></name> <operator>&lt;&lt;</operator> <name>i</name> <operator>&lt;&lt;</operator> <literal type="char">' '</literal></expr>;</expr_stmt></block_content></block></for>

forever


Element

  • <forever>

Subelements

  • <expr_stmt>
  • <block>

function declaration


Element

  • <function_decl>

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Queries

  • function declarations

    //src:function_decl
  • function-declaration return types

    //src:function_decl/src:type
  • function-declaration parameters

    //src:function_decl/src:parameter_list/src:parameter
  • function declarations with only two parameters

    //src:function_decl[count(src:parameter_list/src:parameter) = 2]
  • function declaration names

    //src:function_decl/src:name
  • function declarations that have variadic arguments

    //src:function_decl[src:parameter_list/src:parameter/src:decl/src:type/src:modifier='...']

Examples

struct STUDENT sortstu( STUDENT a, STUDENT b );
void print(STUDENT a);
<function_decl><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>sortstu</name><parameter_list>( <parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>, <parameter><decl><type><name>STUDENT</name></type> <name>b</name></decl></parameter> )</parameter_list>;</function_decl>
<function_decl><type><name>void</name></type> <name>print</name><parameter_list>(<parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>)</parameter_list>;</function_decl>
void foo (int a[]);
<function_decl><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name><name>a</name><index>[]</index></name></decl></parameter>)</parameter_list>;</function_decl>
void foo (int* a);
<function_decl><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>)</parameter_list>;</function_decl>
int add_multiple_values (int number, ...);
<function_decl><type><name>int</name></type> <name>add_multiple_values</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name>number</name></decl></parameter>, <parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list>;</function_decl>
int func(a, b, c)
   int a;
   int b;
   int c;
{ }
<function><type><name>int</name></type> <name>func</name><parameter_list>(<parameter><decl><type><name>a</name></type></decl></parameter>, <parameter><decl><type><name>b</name></type></decl></parameter>, <parameter><decl><type><name>c</name></type></decl></parameter>)</parameter_list>
   <decl_stmt><decl><type><name>int</name></type> <name>a</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>b</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>c</name></decl>;</decl_stmt>
<block>{<block_content> </block_content>}</block></function>
auto temp() -> int;
<function_decl><type><name>auto</name></type> <name>temp</name><parameter_list>()</parameter_list> -&gt; <type><name>int</name></type>;</function_decl>

function definition


Element

  • <function>

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Queries

  • function definitions

    //src:function
  • function-definition return types

    //src:function/src:type
  • function-definition parameters

    //src:function/src:parameter_list/src:parameter
  • function definitions with only two parameters

    //src:function[count(src:parameter_list/src:parameter) = 2]
  • function-definition names

    //src:function/src:name
  • function definitions that have variadic arguments

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:modifier='...']
  • K & R function definitions

    //src:function[src:decl_stmt]

Examples

struct STUDENT sortstu( STUDENT a, STUDENT b ) {
    struct STUDENT x;
    return x;
}
<function><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>sortstu</name><parameter_list>( <parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>, <parameter><decl><type><name>STUDENT</name></type> <name>b</name></decl></parameter> )</parameter_list> <block>{<block_content>
    <decl_stmt><decl><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>x</name></decl>;</decl_stmt>
    <return>return <expr><name>x</name></expr>;</return>
</block_content>}</block></function>
void print(STUDENT a) { }
<function><type><name>void</name></type> <name>print</name><parameter_list>(<parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
void foo (int a[]) { } 
<function><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name><name>a</name><index>[]</index></name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function> 
void foo (int* a) { }
<function><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
int add_multiple_values (int number, ...) { }
<function><type><name>int</name></type> <name>add_multiple_values</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name>number</name></decl></parameter>, <parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
int func(a, b, c)
   int a;
   int b;
   int c;
{ }
<function><type><name>int</name></type> <name>func</name><parameter_list>(<parameter><decl><type><name>a</name></type></decl></parameter>, <parameter><decl><type><name>b</name></type></decl></parameter>, <parameter><decl><type><name>c</name></type></decl></parameter>)</parameter_list>
   <decl_stmt><decl><type><name>int</name></type> <name>a</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>b</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>c</name></decl>;</decl_stmt>
<block>{<block_content> </block_content>}</block></function>
auto temp() -> int { }
<function><type><name>auto</name></type> <name>temp</name><parameter_list>()</parameter_list> -&gt; <type><name>int</name></type> <block>{<block_content> </block_content>}</block></function>

function try-catch


Element

  • <try>

Subelements

  • <catch>
  • <block>
  • <member_list>

XPath Query

  • try blocks with at least two catch blocks.

    //src:try[count(src:catch) >= 2]

Examples

struct S {
    S(const std::string& arg) try : m(arg) {        
    } catch(const std::exception& e) {
    } // implicit throw; here
};
<struct>struct <name>S</name> <block>{<public type="default">
    <constructor><name>S</name><parameter_list>(<parameter><decl><type><specifier>const</specifier> <name><name>std</name><operator>::</operator><name>string</name></name><modifier>&amp;</modifier></type> <name>arg</name></decl></parameter>)</parameter_list> <try>try <member_init_list>: <call><name>m</name><argument_list>(<argument><expr><name>arg</name></expr></argument>)</argument_list></call> </member_init_list><block>{<block_content>        
    </block_content>}</block> <catch>catch<parameter_list>(<parameter><decl><type><specifier>const</specifier> <name><name>std</name><operator>::</operator><name>exception</name></name><modifier>&amp;</modifier></type> <name>e</name></decl></parameter>)</parameter_list> <block>{<block_content>
    </block_content>}</block></catch></try></constructor> <comment type="line">// implicit throw; here</comment>
</public>}</block>;</struct>
int f(int n) try {

} catch(...) {

}
<function><type><name>int</name></type> <name>f</name><parameter_list>(<parameter><decl><type><name>int</name></type> <name>n</name></decl></parameter>)</parameter_list> <try>try <block>{<block_content>

</block_content>}</block> <catch>catch<parameter_list>(<parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list> <block>{<block_content>

</block_content>}</block></catch></try></function>

goto statement


Element

  • <goto>

Subelement

  • <name>

XPath Query

  • goto statements

    //src:goto

Example

goto stop;
<goto>goto <name>stop</name>;</goto>

if


Element

  • <if>

Subelements

  • <condition>
  • <block>

XPath Query

  • all ifs

    //src:if

if statement


Element

  • <if_stmt>

Subelements

  • <if>
  • <else>
  • <if type="elseif">

XPath Queries

  • if conditions

    //src:if/src:condition
  • then

    //src:if/src:block
  • else

    //src:else/src:block
  • if statements without an else

    //src:if_stmt[not(src:else)]
  • else-if

    //src:if[@type="elseif"]
  • First if in a nested if statement

    //src:if_stmt/src:if[1]
  • Second if in a nested if statement

    //src:if_stmt/src:if[2]
  • Last if in a nested if statement

    //src:if_stmt/src:if[last()]

Examples

if then

if (A)
    B;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if></if_stmt>

if then else

if (A)
    B;
else
    C;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

if then elseif

if (A)
    B;
else if (A2)
    C;
else
    D:
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<if type="elseif">else if <condition>(<expr><name>A2</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <label><name>D</name>:</label></block_content></block></else></if_stmt>
if(x > 5)
    y+=4;
<if_stmt><if>if<condition>(<expr><name>x</name> <operator>&gt;</operator> <literal type="number">5</literal></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name><operator>+=</operator><literal type="number">4</literal></expr>;</expr_stmt></block_content></block></if></if_stmt>
if ( i > 0 ) {
    y = x / i;
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if></if_stmt>
if ( i > 0 )
    y = x / i;
else 
{
    x = i;
    y = f( x );
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt></block_content></block></if>
<else>else 
<block>{<block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <call><name>f</name><argument_list>( <argument><expr><name>x</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
</block_content>}</block></else></if_stmt>

Without braces

if ( i > 0 )
    if ( j > i )
        x = j;
    else
        x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if>
    <else>else<block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt></block_content></block></if></if_stmt>

With braces

if ( i > 0 ) 
{
    if ( j > i )
        x = j;
}
else
    x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if></if_stmt>
</block_content>}</block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt>
if ( i > 0 ) 
{
 	x = i;   
}
else if( i < 0)
	x = q;
else 
    x = j;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
 	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>   
</block_content>}</block></if>
<if type="elseif">else if<condition>( <expr><name>i</name> <operator>&lt;</operator> <literal type="number">0</literal></expr>)</condition><block type="pseudo"><block_content>
	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>q</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content> 
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

implicit conversion operator declaration


Element

  • <function_decl type="operator">

Subelements

  • <name>
  • <parameter_list>

XPath Query

  • implicit conversion operator overload declarations

    //src:function_decl[src:type='operator'][not(src:type)]

Example

operator Foo() const;
<function_decl type="operator"><name>operator <name>Foo</name></name><parameter_list>()</parameter_list> <specifier>const</specifier>;</function_decl>

implicit conversion operator definition


Element

  • <function type="operator">

Subelements

  • <name>
  • <parameter_list>
  • <block>

XPath Query

  • implicit conversion operator overload definitions

    //src:function[src:type='operator'][not(src:type)]

Example

operator Foo() const { return x->foo; }
<function type="operator"><name>operator <name>Foo</name></name><parameter_list>()</parameter_list> <specifier>const</specifier> <block>{<block_content> <return>return <expr><name><name>x</name><operator>-&gt;</operator><name>foo</name></name></expr>;</return> </block_content>}</block></function>

incr


Element

  • <incr>

Subelement

  • <expr>

XPath Query

  • increment of for loops

    //src:incr

inheritance list


Element

  • <super_list>

Subelement

  • <super>

XPath Queries

  • classes with at least one super class

    //src:class[src:super]
  • classes that inherit from bar

    //src:class[src:super/src:name= 'bar']

Example

class Foo
	:Bar1, OtherBar
{ };
<class>class <name>Foo</name>
	<super_list>:<super><name>Bar1</name></super>, <super><name>OtherBar</name></super></super_list>
<block>{<private type="default"> </private>}</block>;</class>

inline


Element

  • <specifier>

XPath Queries

  • inline function declarations

    //src:function_decl[src:type/src:specifier='inline']
  • inline namespace declarations

    //src:namespace[src:specifier='inline']

Examples

inline void swapValues(int* a,int* b);
<function_decl><type><specifier>inline</specifier> <name>void</name></type> <name>swapValues</name><parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>,<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>b</name></decl></parameter>)</parameter_list>;</function_decl>
inline namespace ns { }
<namespace><specifier>inline</specifier> namespace <name>ns</name> <block>{ }</block></namespace>

label


Element

  • <label>

Subelement

  • <name>

XPath Queries

  • labels

    //src:label
  • label names

    //src:label/src:name
  • labels with a goto statement

    //src:label[src:name = //src:goto/src:name]
  • labels without a goto statement

    //src:label[not(src:name[. = //src:goto/src:name])]

Example

stop:
<label><name>stop</name>:</label>

lambda functions


Element

  • <lambda>

Subelements

  • <capture>
  • <parameter_list>
  • <type>
  • <block>

XPath Queries

  • lambda functions

    //src:lambda
  • lambda functions without a specified return type

    //src:lambda[not(src:type)]
  • lambdas which have a the return type of int

    //src:lambda[src:type/src:name'int']
  • lambda functions which explicitly capture one variable.

    //src:lambda[count(src:capture/src:argument/src:modifier[. != '=' and . != '&']) = 1]
  • lambda functions which capture all variables by reference.

    //src:lambda[src:capture/src:argument/src:modifier='&' and count(src:capture/src:argument)] = 1

Examples

[](int x) { return 0;} 
<expr_stmt><expr><lambda><capture>[]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return></block_content>}</block></lambda></expr></expr_stmt> 
[] { return 0; } 
<expr_stmt><expr><lambda><capture>[]</capture> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return> </block_content>}</block></lambda></expr></expr_stmt> 
[](int x) -> int { return 0;} 
<expr_stmt><expr><lambda><capture>[]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> -&gt; <type><name>int</name></type> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return></block_content>}</block></lambda></expr></expr_stmt> 
[i](int x) { return i; } 
<expr_stmt><expr><lambda><capture>[<argument><name>i</name></argument>]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> <return>return <expr><name>i</name></expr>;</return> </block_content>}</block></lambda></expr></expr_stmt> 
[=](int x) { return 0;} 
<expr_stmt><expr><lambda><capture>[<argument><modifier>=</modifier></argument>]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return></block_content>}</block></lambda></expr></expr_stmt> 
[&](int x) { return 0;} 
<expr_stmt><expr><lambda><capture>[<argument><modifier>&amp;</modifier></argument>]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return></block_content>}</block></lambda></expr></expr_stmt> 
[=](int const& x) mutable { return 0;} 
<expr_stmt><expr><lambda><capture>[<argument><modifier>=</modifier></argument>]</capture><parameter_list>(<parameter><decl><type><name>int</name> <specifier>const</specifier><modifier>&amp;</modifier></type> <name>x</name></decl></parameter>)</parameter_list> <specifier>mutable</specifier> <block>{<block_content> <return>return <expr><literal type="number">0</literal></expr>;</return></block_content>}</block></lambda></expr></expr_stmt> 
[&, =a](int x) { }
<expr><lambda><capture>[<argument><modifier>&amp;</modifier></argument>, <argument><modifier>=</modifier><name>a</name></argument>]</capture><parameter_list>(<parameter><decl><type><name>int</name></type> <name>x</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></lambda></expr>

literal


Element

  • <literal type="number|char|string|boolean|complex|null">

XPath Queries

  • literals

    //src:literal
  • string literals

    //src:literal[@type='string']

Example

123;
42.0;
'c';
"Hello";
true;
2 + 3i;
nullptr;
L"string";
u"UTF-16 string.";
U"UTF-32 string.";
R"a("()")a";
u8R"|||(a "raw UTF-8" string)|||";
uR"*(a "raw UTF-16" string)*";
UR"(a "raw UTF-32" string)";
<expr_stmt><expr><literal type="number">123</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="number">42.0</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="char">'c'</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">"Hello"</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="boolean">true</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="complex">2 + 3i</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="null">nullptr</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">L"string"</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">u"UTF-16 string."</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">U"UTF-32 string."</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">R"a("()")a"</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">u8R"|||(a "raw UTF-8" string)|||"</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">uR"*(a "raw UTF-16" string)*"</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">UR"(a "raw UTF-32" string)"</literal></expr>;</expr_stmt>

member access


Element

  • <expr>

Subelements

  • <name>
  • <operator>

XPath Query

  • uses of the . operator

    //src:operator[.='.']

Example

t.tm_sec;
<expr_stmt><expr><name><name>t</name><operator>.</operator><name>tm_sec</name></name></expr>;</expr_stmt>

mutable


Element

  • <specifier>

XPath Query

  • mutable variable declarations

    //src:decl[src:type/src:specifier='mutable']

Example

mutable int i;
<decl_stmt><decl><type><specifier>mutable</specifier> <name>int</name></type> <name>i</name></decl>;</decl_stmt>

namespace


Element

  • <namespace>

Subelements

  • <name>
  • <block>

XPath Queries

  • namespaces

    //src:namespace
  • inline namespaces

    //src:namespace[src:specifier='inline']
  • using namespace declarations

    //src:using[src:namespace]
  • namespace assignments

    //src:namespace[count(src:name) > 1]
  • anonymous namespace declarations

    //src:namespace[not(src:name)]

Examples

namespace ns { }
<namespace>namespace <name>ns</name> <block>{ }</block></namespace>
inline namespace ns { }
<namespace><specifier>inline</specifier> namespace <name>ns</name> <block>{ }</block></namespace>
namespace ns;
<namespace>namespace <name>ns</name>;</namespace>
using namespace ns;
<using>using <namespace>namespace <name>ns</name>;</namespace></using>
namespace new_name = ns; 
<namespace>namespace <name>new_name</name> = <name>ns</name>;</namespace> 
namespace { }
<namespace>namespace <block>{ }</block></namespace>

new


Element

  • <operator>

XPath Queries

  • expressions which call new

    //src:expr[src:operator='new']
  • expressions which call array new

    //src:expr[src:operator[.='new']/following-sibling::src:name/src:index]
  • expressions which call no throw new

    //src:expr[src:operator[.='new']/following-sibling::src:name[src:name='nothrow']]

Examples

regular new

new foo();
<expr_stmt><expr><operator>new</operator> <call><name>foo</name><argument_list>()</argument_list></call></expr>;</expr_stmt>

array new 1

new foo[5];
<expr_stmt><expr><operator>new</operator> <name><name>foo</name><index>[<expr><literal type="number">5</literal></expr>]</index></name></expr>;</expr_stmt>

array new 2

new foo[5]();
<expr_stmt><expr><operator>new</operator> <name><name>foo</name><index>[<expr><literal type="number">5</literal></expr>]</index></name><operator>(</operator><operator>)</operator></expr>;</expr_stmt>

std::nothrow new

new (std::nothrow) char [50000000];
<expr_stmt><expr><operator>new</operator> <operator>(</operator><name><name>std</name><operator>::</operator><name>nothrow</name></name><operator>)</operator> <name><name>char</name> <index>[<expr><literal type="number">50000000</literal></expr>]</index></name></expr>;</expr_stmt>

placement new

new (place) int;
<expr_stmt><expr><operator>new</operator> <operator>(</operator><name>place</name><operator>)</operator> <name>int</name></expr>;</expr_stmt>

omp:argument


Element

  • <omp:argument>

Subelement

  • <omp:expr>

XPath Query

  • omp arguments

    //omp:argument

omp:argument_list


Element

  • <omp:argument_list>

Subelement

  • <omp:argument>

XPath Query

  • omp argument lists

    //omp:argument_list

omp:clause


Element

  • <omp:clause>

Subelements

  • <omp:name>
  • <omp:argument_list>

XPath Query

  • omp clauses

    //omp:clause

omp:directive


Element

  • <omp:directive>

Subelements

  • <omp:name>
  • <omp:clause>

XPath Queries

  • omp directives

    //omp:directive
  • omp directives with the name ‘parallel’

    //omp:directive[omp:name='parallel']

Example

#pragma omp parallel
#pragma omp parallel if()
#pragma omp parallel if(list)
#pragma omp parallel if(one, two)
#pragma omp parallel if(one, two) if(one, two)
#pragma omp parallel if(one, two), if(one, two)
#pragma omp parallel reduction(+: sum)
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>()</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>list</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause>, <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>reduction</omp:name><omp:argument_list>(<omp:argument><omp:expr>+: sum</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>

omp:expr


Element

  • <omp:expr>

XPath Query

  • omp expressions

    //omp:expr

omp:name


Element

  • <omp:name>

XPath Query

  • omp names

    //omp:name

operator overloading declaration


Element

  • <function_decl type="operator">

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Query

  • operator declarations

    //src:function_decl[src:type='operator']

Example

Foo& operator=(Foo&& );
<function_decl type="operator"><type><name>Foo</name><modifier>&amp;</modifier></type> <name>operator<name>=</name></name><parameter_list>(<parameter><decl><type><name>Foo</name><modifier>&amp;&amp;</modifier></type></decl></parameter> )</parameter_list>;</function_decl>

operator overloading definition


Element

  • <function type="operator">

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Query

  • operator overload definitions

    //src:function[src:type='operator']

Example

bool operator==(Foo const&, Foo const& ) { }
<function type="operator"><type><name>bool</name></type> <name>operator<name>==</name></name><parameter_list>(<parameter><decl><type><name>Foo</name> <specifier>const</specifier><modifier>&amp;</modifier></type></decl></parameter>, <parameter><decl><type><name>Foo</name> <specifier>const</specifier><modifier>&amp;</modifier></type></decl></parameter> )</parameter_list> <block>{<block_content> </block_content>}</block></function>

override


Element

  • <specifier>

XPath Query

  • overridden function declarations

    //src:function_decl[src:specifier='override']

Example

void foo() const override; 
<function_decl><type><name>void</name></type> <name>foo</name><parameter_list>()</parameter_list> <specifier>const</specifier> <specifier>override</specifier>;</function_decl> 

pointer declaration


Element

  • <modifier>

XPath Queries

  • declarations of pointers

    //src:decl[src:type/src:modifier='*']
  • function pointers

    //src:function_decl[contains(., ')')]

Examples

char *message;
<decl_stmt><decl><type><name>char</name> <modifier>*</modifier></type><name>message</name></decl>;</decl_stmt>
int *pointers[10];
<decl_stmt><decl><type><name>int</name> <modifier>*</modifier></type><name><name>pointers</name><index>[<expr><literal type="number">10</literal></expr>]</index></name></decl>;</decl_stmt>
int (*pointer)[10];
<expr_stmt><expr><call><name>int</name> <argument_list>(<argument><expr><operator>*</operator><name>pointer</name></expr></argument>)</argument_list></call><index>[<expr><literal type="number">10</literal></expr>]</index></expr>;</expr_stmt>
int const *x;
<decl_stmt><decl><type><name>int</name> <specifier>const</specifier> <modifier>*</modifier></type><name>x</name></decl>;</decl_stmt>
int(*X)(void);
int(*X)(int, float);
int(*X)(char const*,...);
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>void</name></type></decl></parameter>)</parameter_list>;</function_decl>
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>float</name></type></decl></parameter>)</parameter_list>;</function_decl>
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>char</name> <specifier>const</specifier><modifier>*</modifier></type></decl></parameter>,<parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list>;</function_decl>
int volatile *const z = &some_object;
<decl_stmt><decl><type><name>int</name> <specifier>volatile</specifier> <modifier>*</modifier><specifier>const</specifier></type> <name>z</name> <init>= <expr><operator>&amp;</operator><name>some_object</name></expr></init></decl>;</decl_stmt>
int *const volatile w = &some_object;
<decl_stmt><decl><type><name>int</name> <modifier>*</modifier><specifier>const</specifier> <specifier>volatile</specifier></type> <name>w</name> <init>= <expr><operator>&amp;</operator><name>some_object</name></expr></init></decl>;</decl_stmt>

private access specifier


Element

  • <private>

XPath Query

  • private members

    //src:private/src:decl_stmt

Example

struct Foo {
private:
};
<struct>struct <name>Foo</name> <block>{<public type="default">
</public><private>private:
</private>}</block>;</struct>

private default access specifier


Element

  • <private type="default">

XPath Query

  • function declarations withe default private access

    //src:private[src:type='default']/src:function_decl

Example

class Foo
{
	
};
<class>class <name>Foo</name>
<block>{<private type="default">
	
</private>}</block>;</class>

private inheritance specifier


Element

  • <specifier>

XPath Query

  • classes with private inheritance

    //src:class[src:super/src:specifier='private']

Example

class Foo
	:private Bar
{ };
<class>class <name>Foo</name>
	<super_list>:<super><specifier>private</specifier> <name>Bar</name></super></super_list>
<block>{<private type="default"> </private>}</block>;</class>

protected access specifier


Element

  • <protected>

XPath Query

  • protected function declarations

    //src:protected/src:function_decl

Example

class Foo {
protected:
};
<class>class <name>Foo</name> <block>{<private type="default">
</private><protected>protected:
</protected>}</block>;</class>

protected inheritance specifier


Element

  • <specifier>

XPath Query

  • classes with protected inheritance

    //src:class[src:super/src:specifier='protected']

Example

class Foo
	:protected Bar
{ };
<class>class <name>Foo</name>
	<super_list>:<super><specifier>protected</specifier> <name>Bar</name></super></super_list>
<block>{<private type="default"> </private>}</block>;</class>

public access specifier


Element

  • <public>

XPath Query

  • public functions

    //src:public/src:function_decl

Example

class Foo {
public:
};
<class>class <name>Foo</name> <block>{<private type="default">
</private><public>public:
</public>}</block>;</class>

public default access specifier


Element

  • <public type="default">

XPath Query

  • function declarations with default public access

    //src:public[src:type='default']/src:function_decl

Example

struct Foo {

};
<struct>struct <name>Foo</name> <block>{<public type="default">

</public>}</block>;</struct>

public inheritance specifier


Element

  • <specifier>

XPath Query

  • classes with private inheritance

    //src:class[src:super/src:specifier='public']

Example

class Foo
	:public Bar
{ };
<class>class <name>Foo</name>
	<super_list>:<super><specifier>public</specifier> <name>Bar</name></super></super_list>
<block>{<private type="default"> </private>}</block>;</class>

r-value reference


Element

  • <ref_qualifier>

XPath Query

  • types with r-value references

    //src:type[.//src:ref_qualifier]

reference declaration


Element

  • <modifier>

XPath Query

  • reference variable declarations

    //src:decl[src:type/src:modifier='&']

Example

int& x;
<decl_stmt><decl><type><name>int</name><modifier>&amp;</modifier></type> <name>x</name></decl>;</decl_stmt>

register


Element

  • <specifier>

XPath Query

  • variable declarations with the register specifier

    //src:decl[src:type/src:specifier='register']

Example

register int x;
<decl_stmt><decl><type><specifier>register</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>

restrict


Element

  • <specifier>

XPath Query

  • variables declarations with the restrict specifier

    //src:decl[src:type/src:specifier='restrict']

Example

restrict double* x;
<decl_stmt><decl><type><specifier>restrict</specifier> <name>double</name><modifier>*</modifier></type> <name>x</name></decl>;</decl_stmt>

return statement


Element

  • <return>

Subelement

  • <expr>

XPath Queries

  • return statements

    //src:return
  • return expressions

    //src:return/src:expr
  • return statements that return true

    //src:return[src:expr='true']
  • functions with more then one return

    //src:function[count(.//src:return) > 1]

Examples

return;
<return>return;</return>
return true;
<return>return <expr><name>true</name></expr>;</return>
return( s * (long long)s );
<return>return<expr><operator>(</operator> <name>s</name> <operator>*</operator> <operator>(</operator><name>long</name> <name>long</name><operator>)</operator><name>s</name> <operator>)</operator></expr>;</return>

rvalue reference


Element

  • <modifier>

XPath Query

  • rvalue reference variable declarations

    //src:decl[src:type/src:modifier='&&']

Example

int&& x;
<decl_stmt><decl><type><name>int</name><modifier>&amp;&amp;</modifier></type> <name>x</name></decl>;</decl_stmt>

sizeof


Element

  • <sizeof>

Subelements

  • <argument_list>
  • <name>

XPath Query

  • uses of sizeof

    //src:sizeof

Example

sizeof(struct type);
<expr_stmt><expr><sizeof>sizeof<argument_list>(<argument><expr>struct <name>type</name></expr></argument>)</argument_list></sizeof></expr>;</expr_stmt>

sizeof...


Element

  • <sizeof type="pack">

Subelements

  • <argument_list>
  • <name>

XPath Query

  • uses of sizeof…

    //src:sizeof[@type='pack']

Example

sizeof...(Args);
<expr_stmt><expr><sizeof type="pack">sizeof...<argument_list>(<argument><expr><name>Args</name></expr></argument>)</argument_list></sizeof></expr>;</expr_stmt>

static


Element

  • <specifier>

XPath Queries

  • static variables

    //src:decl[src:type/src:specifier='static']
  • static function declarations

    //src:function_decl[src:type/src:specifier='static']

Examples

static int x;
<decl_stmt><decl><type><specifier>static</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>
static void foo();
<function_decl><type><specifier>static</specifier> <name>void</name></type> <name>foo</name><parameter_list>()</parameter_list>;</function_decl>

static_assert


Element

  • <assert type="static">

Subelement

  • <argument_list>

XPath Query

  • uses of static_assert

    //src:assert[@type='static']

Example

static_assert(cond, "msg");
<assert type="static">static_assert<argument_list>(<argument><expr><name>cond</name></expr></argument>, <argument><expr><literal type="string">"msg"</literal></expr></argument>)</argument_list>;</assert>

struct declaration


Element

  • <struct_decl>

Subelement

  • <name>

XPath Query

  • forward struct declarations

    //src:struct_decl

Example

forward declaration

struct employee;
<struct_decl>struct <name>employee</name>;</struct_decl>

struct definition


Element

  • <struct>

Subelements

  • <name>
  • <super>
  • <block>

XPath Queries

  • struct definitions

    //src:struct
  • struct members

    //src:struct/src:block/*[self::src:public | self::src:private | self::src:protected]/src:decl_stmt

Examples

struct a {
    int x;
    double y;
    float z;
 };
<struct>struct <name>a</name> <block>{
    <decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>double</name></type> <name>y</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>float</name></type> <name>z</name></decl>;</decl_stmt>
 }</block>;</struct>

variable of an anonymous struct type

struct
{
    int x;
    int y;
} mystruct;
<struct>struct
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>y</name></decl>;</decl_stmt>
}</block> <decl><name>mystruct</name></decl>;</struct>

declaring a struct and instance

struct employee
{
    char name[20];
    int id;
    long cls;
} temp;
<struct>struct <name>employee</name>
<block>{
    <decl_stmt><decl><type><name>char</name></type> <name><name>name</name><index>[<expr><literal type="number">20</literal></expr>]</index></name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>id</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>long</name></type> <name>cls</name></decl>;</decl_stmt>
}</block> <decl><name>temp</name></decl>;</struct>

switch statement


Element

  • <switch>

Subelements

  • <condition>
  • <case>
  • <block>

XPath Queries

  • switch statements

    //src:switch
  • switch-statement conditions

    //src:switch/src:condition

Examples

switch (c) {

    case 'A':
        ++capa;
    case 'a':
        ++lettera;
    default :
        ++total;
}
<switch>switch <condition>(<expr><name>c</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><literal type="char">'A'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>capa</name></expr>;</expr_stmt>
    <case>case <expr><literal type="char">'a'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>lettera</name></expr>;</expr_stmt>
    <default>default :</default>
        <expr_stmt><expr><operator>++</operator><name>total</name></expr>;</expr_stmt>
</block_content>}</block></switch>
switch (i) {

    case -1:
        ++n;
        break;
    case 0 :
        ++z;
        break;
    case 1 :
        ++p;
        break;
}
<switch>switch <condition>(<expr><name>i</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><operator>-</operator><literal type="number">1</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>n</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">0</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>z</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">1</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>p</name></expr>;</expr_stmt>
        <break>break;</break>
</block_content>}</block></switch>

template


Element

  • <template>

Subelements

  • <parameter_list>
  • <parameter>
  • <typename>

XPath Queries

  • class templates

    //src:class[src:template]
  • function templates

    //src:function[src:template]

Examples

templated class

template<typename T>
class Foo {
};
<class><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
class <name>Foo</name> <block>{<private type="default">
</private>}</block>;</class>

templated function

template<typename T>
void swap(T& lhs, T& rhs);
<function_decl><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
<type><name>void</name></type> <name>swap</name><parameter_list>(<parameter><decl><type><name>T</name><modifier>&amp;</modifier></type> <name>lhs</name></decl></parameter>, <parameter><decl><type><name>T</name><modifier>&amp;</modifier></type> <name>rhs</name></decl></parameter>)</parameter_list>;</function_decl>

partial template specialization

template<typename T>
class Foo<T, void>
{

};
<class><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
class <name><name>Foo</name><argument_list type="generic">&lt;<argument><expr><name>T</name></expr></argument>, <argument><expr><name>void</name></expr></argument>&gt;</argument_list></name>
<block>{<private type="default">

</private>}</block>;</class>

template member function template

template<typename T1>
template<typename T2>
int string<T1>::compare(const T2& s) { }
<function><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T1</name></parameter>&gt;</parameter_list></template>
<template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T2</name></parameter>&gt;</parameter_list></template>
<type><name>int</name></type> <name><name><name>string</name><argument_list type="generic">&lt;<argument><expr><name>T1</name></expr></argument>&gt;</argument_list></name><operator>::</operator><name>compare</name></name><parameter_list>(<parameter><decl><type><specifier>const</specifier> <name>T2</name><modifier>&amp;</modifier></type> <name>s</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
template<typename T1>
<template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T1</name></parameter>&gt;</parameter_list></template>

template parameter pack


Element

  • <modifier>

XPath Query

  • class templates with a template parameter pack

    //src:class[src:template/src:parameter_list/src:parameter/src:type/src:modifier='...']

Example

template<typename... Args>
class Foo { };
<class><template>template<parameter_list>&lt;<parameter><type><name>typename</name><modifier>...</modifier></type> <name>Args</name></parameter>&gt;</parameter_list></template>
class <name>Foo</name> <block>{<private type="default"> </private>}</block>;</class>

template parameters


Element

  • <parameter_list>

Subelement

  • <param>

XPath Queries

  • template parameters

    //src:template/src:parameter_list/src:parameter
  • class templates with a template parameter

    //src:class[src:template/src:parameter_list/src:parameter/src:type/src:template]

Examples

typename parameter

template<typename T>
struct Foo { };
<struct><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
struct <name>Foo</name> <block>{<public type="default"> </public>}</block>;</struct>

class parameter

template<class T>
struct Foo { };
<struct><template>template<parameter_list>&lt;<parameter><type><name>class</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
struct <name>Foo</name> <block>{<public type="default"> </public>}</block>;</struct>

default template parameter

template<typename T = Bar>
class Foo { };
<class><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name> <init>= <expr><name>Bar</name></expr></init></parameter>&gt;</parameter_list></template>
class <name>Foo</name> <block>{<private type="default"> </private>}</block>;</class>

template parameter pack

template<class ... Types> struct Tuple {};
<struct><template>template<parameter_list>&lt;<parameter><type><name>class</name> <modifier>...</modifier></type> <name>Types</name></parameter>&gt;</parameter_list></template> struct <name>Tuple</name> <block>{<public type="default"/>}</block>;</struct>

template template parameter

template<template<typename> class C>
class Foo { };
<class><template>template<parameter_list>&lt;<parameter><type><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type></parameter>&gt;</parameter_list></template> <name>class</name></type> <name>C</name></parameter>&gt;</parameter_list></template>
class <name>Foo</name> <block>{<private type="default"> </private>}</block>;</class>

template specifier


Element

  • <specifier>

XPath Query

  • names with a template specifier

    //src:name[src:name/src:specifier='template']

Example

template used as a specifier

typename t::template iterator<int>::value_type v;
<decl_stmt><decl><type><name><typename>typename</typename> <name>t</name><operator>::</operator><specifier>template</specifier> <name>iterator</name><argument_list type="generic">&lt;<argument><expr><name>int</name></expr></argument>&gt;</argument_list><operator>::</operator><name>value_type</name></name></type> <name>v</name></decl>;</decl_stmt>

ternary operator


Element

  • <ternary>

Subelements

  • <condition>
  • <then>
  • <else>

XPath Query

  • ternary operators

    //src:ternary

Example

a ? x : y;
<expr_stmt><expr><ternary><condition><expr><name>a</name></expr> ?</condition><then> <expr><name>x</name></expr> </then><else>: <expr><name>y</name></expr></else></ternary></expr>;</expr_stmt>

then


Element

  • <then>

Subelement

  • <expr>

XPath Query

  • then parts of ternary

    //src:then

this


Element

  • <name>

XPath Query

  • uses of this

    //src:name[.='this']

Example

this->x = 5;
<expr_stmt><expr><name><name>this</name><operator>-&gt;</operator><name>x</name></name> <operator>=</operator> <literal type="number">5</literal></expr>;</expr_stmt>

thread_local


Element

  • <specifier>

XPath Query

  • thread_local variable declarations

    //src:decl[src:type/src:specifier='thread_local']

Example

thread_local int i;
<decl_stmt><decl><type><specifier>thread_local</specifier> <name>int</name></type> <name>i</name></decl>;</decl_stmt>

try


Element

  • <try>

Subelements

  • <block>
  • <catch>

XPath Query

  • try block

    //src:try

Example

try {

}
<try>try <block>{<block_content>

</block_content>}</block></try>

type


Element

  • <type>

Subelements

  • <specifier>
  • <name>

XPath Queries

  • types

    //src:type
  • declaration types

    //src:decl/src:type
  • function types

    //src:function/src:type
  • function declaration types

    //src:function_decl/src:type

typedef


Element

  • <typedef>

Subelements

  • <type>
  • <name>
  • <function_decl>

XPath Queries

  • typedefs

    //src:typedef
  • types in typedefs

    //src:typedef/src:type
  • typedef names

    //src:typedef/src:name
  • typedefs that define a struct

    //src:typedef[src:type/src:struct]
  • typedefs that declare a function type

    //src:typedef[src:function_decl]
  • typedefs of function pointers

    //src:typedef[contains(src:function_decl, ')')]
  • names of typedefs of function pointers

    //src:typedef/src:function_decl[contains(., ')')]/src:name

Examples

typedef char C;
typedef unsigned int WORD;
typedef char * pChar;
typedef char field [50]; 
typedef char field, *field2; 
<typedef>typedef <type><name>char</name></type> <name>C</name>;</typedef>
<typedef>typedef <type><name>unsigned</name> <name>int</name></type> <name>WORD</name>;</typedef>
<typedef>typedef <type><name>char</name> <modifier>*</modifier></type> <name>pChar</name>;</typedef>
<typedef>typedef <type><name>char</name></type> <name><name>field</name> <index>[<expr><literal type="number">50</literal></expr>]</index></name>;</typedef> 
<typedef>typedef <type><name>char</name></type> <name>field</name>, <modifier>*</modifier><name>field2</name>;</typedef> 
typedef struct club 
{
    char name[30];
    int size, year;
} GROUP;
<typedef>typedef <type><struct>struct <name>club</name> 
<block>{
    <decl_stmt><decl><type><name>char</name></type> <name><name>name</name><index>[<expr><literal type="number">30</literal></expr>]</index></name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>size</name></decl>, <name>year</name>;</decl_stmt>
}</block></struct></type> <name>GROUP</name>;</typedef>
typedef void DRAWF( int, int );
<typedef>typedef <function_decl><type><name>void</name></type> <name>DRAWF</name><parameter_list>( <parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>int</name></type></decl></parameter> )</parameter_list>;</function_decl></typedef>
typedef void (*DRAWF)( int, int );
<typedef>typedef <function_decl><type><name>void</name></type> (<modifier>*</modifier><name>DRAWF</name>)<parameter_list>( <parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>int</name></type></decl></parameter> )</parameter_list>;</function_decl></typedef>

typeid


Element

  • <typeid>

Subelement

  • <argument_list>

XPath Query

  • uses of typeid

    //src:typeid

Example

typeid(x);
<expr_stmt><expr><typeid>typeid<argument_list>(<argument><expr><name>x</name></expr></argument>)</argument_list></typeid></expr>;</expr_stmt>

typename


Element

  • <typename>

XPath Query

  • class templates with a typename in the parameter list

    //src:class[src:template/src:parameter_list/src:parameter/src:type/src:typename]

Example

typename parameter

template<typename T>
struct Foo { };
<struct><template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T</name></parameter>&gt;</parameter_list></template>
struct <name>Foo</name> <block>{<public type="default"> </public>}</block>;</struct>

uniform initialization syntax


Element

  • <call>

Subelement

  • <block>

XPath Query

  • declaration statements with the uniform initialization syntax

    //src:decl_stmt[contains(src:decl/src:argument_list, '{')]

Example

T x{ arg };
<decl_stmt><decl><type><name>T</name></type> <name>x</name><argument_list>{ <argument><expr><name>arg</name></expr></argument> }</argument_list></decl>;</decl_stmt>

union declaration


Element

  • <union_decl>

Subelement

  • <name>

XPath Query

  • forward declarations for unions

    //src:union_decl

Example

union X;
<union_decl>union <name>X</name>;</union_decl>

union definition


Element

  • <union>

Subelements

  • <name>
  • <block>

XPath Query

  • union definitions

    //src:union

Example

union sign
{
    int svar;
    unsigned uvar;
} number;
<union>union <name>sign</name>
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>svar</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>unsigned</name></type> <name>uvar</name></decl>;</decl_stmt>
}</block> <decl><name>number</name></decl>;</union>

using


Element

  • <using>

Subelement

  • <name>

XPath Queries

  • using declarations

    //src:using
  • using namespace declarations

    //src:using[src:namespace]
  • using declarations that import a single item which isn’t a namespace

    //src:using[not(src:namespace) and not(src:template)]
  • templated using declarations

    //src:using[src:template]

Examples

using namespace std;
<using>using <namespace>namespace <name>std</name>;</namespace></using>
using Base::reference;
<using>using <name><name>Base</name><operator>::</operator><name>reference</name></name>;</using>

type aliasing

template<class T> using Vec = vector<T, Alloc<T>>;
<using><template>template<parameter_list>&lt;<parameter><type><name>class</name></type> <name>T</name></parameter>&gt;</parameter_list></template> using <name>Vec</name> <init>= <type><name><name>vector</name><argument_list type="generic">&lt;<argument><expr><name>T</name></expr></argument>, <argument><expr><name><name>Alloc</name><argument_list type="generic">&lt;<argument><expr><name>T</name></expr></argument>&gt;</argument_list></name></expr></argument>&gt;</argument_list></name></type></init>;</using>

variable declaration


Element

  • <decl>

Subelements

  • <name>
  • <init>

XPath Queries

  • variable declarations

    //src:decl
  • variable declarations with an initialization

    //src:decl[src:init]
  • variable declarations with the struct qualifier

    //src:decl[contains(src:type, 'struct')]

Examples

int x;
<decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>

struct declarations

struct X y;
<decl_stmt><decl><type><name><name>struct</name> <name>X</name></name></type> <name>y</name></decl>;</decl_stmt>

variable declaration statement


Element

  • <decl_stmt>

Subelement

  • <decl>

XPath Queries

  • declaration statements

    //src:decl_stmt
  • variable declaration statements with the union qualifier

    //src:decl_stmt/src:decl[contains(src:type, 'union')]

Examples

int x;
<decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>

struct declarations

struct X y;
<decl_stmt><decl><type><name><name>struct</name> <name>X</name></name></type> <name>y</name></decl>;</decl_stmt>

template variable

vector<int> x;
<decl_stmt><decl><type><name><name>vector</name><argument_list type="generic">&lt;<argument><expr><name>int</name></expr></argument>&gt;</argument_list></name></type> <name>x</name></decl>;</decl_stmt>

virtual


Element

  • <specifier>

XPath Query

  • virtual function declarations

    //src:function_decl[src:type/src:specifier='virtual']

Example

virtual void dump() const;
<function_decl><type><specifier>virtual</specifier> <name>void</name></type> <name>dump</name><parameter_list>()</parameter_list> <specifier>const</specifier>;</function_decl>

volatile


Element

  • <specifier>

XPath Query

  • volatile variables

    //src:decl[src:type/src:specifier='volatile']

Example

volatile int foo; 
int volatile foo;
<decl_stmt><decl><type><specifier>volatile</specifier> <name>int</name></type> <name>foo</name></decl>;</decl_stmt> 
<decl_stmt><decl><type><name>int</name> <specifier>volatile</specifier></type> <name>foo</name></decl>;</decl_stmt>

while statement


Element

  • <while>

Subelements

  • <condition>
  • <block>

XPath Queries

  • while loops

    //src:while
  • while-loop conditions

    //src:while/src:condition
  • while loops with a condition containing the variable i

    //src:while[src:condition//src:name = 'i']

Example

while ( i >= 0 ) 
{
    string1[i] = string2[i];
    i--;
}
<while>while <condition>( <expr><name>i</name> <operator>&gt;=</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
    <expr_stmt><expr><name><name>string1</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name><name>string2</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block></while>