CodeQL library for C/C++
Search

Module Assignment

Import path

import semmle.code.cpp.exprs.Assignment

Imports

ArithmeticOperation

Provides classes for modeling arithmetic operations such as +, -, * and ++.

BitwiseOperation

Provides classes for modeling bitwise operations such as ~, <<, & and |.

Expr

Provides classes modeling C/C++ expressions.

Classes

AssignAddExpr

A non-overloaded += assignment expression on a non-pointer lvalue. a += b;

AssignAndExpr

A non-overloaded AND (&=) assignment expression. a &= b;

AssignArithmeticOperation

A non-overloaded arithmetic assignment operation on a non-pointer lvalue: +=, -=, *=, /= and %=.

AssignBitwiseOperation

A non-overloaded bitwise assignment operation: &=, |=, ^=, <<=, and >>=.

AssignDivExpr

A non-overloaded /= assignment expression. a /= b;

AssignExpr

A non-overloaded assignment operation with the operator =. a = b;

AssignLShiftExpr

A non-overloaded <<= assignment expression. a <<= b;

AssignMulExpr

A non-overloaded *= assignment expression. a *= b;

AssignOperation

A non-overloaded binary assignment operation other than =.

AssignOrExpr

A non-overloaded OR (|=) assignment expression. a |= b;

AssignPointerAddExpr

A non-overloaded += pointer assignment expression. ptr += index;

AssignPointerSubExpr

A non-overloaded -= pointer assignment expression. ptr -= index;

AssignRShiftExpr

A non-overloaded >>= assignment expression. a >>= b;

AssignRemExpr

A non-overloaded %= assignment expression. a %= b;

AssignSubExpr

A non-overloaded -= assignment expression on a non-pointer lvalue. a -= b;

AssignXorExpr

A non-overloaded XOR (^=) assignment expression. a ^= b;

Assignment

A non-overloaded binary assignment operation, including =, +=, &=, etc. A C++ overloaded assignment operation looks syntactically identical but is instead a FunctionCall.

ConditionDeclExpr

A C++ variable declaration inside the conditional expression of a while, if or for compound statement. Declaring a variable this way narrows its lifetime and scope to be strictly the compound statement itself. For example: extern int x, y; if (bool c = x < y) { do_something_with(c); } // c is no longer in scope while (int d = x - y) { do_something_else_with(d); } // d is no longer is scope