mirror of
https://github.com/github/codeql.git
synced 2025-12-23 12:16:33 +01:00
C++: fix implicit this
This commit is contained in:
committed by
Mathias Vorreiter Pedersen
parent
b2e4276bc8
commit
fe891746bf
@@ -203,7 +203,7 @@ class PointerFieldAccess extends FieldAccess {
|
||||
|
||||
PointerFieldAccess() {
|
||||
exists(PointerType t |
|
||||
t = getQualifier().getFullyConverted().getUnspecifiedType() and
|
||||
t = this.getQualifier().getFullyConverted().getUnspecifiedType() and
|
||||
t.getBaseType() instanceof Class
|
||||
)
|
||||
}
|
||||
@@ -218,7 +218,9 @@ class PointerFieldAccess extends FieldAccess {
|
||||
class DotFieldAccess extends FieldAccess {
|
||||
override string getAPrimaryQlClass() { result = "DotFieldAccess" }
|
||||
|
||||
DotFieldAccess() { exists(Class c | c = getQualifier().getFullyConverted().getUnspecifiedType()) }
|
||||
DotFieldAccess() {
|
||||
exists(Class c | c = this.getQualifier().getFullyConverted().getUnspecifiedType())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -148,7 +148,7 @@ class PostfixIncrExpr extends IncrementOperation, PostfixCrementOperation, @post
|
||||
|
||||
override int getPrecedence() { result = 17 }
|
||||
|
||||
override string toString() { result = "... " + getOperator() }
|
||||
override string toString() { result = "... " + this.getOperator() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ class PostfixDecrExpr extends DecrementOperation, PostfixCrementOperation, @post
|
||||
|
||||
override int getPrecedence() { result = 17 }
|
||||
|
||||
override string toString() { result = "... " + getOperator() }
|
||||
override string toString() { result = "... " + this.getOperator() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,12 +35,12 @@ class BuiltInVarArgsStart extends VarArgsExpr, @vastartexpr {
|
||||
/**
|
||||
* Gets the `va_list` argument.
|
||||
*/
|
||||
final Expr getVAList() { result = getChild(0) }
|
||||
final Expr getVAList() { result = this.getChild(0) }
|
||||
|
||||
/**
|
||||
* Gets the argument that specifies the last named parameter before the ellipsis.
|
||||
*/
|
||||
final VariableAccess getLastNamedParameter() { result = getChild(1) }
|
||||
final VariableAccess getLastNamedParameter() { result = this.getChild(1) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ class BuiltInVarArgsEnd extends VarArgsExpr, @vaendexpr {
|
||||
/**
|
||||
* Gets the `va_list` argument.
|
||||
*/
|
||||
final Expr getVAList() { result = getChild(0) }
|
||||
final Expr getVAList() { result = this.getChild(0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class BuiltInVarArg extends VarArgsExpr, @vaargexpr {
|
||||
/**
|
||||
* Gets the `va_list` argument.
|
||||
*/
|
||||
final Expr getVAList() { result = getChild(0) }
|
||||
final Expr getVAList() { result = this.getChild(0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,12 +98,12 @@ class BuiltInVarArgCopy extends VarArgsExpr, @vacopyexpr {
|
||||
/**
|
||||
* Gets the destination `va_list` argument.
|
||||
*/
|
||||
final Expr getDestinationVAList() { result = getChild(0) }
|
||||
final Expr getDestinationVAList() { result = this.getChild(0) }
|
||||
|
||||
/**
|
||||
* Gets the the source `va_list` argument.
|
||||
*/
|
||||
final Expr getSourceVAList() { result = getChild(1) }
|
||||
final Expr getSourceVAList() { result = this.getChild(1) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,10 +71,10 @@ class Call extends Expr, NameQualifiableElement, TCall {
|
||||
* at index 2, respectively.
|
||||
*/
|
||||
Expr getAnArgumentSubExpr(int index) {
|
||||
result = getArgument(index)
|
||||
result = this.getArgument(index)
|
||||
or
|
||||
exists(Expr mid |
|
||||
mid = getAnArgumentSubExpr(index) and
|
||||
mid = this.getAnArgumentSubExpr(index) and
|
||||
not mid instanceof Call and
|
||||
not mid instanceof SizeofOperator and
|
||||
result = mid.getAChild()
|
||||
@@ -167,27 +167,27 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
override string getAPrimaryQlClass() { result = "FunctionCall" }
|
||||
|
||||
/** Gets an explicit template argument for this call. */
|
||||
Locatable getAnExplicitTemplateArgument() { result = getExplicitTemplateArgument(_) }
|
||||
Locatable getAnExplicitTemplateArgument() { result = this.getExplicitTemplateArgument(_) }
|
||||
|
||||
/** Gets an explicit template argument value for this call. */
|
||||
Locatable getAnExplicitTemplateArgumentKind() { result = getExplicitTemplateArgumentKind(_) }
|
||||
Locatable getAnExplicitTemplateArgumentKind() { result = this.getExplicitTemplateArgumentKind(_) }
|
||||
|
||||
/** Gets a template argument for this call. */
|
||||
Locatable getATemplateArgument() { result = getTarget().getATemplateArgument() }
|
||||
Locatable getATemplateArgument() { result = this.getTarget().getATemplateArgument() }
|
||||
|
||||
/** Gets a template argument value for this call. */
|
||||
Locatable getATemplateArgumentKind() { result = getTarget().getATemplateArgumentKind() }
|
||||
Locatable getATemplateArgumentKind() { result = this.getTarget().getATemplateArgumentKind() }
|
||||
|
||||
/** Gets the nth explicit template argument for this call. */
|
||||
Locatable getExplicitTemplateArgument(int n) {
|
||||
n < getNumberOfExplicitTemplateArguments() and
|
||||
result = getTemplateArgument(n)
|
||||
n < this.getNumberOfExplicitTemplateArguments() and
|
||||
result = this.getTemplateArgument(n)
|
||||
}
|
||||
|
||||
/** Gets the nth explicit template argument value for this call. */
|
||||
Locatable getExplicitTemplateArgumentKind(int n) {
|
||||
n < getNumberOfExplicitTemplateArguments() and
|
||||
result = getTemplateArgumentKind(n)
|
||||
n < this.getNumberOfExplicitTemplateArguments() and
|
||||
result = this.getTemplateArgumentKind(n)
|
||||
}
|
||||
|
||||
/** Gets the number of explicit template arguments for this call. */
|
||||
@@ -198,19 +198,19 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
}
|
||||
|
||||
/** Gets the number of template arguments for this call. */
|
||||
int getNumberOfTemplateArguments() { result = count(int i | exists(getTemplateArgument(i))) }
|
||||
int getNumberOfTemplateArguments() { result = count(int i | exists(this.getTemplateArgument(i))) }
|
||||
|
||||
/** Gets the nth template argument for this call (indexed from 0). */
|
||||
Locatable getTemplateArgument(int n) { result = getTarget().getTemplateArgument(n) }
|
||||
Locatable getTemplateArgument(int n) { result = this.getTarget().getTemplateArgument(n) }
|
||||
|
||||
/** Gets the nth template argument value for this call (indexed from 0). */
|
||||
Locatable getTemplateArgumentKind(int n) { result = getTarget().getTemplateArgumentKind(n) }
|
||||
Locatable getTemplateArgumentKind(int n) { result = this.getTarget().getTemplateArgumentKind(n) }
|
||||
|
||||
/** Holds if any template arguments for this call are implicit / deduced. */
|
||||
predicate hasImplicitTemplateArguments() {
|
||||
exists(int i |
|
||||
exists(getTemplateArgument(i)) and
|
||||
not exists(getExplicitTemplateArgument(i))
|
||||
exists(this.getTemplateArgument(i)) and
|
||||
not exists(this.getExplicitTemplateArgument(i))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -233,9 +233,9 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
* visible at the call site.
|
||||
*/
|
||||
Type getExpectedReturnType() {
|
||||
if getTargetType() instanceof RoutineType
|
||||
then result = getTargetType().(RoutineType).getReturnType()
|
||||
else result = getTarget().getType()
|
||||
if this.getTargetType() instanceof RoutineType
|
||||
then result = this.getTargetType().(RoutineType).getReturnType()
|
||||
else result = this.getTarget().getType()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,9 +247,9 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
* was visible at the call site.
|
||||
*/
|
||||
Type getExpectedParameterType(int n) {
|
||||
if getTargetType() instanceof RoutineType
|
||||
then result = getTargetType().(RoutineType).getParameterType(n)
|
||||
else result = getTarget().getParameter(n).getType()
|
||||
if this.getTargetType() instanceof RoutineType
|
||||
then result = this.getTargetType().(RoutineType).getParameterType(n)
|
||||
else result = this.getTarget().getParameter(n).getType()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
/**
|
||||
* Gets the type of this expression, that is, the return type of the function being called.
|
||||
*/
|
||||
override Type getType() { result = getExpectedReturnType() }
|
||||
override Type getType() { result = this.getExpectedReturnType() }
|
||||
|
||||
/**
|
||||
* Holds if this is a call to a virtual function.
|
||||
@@ -280,7 +280,7 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
|
||||
/** Gets a textual representation of this function call. */
|
||||
override string toString() {
|
||||
if exists(getTarget())
|
||||
if exists(this.getTarget())
|
||||
then result = "call to " + this.getTarget().getName()
|
||||
else result = "call to unknown function"
|
||||
}
|
||||
@@ -288,15 +288,15 @@ class FunctionCall extends Call, @funbindexpr {
|
||||
override predicate mayBeImpure() {
|
||||
this.getChild(_).mayBeImpure() or
|
||||
this.getTarget().mayHaveSideEffects() or
|
||||
isVirtual() or
|
||||
getTarget().getAnAttribute().getName() = "weak"
|
||||
this.isVirtual() or
|
||||
this.getTarget().getAnAttribute().getName() = "weak"
|
||||
}
|
||||
|
||||
override predicate mayBeGloballyImpure() {
|
||||
this.getChild(_).mayBeGloballyImpure() or
|
||||
this.getTarget().mayHaveSideEffects() or
|
||||
isVirtual() or
|
||||
getTarget().getAnAttribute().getName() = "weak"
|
||||
this.isVirtual() or
|
||||
this.getTarget().getAnAttribute().getName() = "weak"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class OverloadedPointerDereferenceExpr extends FunctionCall {
|
||||
* ```
|
||||
*/
|
||||
class OverloadedArrayExpr extends FunctionCall {
|
||||
OverloadedArrayExpr() { getTarget().hasName("operator[]") }
|
||||
OverloadedArrayExpr() { this.getTarget().hasName("operator[]") }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "OverloadedArrayExpr" }
|
||||
|
||||
@@ -585,7 +585,7 @@ class ConstructorFieldInit extends ConstructorInit, @ctorfieldinit {
|
||||
*/
|
||||
Expr getExpr() { result = this.getChild(0) }
|
||||
|
||||
override string toString() { result = "constructor init of field " + getTarget().getName() }
|
||||
override string toString() { result = "constructor init of field " + this.getTarget().getName() }
|
||||
|
||||
override predicate mayBeImpure() { this.getExpr().mayBeImpure() }
|
||||
|
||||
|
||||
@@ -188,8 +188,8 @@ private predicate isPointerToMemberOrNullPointer(Type type) {
|
||||
class ArithmeticConversion extends Cast {
|
||||
ArithmeticConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
isArithmeticOrEnum(getUnspecifiedType()) and
|
||||
isArithmeticOrEnum(getExpr().getUnspecifiedType())
|
||||
isArithmeticOrEnum(this.getUnspecifiedType()) and
|
||||
isArithmeticOrEnum(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getSemanticConversionString() { result = "arithmetic conversion" }
|
||||
@@ -204,8 +204,8 @@ class ArithmeticConversion extends Cast {
|
||||
*/
|
||||
class IntegralConversion extends ArithmeticConversion {
|
||||
IntegralConversion() {
|
||||
isIntegralOrEnum(getUnspecifiedType()) and
|
||||
isIntegralOrEnum(getExpr().getUnspecifiedType())
|
||||
isIntegralOrEnum(this.getUnspecifiedType()) and
|
||||
isIntegralOrEnum(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -224,8 +224,8 @@ class IntegralConversion extends ArithmeticConversion {
|
||||
*/
|
||||
class FloatingPointConversion extends ArithmeticConversion {
|
||||
FloatingPointConversion() {
|
||||
getUnspecifiedType() instanceof FloatingPointType and
|
||||
getExpr().getUnspecifiedType() instanceof FloatingPointType
|
||||
this.getUnspecifiedType() instanceof FloatingPointType and
|
||||
this.getExpr().getUnspecifiedType() instanceof FloatingPointType
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -244,8 +244,8 @@ class FloatingPointConversion extends ArithmeticConversion {
|
||||
*/
|
||||
class FloatingPointToIntegralConversion extends ArithmeticConversion {
|
||||
FloatingPointToIntegralConversion() {
|
||||
isIntegralOrEnum(getUnspecifiedType()) and
|
||||
getExpr().getUnspecifiedType() instanceof FloatingPointType
|
||||
isIntegralOrEnum(this.getUnspecifiedType()) and
|
||||
this.getExpr().getUnspecifiedType() instanceof FloatingPointType
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -264,8 +264,8 @@ class FloatingPointToIntegralConversion extends ArithmeticConversion {
|
||||
*/
|
||||
class IntegralToFloatingPointConversion extends ArithmeticConversion {
|
||||
IntegralToFloatingPointConversion() {
|
||||
getUnspecifiedType() instanceof FloatingPointType and
|
||||
isIntegralOrEnum(getExpr().getUnspecifiedType())
|
||||
this.getUnspecifiedType() instanceof FloatingPointType and
|
||||
isIntegralOrEnum(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -290,8 +290,8 @@ class IntegralToFloatingPointConversion extends ArithmeticConversion {
|
||||
class PointerConversion extends Cast {
|
||||
PointerConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
isPointerOrNullPointer(getUnspecifiedType()) and
|
||||
isPointerOrNullPointer(getExpr().getUnspecifiedType())
|
||||
isPointerOrNullPointer(this.getUnspecifiedType()) and
|
||||
isPointerOrNullPointer(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { not exists(qlCast(this)) and result = "PointerConversion" }
|
||||
@@ -315,8 +315,8 @@ class PointerToMemberConversion extends Cast {
|
||||
PointerToMemberConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
exists(Type fromType, Type toType |
|
||||
fromType = getExpr().getUnspecifiedType() and
|
||||
toType = getUnspecifiedType() and
|
||||
fromType = this.getExpr().getUnspecifiedType() and
|
||||
toType = this.getUnspecifiedType() and
|
||||
isPointerToMemberOrNullPointer(fromType) and
|
||||
isPointerToMemberOrNullPointer(toType) and
|
||||
// A conversion from nullptr to nullptr is a `PointerConversion`, not a
|
||||
@@ -345,8 +345,8 @@ class PointerToMemberConversion extends Cast {
|
||||
class PointerToIntegralConversion extends Cast {
|
||||
PointerToIntegralConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
isIntegralOrEnum(getUnspecifiedType()) and
|
||||
isPointerOrNullPointer(getExpr().getUnspecifiedType())
|
||||
isIntegralOrEnum(this.getUnspecifiedType()) and
|
||||
isPointerOrNullPointer(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -366,8 +366,8 @@ class PointerToIntegralConversion extends Cast {
|
||||
class IntegralToPointerConversion extends Cast {
|
||||
IntegralToPointerConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
isPointerOrNullPointer(getUnspecifiedType()) and
|
||||
isIntegralOrEnum(getExpr().getUnspecifiedType())
|
||||
isPointerOrNullPointer(this.getUnspecifiedType()) and
|
||||
isIntegralOrEnum(this.getExpr().getUnspecifiedType())
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() {
|
||||
@@ -403,7 +403,7 @@ class BoolConversion extends Cast {
|
||||
class VoidConversion extends Cast {
|
||||
VoidConversion() {
|
||||
conversionkinds(underlyingElement(this), 0) and
|
||||
getUnspecifiedType() instanceof VoidType
|
||||
this.getUnspecifiedType() instanceof VoidType
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { not exists(qlCast(this)) and result = "VoidConversion" }
|
||||
@@ -434,8 +434,8 @@ class InheritanceConversion extends Cast {
|
||||
* conversion is to an indirect virtual base class.
|
||||
*/
|
||||
final ClassDerivation getDerivation() {
|
||||
result.getBaseClass() = getBaseClass() and
|
||||
result.getDerivedClass() = getDerivedClass()
|
||||
result.getBaseClass() = this.getBaseClass() and
|
||||
result.getDerivedClass() = this.getDerivedClass()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,12 +490,12 @@ class BaseClassConversion extends InheritanceConversion {
|
||||
|
||||
override Class getBaseClass() { result = getConversionClass(this) }
|
||||
|
||||
override Class getDerivedClass() { result = getConversionClass(getExpr()) }
|
||||
override Class getDerivedClass() { result = getConversionClass(this.getExpr()) }
|
||||
|
||||
/**
|
||||
* Holds if this conversion is to a virtual base class.
|
||||
*/
|
||||
predicate isVirtual() { getDerivation().isVirtual() or not exists(getDerivation()) }
|
||||
predicate isVirtual() { this.getDerivation().isVirtual() or not exists(this.getDerivation()) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,7 +515,7 @@ class DerivedClassConversion extends InheritanceConversion {
|
||||
|
||||
override string getSemanticConversionString() { result = "derived class conversion" }
|
||||
|
||||
override Class getBaseClass() { result = getConversionClass(getExpr()) }
|
||||
override Class getBaseClass() { result = getConversionClass(this.getExpr()) }
|
||||
|
||||
override Class getDerivedClass() { result = getConversionClass(this) }
|
||||
}
|
||||
@@ -637,8 +637,8 @@ class DynamicCast extends Cast, @dynamic_cast {
|
||||
*/
|
||||
class UuidofOperator extends Expr, @uuidof {
|
||||
override string toString() {
|
||||
if exists(getTypeOperand())
|
||||
then result = "__uuidof(" + getTypeOperand().getName() + ")"
|
||||
if exists(this.getTypeOperand())
|
||||
then result = "__uuidof(" + this.getTypeOperand().getName() + ")"
|
||||
else result = "__uuidof(0)"
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Expr extends StmtParent, @expr {
|
||||
Function getEnclosingFunction() { result = exprEnclosingElement(this) }
|
||||
|
||||
/** Gets the nearest enclosing set of curly braces around this expression in the source, if any. */
|
||||
BlockStmt getEnclosingBlock() { result = getEnclosingStmt().getEnclosingBlock() }
|
||||
BlockStmt getEnclosingBlock() { result = this.getEnclosingStmt().getEnclosingBlock() }
|
||||
|
||||
override Stmt getEnclosingStmt() {
|
||||
result = this.getParent().(Expr).getEnclosingStmt()
|
||||
@@ -219,13 +219,13 @@ class Expr extends StmtParent, @expr {
|
||||
* Holds if this expression is a _glvalue_. A _glvalue_ is either an _lvalue_ or an
|
||||
* _xvalue_.
|
||||
*/
|
||||
predicate isGLValueCategory() { isLValueCategory() or isXValueCategory() }
|
||||
predicate isGLValueCategory() { this.isLValueCategory() or this.isXValueCategory() }
|
||||
|
||||
/**
|
||||
* Holds if this expression is an _rvalue_. An _rvalue_ is either a _prvalue_ or an
|
||||
* _xvalue_.
|
||||
*/
|
||||
predicate isRValueCategory() { isPRValueCategory() or isXValueCategory() }
|
||||
predicate isRValueCategory() { this.isPRValueCategory() or this.isXValueCategory() }
|
||||
|
||||
/**
|
||||
* Gets a string representation of the value category of the expression.
|
||||
@@ -240,15 +240,15 @@ class Expr extends StmtParent, @expr {
|
||||
* `hasLValueToRvalueConversion()` holds.
|
||||
*/
|
||||
string getValueCategoryString() {
|
||||
isLValueCategory() and
|
||||
this.isLValueCategory() and
|
||||
result = "lvalue"
|
||||
or
|
||||
isXValueCategory() and
|
||||
this.isXValueCategory() and
|
||||
result = "xvalue"
|
||||
or
|
||||
(
|
||||
isPRValueCategory() and
|
||||
if hasLValueToRValueConversion() then result = "prvalue(load)" else result = "prvalue"
|
||||
this.isPRValueCategory() and
|
||||
if this.hasLValueToRValueConversion() then result = "prvalue(load)" else result = "prvalue"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ class Expr extends StmtParent, @expr {
|
||||
* such as an expression inside a sizeof.
|
||||
*/
|
||||
predicate isUnevaluated() {
|
||||
exists(Element e | e = getParentWithConversions+() |
|
||||
exists(Element e | e = this.getParentWithConversions+() |
|
||||
e instanceof SizeofOperator
|
||||
or
|
||||
exists(Expr e2 |
|
||||
@@ -279,7 +279,7 @@ class Expr extends StmtParent, @expr {
|
||||
e instanceof AlignofOperator
|
||||
)
|
||||
or
|
||||
exists(Decltype d | d.getExpr() = getParentWithConversions*())
|
||||
exists(Decltype d | d.getExpr() = this.getParentWithConversions*())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,7 +725,7 @@ class PointerDereferenceExpr extends UnaryOperation, @indirect {
|
||||
*
|
||||
* Gets the expression that is being dereferenced.
|
||||
*/
|
||||
deprecated Expr getExpr() { result = getOperand() }
|
||||
deprecated Expr getExpr() { result = this.getOperand() }
|
||||
|
||||
override string getOperator() { result = "*" }
|
||||
|
||||
@@ -780,15 +780,15 @@ class NewOrNewArrayExpr extends Expr, @any_new_expr {
|
||||
* Gets the alignment argument passed to the allocation function, if any.
|
||||
*/
|
||||
Expr getAlignmentArgument() {
|
||||
hasAlignedAllocation() and
|
||||
this.hasAlignedAllocation() and
|
||||
(
|
||||
// If we have an allocator call, the alignment is the second argument to
|
||||
// that call.
|
||||
result = getAllocatorCall().getArgument(1)
|
||||
result = this.getAllocatorCall().getArgument(1)
|
||||
or
|
||||
// Otherwise, the alignment winds up as child number 3 of the `new`
|
||||
// itself.
|
||||
result = getChild(3)
|
||||
result = this.getChild(3)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -916,7 +916,7 @@ class NewArrayExpr extends NewOrNewArrayExpr, @new_array_expr {
|
||||
* Gets the element type of the array being allocated.
|
||||
*/
|
||||
Type getAllocatedElementType() {
|
||||
result = getType().getUnderlyingType().(PointerType).getBaseType()
|
||||
result = this.getType().getUnderlyingType().(PointerType).getBaseType()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -946,7 +946,12 @@ class DeleteExpr extends Expr, @delete_expr {
|
||||
*/
|
||||
Type getDeletedObjectType() {
|
||||
result =
|
||||
getExpr().getFullyConverted().getType().stripTopLevelSpecifiers().(PointerType).getBaseType()
|
||||
this.getExpr()
|
||||
.getFullyConverted()
|
||||
.getType()
|
||||
.stripTopLevelSpecifiers()
|
||||
.(PointerType)
|
||||
.getBaseType()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -957,7 +962,7 @@ class DeleteExpr extends Expr, @delete_expr {
|
||||
/**
|
||||
* Gets the destructor to be called to destroy the object, if any.
|
||||
*/
|
||||
Destructor getDestructor() { result = getDestructorCall().getTarget() }
|
||||
Destructor getDestructor() { result = this.getDestructorCall().getTarget() }
|
||||
|
||||
/**
|
||||
* Gets the `operator delete` that deallocates storage. Does not hold
|
||||
@@ -1020,7 +1025,12 @@ class DeleteArrayExpr extends Expr, @delete_array_expr {
|
||||
*/
|
||||
Type getDeletedElementType() {
|
||||
result =
|
||||
getExpr().getFullyConverted().getType().stripTopLevelSpecifiers().(PointerType).getBaseType()
|
||||
this.getExpr()
|
||||
.getFullyConverted()
|
||||
.getType()
|
||||
.stripTopLevelSpecifiers()
|
||||
.(PointerType)
|
||||
.getBaseType()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1034,7 +1044,7 @@ class DeleteArrayExpr extends Expr, @delete_array_expr {
|
||||
/**
|
||||
* Gets the destructor to be called to destroy each element in the array, if any.
|
||||
*/
|
||||
Destructor getDestructor() { result = getDestructorCall().getTarget() }
|
||||
Destructor getDestructor() { result = this.getDestructorCall().getTarget() }
|
||||
|
||||
/**
|
||||
* Gets the `operator delete[]` that deallocates storage.
|
||||
@@ -1101,7 +1111,7 @@ class StmtExpr extends Expr, @expr_stmt {
|
||||
* x = ({ dosomething(); a+b; });
|
||||
* ```
|
||||
*/
|
||||
Expr getResultExpr() { result = getStmtResultExpr(getStmt()) }
|
||||
Expr getResultExpr() { result = getStmtResultExpr(this.getStmt()) }
|
||||
}
|
||||
|
||||
/** Get the result expression of a statement. (Helper function for StmtExpr.) */
|
||||
@@ -1230,20 +1240,20 @@ class FoldExpr extends Expr, @foldexpr {
|
||||
predicate isRightFold() { fold(underlyingElement(this), _, false) }
|
||||
|
||||
/** Holds if this is a unary fold expression. */
|
||||
predicate isUnaryFold() { getNumChild() = 1 }
|
||||
predicate isUnaryFold() { this.getNumChild() = 1 }
|
||||
|
||||
/** Holds if this is a binary fold expression. */
|
||||
predicate isBinaryFold() { getNumChild() = 2 }
|
||||
predicate isBinaryFold() { this.getNumChild() = 2 }
|
||||
|
||||
/**
|
||||
* Gets the child expression containing the unexpanded parameter pack.
|
||||
*/
|
||||
Expr getPackExpr() {
|
||||
this.isUnaryFold() and
|
||||
result = getChild(0)
|
||||
result = this.getChild(0)
|
||||
or
|
||||
this.isBinaryFold() and
|
||||
if this.isRightFold() then result = getChild(0) else result = getChild(1)
|
||||
if this.isRightFold() then result = this.getChild(0) else result = this.getChild(1)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1251,7 +1261,7 @@ class FoldExpr extends Expr, @foldexpr {
|
||||
*/
|
||||
Expr getInitExpr() {
|
||||
this.isBinaryFold() and
|
||||
if this.isRightFold() then result = getChild(1) else result = getChild(0)
|
||||
if this.isRightFold() then result = this.getChild(1) else result = this.getChild(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class LambdaExpression extends Expr, @lambdaexpr {
|
||||
/**
|
||||
* Gets an implicitly or explicitly captured value of this lambda expression.
|
||||
*/
|
||||
LambdaCapture getACapture() { result = getCapture(_) }
|
||||
LambdaCapture getACapture() { result = this.getCapture(_) }
|
||||
|
||||
/**
|
||||
* Gets the nth implicitly or explicitly captured value of this lambda expression.
|
||||
@@ -58,13 +58,13 @@ class LambdaExpression extends Expr, @lambdaexpr {
|
||||
* - The return type.
|
||||
* - The statements comprising the lambda body.
|
||||
*/
|
||||
Operator getLambdaFunction() { result = getType().(Closure).getLambdaFunction() }
|
||||
Operator getLambdaFunction() { result = this.getType().(Closure).getLambdaFunction() }
|
||||
|
||||
/**
|
||||
* Gets the initializer that initializes the captured variables in the closure, if any.
|
||||
* A lambda that does not capture any variables will not have an initializer.
|
||||
*/
|
||||
ClassAggregateLiteral getInitializer() { result = getChild(0) }
|
||||
ClassAggregateLiteral getInitializer() { result = this.getChild(0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ class Closure extends Class {
|
||||
* ```
|
||||
*/
|
||||
class LambdaCapture extends Locatable, @lambdacapture {
|
||||
override string toString() { result = getField().getName() }
|
||||
override string toString() { result = this.getField().getName() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "LambdaCapture" }
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ class TextLiteral extends Literal {
|
||||
|
||||
/** Gets a hex escape sequence that appears in the character or string literal (see [lex.ccon] in the C++ Standard). */
|
||||
string getAHexEscapeSequence(int occurrence, int offset) {
|
||||
result = getValueText().regexpFind("(?<!\\\\)\\\\x[0-9a-fA-F]+", occurrence, offset)
|
||||
result = this.getValueText().regexpFind("(?<!\\\\)\\\\x[0-9a-fA-F]+", occurrence, offset)
|
||||
}
|
||||
|
||||
/** Gets an octal escape sequence that appears in the character or string literal (see [lex.ccon] in the C++ Standard). */
|
||||
string getAnOctalEscapeSequence(int occurrence, int offset) {
|
||||
result = getValueText().regexpFind("(?<!\\\\)\\\\[0-7]{1,3}", occurrence, offset)
|
||||
result = this.getValueText().regexpFind("(?<!\\\\)\\\\[0-7]{1,3}", occurrence, offset)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,27 +75,27 @@ class TextLiteral extends Literal {
|
||||
string getANonStandardEscapeSequence(int occurrence, int offset) {
|
||||
// Find all single character escape sequences (ignoring the start of octal escape sequences),
|
||||
// together with anything starting like a hex escape sequence but not followed by a hex digit.
|
||||
result = getValueText().regexpFind("\\\\[^x0-7\\s]|\\\\x[^0-9a-fA-F]", occurrence, offset) and
|
||||
result = this.getValueText().regexpFind("\\\\[^x0-7\\s]|\\\\x[^0-9a-fA-F]", occurrence, offset) and
|
||||
// From these, exclude all standard escape sequences.
|
||||
not result = getAStandardEscapeSequence(_, _)
|
||||
not result = this.getAStandardEscapeSequence(_, _)
|
||||
}
|
||||
|
||||
/** Gets a simple escape sequence that appears in the char or string literal (see [lex.ccon] in the C++ Standard). */
|
||||
string getASimpleEscapeSequence(int occurrence, int offset) {
|
||||
result = getValueText().regexpFind("\\\\['\"?\\\\abfnrtv]", occurrence, offset)
|
||||
result = this.getValueText().regexpFind("\\\\['\"?\\\\abfnrtv]", occurrence, offset)
|
||||
}
|
||||
|
||||
/** Gets a standard escape sequence that appears in the char or string literal (see [lex.ccon] in the C++ Standard). */
|
||||
string getAStandardEscapeSequence(int occurrence, int offset) {
|
||||
result = getASimpleEscapeSequence(occurrence, offset) or
|
||||
result = getAnOctalEscapeSequence(occurrence, offset) or
|
||||
result = getAHexEscapeSequence(occurrence, offset)
|
||||
result = this.getASimpleEscapeSequence(occurrence, offset) or
|
||||
result = this.getAnOctalEscapeSequence(occurrence, offset) or
|
||||
result = this.getAHexEscapeSequence(occurrence, offset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of the string literal (including null) before escape sequences added by the extractor.
|
||||
*/
|
||||
int getOriginalLength() { result = getValue().length() + 1 }
|
||||
int getOriginalLength() { result = this.getValue().length() + 1 }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +216,7 @@ class ClassAggregateLiteral extends AggregateLiteral {
|
||||
(
|
||||
// If the field has an explicit initializer expression, then the field is
|
||||
// initialized.
|
||||
exists(getFieldExpr(field))
|
||||
exists(this.getFieldExpr(field))
|
||||
or
|
||||
// If the type is not a union, all fields without initializers are value
|
||||
// initialized.
|
||||
@@ -224,7 +224,7 @@ class ClassAggregateLiteral extends AggregateLiteral {
|
||||
or
|
||||
// If the type is a union, and there are no explicit initializers, then
|
||||
// the first declared field is value initialized.
|
||||
not exists(getAChild()) and
|
||||
not exists(this.getAChild()) and
|
||||
field.getInitializationOrder() = 0
|
||||
)
|
||||
}
|
||||
@@ -239,8 +239,8 @@ class ClassAggregateLiteral extends AggregateLiteral {
|
||||
*/
|
||||
pragma[inline]
|
||||
predicate isValueInitialized(Field field) {
|
||||
isInitialized(field) and
|
||||
not exists(getFieldExpr(field))
|
||||
this.isInitialized(field) and
|
||||
not exists(this.getFieldExpr(field))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
|
||||
bindingset[elementIndex]
|
||||
predicate isInitialized(int elementIndex) {
|
||||
elementIndex >= 0 and
|
||||
elementIndex < getArraySize()
|
||||
elementIndex < this.getArraySize()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,8 +298,8 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
|
||||
*/
|
||||
bindingset[elementIndex]
|
||||
predicate isValueInitialized(int elementIndex) {
|
||||
isInitialized(elementIndex) and
|
||||
not exists(getElementExpr(elementIndex))
|
||||
this.isInitialized(elementIndex) and
|
||||
not exists(this.getElementExpr(elementIndex))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user