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 while 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 statement

<block>

label

<label>

<name>

goto statement

<goto>

<name>

empty statement

<empty_stmt>

Specifiers XML Element Subelements

const

<specifier>

volatile

<specifier>

restrict

<specifier>

auto

<specifier>

register

<specifier>

extern linkage

<extern>

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

extern specifier

<specifier>

static

<specifier>

inline

<specifier>

Declarations/Definitions 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>, <block>

pointer declaration

<modifier>

typedef

<typedef>

<type>, <name>, <function_decl>

array declaration

<decl>

<name>

array initialization

<init>

<block>

bitfield

<range>

<expr>

Struct, Union and Enum XML Element Subelements

struct declaration

<struct_decl>

<name>

struct definition

<struct>

<name>, <block>

struct initialization

<decl_stmt>

<decl>

union declaration

<union_decl>

<name>, <block>

union definition

<union>

<name>, <block>

enum definition

<enum>

<name>, <block>

enum declaration

<enum>

<name>

Expressions XML Element Subelements

function call

<call>

<name>, <argument_list>, <argument>

array indexing

<name>

<name>

ternary operator

<ternary>

<condition>, <then>, <else>

dereference member access

<expr>

<name>, <operator>

member access

<expr>

<name>, <operator>

Other XML Element Subelements

cast

<operator>

sizeof

<sizeof>

<argument_list>

_Alignas

<alignas>

<argument_list>

_Alignof

<alignof>

<argument_list>

_Atomic

<atomic>

<argument_list>

_Generic

<generic_selection>

<selector>, <association_list>

_Noreturn

<specifier>

_Static_assert

<assert>

<argument_list>

_Thread_local

<specifier>

asm

<asm>

if statement


Element

Subelements

XPath Queries

  • if statements

    //src:if
  • Conditions of if statements

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

    //src:then
  • else statements

    //src:else
  • if statements without an else, this doesn’t exclude else if statements

    //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>
else if( i < 0)
	x = q;
else 
    x = j;
<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>

while statement


Element

Subelements

XPath Queries

  • while statements

    //src:while
  • Conditions of while statements

    //src:while/src:condition
  • while statements which have a condition containing the variable ‘i’

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

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
  • Initialization statements of for loops

    //src:for/src:control/src:init
  • Conditions of for loops

    //src:for/src:control/src:condition
  • Increment expressions of for loops

    //src:for/src:control/src:incr
  • 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 increment as part of the increment expression

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

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>

return statement


Element

Subelement

XPath Queries

  • return statements

    //src:return
  • Functions with more than one return statement

    //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 which use SATURDAY

    //src:case[.//src:name = 'SATURDAY']
  • switch statements which have 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 which have a default label

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

Example

default:
<default>default:</default>

label


Element

Subelement

XPath Queries

  • labels

    //src:label
  • labels without goto statements

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

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 specifier restrict

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


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>

register


Element

XPath Query

  • variables declared with the specifier register

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


Element

Subelements

XPath Query

  • extern blocks

    //src:extern

Examples

External 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>

static


Element

XPath Queries

  • static functions

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

variable declaration statement


Element

Subelement

XPath Queries

  • variable 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>

variable declaration


Element

Subelements

XPath Queries

  • variable declarations

    //src:decl
  • variable declarations which also initialize the variable

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

    //src:decl[src:type/src:name/src:name = '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
  • return types from function declarations

    //src:function_decl/src:type
  • parameters from function declarations

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

    //src:function_decl[src:parameter_list[count(src:parameter) = 2]]
  • Names of function declarations

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

function definition


Element

Subelements

XPath Queries

  • function definitions

    //src:function
  • return types from function definitions

    //src:function/src:type
  • parameters from function definitions

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

    //src:function[src:parameter_list[count(src:parameter) = 2]]
  • Names of function definitions

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

pointer declaration


Element

XPath Queries

  • variable declarations of a pointer

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

    //src:function_decl[src:modifier ='*']

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>

typedef


Element

Subelements

XPath Queries

  • typedefs

    //src:typedef
  • types within typedefs

    //src:typedef/src:type
  • names for typedefs

    //src:typedef/src:name
  • typedefs that are used to define a struct

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

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

    //src:typedef[src:function_decl/src:modifier= '*']
  • names from typedefs of function pointers

    //src:typedef/src:function_decl/src:modifier[.='*']/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>

bitfield


Element

Subelement

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>

struct declaration


Element

Subelement

XPath Query

  • of the forward declarations for all structs

    //src:struct_decl

Example

Forward declaration

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

union declaration


Element

Subelements

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>

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>

sizeof


Element

Subelement

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>

_Alignof


Element

Subelement

XPath Query

  • uses of _Alignof

    //src:alignof

Example

_Alignof(union type);
<expr_stmt><expr><alignof>_Alignof<argument_list>(<argument><expr>union <name>type</name></expr></argument>)</argument_list></alignof></expr>;</expr_stmt>

_Static_assert


Element

Subelement

XPath Query

  • uses of _Static_assert

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

Example

_Static_assert(DEBUG_LEVEL > 5, "Message");
<assert type="static">_Static_assert<argument_list>(<argument><expr><name>DEBUG_LEVEL</name> <operator>&gt;</operator> <literal type="number">5</literal></expr></argument>, <argument><expr><literal type="string">"Message"</literal></expr></argument>)</argument_list>;</assert>

_Thread_local


Element

XPath Query

  • uses of _Thread_local

    //src:specifier[.='_Thread_local']

Example

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

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>