mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Add DerefExpr class.
This commit is contained in:
13
rust/ql/lib/codeql/rust/elements/DerefExpr.qll
Normal file
13
rust/ql/lib/codeql/rust/elements/DerefExpr.qll
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Provides classes for deref expressions (`*`).
|
||||
*/
|
||||
|
||||
private import codeql.rust.elements.PrefixExpr
|
||||
private import codeql.rust.elements.Operation
|
||||
|
||||
/**
|
||||
* A dereference expression, `*`.
|
||||
*/
|
||||
final class DerefExpr extends PrefixExpr, Operation {
|
||||
DerefExpr() { this.getOperatorName() = "*" }
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import codeql.rust.elements.ArithmeticOperation
|
||||
import codeql.rust.elements.AssignmentOperation
|
||||
import codeql.rust.elements.BitwiseOperation
|
||||
import codeql.rust.elements.ComparisonOperation
|
||||
import codeql.rust.elements.DerefExpr
|
||||
import codeql.rust.elements.LiteralExprExt
|
||||
import codeql.rust.elements.LogicalOperation
|
||||
import codeql.rust.elements.AsyncBlockExpr
|
||||
|
||||
@@ -45,6 +45,8 @@ string describe(Expr op) {
|
||||
op instanceof BinaryBitwiseOperation and result = "BinaryBitwiseOperation"
|
||||
or
|
||||
op instanceof AssignBitwiseOperation and result = "AssignBitwiseOperation"
|
||||
or
|
||||
op instanceof DerefExpr and result = "DerefExpr"
|
||||
}
|
||||
|
||||
module OperationsTest implements TestSig {
|
||||
|
||||
@@ -49,7 +49,7 @@ fn test_operations(
|
||||
x >>= y; // $ Operation Op=>>= Operands=2 AssignmentOperation BinaryExpr BitwiseOperation AssignBitwiseOperation
|
||||
|
||||
// miscellaneous expressions that might be operations
|
||||
*ptr; // $ Operation Op=* Operands=1 PrefixExpr
|
||||
*ptr; // $ Operation Op=* Operands=1 PrefixExpr DerefExpr
|
||||
&x; // $ RefExpr
|
||||
res?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user