mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
Rust: Make RefExpr an Operation.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
private import codeql.rust.elements.internal.generated.RefExpr
|
||||
private import codeql.rust.elements.internal.OperationImpl::Impl as OperationImpl
|
||||
|
||||
/**
|
||||
* INTERNAL: This module contains the customizable definition of `RefExpr` and should not
|
||||
@@ -21,11 +22,15 @@ module Impl {
|
||||
* let raw_mut: &mut i32 = &raw mut foo;
|
||||
* ```
|
||||
*/
|
||||
class RefExpr extends Generated::RefExpr {
|
||||
class RefExpr extends Generated::RefExpr, OperationImpl::Operation {
|
||||
override string toStringImpl() {
|
||||
result = "&" + concat(int i | | this.getSpecPart(i), " " order by i)
|
||||
}
|
||||
|
||||
override string getOperatorName() { result = "&" }
|
||||
|
||||
override Expr getAnOperand() { result = this.getExpr() }
|
||||
|
||||
private string getSpecPart(int index) {
|
||||
index = 0 and this.isRaw() and result = "raw"
|
||||
or
|
||||
|
||||
@@ -50,7 +50,7 @@ fn test_operations(
|
||||
|
||||
// miscellaneous expressions that might be operations
|
||||
*ptr; // $ Operation Op=* Operands=1 PrefixExpr DerefExpr
|
||||
&x; // $ RefExpr
|
||||
&x; // $ Operation Op=& Operands=1 RefExpr MISSING: PrefixExpr
|
||||
res?;
|
||||
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user