C++ srcML Language Documentation

Statements XML Element Subelements

if statement

<if>

<condition>, <then>, <else>, <elseif>

while statement

<while>

<condition>, <block>

for statement

<for>

<control>, <block>

do statement

<do>

<block>, <condition>

break statement

<break>

continue statement

<continue>

return statement

<return>

<expr>

switch statement

<switch>

<condition>, <case>, <block>

case statement

<case>

<expr>

default statement

<default>

block

<block>

label

<label>

<name>

goto statement

<goto>

<name>

empty statement

<empty_stmt>

Specifiers XML Element Subelements

const

<specifier>

static

<specifier>

inline

<specifier>

volatile

<specifier>

restrict

<specifier>

auto specifier

<specifier>

auto type

<name>

register

<specifier>

extern block

<extern>

<literal>, <function_decl>, <decl_stmt>, <block>

extern specifier

<specifier>

mutable

<specifier>

thread_local

<specifier>

constexpr

<specifier>

final

<specifier>

override

<specifier>

friend

<friend>

virtual

<specifier>

delete specifier

<specifier>

default specifier

<specifier>

explicit

<specifier>

template specifier

<specifier>

<parameter_list>, <parameter>, <typename>

Declarations, Definitions and Initializations XML Element Subelements

variable declaration statement

<decl_stmt>

<decl>

variable declaration

<decl>

<name>, <init>

function declaration

<function_decl>

<type>, <name>, <parameter_list>

function definition

<function>

<type>, <name>, <parameter_list>

default function arguments

<init>

<expr>

abstract function declaration

<literal>

lambda functions

<lambda>

<parameter_list>, <capture>, <block>

namespace

<namespace>

<name>, <block>

using

<using>

<name>

typedef

<typedef>

<type>, <name>, <function_decl>

pointer declaration

<modifier>

reference declaration

<modifier>

rvalue Reference

<modifier>

array declaration

<decl>

<name>, <index>

array initialization

<init>

<block>

bitfield

<range>

<literal>, <name>

Uniform initialization syntax

<call>

<block>

operator overloading declaration

<function_decl>

<type>, <name>, <parameter_list>

operator overloading definition

<function>

<type>, <name>, <parameter_list>

implicit conversion operator declaration

<function_decl>

<name>, <parameter_list>

implicit conversion operator definition

<function>

<name>, <parameter_list>

explicit conversion operator declaration

<function_decl>

<type>, <name>, <parameter_list>

explicit conversion operator definition

<function>

<type>, <name>, <parameter_list>

Classes, Structs, Unions and Enums XML Element Subelements

class

<class>

<name>, <block>

class declaration

<class_decl>

<name>

inheritance list

<super>

<specifier>, <name>

default public visibility

<public>

public visibility

<public>

default private visibility

<private>

private visibility

<private>

protected visibility

<protected>

protected inheritance specifier

<specifier>

private inheritance specifier

<specifier>

public inheritance specifier

<specifier>

constructor

<constructor>

<name>, <parameter_list>, <member_list>, <block>

constructor declaration

<constructor_decl>

<name>, <parameter_list>

destructor

<destructor>

<name>

destructor declaration

<destructor_decl>

<name>

struct declaration

<struct_decl>

struct definition

<struct>

<name>, <super>

struct initialization

<decl_stmt>

<decl>, <init>, <block>

union declaration

<union_decl>

<name>

union definition

<union>

<name>, <block>

enum definition

<enum>

<name>, <block>

enum declaration

<enum>

<name>

enum class

<enum>

Expressions XML Element Subelements

function call

<call>

<name>, <argument_list>

new

<operator>

delete

<operator>

array indexing

<name>

<name>, <index>

ternary operator

<ternary>

<condition>, <then>, <else>

dereference member access

<expr>

<name>, <operator>

member access

<expr>

<name>, <operator>

this

<name>

Other XML Element Subelements

static_cast

<cast>

<argument_list>

dynamic_cast

<cast>

<argument_list>

reinterpret_cast

<cast>

<argument_list>

const_cast

<cast>

<argument_list>

c-style cast

<operator>

<name>

static_assert

<assert>

<argument_list>

sizeof

<sizeof>

<argument_list>

typeid

<typeid>

<argument_list>

noexcept

<noexcept>

<argument_list>

alignof

<alignof>

<argument_list>

alignas

<alignas>

<argument_list>

decltype

<decltype>

<argument_list>

attributes

<attribute>

<expr>

asm

<asm>

Templates XML Element Subelements

template

<template>

<parameter_list>, <parameter>, <typename>

template parameters

<parameter_list>

<param>

typename

<typename>

class type specifier

<typename>

template parameter pack

<modifier>

Exceptions XML Element Subelements

throw

<throw>

<expr>

try

<try>

<block>, <catch>

catch

<catch>

<parameter_list>

function try-catch

<try>

<catch>, <block>, <member_list>

if statement


Element

Subelements

XPath Queries

  • if statements

    //src:if
  • if-statement conditions

    //src:if/src:condition
  • then statements

    //src:if/src:then
  • else statements

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

    //src:if[count(src:else) = 0]
  • nested if statements

    //src:if//src:if
  • else-if statements

    //src:elseif

