mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++/C#: Add IR SSA sanity tests
This commit is contained in:
committed by
Dave Bartolomeo
parent
bc48c25690
commit
51ff262cbc
@@ -143,6 +143,11 @@
|
|||||||
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
|
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
|
||||||
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
|
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
|
||||||
],
|
],
|
||||||
|
"IR SSASanity": [
|
||||||
|
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.qll",
|
||||||
|
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.qll",
|
||||||
|
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSASanity.qll"
|
||||||
|
],
|
||||||
"C++ IR InstructionImports": [
|
"C++ IR InstructionImports": [
|
||||||
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
|
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
|
||||||
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/InstructionImports.qll",
|
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/InstructionImports.qll",
|
||||||
|
|||||||
@@ -865,3 +865,16 @@ private module CachedForDebugging {
|
|||||||
result.getTag() = var.getTag()
|
result.getTag() = var.getTag()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module SSASanity {
|
||||||
|
query predicate multipleOperandMemoryLocations(OldIR::MemoryOperand operand, string message,
|
||||||
|
OldIR::IRFunction func, string funcText) {
|
||||||
|
exists(int locationCount |
|
||||||
|
locationCount = strictcount(Alias::getOperandMemoryLocation(operand)) and
|
||||||
|
locationCount > 1 and
|
||||||
|
func = operand.getEnclosingIRFunction() and
|
||||||
|
funcText = Language::getIdentityString(func.getFunction()) and
|
||||||
|
message = "Operand has " + locationCount.toString() + " memory accesses in function '$@'."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* @name Aliased SSA Sanity Check
|
||||||
|
* @description Performs sanity checks on the SSA construction. This query should have no results.
|
||||||
|
* @kind table
|
||||||
|
* @id cpp/aliased-ssa-sanity-check
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SSASanity
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
private import SSAConstruction as SSA
|
||||||
|
import SSA::SSASanity
|
||||||
@@ -865,3 +865,16 @@ private module CachedForDebugging {
|
|||||||
result.getTag() = var.getTag()
|
result.getTag() = var.getTag()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module SSASanity {
|
||||||
|
query predicate multipleOperandMemoryLocations(OldIR::MemoryOperand operand, string message,
|
||||||
|
OldIR::IRFunction func, string funcText) {
|
||||||
|
exists(int locationCount |
|
||||||
|
locationCount = strictcount(Alias::getOperandMemoryLocation(operand)) and
|
||||||
|
locationCount > 1 and
|
||||||
|
func = operand.getEnclosingIRFunction() and
|
||||||
|
funcText = Language::getIdentityString(func.getFunction()) and
|
||||||
|
message = "Operand has " + locationCount.toString() + " memory accesses in function '$@'."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* @name Unaliased SSA Sanity Check
|
||||||
|
* @description Performs sanity checks on the SSA construction. This query should have no results.
|
||||||
|
* @kind table
|
||||||
|
* @id cpp/unaliased-ssa-sanity-check
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SSASanity
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
private import SSAConstruction as SSA
|
||||||
|
import SSA::SSASanity
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.ql
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.ql
|
||||||
@@ -865,3 +865,16 @@ private module CachedForDebugging {
|
|||||||
result.getTag() = var.getTag()
|
result.getTag() = var.getTag()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module SSASanity {
|
||||||
|
query predicate multipleOperandMemoryLocations(OldIR::MemoryOperand operand, string message,
|
||||||
|
OldIR::IRFunction func, string funcText) {
|
||||||
|
exists(int locationCount |
|
||||||
|
locationCount = strictcount(Alias::getOperandMemoryLocation(operand)) and
|
||||||
|
locationCount > 1 and
|
||||||
|
func = operand.getEnclosingIRFunction() and
|
||||||
|
funcText = Language::getIdentityString(func.getFunction()) and
|
||||||
|
message = "Operand has " + locationCount.toString() + " memory accesses in function '$@'."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* @name Unaliased SSA Sanity Check
|
||||||
|
* @description Performs sanity checks on the SSA construction. This query should have no results.
|
||||||
|
* @kind table
|
||||||
|
* @id csharp/unaliased-ssa-sanity-check
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SSASanity
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
private import SSAConstruction as SSA
|
||||||
|
import SSA::SSASanity
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSASanity.ql
|
||||||
Reference in New Issue
Block a user