CodeQL library for C/C++
Search

Module Expr

Provides classes modeling C/C++ expressions.

Import path

import semmle.code.cpp.exprs.Expr

Imports

Element

Provides the Element class, which is the base class for all classes representing C or C++ program elements.

Classes

AddressOfExpr

A C/C++ address-of expression. int *ptr = &var;

AssumeExpr

A Microsoft C/C++ __assume expression.

BinaryOperation

A C/C++ binary operation.

BlockExpr

A code block expression, for example: ^ int (int x, int y) {return x + y;} Blocks are a language extension supported by Clang, and by Apple’s branch of GCC.

CoAwaitExpr

A C/C++ co_await expression. co_await foo();

CoYieldExpr

A C/C++ co_yield expression. co_yield 1;

CommaExpr

A C/C++ comma expression. int c = compute1(), compute2(), resulting_value;

DeleteArrayExpr

A C++ delete[] (array) expression. delete[] arr;

DeleteExpr

A C++ delete (non-array) expression. delete ptr;

ErrorExpr

A C/C++ expression that has not been resolved.

Expr

A C/C++ expression.

FoldExpr

A C++17 fold expression. This will only appear in an uninstantiated template; any instantiations of the template will instead contain the sequence of expressions given by expanding the fold. template < typename... T > auto sum ( T... t ) { return ( t + ... + 0 ); }

NewArrayExpr

A C++ new[] (array) expression. Foo *foo = new Foo[]{1, 3, 5}; Bar *bar = new Bar[5];

NewExpr

A C++ new (non-array) expression. Foo *ptr = new Foo(3);

NewOrNewArrayExpr

A C++ new or new[] expression.

NoExceptExpr

A C++11 noexcept expression, returning true if its subexpression is guaranteed not to throw exceptions. For example: if (noexcept(func_1() + func_2())) { }

Operation

A C/C++ operation.

ParenthesisExpr

A C/C++ parenthesis expression.

ParenthesizedBracedInitializerList

A C++11 parenthesized braced initializer list within a template.

PointerDereferenceExpr

An instance of the built-in unary operator * applied to a type.

ReThrowExpr

A C++ throw expression with no argument (which causes the current exception to be re-thrown). throw;

ReferenceDereferenceExpr

An implicit conversion from type T & to type T.

ReferenceToExpr

An implicit conversion from type T to type T &.

SpaceshipExpr

A C++ three-way comparison operation, also known as the spaceship operation. This is specific to C++20 and later. auto c = (a <=> b);

StmtExpr

A compound statement enclosed in parentheses used as an expression (a GNU extension to C/C++). In the example below, b is the return value from the compound statement. int a = ({ int b = c + d; b; });

ThisExpr

A C++ this expression.

ThrowExpr

A C++ throw expression. throw Exc(2);

UnaryOperation

A C/C++ unary operation.