mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
C++/C#: Add new MemoryAccessKind to represent entire allocation
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
private newtype TMemoryAccessKind =
|
private newtype TMemoryAccessKind =
|
||||||
TIndirectMemoryAccess() or
|
TIndirectMemoryAccess() or
|
||||||
TBufferMemoryAccess() or
|
TBufferMemoryAccess() or
|
||||||
|
TEntireAllocationMemoryAccess() or
|
||||||
TEscapedMemoryAccess() or
|
TEscapedMemoryAccess() or
|
||||||
TNonLocalMemoryAccess() or
|
TNonLocalMemoryAccess() or
|
||||||
TPhiMemoryAccess() or
|
TPhiMemoryAccess() or
|
||||||
@@ -43,6 +44,16 @@ class BufferMemoryAccess extends MemoryAccessKind, TBufferMemoryAccess {
|
|||||||
final override predicate usesAddressOperand() { any() }
|
final override predicate usesAddressOperand() { any() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operand or results accesses all memory in the contiguous allocation that contains the address
|
||||||
|
* specified by the `AddressOperand` on the same instruction.
|
||||||
|
*/
|
||||||
|
class EntireAllocationMemoryAccess extends MemoryAccessKind, TEntireAllocationMemoryAccess {
|
||||||
|
override string toString() { result = "alloc" }
|
||||||
|
|
||||||
|
final override predicate usesAddressOperand() { any() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The operand or result accesses all memory whose address has escaped.
|
* The operand or result accesses all memory whose address has escaped.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -232,6 +232,31 @@ abstract class BufferReadOpcode extends BufferAccessOpcode {
|
|||||||
final override MemoryAccessKind getReadMemoryAccess() { result instanceof BufferMemoryAccess }
|
final override MemoryAccessKind getReadMemoryAccess() { result instanceof BufferMemoryAccess }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that access an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationAccessOpcode extends Opcode {
|
||||||
|
final override predicate hasAddressOperand() { any() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that write to an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationWriteOpcode extends EntireAllocationAccessOpcode {
|
||||||
|
final override MemoryAccessKind getWriteMemoryAccess() {
|
||||||
|
result instanceof EntireAllocationMemoryAccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that reads from an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationReadOpcode extends EntireAllocationAccessOpcode {
|
||||||
|
final override MemoryAccessKind getReadMemoryAccess() {
|
||||||
|
result instanceof EntireAllocationMemoryAccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An opcode that accesses a memory buffer whose size is determined by a `BufferSizeOperand`.
|
* An opcode that accesses a memory buffer whose size is determined by a `BufferSizeOperand`.
|
||||||
*/
|
*/
|
||||||
@@ -325,7 +350,7 @@ module Opcode {
|
|||||||
final override string toString() { result = "InitializeParameter" }
|
final override string toString() { result = "InitializeParameter" }
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitializeIndirection extends IndirectWriteOpcode, TInitializeIndirection {
|
class InitializeIndirection extends EntireAllocationWriteOpcode, TInitializeIndirection {
|
||||||
final override string toString() { result = "InitializeIndirection" }
|
final override string toString() { result = "InitializeIndirection" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +374,7 @@ module Opcode {
|
|||||||
final override string toString() { result = "ReturnVoid" }
|
final override string toString() { result = "ReturnVoid" }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReturnIndirection extends IndirectReadOpcode, TReturnIndirection {
|
class ReturnIndirection extends EntireAllocationReadOpcode, TReturnIndirection {
|
||||||
final override string toString() { result = "ReturnIndirection" }
|
final override string toString() { result = "ReturnIndirection" }
|
||||||
|
|
||||||
final override predicate hasOperandInternal(OperandTag tag) {
|
final override predicate hasOperandInternal(OperandTag tag) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
private newtype TMemoryAccessKind =
|
private newtype TMemoryAccessKind =
|
||||||
TIndirectMemoryAccess() or
|
TIndirectMemoryAccess() or
|
||||||
TBufferMemoryAccess() or
|
TBufferMemoryAccess() or
|
||||||
|
TEntireAllocationMemoryAccess() or
|
||||||
TEscapedMemoryAccess() or
|
TEscapedMemoryAccess() or
|
||||||
TNonLocalMemoryAccess() or
|
TNonLocalMemoryAccess() or
|
||||||
TPhiMemoryAccess() or
|
TPhiMemoryAccess() or
|
||||||
@@ -43,6 +44,16 @@ class BufferMemoryAccess extends MemoryAccessKind, TBufferMemoryAccess {
|
|||||||
final override predicate usesAddressOperand() { any() }
|
final override predicate usesAddressOperand() { any() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operand or results accesses all memory in the contiguous allocation that contains the address
|
||||||
|
* specified by the `AddressOperand` on the same instruction.
|
||||||
|
*/
|
||||||
|
class EntireAllocationMemoryAccess extends MemoryAccessKind, TEntireAllocationMemoryAccess {
|
||||||
|
override string toString() { result = "alloc" }
|
||||||
|
|
||||||
|
final override predicate usesAddressOperand() { any() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The operand or result accesses all memory whose address has escaped.
|
* The operand or result accesses all memory whose address has escaped.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -232,6 +232,31 @@ abstract class BufferReadOpcode extends BufferAccessOpcode {
|
|||||||
final override MemoryAccessKind getReadMemoryAccess() { result instanceof BufferMemoryAccess }
|
final override MemoryAccessKind getReadMemoryAccess() { result instanceof BufferMemoryAccess }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that access an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationAccessOpcode extends Opcode {
|
||||||
|
final override predicate hasAddressOperand() { any() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that write to an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationWriteOpcode extends EntireAllocationAccessOpcode {
|
||||||
|
final override MemoryAccessKind getWriteMemoryAccess() {
|
||||||
|
result instanceof EntireAllocationMemoryAccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opcode that reads from an entire memory allocation.
|
||||||
|
*/
|
||||||
|
abstract class EntireAllocationReadOpcode extends EntireAllocationAccessOpcode {
|
||||||
|
final override MemoryAccessKind getReadMemoryAccess() {
|
||||||
|
result instanceof EntireAllocationMemoryAccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An opcode that accesses a memory buffer whose size is determined by a `BufferSizeOperand`.
|
* An opcode that accesses a memory buffer whose size is determined by a `BufferSizeOperand`.
|
||||||
*/
|
*/
|
||||||
@@ -325,7 +350,7 @@ module Opcode {
|
|||||||
final override string toString() { result = "InitializeParameter" }
|
final override string toString() { result = "InitializeParameter" }
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitializeIndirection extends IndirectWriteOpcode, TInitializeIndirection {
|
class InitializeIndirection extends EntireAllocationWriteOpcode, TInitializeIndirection {
|
||||||
final override string toString() { result = "InitializeIndirection" }
|
final override string toString() { result = "InitializeIndirection" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +374,7 @@ module Opcode {
|
|||||||
final override string toString() { result = "ReturnVoid" }
|
final override string toString() { result = "ReturnVoid" }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReturnIndirection extends IndirectReadOpcode, TReturnIndirection {
|
class ReturnIndirection extends EntireAllocationReadOpcode, TReturnIndirection {
|
||||||
final override string toString() { result = "ReturnIndirection" }
|
final override string toString() { result = "ReturnIndirection" }
|
||||||
|
|
||||||
final override predicate hasOperandInternal(OperandTag tag) {
|
final override predicate hasOperandInternal(OperandTag tag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user