зеркало из https://github.com/github/codeql.git
CPP: *lvalue* -> _lvalue_ and similar.
This commit is contained in:
Родитель
e883220de3
Коммит
e72bf2d35e
|
@ -10,7 +10,7 @@ import semmle.code.cpp.exprs.BitwiseOperation
|
|||
* This is an abstract root QL class for all (non-overloaded) assignments.
|
||||
*/
|
||||
abstract class Assignment extends Operation {
|
||||
/** Gets the *lvalue* of this assignment. */
|
||||
/** Gets the _lvalue_ of this assignment. */
|
||||
Expr getLValue() { this.hasChild(result, 0) }
|
||||
|
||||
/** Gets the rvalue of this assignment. */
|
||||
|
@ -53,13 +53,13 @@ abstract class AssignOperation extends Assignment {
|
|||
}
|
||||
|
||||
/**
|
||||
* A non-overloaded arithmetic assignment operation on a non-pointer *lvalue*:
|
||||
* A non-overloaded arithmetic assignment operation on a non-pointer _lvalue_:
|
||||
* `+=`, `-=`, `*=`, `/=` and `%=`.
|
||||
*/
|
||||
abstract class AssignArithmeticOperation extends AssignOperation { }
|
||||
|
||||
/**
|
||||
* A non-overloaded `+=` assignment expression on a non-pointer *lvalue*.
|
||||
* A non-overloaded `+=` assignment expression on a non-pointer _lvalue_.
|
||||
* ```
|
||||
* a += b;
|
||||
* ```
|
||||
|
@ -71,7 +71,7 @@ class AssignAddExpr extends AssignArithmeticOperation, @assignaddexpr {
|
|||
}
|
||||
|
||||
/**
|
||||
* A non-overloaded `-=` assignment expression on a non-pointer *lvalue*.
|
||||
* A non-overloaded `-=` assignment expression on a non-pointer _lvalue_.
|
||||
* ```
|
||||
* a -= b;
|
||||
* ```
|
||||
|
|
|
@ -399,7 +399,7 @@ class VoidConversion extends Cast {
|
|||
}
|
||||
|
||||
/**
|
||||
* A conversion between two pointers or *glvalue*s related by inheritance.
|
||||
* A conversion between two pointers or _glvalue_s related by inheritance.
|
||||
*
|
||||
* The base class will always be either a direct base class of the derived class,
|
||||
* or a virtual base class of the derived class. A conversion to an indirect
|
||||
|
@ -459,8 +459,8 @@ private Class getConversionClass(Expr expr) {
|
|||
}
|
||||
|
||||
/**
|
||||
* A conversion from a pointer or *glvalue* of a derived class to a pointer or
|
||||
* *glvalue* of a direct or virtual base class.
|
||||
* A conversion from a pointer or _glvalue_ of a derived class to a pointer or
|
||||
* _glvalue_ of a direct or virtual base class.
|
||||
*
|
||||
* The conversion is either implicit or underlies a particular cast.
|
||||
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||
|
@ -486,7 +486,7 @@ class BaseClassConversion extends InheritanceConversion {
|
|||
}
|
||||
|
||||
/**
|
||||
* A conversion from a pointer or *glvalue* to a base class to a pointer or *glvalue*
|
||||
* A conversion from a pointer or _glvalue_ to a base class to a pointer or _glvalue_
|
||||
* to a direct derived class.
|
||||
*
|
||||
* The conversion is either implicit or underlies a particular cast.
|
||||
|
@ -548,8 +548,8 @@ class PointerToMemberDerivedClassConversion extends Cast {
|
|||
}
|
||||
|
||||
/**
|
||||
* A conversion of a *glvalue* from one type to another. The conversion does not
|
||||
* modify the address of the *glvalue*. For *glvalue* conversions involving base and
|
||||
* A conversion of a _glvalue_ from one type to another. The conversion does not
|
||||
* modify the address of the _glvalue_. For _glvalue_ conversions involving base and
|
||||
* derived classes, see `BaseClassConversion` and `DerivedClassConversion`.
|
||||
*
|
||||
* The conversion is either implicit or underlies a particular cast.
|
||||
|
@ -567,7 +567,7 @@ class GlvalueConversion extends Cast {
|
|||
}
|
||||
|
||||
/**
|
||||
* The adjustment of the type of a class *prvalue*. Most commonly seen in code
|
||||
* The adjustment of the type of a class _prvalue_. Most commonly seen in code
|
||||
* similar to:
|
||||
* ```
|
||||
* class String { ... };
|
||||
|
@ -576,7 +576,7 @@ class GlvalueConversion extends Cast {
|
|||
* const String& r = func();
|
||||
* }
|
||||
* ```
|
||||
* In the above example, the result of the call to `func` is a *prvalue* of type
|
||||
* In the above example, the result of the call to `func` is a _prvalue_ of type
|
||||
* `String`, which will be adjusted to type `const String` before being bound
|
||||
* to the reference.
|
||||
*
|
||||
|
|
|
@ -165,36 +165,36 @@ class Expr extends StmtParent, @expr {
|
|||
predicate mayBeGloballyImpure() { any() }
|
||||
|
||||
/**
|
||||
* Holds if this expression is an *lvalue*. An *lvalue* is an expression that
|
||||
* 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.
|
||||
*/
|
||||
predicate isLValueCategory() { expr_types(underlyingElement(this), _, 3) }
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
predicate isXValueCategory() { expr_types(underlyingElement(this), _, 2) }
|
||||
|
||||
/**
|
||||
* Holds if this expression is a *prvalue*. A *prvalue* is an expression that
|
||||
* 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.
|
||||
*/
|
||||
predicate isPRValueCategory() { expr_types(underlyingElement(this), _, 1) }
|
||||
|
||||
/**
|
||||
* Holds if this expression is a glvalue. A glvalue is either an *lvalue* or an
|
||||
* *xvalue*.
|
||||
* Holds if this expression is a glvalue. A glvalue is either an _lvalue_ or an
|
||||
* _xvalue_.
|
||||
*/
|
||||
predicate isGLValueCategory() { isLValueCategory() or isXValueCategory() }
|
||||
|
||||
/**
|
||||
* Holds if this expression is an *rvalue*. An *rvalue* is either a *prvalue* or an
|
||||
* *xvalue*.
|
||||
* Holds if this expression is an _rvalue_. An _rvalue_ is either a _prvalue_ or an
|
||||
* _xvalue_.
|
||||
*/
|
||||
predicate isRValueCategory() { isPRValueCategory() or isXValueCategory() }
|
||||
|
||||
|
@ -207,7 +207,7 @@ class Expr extends StmtParent, @expr {
|
|||
* - "prvalue"
|
||||
* - "prvalue(load)"
|
||||
*
|
||||
* The "prvalue(load)" string is used when the expression is a *prvalue*, but
|
||||
* The "prvalue(load)" string is used when the expression is a _prvalue_, but
|
||||
* `hasLValueToRvalueConversion()` holds.
|
||||
*/
|
||||
string getValueCategoryString() {
|
||||
|
@ -254,32 +254,32 @@ class Expr extends StmtParent, @expr {
|
|||
}
|
||||
|
||||
/**
|
||||
* Holds if this expression has undergone an *lvalue*-to-*rvalue* conversion to
|
||||
* 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()`
|
||||
* 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()`
|
||||
* The `VariableAccess` for `y` is an _lvalue_, and `hasLValueToRValueConversion()`
|
||||
* does not hold because the value of `y` was not extracted.
|
||||
*
|
||||
* See [conv.lval] for more about the *lvalue*-to-*rvalue* conversion
|
||||
* See [conv.lval] for more about the _lvalue_-to-_rvalue_ conversion
|
||||
*/
|
||||
predicate hasLValueToRValueConversion() { expr_isload(underlyingElement(this)) }
|
||||
|
||||
/**
|
||||
* Holds if this expression is an *lvalue*, in the sense of having an address.
|
||||
* Holds if this expression is an _lvalue_, in the sense of having an address.
|
||||
*
|
||||
* Being an *lvalue* is best approximated as having an address.
|
||||
* This is a strict superset of modifiable *lvalue*s, which are best approximated by things which could be on the left-hand side of an assignment.
|
||||
* This is also a strict superset of expressions which provide an *lvalue*, which is best approximated by things whose address is important.
|
||||
* Being an _lvalue_ is best approximated as having an address.
|
||||
* This is a strict superset of modifiable _lvalue_s, which are best approximated by things which could be on the left-hand side of an assignment.
|
||||
* This is also a strict superset of expressions which provide an _lvalue_, which is best approximated by things whose address is important.
|
||||
*
|
||||
* See [basic.lval] in the C++ language specification.
|
||||
* In C++03, every expression is either an *lvalue* or an *rvalue*.
|
||||
* In C++11, every expression is exactly one of an *lvalue*, an *xvalue*, or a *prvalue* (with *rvalue*s being the union of *xvalue*s and *prvalue*s).
|
||||
* Using the C++11 terminology, this predicate selects expressions whose value category is *lvalue*.
|
||||
* In C++03, every expression is either an _lvalue_ or an _rvalue_.
|
||||
* In C++11, every expression is exactly one of an _lvalue_, an _xvalue_, or a _prvalue_ (with _rvalue_s being the union of _xvalue_s and _prvalue_s).
|
||||
* Using the C++11 terminology, this predicate selects expressions whose value category is _lvalue_.
|
||||
*/
|
||||
predicate isLValue() {
|
||||
// C++ n3337 - 5.1.1 clause 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче