mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
[CPP-418] Address review comments.
This commit is contained in:
committed by
Geoffrey White
parent
e2d5a82735
commit
6eac51dba4
@@ -312,7 +312,7 @@ class BuiltInType extends Type, @builtintype {
|
|||||||
/**
|
/**
|
||||||
* An erroneous type. This type has no corresponding C/C++ syntax.
|
* An erroneous type. This type has no corresponding C/C++ syntax.
|
||||||
*
|
*
|
||||||
* ErroneousType is the type of ErrorExpr, which it turn refers to an illegal
|
* ErroneousType is the type of ErrorExpr, which in turn refers to an illegal
|
||||||
* language construct. In the example below, a temporary (`0`) cannot be bound
|
* language construct. In the example below, a temporary (`0`) cannot be bound
|
||||||
* to an lvalue reference (`int &`):
|
* to an lvalue reference (`int &`):
|
||||||
* ```
|
* ```
|
||||||
@@ -1335,7 +1335,6 @@ class FunctionPointerIshType extends DerivedType {
|
|||||||
* int C::* p = &C::m; // pointer to data member m of class C
|
* int C::* p = &C::m; // pointer to data member m of class C
|
||||||
* class C *;
|
* class C *;
|
||||||
* int val = c.*p; // access data member
|
* int val = c.*p; // access data member
|
||||||
*
|
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class PointerToMemberType extends Type, @ptrtomember {
|
class PointerToMemberType extends Type, @ptrtomember {
|
||||||
@@ -1434,11 +1433,11 @@ class RoutineType extends Type, @routinetype {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A C++ typename template parameter.
|
* A C++ `typename` (or `class`) template parameter.
|
||||||
*
|
*
|
||||||
* In the example below, `T` is a template parameter:
|
* In the example below, `T` is a template parameter:
|
||||||
* ```
|
* ```
|
||||||
* template <typename T>
|
* template <class T>
|
||||||
* class C { };
|
* class C { };
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@@ -1458,8 +1457,8 @@ class TemplateParameter extends UserType {
|
|||||||
* In the example below, `T` is a template template parameter (although its name
|
* In the example below, `T` is a template template parameter (although its name
|
||||||
* may be omitted):
|
* may be omitted):
|
||||||
* ```
|
* ```
|
||||||
* template <template <typename T> class H, class S>
|
* template <template <typename T> class Container, class Elem>
|
||||||
* void f(const H<S> &value) { }
|
* void foo(const ContainerH<Elem> &value) { }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class TemplateTemplateParameter extends TemplateParameter {
|
class TemplateTemplateParameter extends TemplateParameter {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import semmle.code.cpp.exprs.BitwiseOperation
|
|||||||
*/
|
*/
|
||||||
abstract class Assignment extends Operation {
|
abstract class Assignment extends Operation {
|
||||||
/** Gets the *lvalue* of this assignment. */
|
/** Gets the *lvalue* of this assignment. */
|
||||||
Expr get*lvalue*() { this.hasChild(result, 0) }
|
Expr getLValue() { this.hasChild(result, 0) }
|
||||||
|
|
||||||
/** Gets the rvalue of this assignment. */
|
/** Gets the rvalue of this assignment. */
|
||||||
Expr getRValue() { this.hasChild(result, 1) }
|
Expr getRValue() { this.hasChild(result, 1) }
|
||||||
@@ -22,7 +22,7 @@ abstract class Assignment extends Operation {
|
|||||||
this.getRValue().mayBeGloballyImpure()
|
this.getRValue().mayBeGloballyImpure()
|
||||||
or
|
or
|
||||||
not exists(VariableAccess va, LocalScopeVariable v |
|
not exists(VariableAccess va, LocalScopeVariable v |
|
||||||
va = this.get*lvalue*() and
|
va = this.getLValue() and
|
||||||
v = va.getTarget() and
|
v = va.getTarget() and
|
||||||
not va.getConversion+() instanceof ReferenceDereferenceExpr and
|
not va.getConversion+() instanceof ReferenceDereferenceExpr and
|
||||||
not v.isStatic()
|
not v.isStatic()
|
||||||
|
|||||||
@@ -78,29 +78,36 @@ class BuiltInNoOp extends BuiltInOperation, @noopexpr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A C++ `__offsetof` built-in operation (used by some implementations
|
* DEPRECATED: Use `BuiltInOperationBuiltInOffsetOf` instead.
|
||||||
* of `offsetof` in the presence of user-defined `operator &`).
|
*/
|
||||||
*
|
deprecated class BuiltInOperationOffsetOf = BuiltInOperationBuiltInOffsetOf;
|
||||||
* It computes the offset (in bytes) of data member `m` from the beginning
|
|
||||||
* of its enclosing `struct`/`class`/`union` `st`.
|
/**
|
||||||
|
* A C/C++ `__offsetof` built-in operation (used by some implementations
|
||||||
|
* of `offsetof`). The operation retains its semantics even in the presence
|
||||||
|
* of an overloaded `operator &`). This is a GNU/Clang extension.
|
||||||
* ```
|
* ```
|
||||||
* #define offsetof(st, m) __offsetof(st, m)
|
* struct S {
|
||||||
|
* int a, b;
|
||||||
|
* };
|
||||||
|
* int d = __builtin_offsetof(struct S, b); // usually 4
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class BuiltInOperationOffsetOf extends BuiltInOperation, @offsetofexpr {
|
class BuiltInOperationBuiltInOffsetOf extends BuiltInOperation, @offsetofexpr {
|
||||||
override string toString() { result = "__offsetof" }
|
override string toString() { result = "__builtin_offsetof" }
|
||||||
|
|
||||||
override string getCanonicalQLClass() { result = "BuiltInOperationOffsetOf" }
|
override string getCanonicalQLClass() { result = "BuiltInOperationBuiltInOffsetOf" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A C/C++ `__INTADDR__` expression, used by EDG to implement `offsetof`
|
* A C/C++ `__INTADDR__` built-in operation (used by some implementations
|
||||||
* in the presence of user-defined `operator &`.
|
* of `offsetof`). The operation retains its semantics even in the presence
|
||||||
*
|
* of an overloaded `operator &`). This is an EDG extension.
|
||||||
* It computes the offset (in bytes) of data member `m` from the beginning
|
|
||||||
* of its enclosing `struct`/`class`/`union` `st`.
|
|
||||||
* ```
|
* ```
|
||||||
* #define offsetof(st, m) __INTADDR__(st, m)
|
* struct S {
|
||||||
|
* int a, b;
|
||||||
|
* };
|
||||||
|
* int d = __INTADDR__(struct S, b); // usually 4
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class BuiltInIntAddr extends BuiltInOperation, @intaddrexpr {
|
class BuiltInIntAddr extends BuiltInOperation, @intaddrexpr {
|
||||||
@@ -541,7 +548,7 @@ class BuiltInOperationIsDestructible extends BuiltInOperation, @isdestructibleex
|
|||||||
* The `__is_nothrow_destructible` built-in operation (used by some
|
* The `__is_nothrow_destructible` built-in operation (used by some
|
||||||
* implementations of the `<type_traits>` header).
|
* implementations of the `<type_traits>` header).
|
||||||
*
|
*
|
||||||
* Returns `true` if the type is destructible and whose constructor, and those
|
* Returns `true` if the type is destructible and whose destructor, and those
|
||||||
* of member data and any super`class`es all have an empty exception
|
* of member data and any super`class`es all have an empty exception
|
||||||
* specification.
|
* specification.
|
||||||
* ```
|
* ```
|
||||||
@@ -558,7 +565,7 @@ class BuiltInOperationIsNothrowDestructible extends BuiltInOperation, @isnothrow
|
|||||||
* The `__is_trivially_destructible` built-in operation (used by some
|
* The `__is_trivially_destructible` built-in operation (used by some
|
||||||
* implementations of the `<type_traits>` header).
|
* implementations of the `<type_traits>` header).
|
||||||
*
|
*
|
||||||
* Returns `true` if the type is destructible and whose constructor, and those
|
* Returns `true` if the type is destructible and whose destructor, and those
|
||||||
* of member data and any super`class`es are all trivial (compiler-generated).
|
* of member data and any super`class`es are all trivial (compiler-generated).
|
||||||
* ```
|
* ```
|
||||||
* bool v = __is_trivially_destructible(MyType);
|
* bool v = __is_trivially_destructible(MyType);
|
||||||
@@ -575,8 +582,7 @@ class BuiltInOperationIsTriviallyDestructible extends BuiltInOperation, @istrivi
|
|||||||
* implementations of the `<type_traits>` header).
|
* implementations of the `<type_traits>` header).
|
||||||
*
|
*
|
||||||
* Returns `true` if the assignment operator `C::operator =(const C& c)` is
|
* Returns `true` if the assignment operator `C::operator =(const C& c)` is
|
||||||
* trivial (compiler-generated). The * generated code will have resembled a
|
* trivial (compiler-generated).
|
||||||
* `memcpy` operation.
|
|
||||||
* ```
|
* ```
|
||||||
* template<typename T>
|
* template<typename T>
|
||||||
* struct is_trivially_assignable
|
* struct is_trivially_assignable
|
||||||
@@ -595,7 +601,7 @@ class BuiltInOperationIsTriviallyAssignable extends BuiltInOperation, @istrivial
|
|||||||
* implementations of the `<type_traits>` header).
|
* implementations of the `<type_traits>` header).
|
||||||
*
|
*
|
||||||
* Returns true if there exists a `C::operator =(const C& c) nothrow`
|
* Returns true if there exists a `C::operator =(const C& c) nothrow`
|
||||||
* assignment operator (i.e, with an empty excepion specification).
|
* assignment operator (i.e, with an empty exception specification).
|
||||||
* ```
|
* ```
|
||||||
* bool v = __is_nothrow_assignable(MyType);
|
* bool v = __is_nothrow_assignable(MyType);
|
||||||
* ```
|
* ```
|
||||||
|
|||||||
@@ -22,17 +22,17 @@ abstract class Conversion extends Expr {
|
|||||||
/**
|
/**
|
||||||
* A C/C++ cast expression.
|
* A C/C++ cast expression.
|
||||||
*
|
*
|
||||||
* To get the type which the expression is being cast to, use **Cast::getType()**.
|
* To get the type which the expression is being cast to, use `Cast::getType()`.
|
||||||
*
|
*
|
||||||
* There are two groups of subtypes of **Cast**. The first group differentiates
|
* There are two groups of subtypes of `Cast`. The first group differentiates
|
||||||
* between the different cast syntax forms, e.g. **CStyleCast**, **StaticCast**,
|
* between the different cast syntax forms, e.g. `CStyleCast`, `StaticCast`,
|
||||||
* etc. The second group differentiates between the semantic operation being
|
* etc. The second group differentiates between the semantic operation being
|
||||||
* performed by the cast, e.g. **IntegralConversion**, **PointerBaseClassConversion**,
|
* performed by the cast, e.g. `IntegralConversion`, `PointerBaseClassConversion`,
|
||||||
* etc.
|
* etc.
|
||||||
* The two groups are largely orthogonal to one another. For example, a
|
* The two groups are largely orthogonal to one another. For example, a
|
||||||
* cast that is syntactically as **CStyleCast** may also be an **IntegralConversion**,
|
* cast that is syntactically as `CStyleCast` may also be an `IntegralConversion`,
|
||||||
* a **PointerBaseClassConversion**, or some other semantic conversion. Similarly,
|
* a `PointerBaseClassConversion`, or some other semantic conversion. Similarly,
|
||||||
* a **PointerDerivedClassConversion** may also be a **CStyleCast** or a **StaticCast**.
|
* a `PointerDerivedClassConversion` may also be a `CStyleCast` or a `StaticCast`.
|
||||||
*
|
*
|
||||||
* This is an abstract root QL class representing the different casts. For
|
* This is an abstract root QL class representing the different casts. For
|
||||||
* specific examples, consult the documentation for any of QL classes mentioned above.
|
* specific examples, consult the documentation for any of QL classes mentioned above.
|
||||||
@@ -47,7 +47,7 @@ abstract class Cast extends Conversion, @cast {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* INTERNAL: Do not use.
|
* INTERNAL: Do not use.
|
||||||
* Query predicates used to check invariants that should hold for all **Cast**
|
* Query predicates used to check invariants that should hold for all `Cast`
|
||||||
* nodes. To run all sanity queries for the ASTs, including the ones below,
|
* nodes. To run all sanity queries for the ASTs, including the ones below,
|
||||||
* run "semmle/code/cpp/ASTSanity.ql".
|
* run "semmle/code/cpp/ASTSanity.ql".
|
||||||
*/
|
*/
|
||||||
@@ -167,8 +167,8 @@ private predicate isPointerToMemberOrNullPointer(Type type) {
|
|||||||
* A conversion from one arithmetic or `enum` type to another.
|
* A conversion from one arithmetic or `enum` type to another.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class ArithmeticConversion extends Cast {
|
class ArithmeticConversion extends Cast {
|
||||||
ArithmeticConversion() {
|
ArithmeticConversion() {
|
||||||
@@ -184,8 +184,8 @@ class ArithmeticConversion extends Cast {
|
|||||||
* A conversion from one integral or enum type to another.
|
* A conversion from one integral or enum type to another.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class IntegralConversion extends ArithmeticConversion {
|
class IntegralConversion extends ArithmeticConversion {
|
||||||
IntegralConversion() {
|
IntegralConversion() {
|
||||||
@@ -204,8 +204,8 @@ class IntegralConversion extends ArithmeticConversion {
|
|||||||
* A conversion from one floating point type.
|
* A conversion from one floating point type.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class FloatingPointConversion extends ArithmeticConversion {
|
class FloatingPointConversion extends ArithmeticConversion {
|
||||||
FloatingPointConversion() {
|
FloatingPointConversion() {
|
||||||
@@ -224,8 +224,8 @@ class FloatingPointConversion extends ArithmeticConversion {
|
|||||||
* A conversion from a floating point type to an integral or enum type.
|
* A conversion from a floating point type to an integral or enum type.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class FloatingPointToIntegralConversion extends ArithmeticConversion {
|
class FloatingPointToIntegralConversion extends ArithmeticConversion {
|
||||||
FloatingPointToIntegralConversion() {
|
FloatingPointToIntegralConversion() {
|
||||||
@@ -244,8 +244,8 @@ class FloatingPointToIntegralConversion extends ArithmeticConversion {
|
|||||||
* A conversion from an integral or enum type to a floating point type.
|
* A conversion from an integral or enum type to a floating point type.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class IntegralToFloatingPointConversion extends ArithmeticConversion {
|
class IntegralToFloatingPointConversion extends ArithmeticConversion {
|
||||||
IntegralToFloatingPointConversion() {
|
IntegralToFloatingPointConversion() {
|
||||||
@@ -264,13 +264,13 @@ class IntegralToFloatingPointConversion extends ArithmeticConversion {
|
|||||||
* A conversion from one pointer type to another.
|
* A conversion from one pointer type to another.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*
|
*
|
||||||
* The conversion does
|
* The conversion does
|
||||||
* not modify the value of the pointer. For pointer conversions involving
|
* not modify the value of the pointer. For pointer conversions involving
|
||||||
* casts between base and derived classes, please see see **BaseClassConversion** or
|
* casts between base and derived classes, please see see `BaseClassConversion` or
|
||||||
* **DerivedClassConversion**.
|
* `DerivedClassConversion`.
|
||||||
*/
|
*/
|
||||||
class PointerConversion extends Cast {
|
class PointerConversion extends Cast {
|
||||||
PointerConversion() {
|
PointerConversion() {
|
||||||
@@ -290,13 +290,13 @@ class PointerConversion extends Cast {
|
|||||||
* A conversion from one pointer-to-member type to another.
|
* A conversion from one pointer-to-member type to another.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*
|
*
|
||||||
* The conversion does not modify the value of the pointer-to-member.
|
* The conversion does not modify the value of the pointer-to-member.
|
||||||
* For pointer-to-member conversions involving casts between base and
|
* For pointer-to-member conversions involving casts between base and
|
||||||
* derived classes, please see **PointerToMemberBaseClassConversion**
|
* derived classes, please see `PointerToMemberBaseClassConversion`
|
||||||
* or **PointerToMemberDerivedClassConversion**.
|
* or `PointerToMemberDerivedClassConversion`.
|
||||||
*/
|
*/
|
||||||
class PointerToMemberConversion extends Cast {
|
class PointerToMemberConversion extends Cast {
|
||||||
PointerToMemberConversion() {
|
PointerToMemberConversion() {
|
||||||
@@ -326,8 +326,8 @@ class PointerToMemberConversion extends Cast {
|
|||||||
* A conversion from a pointer type to an integral or enum type.
|
* A conversion from a pointer type to an integral or enum type.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class PointerToIntegralConversion extends Cast {
|
class PointerToIntegralConversion extends Cast {
|
||||||
PointerToIntegralConversion() {
|
PointerToIntegralConversion() {
|
||||||
@@ -347,8 +347,8 @@ class PointerToIntegralConversion extends Cast {
|
|||||||
* A conversion from an integral or enum type to a pointer type.
|
* A conversion from an integral or enum type to a pointer type.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class IntegralToPointerConversion extends Cast {
|
class IntegralToPointerConversion extends Cast {
|
||||||
IntegralToPointerConversion() {
|
IntegralToPointerConversion() {
|
||||||
@@ -369,8 +369,8 @@ class IntegralToPointerConversion extends Cast {
|
|||||||
* `false`, or `nullptr`. Returns `true` otherwise.
|
* `false`, or `nullptr`. Returns `true` otherwise.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class BoolConversion extends Cast {
|
class BoolConversion extends Cast {
|
||||||
BoolConversion() { conversionkinds(underlyingElement(this), 1) }
|
BoolConversion() { conversionkinds(underlyingElement(this), 1) }
|
||||||
@@ -384,8 +384,8 @@ class BoolConversion extends Cast {
|
|||||||
* A conversion to `void`.
|
* A conversion to `void`.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class VoidConversion extends Cast {
|
class VoidConversion extends Cast {
|
||||||
VoidConversion() {
|
VoidConversion() {
|
||||||
@@ -407,8 +407,8 @@ class VoidConversion extends Cast {
|
|||||||
* direct base classes.
|
* direct base classes.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class InheritanceConversion extends Cast {
|
class InheritanceConversion extends Cast {
|
||||||
InheritanceConversion() {
|
InheritanceConversion() {
|
||||||
@@ -463,8 +463,8 @@ private Class getConversionClass(Expr expr) {
|
|||||||
* *glvalue* of a direct or virtual base class.
|
* *glvalue* of a direct or virtual base class.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class BaseClassConversion extends InheritanceConversion {
|
class BaseClassConversion extends InheritanceConversion {
|
||||||
BaseClassConversion() { conversionkinds(underlyingElement(this), 2) }
|
BaseClassConversion() { conversionkinds(underlyingElement(this), 2) }
|
||||||
@@ -490,8 +490,8 @@ class BaseClassConversion extends InheritanceConversion {
|
|||||||
* to a direct derived class.
|
* to a direct derived class.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class DerivedClassConversion extends InheritanceConversion {
|
class DerivedClassConversion extends InheritanceConversion {
|
||||||
DerivedClassConversion() { conversionkinds(underlyingElement(this), 3) }
|
DerivedClassConversion() { conversionkinds(underlyingElement(this), 3) }
|
||||||
@@ -512,8 +512,8 @@ class DerivedClassConversion extends InheritanceConversion {
|
|||||||
* of an immediate base class.
|
* of an immediate base class.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class PointerToMemberBaseClassConversion extends Cast {
|
class PointerToMemberBaseClassConversion extends Cast {
|
||||||
PointerToMemberBaseClassConversion() { conversionkinds(underlyingElement(this), 4) }
|
PointerToMemberBaseClassConversion() { conversionkinds(underlyingElement(this), 4) }
|
||||||
@@ -532,8 +532,8 @@ class PointerToMemberBaseClassConversion extends Cast {
|
|||||||
* of an immediate derived class.
|
* of an immediate derived class.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class PointerToMemberDerivedClassConversion extends Cast {
|
class PointerToMemberDerivedClassConversion extends Cast {
|
||||||
PointerToMemberDerivedClassConversion() { conversionkinds(underlyingElement(this), 5) }
|
PointerToMemberDerivedClassConversion() { conversionkinds(underlyingElement(this), 5) }
|
||||||
@@ -553,8 +553,8 @@ class PointerToMemberDerivedClassConversion extends Cast {
|
|||||||
* derived classes, see `BaseClassConversion` and `DerivedClassConversion`.
|
* derived classes, see `BaseClassConversion` and `DerivedClassConversion`.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class GlvalueConversion extends Cast {
|
class GlvalueConversion extends Cast {
|
||||||
GlvalueConversion() { conversionkinds(underlyingElement(this), 6) }
|
GlvalueConversion() { conversionkinds(underlyingElement(this), 6) }
|
||||||
@@ -581,8 +581,8 @@ class GlvalueConversion extends Cast {
|
|||||||
* to the reference.
|
* to the reference.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class PrvalueAdjustmentConversion extends Cast {
|
class PrvalueAdjustmentConversion extends Cast {
|
||||||
PrvalueAdjustmentConversion() { conversionkinds(underlyingElement(this), 7) }
|
PrvalueAdjustmentConversion() { conversionkinds(underlyingElement(this), 7) }
|
||||||
@@ -812,8 +812,8 @@ class AlignofTypeOperator extends AlignofOperator {
|
|||||||
* A C/C++ array to pointer conversion.
|
* A C/C++ array to pointer conversion.
|
||||||
*
|
*
|
||||||
* The conversion is either implicit or underlies a particular cast.
|
* The conversion is either implicit or underlies a particular cast.
|
||||||
* Please see **CStyleCast**, **StaticCast**, **ConstCast**
|
* Please see `CStyleCast`, `StaticCast`, `ConstCast`
|
||||||
* or **ReinterpretCast** for more information.
|
* or `ReinterpretCast` for more information.
|
||||||
*/
|
*/
|
||||||
class ArrayToPointerConversion extends Conversion, @array_to_pointer {
|
class ArrayToPointerConversion extends Conversion, @array_to_pointer {
|
||||||
/** Gets a textual representation of this conversion. */
|
/** Gets a textual representation of this conversion. */
|
||||||
|
|||||||
@@ -202,24 +202,24 @@ class Expr extends StmtParent, @expr {
|
|||||||
* Gets a string representation of the value category of the expression.
|
* Gets a string representation of the value category of the expression.
|
||||||
* This is intended only for debugging. The possible values are:
|
* This is intended only for debugging. The possible values are:
|
||||||
*
|
*
|
||||||
* - "*lvalue*"
|
* - "lvalue"
|
||||||
* - "*xvalue*"
|
* - "xvalue"
|
||||||
* - "*prvalue*"
|
* - "prvalue"
|
||||||
* - "*prvalue*(load)"
|
* - "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.
|
* `hasLValueToRvalueConversion()` holds.
|
||||||
*/
|
*/
|
||||||
string getValueCategoryString() {
|
string getValueCategoryString() {
|
||||||
isLValueCategory() and
|
isLValueCategory() and
|
||||||
result = "*lvalue*"
|
result = "lvalue"
|
||||||
or
|
or
|
||||||
isXValueCategory() and
|
isXValueCategory() and
|
||||||
result = "*xvalue*"
|
result = "xvalue"
|
||||||
or
|
or
|
||||||
(
|
(
|
||||||
isPRValueCategory() and
|
isPRValueCategory() and
|
||||||
if hasLValueToRValueConversion() then result = "*prvalue*(load)" else result = "*prvalue*"
|
if hasLValueToRValueConversion() then result = "prvalue(load)" else result = "prvalue"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,18 +254,18 @@ 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.
|
* extract its value.
|
||||||
* for example:
|
* for example:
|
||||||
* ```
|
* ```
|
||||||
* y = x;
|
* 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`.
|
* 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.
|
* 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)) }
|
predicate hasLValueToRValueConversion() { expr_isload(underlyingElement(this)) }
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ class ParenthesisExpr extends Conversion, @parexpr {
|
|||||||
/**
|
/**
|
||||||
* A C/C++ expression that has not been resolved.
|
* A C/C++ expression that has not been resolved.
|
||||||
*
|
*
|
||||||
* It is assigned **ErroneousType** as its type.
|
* It is assigned `ErroneousType` as its type.
|
||||||
*/
|
*/
|
||||||
class ErrorExpr extends Expr, @errorexpr {
|
class ErrorExpr extends Expr, @errorexpr {
|
||||||
override string toString() { result = "<error expr>" }
|
override string toString() { result = "<error expr>" }
|
||||||
@@ -637,7 +637,7 @@ class AddressOfExpr extends UnaryOperation, @address_of {
|
|||||||
* An implicit conversion from type `T` to type `T &`.
|
* An implicit conversion from type `T` to type `T &`.
|
||||||
*
|
*
|
||||||
* This typically occurs when an expression of type `T` is used to initialize a variable or parameter of
|
* This typically occurs when an expression of type `T` is used to initialize a variable or parameter of
|
||||||
* type `T &`, and is to reference types what **AddressOfExpr** is to pointer types, though this class is
|
* type `T &`, and is to reference types what `AddressOfExpr` is to pointer types, though this class is
|
||||||
* considered to be a conversion rather than an operation, and as such doesn't occur in the main AST.
|
* considered to be a conversion rather than an operation, and as such doesn't occur in the main AST.
|
||||||
* ```
|
* ```
|
||||||
* int &var_ref = var;
|
* int &var_ref = var;
|
||||||
@@ -654,7 +654,7 @@ class ReferenceToExpr extends Conversion, @reference_to {
|
|||||||
/**
|
/**
|
||||||
* An instance of the built-in unary `operator *` applied to a type.
|
* An instance of the built-in unary `operator *` applied to a type.
|
||||||
*
|
*
|
||||||
* For user-defined overloads of `operator *`, see **OverloadedPointerDereferenceExpr**.
|
* For user-defined overloads of `operator *`, see `OverloadedPointerDereferenceExpr`.
|
||||||
* ```
|
* ```
|
||||||
* int var = *varptr;
|
* int var = *varptr;
|
||||||
* ```
|
* ```
|
||||||
@@ -688,7 +688,7 @@ class PointerDereferenceExpr extends UnaryOperation, @indirect {
|
|||||||
* An implicit conversion from type `T &` to type `T`.
|
* An implicit conversion from type `T &` to type `T`.
|
||||||
*
|
*
|
||||||
* This typically occurs when an variable of type `T &` is used in a context which expects type `T`, and
|
* This typically occurs when an variable of type `T &` is used in a context which expects type `T`, and
|
||||||
* is to reference types what **PointerDereferenceExpr** is to pointer types - though this class is
|
* is to reference types what `PointerDereferenceExpr` is to pointer types - though this class is
|
||||||
* considered to be a conversion rather than an operation, and as such doesn't occur in the main AST.
|
* considered to be a conversion rather than an operation, and as such doesn't occur in the main AST.
|
||||||
* ```
|
* ```
|
||||||
* float &f_ref = get_ref();
|
* float &f_ref = get_ref();
|
||||||
@@ -1116,7 +1116,7 @@ class NoExceptExpr extends Expr, @noexceptexpr {
|
|||||||
* of the template will instead contain the sequence of expressions given by expanding the fold.
|
* of the template will instead contain the sequence of expressions given by expanding the fold.
|
||||||
* ```
|
* ```
|
||||||
* template < typename... T >
|
* template < typename... T >
|
||||||
* auto sum ( T <20> t ) { return ( t + ... + 0 ); }
|
* auto sum ( T... t ) { return ( t + ... + 0 ); }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class FoldExpr extends Expr, @foldexpr {
|
class FoldExpr extends Expr, @foldexpr {
|
||||||
|
|||||||
Reference in New Issue
Block a user