Class Expr

A C/C++ expression.

This is the root QL class for all expressions.

Import path

import cpp

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

getAChild

Gets a child of this expression.

getActualType

Gets the type of this expression, after any implicit conversions and explicit casts, and after resolving typedefs.

getChild

Gets the nth child of this expression.

getControlFlowScope

Gets the function containing this control-flow node.

getConversion

Gets the conversion associated with this expression, if any.

getConversionString

Gets a string describing the conversion associated with this expression, or "" if there is none.

getEnclosingBlock

Gets the nearest enclosing set of curly braces around this expression in the source, if any.

getEnclosingFunction

Gets the enclosing function of this expression, if any.

getEnclosingStmt

Gets the smallest statement containing this control-flow node.

getEnclosingVariable

Gets the enclosing variable of this expression, if any.

getExplicitlyConverted

Gets this expression with all of its explicit casts, but none of its implicit casts. More precisely this takes conversions up to the last explicit cast (there may be implicit conversions along the way), but does not include conversions after the last explicit cast.

getFullyConverted

Gets the fully converted form of this expression, including all type casts and other conversions.

getImplicitlyConverted

Gets this expression with all of its initial implicit casts, but none of its explicit casts. More precisely, this takes all implicit conversions up to (but not including) the first explicit cast (if any).

getKind

Gets an integer indicating the type of expression that this represents.

getLocation

Gets the location of this expression.

getNumChild

Gets the number of direct children of this expression.

getParent

Gets the parent of this expression, if any.

getParentWithConversions

Gets the parent of this expression, if any, in an alternative syntax tree that has Conversions as part of the tree.

getPrecedence

Gets the precedence of the main operator of this expression; higher precedence binds tighter.

getType

Gets the type of this expression.

getUnderlyingType

Gets the type of this expression after typedefs have been resolved.

getUnspecifiedType

Gets the type of this expression after specifiers have been deeply stripped and typedefs have been resolved.

getValue

Gets the value of this expression, if it is a constant.

getValueCategoryString

Gets a string representation of the value category of the expression. This is intended only for debugging. The possible values are:

getValueText

Gets the source text for the value of this expression, if it is a constant.

hasChild

Holds if e is the nth child of this expression.

hasConversion

Holds if this expression has a conversion.

hasExplicitConversion

Holds if this expression has an explicit conversion.

hasImplicitConversion

Holds if this expression has an implicit conversion.

hasLValueToRValueConversion

Holds if this expression has undergone an lvalue-to-rvalue conversion to extract its value. for example: y = x; The VariableAccess for x is a prvalue, and hasLValueToRValueConversion() holds because the value of x was loaded from the location of x. The VariableAccess for y is an lvalue, and hasLValueToRValueConversion() does not hold because the value of y was not extracted.

isCompilerGenerated

Holds if this is an auxiliary expression generated by the compiler.

isConstant

Holds if this expression has a value that can be determined at compile time.

isGLValueCategory

Holds if this expression is a glvalue. A glvalue is either an lvalue or an xvalue.

isLValue

Holds if this expression is an lvalue, in the sense of having an address.

isLValueCategory

Holds if this expression is an lvalue. An lvalue is an expression that represents a location, rather than a value. See [basic.lval] for more about lvalues.

isPRValueCategory

Holds if this expression is a prvalue. A prvalue is an expression that represents a value, rather than a location. See [basic.lval] for more about prvalues.

isParenthesised

Holds if this expression is parenthesised.

isPure

Holds if this expression is side-effect free (conservative approximation). This predicate cannot be overridden; override mayBeImpure() instead.

isRValueCategory

Holds if this expression is an rvalue. An rvalue is either a prvalue or an xvalue.

isUnevaluated

Holds if this expression will not be evaluated because of its context, such as an expression inside a sizeof.

isXValueCategory

Holds if this expression is an xvalue. An xvalue is a location whose lifetime is about to end (e.g. an rvalue reference returned from a function call). See [basic.lval] for more about xvalues.

mayBeGloballyImpure

Holds if it is possible that the expression may be impure. If we are not sure, then it holds. Unlike mayBeImpure(), this predicate does not consider modifications to temporary local variables to be impure. If you call a function in which nothing may be globally impure then the function as a whole will have no side-effects, even if it mutates its own fresh stack variables.

mayBeImpure

Holds if it is possible that the expression may be impure. If we are not sure, then it holds.

toString

Gets a textual representation of this expression.

Inherited predicates

findRootCause

Gets the source of this element: either itself or a macro that expanded to this element.

from Element
fromLibrary

Holds if this element may be from a library.

from Element
fromSource

Holds if this element may be from source.

from Element
getAFalseSuccessor

Gets a node such that the control-flow edge (this, result) may be taken when this expression is false.

from ControlFlowNode
getAPredecessorfrom ControlFlowNode
getASuccessorfrom ControlFlowNode
getATrueSuccessor

Gets a node such that the control-flow edge (this, result) may be taken when this expression is true.

from ControlFlowNode
getBasicBlockfrom ControlFlowNode
getCanonicalQLClass

Canonical QL class corresponding to this element.

from ElementBase
getEnclosingElement

Gets the closest Element enclosing this one.

from Element
getFile

Gets the primary file where this element occurs.

from Element
getParentScope

Gets the parent scope of this Element, if any. A scope is a Type (Class / Enum), a Namespace, a Block, a Function, or certain kinds of Statement.

from Element
isAffectedByMacro

Holds if this element is affected in any way by a macro. All elements that are totally or partially generated by a macro are included, so this is a super-set of isInMacroExpansion.

from Element
isCondition

Holds if this node is the top-level expression of a conditional statement, meaning that this.getATrueSuccessor() or this.getAFalseSuccessor() will have a result.

from ControlFlowNode
isFromTemplateInstantiation

Holds if this Element is a part of a template instantiation (but not the template itself).

from Element
isFromUninstantiatedTemplate

Holds if this Element is part of a template template (not if it is part of an instantiation of template). This means it is represented in the database purely as syntax and without guarantees on the presence or correctness of type-based operations such as implicit conversions.

from Element
isInMacroExpansion

Holds if this element comes from a macro expansion. Only elements that are entirely generated by a macro are included - for elements that partially come from a macro, see isAffectedByMacro.

from Element