From 3266a8902376203ca95d44ba18affceaa1910dea Mon Sep 17 00:00:00 2001 From: Robert Marsh Date: Fri, 7 Feb 2020 16:56:57 -0800 Subject: [PATCH] C++: document DynamicAllocationInstruction --- .../ir/implementation/aliased_ssa/Instruction.qll | 12 +++++++++--- .../code/cpp/ir/implementation/raw/Instruction.qll | 12 +++++++++--- .../ir/implementation/unaliased_ssa/Instruction.qll | 12 +++++++++--- .../csharp/ir/implementation/raw/Instruction.qll | 12 +++++++++--- .../ir/implementation/unaliased_ssa/Instruction.qll | 12 +++++++++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll b/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll +++ b/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll b/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /**