diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll index 1895726ecb4..afec2384b23 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll @@ -878,7 +878,11 @@ module Public { /** Gets the parameter through which this value is assigned. */ Parameter getParameter() { - result = this.getCallInstruction().getStaticCallTarget().getParameter(this.getArgumentIndex()) + result = + this.getCallInstruction() + .getStaticCallTarget() + .(Function) + .getParameter(this.getArgumentIndex()) } } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll index 45a6755356b..4d109c0716d 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll @@ -175,7 +175,8 @@ private class PointerWrapperTypeIndirection extends Indirection instanceof Point override predicate isAdditionalDereference(Instruction deref, Operand address) { exists(CallInstruction call | operandForFullyConvertedCall(getAUse(deref), call) and - this = call.getStaticCallTarget().getClassAndName(["operator*", "operator->", "get"]) and + this = + call.getStaticCallTarget().(Function).getClassAndName(["operator*", "operator->", "get"]) and address = call.getThisArgumentOperand() ) } @@ -194,7 +195,7 @@ private module IteratorIndirections { override predicate isAdditionalWrite(Node0Impl value, Operand address, boolean certain) { exists(CallInstruction call | call.getArgumentOperand(0) = value.asOperand() | - this = call.getStaticCallTarget().getClassAndName("operator=") and + this = call.getStaticCallTarget().(Function).getClassAndName("operator=") and address = call.getThisArgumentOperand() and certain = false ) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll index 8d3e960c3f8..b7dcd4d8f75 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll @@ -495,7 +495,7 @@ class FieldInstruction extends Instruction { * `FunctionAddress` instruction. */ class FunctionInstruction extends Instruction { - Language::Function funcSymbol; + Language::Declaration funcSymbol; FunctionInstruction() { funcSymbol = Raw::getInstructionFunction(this) } @@ -504,7 +504,7 @@ class FunctionInstruction extends Instruction { /** * Gets the function that this instruction references. */ - final Language::Function getFunctionSymbol() { result = funcSymbol } + final Language::Declaration getFunctionSymbol() { result = funcSymbol } } /** @@ -1678,7 +1678,7 @@ class CallInstruction extends Instruction { /** * Gets the `Function` that the call targets, if this is statically known. */ - final Language::Function getStaticCallTarget() { + final Language::Declaration getStaticCallTarget() { result = this.getCallTarget().(FunctionAddressInstruction).getFunctionSymbol() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 8d3e960c3f8..b7dcd4d8f75 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -495,7 +495,7 @@ class FieldInstruction extends Instruction { * `FunctionAddress` instruction. */ class FunctionInstruction extends Instruction { - Language::Function funcSymbol; + Language::Declaration funcSymbol; FunctionInstruction() { funcSymbol = Raw::getInstructionFunction(this) } @@ -504,7 +504,7 @@ class FunctionInstruction extends Instruction { /** * Gets the function that this instruction references. */ - final Language::Function getFunctionSymbol() { result = funcSymbol } + final Language::Declaration getFunctionSymbol() { result = funcSymbol } } /** @@ -1678,7 +1678,7 @@ class CallInstruction extends Instruction { /** * Gets the `Function` that the call targets, if this is statically known. */ - final Language::Function getStaticCallTarget() { + final Language::Declaration getStaticCallTarget() { result = this.getCallTarget().(FunctionAddressInstruction).getFunctionSymbol() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll index 7a667fcc017..f3d88908cd6 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll @@ -115,7 +115,7 @@ module Raw { } cached - Function getInstructionFunction(Instruction instruction) { + Declaration getInstructionFunction(Instruction instruction) { result = getInstructionTranslatedElement(instruction) .getInstructionFunction(getInstructionTag(instruction)) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll index 1a5c65d364d..f3d084883a7 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll @@ -348,7 +348,7 @@ class TranslatedExprCall extends TranslatedCallExpr { class TranslatedFunctionCall extends TranslatedCallExpr, TranslatedDirectCall { override FunctionCall expr; - override Function getInstructionFunction(InstructionTag tag) { + override Declaration getInstructionFunction(InstructionTag tag) { tag = CallTargetTag() and result = expr.getTarget() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll index c30cc4bbc5c..117c92e3fe5 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll @@ -1182,7 +1182,7 @@ abstract class TranslatedElement extends TTranslatedElement { * If the instruction specified by `tag` is a `FunctionInstruction`, gets the * `Function` for that instruction. */ - Function getInstructionFunction(InstructionTag tag) { none() } + Declaration getInstructionFunction(InstructionTag tag) { none() } /** * If the instruction specified by `tag` is a `VariableInstruction`, gets the diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll index 712f140e5b8..9a437b90538 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll @@ -1264,7 +1264,7 @@ class TranslatedFunctionAccess extends TranslatedNonConstantExpr { resultType = this.getResultType() } - override Function getInstructionFunction(InstructionTag tag) { + override Declaration getInstructionFunction(InstructionTag tag) { tag = OnlyInstructionTag() and result = expr.getTarget() } @@ -2547,7 +2547,7 @@ class TranslatedAllocatorCall extends TTranslatedAllocatorCall, TranslatedDirect any() } - override Function getInstructionFunction(InstructionTag tag) { + override Declaration getInstructionFunction(InstructionTag tag) { tag = CallTargetTag() and result = expr.getAllocator() } @@ -2630,7 +2630,7 @@ class TranslatedDeleteOrDeleteArrayExpr extends TranslatedNonConstantExpr, Trans result = this.getFirstArgumentOrCallInstruction(kind) } - override Function getInstructionFunction(InstructionTag tag) { + override Declaration getInstructionFunction(InstructionTag tag) { tag = CallTargetTag() and result = expr.getDeallocator() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 8d3e960c3f8..b7dcd4d8f75 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -495,7 +495,7 @@ class FieldInstruction extends Instruction { * `FunctionAddress` instruction. */ class FunctionInstruction extends Instruction { - Language::Function funcSymbol; + Language::Declaration funcSymbol; FunctionInstruction() { funcSymbol = Raw::getInstructionFunction(this) } @@ -504,7 +504,7 @@ class FunctionInstruction extends Instruction { /** * Gets the function that this instruction references. */ - final Language::Function getFunctionSymbol() { result = funcSymbol } + final Language::Declaration getFunctionSymbol() { result = funcSymbol } } /** @@ -1678,7 +1678,7 @@ class CallInstruction extends Instruction { /** * Gets the `Function` that the call targets, if this is statically known. */ - final Language::Function getStaticCallTarget() { + final Language::Declaration getStaticCallTarget() { result = this.getCallTarget().(FunctionAddressInstruction).getFunctionSymbol() }