C++: Add sanity test for missing operand type

This commit is contained in:
Dave Bartolomeo
2019-02-08 16:02:05 -08:00
parent a54d86423a
commit bd46c43067
8 changed files with 32 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import cpp
import semmle.code.cpp.ir.implementation.EdgeKind
import semmle.code.cpp.ir.implementation.MemoryAccessKind
import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.Print
private import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.ir.internal.OperandTag
@@ -92,6 +93,14 @@ module InstructionSanity {
)
}
query predicate missingOperandType(Operand operand, string message) {
exists(Function func |
not exists(operand.getType()) and
func = operand.getUseInstruction().getEnclosingFunction() and
message = "Operand missing type in function '" + getIdentityString(func) + "'."
)
}
/**
* Holds if an instruction, other than `ExitFunction`, has no successors.
*/

View File

@@ -7,6 +7,7 @@ import cpp
import semmle.code.cpp.ir.implementation.EdgeKind
import semmle.code.cpp.ir.implementation.MemoryAccessKind
import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.Print
private import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.ir.internal.OperandTag
@@ -92,6 +93,14 @@ module InstructionSanity {
)
}
query predicate missingOperandType(Operand operand, string message) {
exists(Function func |
not exists(operand.getType()) and
func = operand.getUseInstruction().getEnclosingFunction() and
message = "Operand missing type in function '" + getIdentityString(func) + "'."
)
}
/**
* Holds if an instruction, other than `ExitFunction`, has no successors.
*/

View File

@@ -7,6 +7,7 @@ import cpp
import semmle.code.cpp.ir.implementation.EdgeKind
import semmle.code.cpp.ir.implementation.MemoryAccessKind
import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.Print
private import semmle.code.cpp.ir.implementation.Opcode
private import semmle.code.cpp.ir.internal.OperandTag
@@ -92,6 +93,14 @@ module InstructionSanity {
)
}
query predicate missingOperandType(Operand operand, string message) {
exists(Function func |
not exists(operand.getType()) and
func = operand.getUseInstruction().getEnclosingFunction() and
message = "Operand missing type in function '" + getIdentityString(func) + "'."
)
}
/**
* Holds if an instruction, other than `ExitFunction`, has no successors.
*/

View File

@@ -2,6 +2,7 @@ missingOperand
unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
instructionWithoutSuccessor
ambiguousSuccessors
unexplainedLoop

View File

@@ -2,6 +2,7 @@ missingOperand
unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
instructionWithoutSuccessor
ambiguousSuccessors
unexplainedLoop

View File

@@ -2,6 +2,7 @@ missingOperand
unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
instructionWithoutSuccessor
ambiguousSuccessors
unexplainedLoop

View File

@@ -2,6 +2,7 @@ missingOperand
unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
instructionWithoutSuccessor
ambiguousSuccessors
unexplainedLoop

View File

@@ -2,6 +2,7 @@ missingOperand
unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
instructionWithoutSuccessor
ambiguousSuccessors
unexplainedLoop