mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
C++ IR: Change many uses of getAnyDef to getDef
This changes all the getters on `Instruction` to use `getDef` instead of `getAnyDef`, with the result that these getters now only have a result if the definition is exact. This is a backwards-INCOMPATIBLE change.
This commit is contained in:
@@ -480,7 +480,8 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction.
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
* an `Operand` for which `isDefinitionInexact` holds.
|
||||
*/
|
||||
final Operand getAUse() {
|
||||
result.getAnyDef() = this
|
||||
@@ -698,7 +699,7 @@ class FieldAddressInstruction extends FieldInstruction {
|
||||
}
|
||||
|
||||
final Instruction getObjectAddress() {
|
||||
result = getObjectAddressOperand().getAnyDef()
|
||||
result = getObjectAddressOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,7 +748,7 @@ class ReturnValueInstruction extends ReturnInstruction {
|
||||
}
|
||||
|
||||
final Instruction getReturnValue() {
|
||||
result = getReturnValueOperand().getAnyDef()
|
||||
result = getReturnValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +762,7 @@ class CopyInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceValue() {
|
||||
result = getSourceValueOperand().getAnyDef()
|
||||
result = getSourceValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,7 +786,7 @@ class LoadInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceAddress() {
|
||||
result = getSourceAddressOperand().getAnyDef()
|
||||
result = getSourceAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final LoadOperand getSourceValueOperand() {
|
||||
@@ -807,7 +808,7 @@ class StoreInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getDestinationAddress() {
|
||||
result = getDestinationAddressOperand().getAnyDef()
|
||||
result = getDestinationAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final StoreValueOperand getSourceValueOperand() {
|
||||
@@ -825,7 +826,7 @@ class ConditionalBranchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getCondition() {
|
||||
result = getConditionOperand().getAnyDef()
|
||||
result = getConditionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getTrueSuccessor() {
|
||||
@@ -891,11 +892,11 @@ class BinaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getLeft() {
|
||||
result = getLeftOperand().getAnyDef()
|
||||
result = getLeftOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getRight() {
|
||||
result = getRightOperand().getAnyDef()
|
||||
result = getRightOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,7 +1046,7 @@ class UnaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getUnary() {
|
||||
result = getUnaryOperand().getAnyDef()
|
||||
result = getUnaryOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1276,7 @@ class SwitchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getExpression() {
|
||||
result = getExpressionOperand().getAnyDef()
|
||||
result = getExpressionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getACaseSuccessor() {
|
||||
@@ -1310,7 +1311,7 @@ class CallInstruction extends Instruction {
|
||||
* function pointer.
|
||||
*/
|
||||
final Instruction getCallTarget() {
|
||||
result = getCallTargetOperand().getAnyDef()
|
||||
result = getCallTargetOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1331,7 +1332,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets all of the arguments of the call, including the `this` pointer, if any.
|
||||
*/
|
||||
final Instruction getAnArgument() {
|
||||
result = getAnArgumentOperand().getAnyDef()
|
||||
result = getAnArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1345,7 +1346,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the `this` pointer argument of the call, if any.
|
||||
*/
|
||||
final Instruction getThisArgument() {
|
||||
result = getThisArgumentOperand().getAnyDef()
|
||||
result = getThisArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1360,7 +1361,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the argument at the specified index.
|
||||
*/
|
||||
final Instruction getPositionalArgument(int index) {
|
||||
result = getPositionalArgumentOperand(index).getAnyDef()
|
||||
result = getPositionalArgumentOperand(index).getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,7 +1517,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the address of the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getExceptionAddress() {
|
||||
result = getExceptionAddressOperand().getAnyDef()
|
||||
result = getExceptionAddressOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1530,7 +1531,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getException() {
|
||||
result = getExceptionOperand().getAnyDef()
|
||||
result = getExceptionOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,7 +1661,7 @@ class PhiInstruction extends Instruction {
|
||||
*/
|
||||
pragma[noinline]
|
||||
final Instruction getAnInput() {
|
||||
result = this.getAnInputOperand().getAnyDef()
|
||||
result = this.getAnInputOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1728,7 +1729,7 @@ class ChiInstruction extends Instruction {
|
||||
* memory write.
|
||||
*/
|
||||
final Instruction getTotal() {
|
||||
result = getTotalOperand().getAnyDef()
|
||||
result = getTotalOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1742,7 +1743,7 @@ class ChiInstruction extends Instruction {
|
||||
* Gets the operand that represents the new value written by the memory write.
|
||||
*/
|
||||
final Instruction getPartial() {
|
||||
result = getPartialOperand().getAnyDef()
|
||||
result = getPartialOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,8 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction.
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
* an `Operand` for which `isDefinitionInexact` holds.
|
||||
*/
|
||||
final Operand getAUse() {
|
||||
result.getAnyDef() = this
|
||||
@@ -698,7 +699,7 @@ class FieldAddressInstruction extends FieldInstruction {
|
||||
}
|
||||
|
||||
final Instruction getObjectAddress() {
|
||||
result = getObjectAddressOperand().getAnyDef()
|
||||
result = getObjectAddressOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,7 +748,7 @@ class ReturnValueInstruction extends ReturnInstruction {
|
||||
}
|
||||
|
||||
final Instruction getReturnValue() {
|
||||
result = getReturnValueOperand().getAnyDef()
|
||||
result = getReturnValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +762,7 @@ class CopyInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceValue() {
|
||||
result = getSourceValueOperand().getAnyDef()
|
||||
result = getSourceValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,7 +786,7 @@ class LoadInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceAddress() {
|
||||
result = getSourceAddressOperand().getAnyDef()
|
||||
result = getSourceAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final LoadOperand getSourceValueOperand() {
|
||||
@@ -807,7 +808,7 @@ class StoreInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getDestinationAddress() {
|
||||
result = getDestinationAddressOperand().getAnyDef()
|
||||
result = getDestinationAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final StoreValueOperand getSourceValueOperand() {
|
||||
@@ -825,7 +826,7 @@ class ConditionalBranchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getCondition() {
|
||||
result = getConditionOperand().getAnyDef()
|
||||
result = getConditionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getTrueSuccessor() {
|
||||
@@ -891,11 +892,11 @@ class BinaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getLeft() {
|
||||
result = getLeftOperand().getAnyDef()
|
||||
result = getLeftOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getRight() {
|
||||
result = getRightOperand().getAnyDef()
|
||||
result = getRightOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,7 +1046,7 @@ class UnaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getUnary() {
|
||||
result = getUnaryOperand().getAnyDef()
|
||||
result = getUnaryOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1276,7 @@ class SwitchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getExpression() {
|
||||
result = getExpressionOperand().getAnyDef()
|
||||
result = getExpressionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getACaseSuccessor() {
|
||||
@@ -1310,7 +1311,7 @@ class CallInstruction extends Instruction {
|
||||
* function pointer.
|
||||
*/
|
||||
final Instruction getCallTarget() {
|
||||
result = getCallTargetOperand().getAnyDef()
|
||||
result = getCallTargetOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1331,7 +1332,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets all of the arguments of the call, including the `this` pointer, if any.
|
||||
*/
|
||||
final Instruction getAnArgument() {
|
||||
result = getAnArgumentOperand().getAnyDef()
|
||||
result = getAnArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1345,7 +1346,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the `this` pointer argument of the call, if any.
|
||||
*/
|
||||
final Instruction getThisArgument() {
|
||||
result = getThisArgumentOperand().getAnyDef()
|
||||
result = getThisArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1360,7 +1361,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the argument at the specified index.
|
||||
*/
|
||||
final Instruction getPositionalArgument(int index) {
|
||||
result = getPositionalArgumentOperand(index).getAnyDef()
|
||||
result = getPositionalArgumentOperand(index).getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,7 +1517,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the address of the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getExceptionAddress() {
|
||||
result = getExceptionAddressOperand().getAnyDef()
|
||||
result = getExceptionAddressOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1530,7 +1531,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getException() {
|
||||
result = getExceptionOperand().getAnyDef()
|
||||
result = getExceptionOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,7 +1661,7 @@ class PhiInstruction extends Instruction {
|
||||
*/
|
||||
pragma[noinline]
|
||||
final Instruction getAnInput() {
|
||||
result = this.getAnInputOperand().getAnyDef()
|
||||
result = this.getAnInputOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1728,7 +1729,7 @@ class ChiInstruction extends Instruction {
|
||||
* memory write.
|
||||
*/
|
||||
final Instruction getTotal() {
|
||||
result = getTotalOperand().getAnyDef()
|
||||
result = getTotalOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1742,7 +1743,7 @@ class ChiInstruction extends Instruction {
|
||||
* Gets the operand that represents the new value written by the memory write.
|
||||
*/
|
||||
final Instruction getPartial() {
|
||||
result = getPartialOperand().getAnyDef()
|
||||
result = getPartialOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,8 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction.
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
* an `Operand` for which `isDefinitionInexact` holds.
|
||||
*/
|
||||
final Operand getAUse() {
|
||||
result.getAnyDef() = this
|
||||
@@ -698,7 +699,7 @@ class FieldAddressInstruction extends FieldInstruction {
|
||||
}
|
||||
|
||||
final Instruction getObjectAddress() {
|
||||
result = getObjectAddressOperand().getAnyDef()
|
||||
result = getObjectAddressOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,7 +748,7 @@ class ReturnValueInstruction extends ReturnInstruction {
|
||||
}
|
||||
|
||||
final Instruction getReturnValue() {
|
||||
result = getReturnValueOperand().getAnyDef()
|
||||
result = getReturnValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +762,7 @@ class CopyInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceValue() {
|
||||
result = getSourceValueOperand().getAnyDef()
|
||||
result = getSourceValueOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,7 +786,7 @@ class LoadInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getSourceAddress() {
|
||||
result = getSourceAddressOperand().getAnyDef()
|
||||
result = getSourceAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final LoadOperand getSourceValueOperand() {
|
||||
@@ -807,7 +808,7 @@ class StoreInstruction extends CopyInstruction {
|
||||
}
|
||||
|
||||
final Instruction getDestinationAddress() {
|
||||
result = getDestinationAddressOperand().getAnyDef()
|
||||
result = getDestinationAddressOperand().getDef()
|
||||
}
|
||||
|
||||
override final StoreValueOperand getSourceValueOperand() {
|
||||
@@ -825,7 +826,7 @@ class ConditionalBranchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getCondition() {
|
||||
result = getConditionOperand().getAnyDef()
|
||||
result = getConditionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getTrueSuccessor() {
|
||||
@@ -891,11 +892,11 @@ class BinaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getLeft() {
|
||||
result = getLeftOperand().getAnyDef()
|
||||
result = getLeftOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getRight() {
|
||||
result = getRightOperand().getAnyDef()
|
||||
result = getRightOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1045,7 +1046,7 @@ class UnaryInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getUnary() {
|
||||
result = getUnaryOperand().getAnyDef()
|
||||
result = getUnaryOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1276,7 @@ class SwitchInstruction extends Instruction {
|
||||
}
|
||||
|
||||
final Instruction getExpression() {
|
||||
result = getExpressionOperand().getAnyDef()
|
||||
result = getExpressionOperand().getDef()
|
||||
}
|
||||
|
||||
final Instruction getACaseSuccessor() {
|
||||
@@ -1310,7 +1311,7 @@ class CallInstruction extends Instruction {
|
||||
* function pointer.
|
||||
*/
|
||||
final Instruction getCallTarget() {
|
||||
result = getCallTargetOperand().getAnyDef()
|
||||
result = getCallTargetOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1331,7 +1332,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets all of the arguments of the call, including the `this` pointer, if any.
|
||||
*/
|
||||
final Instruction getAnArgument() {
|
||||
result = getAnArgumentOperand().getAnyDef()
|
||||
result = getAnArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1345,7 +1346,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the `this` pointer argument of the call, if any.
|
||||
*/
|
||||
final Instruction getThisArgument() {
|
||||
result = getThisArgumentOperand().getAnyDef()
|
||||
result = getThisArgumentOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1360,7 +1361,7 @@ class CallInstruction extends Instruction {
|
||||
* Gets the argument at the specified index.
|
||||
*/
|
||||
final Instruction getPositionalArgument(int index) {
|
||||
result = getPositionalArgumentOperand(index).getAnyDef()
|
||||
result = getPositionalArgumentOperand(index).getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,7 +1517,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the address of the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getExceptionAddress() {
|
||||
result = getExceptionAddressOperand().getAnyDef()
|
||||
result = getExceptionAddressOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1530,7 +1531,7 @@ class ThrowValueInstruction extends ThrowInstruction {
|
||||
* Gets the exception thrown by this instruction.
|
||||
*/
|
||||
final Instruction getException() {
|
||||
result = getExceptionOperand().getAnyDef()
|
||||
result = getExceptionOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,7 +1661,7 @@ class PhiInstruction extends Instruction {
|
||||
*/
|
||||
pragma[noinline]
|
||||
final Instruction getAnInput() {
|
||||
result = this.getAnInputOperand().getAnyDef()
|
||||
result = this.getAnInputOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1728,7 +1729,7 @@ class ChiInstruction extends Instruction {
|
||||
* memory write.
|
||||
*/
|
||||
final Instruction getTotal() {
|
||||
result = getTotalOperand().getAnyDef()
|
||||
result = getTotalOperand().getDef()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1742,7 +1743,7 @@ class ChiInstruction extends Instruction {
|
||||
* Gets the operand that represents the new value written by the memory write.
|
||||
*/
|
||||
final Instruction getPartial() {
|
||||
result = getPartialOperand().getAnyDef()
|
||||
result = getPartialOperand().getDef()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
| test.cpp:89:28:89:34 | test.cpp:92:8:92:14 | IR only |
|
||||
| test.cpp:100:13:100:18 | test.cpp:103:10:103:12 | AST only |
|
||||
| test.cpp:109:9:109:14 | test.cpp:110:10:110:12 | IR only |
|
||||
| test.cpp:122:18:122:30 | test.cpp:132:22:132:23 | IR only |
|
||||
| test.cpp:122:18:122:30 | test.cpp:140:22:140:23 | IR only |
|
||||
| test.cpp:136:27:136:32 | test.cpp:137:27:137:28 | AST only |
|
||||
| test.cpp:136:27:136:32 | test.cpp:140:22:140:23 | AST only |
|
||||
| test.cpp:142:32:142:37 | test.cpp:145:10:145:11 | IR only |
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
| test.cpp:110:10:110:12 | Load: (reference dereference) | test.cpp:109:9:109:14 | Call: call to source |
|
||||
| test.cpp:126:8:126:19 | Convert: (const int *)... | test.cpp:120:9:120:20 | InitializeParameter: sourceArray1 |
|
||||
| test.cpp:126:8:126:19 | Load: sourceArray1 | test.cpp:120:9:120:20 | InitializeParameter: sourceArray1 |
|
||||
| test.cpp:132:22:132:23 | Load: m1 | test.cpp:122:18:122:30 | InitializeParameter: sourceStruct1 |
|
||||
| test.cpp:140:22:140:23 | Load: m1 | test.cpp:122:18:122:30 | InitializeParameter: sourceStruct1 |
|
||||
| test.cpp:145:10:145:11 | Load: m2 | test.cpp:142:32:142:37 | Call: call to source |
|
||||
| test.cpp:153:17:153:18 | Load: m2 | test.cpp:151:35:151:40 | Call: call to source |
|
||||
| test.cpp:188:8:188:8 | Load: y | test.cpp:186:27:186:32 | Call: call to source |
|
||||
|
||||
Reference in New Issue
Block a user