In this chapter:
Nodes describing an "attribute" as it appeared in the source. The following attribute nodes are available:
AttributeNode describing an "attribute" as it appeared in the source. For example:
|
void fx1() { /* ... */; } void fx2() __attribute__((weak, alias("fx1")));// Both attributes have the same Attribute Group |
Constant value of any type. The following constant nodes are available:
Integer ConstantConstant integer expression. For example:
Real ConstantConstant expression that is a real number. For example: String ConstantConstant string expression. For example:
Template Parameter ConstantA constant template parameter in template class declaration. For example:
bool ConstantA constant value of true or false. enum ConstantAn enum identifier declared in body of enum declaration. For example:
nullptr constantA pointer literal of type std::nullptr_t. For example:
|
Nodes representing various declarations in user code.
Some declaration nodes can be accessed from both their declaration and expressions that reference the declaration. In these cases, the IsDecl
property returns a boolean, allowing users to distinguish between the actual declaration and references to that declaration.
The following declaration nodes are available:
Explicit Template InstanceExplicit template instances for types, functions and variables. For example:
FriendFriend function declaration. For example:
FunctionsFunction declarations. This includes Global and Member functions.. Global FunctionGlobal function declaration. For example:
Member FunctionMember function declaration. For example:
ParameterParameters include parameter and this. ParameterFunction parameter declaration. For example:
ThisParameter usage. For example:
VariablesVariables include global, local, and member variables. Global VariableGlobal Variable. For example:
Local VariableLocal Variable. For example:
Member VariableMember Variable. For example:
|
Includes all types of expression nodes:
AssignmentIncludes all expression nodes used for assignment. ++aPreincrement expression. For example:
--aPre-decrement expression. For example:
a%=bMod-equals operator expression. For example:
a&=bBitwise-and-equals operator expression. For example:
a*=bMultiply-equals operator expression. For example:
a++Post increment expression. For example:
a+=bPlus-equals operator expression. For example:
a--Post decrement expression. For example:
a-=bMinus-equals operator expression. For example:
a/=bDivide-equals operator expression. For example:
a<<=bLeft-shift-equals operator expression. For example:
a=bAssignment operator expression. For example:
a>>=bRight-shift-equals operator expression. For example:
a^=bBitwise-xor-equals operator expression. For example:
a|=bBitwise-or-equals operator expression. For example:
BitwiseExpressions involving non-assignment bitwise operators. a&bBitwise 'and' expression. For example:
a^bBitwise XOR expression. For example:
a|bBitwise 'or' expression. For example:
~aBitwise 'not' expression. For example:
ComparisonExpressions that compare values. a!=bNot-equal operator expression. For example:
a<=b'Less than or equals' expression. For example:
a<b'Less than' expression. For example:
a==bEquality operator expression. For example:
a>=b'Greater than or equals' expression. For example:
a>b'Greater than' expression. For example:
LogicalComparison expressions involving logical operators. !aLogical 'not' expression. For example:
a&&bLogical 'and' expression. For example:
a||bLogical 'or' expression. For example:
MiscellaneousMiscellaneous expressions that don't fit in other categories. &aAddress of expression. For example:
*aDereference expression. For example:
a->bDereference operator expression. For example:
|
size_t a = alignof(int); // alignment of type int |
Expression that casts from one type to another. For example:
void func() { char c = 'c'; int i = (int)c; // normal (C-style) cast } |
A generic association in a generic selection. For example:
_Generic((X) , int: f_int // Generic association , float: f_float // Generic association , default: f_other // Generic association ) |
A C11 generic selection expression. For example:
int is_int = _Generic(10, int: 1, default: 0); // Generic expression |
A compound statement enclosed in parentheses that may appear as an expression in GNU C. For example:
int foo(); void bar(int p){ p=({/* GNU Statement Expression start */ int y = foo (); int z; if(y>0)z = y; else z = -y; z; }); } |
Expression containing initializations, used in member functions. For example:
class Foo { public: Foo() _x(0), _y(0) {} // Initializer list private: int _x; int _y; }; |
An expression using an overloaded operator. For example:
#include <iostream.h> void func() { cout << "Hello, how old are you?" // Overloaded << << endl; // Overloaded << int age; cin >> age; // Overloaded >> } |
Label in goto statement. For example:
void func() { int i; goto label1; //label with name 'label1' | := 0; label1: |:=1; } |
Function call expression. For example:
void foo(int i) {} void bar(int x) { foo(x); // Function call a(b). // Left Hand Side is Function foo, // Right Hand Side is Parameter x } |
Compound statement list. For example:
void func() { for (int i = 0; i >=0, i < 10; i++) { // a,b in for condition } } |
Arrow-star expression used in pointers to member functions. For example:
class Foo { public: void func(); }; typedef void(Foo::*mpf)(); void bar(Foo *f) { mpf ampf = &Foo::func; (f->*ampf)(); // a->*b } |
Dot-star expression used in pointers to member functions. For example:
class Foo { public: void func(); }; typedef void(Foo::*mpf)(); void bar(Foo f) { mpf ampf = &Foo::func; (f.*ampf)(); // a.*b } |
Dot operator expression. For example:
class Foo { public: void func(); int zzz; }; int bar() { Foo f; f.func(); // a.b return f.zzz; // a.b } |
Obsolete. Formerly used to represent scope reference expressions. Use ScopePrefix instead.
Ternary operator expression. For example:
bool func(int x) { return x ? true : false; // Ternary operator a?b:c } |
Array reference. For example:
char array[] = "John Doe"; char c = array[0]; // array reference a[b] |
Inlined assembly expression. For example:
void func() { asm(mov eax, ebp); // asm } |
Delete operator expression. For example:
int *i = new int(); delete(i); // delete |
Ellipses expression used for catch parameters. For example:
void func() { try { } catch(...) {} // catch parameter is (...) } |
New operator expression. For example:
int *i = new int[20]; // new
Sizeof operator expression. For example:
int *i = malloc(20*sizeof(int)); // sizeof
Throw operator expression. For example:
void func() { throw; // throw } |
Typeid operator expression used for RTTI. For example:
class Shape {}; void f(Shape& r) { typeid(r); // typeid |
Noexcept operator. For example:
bool func(int x, int y) { return noexcept(x + y) || noexcept(func(x, y); } |
Explicit destructor call for simple types or classes that do not have a type. For simple types, this represents a pseudo-destructor call. For example:
struct S {} s; s.S::~S(); typedef int INT; int i; i.INT::~INT(); |
Lambda expression. For example:
#include <algorithm> #include <cmath> void mySort(float* x, unsigned N) { std::sort(x, x + N, [](float a, float b) { return a < b; }); // Lambda expression } |
Numerical expressions that are not assignments.
Positive signed expression. For example:
int func(int num) { return +num; // +a } |
Negative signed expression. For example:
int func(int num) { return -num; // -a } |
Modulo expression. For example:
int j = 2; int k = 5 % j; // Mod a%b |
Multiplication expression. For example:
int j = 1; int k = 3 * j; // Multiplication a*b |
Addition expression. For example:
int j = 1; int k = 3 + j; // Multiplication a+b |
Subtraction expression. For example:
int j = 1; int k = 3 - j; // Subtraction a-b |
Division expression. For example:
int j = 2; int k = 5 / j; // Division a/b |
Left-shift expression. For example:
int i = 1, j = 1, k = 1; k = i << j; // Left-shift a<<b |
Right-shift expression. For example:
int i = 1, j = 1, k = 1; k = i >> j; // Right-shift a>>b |
The following nodes do not easily fit into a particular category.
ArgumentActual argument (actual parameter) of a function call. Returned by the "Arguments" property. For example:
BaseClassDerivationRepresents a possible inheritance path led from the parent class represented by BaseType to the child class. For example:
For BaseTypeA Base Class of another class. For example:
FileFile containing source code. Used for rules about relationships of nodes within a file. Lambda CaptureSimple or init capture on a capture list. Includes also implicit captures provided through a capture-default. For example:
Template ArgumentRepresents actual argument used for instantiation of a template class or template function. For example:
Translation UnitRepresents current translation unit. |
Nodes involving the use of namespaces.
namespaceNamespace declaration. For example:
usingUse of 'using' namespace keyword. For example:
|
General node for all types of statements.
BlockBlock statement. Normally contains other statements. Begins and ends with curly braces. For example:
Case LableRepresents a
SimpleA statement that does not fall into any other statement category. The simple statement's body usually contains an expression. For example:
EmptyAn empty
breakBreak statement. For example:
caseCase statement. For example:
catchCatch statement used for exception handling. For example:
continueContinue statement used in loops. For example:
defaultDefault statement used inside a switch statement. For example:
do whjileDo while loop statement. For example:
forFor loop statement. For example:
for rangeRange-based for loop statement. For example:
gotoGoto statement. For example:
ifIf statement. For example:
returnReturn statement. For example:
switchSwitch statement. For example:
tryTry statement. For example:
whileWhile statement. For example:
|
All types that can be used for variable declaration.
ComplexNon-primitive types. This category contains the following types: ArrayArray type. For example:
BuiltinNon-primitive type builtin for a given compiler. ClassUser-defined class type. For example:
|
int i; decltype(i) k; // k is Variable of Type Decltype to Type int. |
User-defined enum type. For example:
enum E { }; //Enum type
Function type. Used for function pointers. For example:
void foo(void (*ptr)(int)) { // ptr is Pointer of Type Function ptr(3); } |
Reference type. Used for passing by reference. For example:
void func(int &i) { // i is Parameter of Type Reference to Type int i = 3; } |
Struct type. For example:
struct Foo { }; // struct
A template parameter in template class declaration. For example:
template <typename T> class Temp{}; // Template Parameter: T
Typedef type. For example:
typedef int INT; INT x; // x is Variable of Type Typedef to Type int. |
Union type. For example":
union MyUnion { // union int x; char *y; }; |
All primitive types. This category contains the following types:
Primitive type bool. For example:
bool b; // b is Variable of Type bool
Primitive type char. For example:
char c; // c is Variable of Type char
Primitive type double. For example:
double d; // d is Variable of Type double
Type double _Complex. For example:
double _Complex fd; // fd is Variable of Type double _Complex |
Primitive type float. For example:
float f; // f is Variable of Type float
Type float _Complex. For example:
float _Complex fc; // fc is Variable of Type float _Complex |
Primitive type int. For example:
int i; // i is Variable of Type int
Primitive type long. For example:
long x; // x is Variable of Type long
Primitive type long double. For example:
long double d; // d is Variable of Type long double
Type long double _Complex. For example:
long double _Complex fd; // fd is Variable of Type long double _Complex |
Pointer type. For example:
char * name; // name is Variable of Type pointer to type char. |
Primitive type short. For example:
short x; // x is Variable of Type short
Primitive type void. Used for void pointers. For example:
void * p; // p is Variable of Type pointer to type void. |
Primitive type wchar_t. For example:
wchar_t c; // c is Variable of Type wchar_t
The type of pointer literal. Example:
decltype(nullptr) t; // variable of std::nullptr_t type