Examples

if(x > 5)
    y+=4;
<if>if<condition>(<expr><name>x</name> <operator>&gt;</operator> <literal type="number">5</literal></expr>)</condition><then><block type="pseudo">
    <expr_stmt><expr><name>y</name><operator>+=</operator><literal type="number">4</literal></expr>;</expr_stmt></block></then></if>
if ( i > 0 ) {
    y = x / i;
}
<if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><then> <block>{
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt>
}</block></then></if>
if ( i > 0 )
    y = x / i;
else 
{
    x = i;
    y = f( x );
}
<if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><then><block type="pseudo">
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt></block></then>
<else>else 
<block>{
    <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></else></if>

Without braces

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

With braces

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

while statement


Element

Subelements

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>{
    <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></while>

for statement


Element

Subelements

XPath Queries

  • for loops

    //src:for
  • for-loop initialization statements

    //src:for/src:control/src:init
  • for loops which 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 which use post decrement as part of the increment expression

    //src:for[src:control/src:incr/src:expr//node()/following-sibling::src:operator[.= '++']]
  • for-loop increments

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

    //src:for/src:control/src:condition
  • range-based for loops

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

Examples

for( ;; ) { }
<for>for<control>( <init>;</init><condition>;</condition> <incr/>)</control> <block>{ }</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>{
  <if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">' '</literal></expr> )</condition><then>
  <block>{
      <expr_stmt><expr><name>space</name><operator>++</operator></expr>;</expr_stmt>
  }</block></then></if>
  <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><then>
  <block>{
      <expr_stmt><expr><name>tab</name><operator>++</operator></expr>;</expr_stmt>
  }</block></then></if>
}</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">
	<expr_stmt><expr><name>a</name> <operator>+=</operator> <name><name>x</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt></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">
    <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></for>

return statement


Element

Subelement

XPath Queries

  • return statements

    //src:return
  • functions with more then one return

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

Examples

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>
return;
<return>return;</return>

case statement


Element

Subelement

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:case[.//src:name = 'SATURDAY']]

Example

case THREE:
<case>case <expr><name>THREE</name></expr>:</case>

default statement


Element

XPath Queries

  • default labels

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

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

Example

default:
<default>default:</default>

label


Element

Subelement

XPath Queries

  • labels

    //src:label
  • labels without a goto statement

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

Example

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

goto statement


Element

Subelement

XPath Query

  • goto statements

    //src:goto

Example

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

empty statement


Element

XPath Query

  • empty statements

    //src:empty_stmt

Example

;
<empty_stmt>;</empty_stmt>

const


Element

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>

static


Element

XPath Queries

  • static function declarations

    //src:function_decl[src:type/src:specifier [.='static']]
  • static variables

    //src:decl[src:type/src:specifier [.='static']]

Examples

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

inline


Element

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><specifier>inline</specifier> <type><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>

volatile


Element

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>

restrict


Element

XPath Query

  • variables declared with the restrict specifier

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

Example

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

auto specifier


Element

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

XPath Query

  • variables declared 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></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>

register


Element

XPath Query

  • variables declared with the register specifier

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

Example

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

extern block


Element

Subelements

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></extern>

extern specifier


Element

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><specifier>extern</specifier> <type><name>int</name></type> <name>X</name></decl>;</decl_stmt>

external structure

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

external function

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

mutable


Element

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>

thread_local


Element

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>

final


Element

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><specifier>virtual</specifier> <type><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>

override


Element

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> 

virtual


Element

XPath Query

  • virtual function declarations

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

Example

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

delete specifier


Element

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>

default specifier


Element

XPath Queries

  • constructors which explicitly use the compiler’s provided implementation

    //src:constructor_decl[src:specifier [.='default']]
  • functions which explicitly use the compiler’s 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>

explicit


Element

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>

template specifier


Element

Subelements

XPath Query

  • names which contain 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><name><specifier>template</specifier> <name>iterator</name><argument_list type="generic">&lt;<argument><expr><name>int</name></expr></argument>&gt;</argument_list></name><operator>::</operator><name>value_type</name></name></type> <name>v</name></decl>;</decl_stmt>

variable declaration statement


Element

Subelement

XPath Queries

  • declaration statements

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

    //src:decl_stmt/src:decl[src:type[contains(., '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>

variable declaration


Element

Subelements

XPath Queries

  • variable declarations

    //src:decl
  • variable declarations with an initialization

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

    //src:decl[src:type[contains(., '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>

function declaration


Element

Subelements

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[src:parameter_list[count(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></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

Subelements

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[src:parameter_list[count(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>{
    <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></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></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></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></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></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></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></function>

abstract function declaration


Element

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><specifier>virtual</specifier> <type><name>void</name></type> <name>dump</name><parameter_list>()</parameter_list> <specifier>const</specifier> = <literal type="number">0</literal>;</function_decl>
</public>}</block>;</struct>

lambda functions


Element

Subelements

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>{ <return>return <expr><literal type="number">0</literal></expr>;</return>}</block></lambda></expr></expr_stmt> 
[] { return 0; } 
<expr_stmt><expr><lambda><capture>[]</capture> <block>{ <return>return <expr><literal type="number">0</literal></expr>;</return> }</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>{ <return>return <expr><literal type="number">0</literal></expr>;</return>}</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>{ <return>return <expr><name>i</name></expr>;</return> }</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>{ <return>return <expr><literal type="number">0</literal></expr>;</return>}</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>{ <return>return <expr><literal type="number">0</literal></expr>;</return>}</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>{ <return>return <expr><literal type="number">0</literal></expr>;</return>}</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></lambda></expr>

namespace


Element

Subelements

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>

using


Element

Subelement

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>

typedef


Element

Subelements

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[src:function_decl/text()[contains(., ')')]]
  • names of typedefs of function pointers

    //src:typedef/src:function_decl[text()[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>

pointer declaration


Element

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>

reference declaration


Element

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>

rvalue Reference


Element

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>

bitfield


Element

Subelements

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>

Uniform initialization syntax


Element

Subelement

XPath Query

  • declaration statements that use the uniform initialization syntax

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

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>

operator overloading declaration


Element

Subelements

XPath Query

  • operator declarations

    //src:function_decl[-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>

implicit conversion operator declaration


Element

Subelements

XPath Query

  • implicit conversion operator overload declarations

    //src:function_decl[-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

Subelements

XPath Query

  • implicit conversion operator overload definitions

    //src:function[-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>{ <return>return <expr><name><name>x</name><operator>-&gt;</operator><name>foo</name></name></expr>;</return> }</block></function>

explicit conversion operator declaration


Element

Subelements

XPath Query

  • explicit conversion operator declarations

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

Example

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

explicit conversion operator definition


Element

Subelements

XPath Query

  • explicit conversion operator overloads

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

Example

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

class declaration


Element

Subelement

XPath Query

  • class declarations

    //src:class_decl

Example

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

inheritance list


Element

Subelements

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>:<name>Bar1</name>, <name>OtherBar</name></super>
<block>{<private type="default"> </private>}</block>;</class>

default public visibility


Element

XPath Query

  • functions declared in the default public area of a struct

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

Example

struct Foo {

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

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

public visibility


Element

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>

default private visibility


Element

XPath Query

  • functions declared within the default private area of a class

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

Example

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

private visibility


Element

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>

protected visibility


Element

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

XPath Query

  • classes that use protected inheritance

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

Example

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

private inheritance specifier


Element

XPath Query

  • classes that use private inheritance

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

Example

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

public inheritance specifier


Element

XPath Query

  • classes that use private inheritance

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

Example

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

constructor


Element

Subelements

XPath Queries

  • constructors

    //src:constuctor
  • constructors with no parameters

    //src:constuctor[src:parameter_list[not(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></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></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></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></constructor>

constructor declaration


Element

Subelements

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>

destructor declaration


Element

Subelement

XPath Query

  • destructor declarations

    //src:destructor_decl

Example

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

struct declaration


Element

XPath Query

  • forward declarations for all structs

    //src:struct_decl

Example

forward declaration

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

union declaration


Element

Subelement

XPath Query

  • forward declarations for unions

    //src:union_decl

Example

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

union definition


Element

Subelements

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>

enum definition


Element

Subelements

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>

enum declaration


Element

Subelement

XPath Query

  • enum declarations

    //src:enum_decl

Example

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

enum class


Element

XPath Query

  • enum class definitions

    //src:enum[-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>

new


Element

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']]]
  • expressions which call placement new

    //src:expr[src:operator[.='new']/following-sibling::node()[2]/self::src:operator[.='(']/following-sibling::node()[not(self::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>

delete


Element

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>

dereference member access


Element

Subelements

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>

member access


Element

Subelements

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>

reinterpret_cast


Element

Subelement

XPath Query

  • uses of reinterpret_cast

    //src:cast[-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>

static_assert


Element

Subelement

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>

alignas


Element

Subelement

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>

attributes


Element

Subelement

XPath Queries

  • attributes

    //src:attribute
  • noreturn functions

    //src:function[src:type/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></function>
[[noreturn]]
<attribute>[[<expr><name>noreturn</name></expr>]]</attribute>

asm


Element

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>

template


Element

Subelements

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></function>
template<typename T1>
<template>template<parameter_list>&lt;<parameter><type><name>typename</name></type> <name>T1</name></parameter>&gt;</parameter_list></template>

template parameters


Element

Subelement

XPath Queries

  • template parameters

    //src:template/src:parameter_list/src:parameter
  • class templates which use a template 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>

typename


Element

XPath Query

  • class templates which use typename as part of its 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>

class type specifier


Element

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/src:name[.='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>

template parameter pack


Element

XPath Query

  • class templates that use 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>

try


Element

Subelements

XPath Query

  • try block

    //src:try

Example

try {

}
<try>try <block>{

}</block></try>

function try-catch


Element

Subelements

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> <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></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> <catch>catch<parameter_list>(<parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list> <block>{

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