Merge pull request #3444 from dbartol/codeql-c-analysis-team/68

Rename `sanity` -> `consistency`
This commit is contained in:
Jonas Jensen
2020-05-12 12:33:08 +02:00
committed by GitHub
127 changed files with 590 additions and 544 deletions

View File

@@ -0,0 +1,9 @@
/**
* @name AST Consistency Check
* @description Performs consistency checks on the Abstract Syntax Tree. This query should have no results.
* @kind table
* @id cpp/ast-consistency-check
*/
import cpp
import CastConsistency

View File

@@ -1,9 +0,0 @@
/**
* @name AST Sanity Check
* @description Performs sanity checks on the Abstract Syntax Tree. This query should have no results.
* @kind table
* @id cpp/ast-sanity-check
*/
import cpp
import CastSanity

View File

@@ -48,10 +48,13 @@ class Cast extends Conversion, @cast {
/**
* INTERNAL: Do not use.
* Query predicates used to check invariants that should hold for all `Cast`
* nodes. To run all sanity queries for the ASTs, including the ones below,
* run "semmle/code/cpp/ASTSanity.ql".
* nodes. To run all consistency queries for the ASTs, including the ones below,
* run "semmle/code/cpp/ASTConsistency.ql".
*/
module CastSanity {
module CastConsistency {
/**
* Holds if the cast has more than one result for `Cast.getSemanticConversionString()`.
*/
query predicate multipleSemanticConversionStrings(Cast cast, Type fromType, string kind) {
// Every cast should have exactly one semantic conversion kind
count(cast.getSemanticConversionString()) > 1 and
@@ -59,12 +62,19 @@ module CastSanity {
fromType = cast.getExpr().getUnspecifiedType()
}
/**
* Holds if the cast has no result for `Cast.getSemanticConversionString()`.
*/
query predicate missingSemanticConversionString(Cast cast, Type fromType) {
// Every cast should have exactly one semantic conversion kind
not exists(cast.getSemanticConversionString()) and
fromType = cast.getExpr().getUnspecifiedType()
}
/**
* Holds if the cast has a result for `Cast.getSemanticConversionString()` that indicates that the
* kind of its semantic conversion is not known.
*/
query predicate unknownSemanticConversionString(Cast cast, Type fromType) {
// Every cast should have a known semantic conversion kind
cast.getSemanticConversionString() = "unknown conversion" and

View File

@@ -0,0 +1,8 @@
/**
* @name IR Consistency Check
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/ir-consistency-check
*/
import implementation.aliased_ssa.IRConsistency

View File

@@ -1,8 +0,0 @@
/**
* @name IR Sanity Check
* @description Performs sanity checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/ir-sanity-check
*/
import implementation.aliased_ssa.IRSanity

View File

@@ -275,12 +275,24 @@ class IROpaqueType extends IRSizedType, TIROpaqueType {
final override int getByteSize() { result = byteSize }
}
module IRTypeSanity {
/**
* INTERNAL: Do not use.
* Query predicates used to check invariants that should hold for all `IRType` objects. To run all
* consistency queries for the IR, including the ones below, run
* "semmle/code/cpp/IR/IRConsistency.ql".
*/
module IRTypeConsistency {
/**
* Holds if the type has no result for `IRType.getCanonicalLanguageType()`.
*/
query predicate missingCanonicalLanguageType(IRType type, string message) {
not exists(type.getCanonicalLanguageType()) and
message = "Type does not have a canonical `LanguageType`"
}
/**
* Holds if the type has more than one result for `IRType.getCanonicalLanguageType()`.
*/
query predicate multipleCanonicalLanguageTypes(IRType type, string message) {
strictcount(type.getCanonicalLanguageType()) > 1 and
message =
@@ -288,11 +300,17 @@ module IRTypeSanity {
concat(type.getCanonicalLanguageType().toString(), ", ")
}
/**
* Holds if the type has no result for `LanguageType.getIRType()`.
*/
query predicate missingIRType(Language::LanguageType type, string message) {
not exists(type.getIRType()) and
message = "`LanguageType` does not have a corresponding `IRType`."
}
/**
* Holds if the type has more than one result for `LanguageType.getIRType()`.
*/
query predicate multipleIRTypes(Language::LanguageType type, string message) {
strictcount(type.getIRType()) > 1 and
message =
@@ -300,5 +318,5 @@ module IRTypeSanity {
concat(type.getIRType().toString(), ", ")
}
import Language::LanguageTypeSanity
import Language::LanguageTypeConsistency
}

View File

@@ -0,0 +1,8 @@
/**
* @name Aliased SSA IR Consistency Check
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/aliased-ssa-ir-consistency-check
*/
import IRConsistency

View File

@@ -1,8 +1,8 @@
private import IR
import InstructionSanity // module is below
import IRTypeSanity // module is in IRType.qll
import InstructionConsistency // module is below
import IRTypeConsistency // module is in IRType.qll
module InstructionSanity {
module InstructionConsistency {
private import internal.InstructionImports as Imports
private import Imports::OperandTag
private import Imports::Overlap

View File

@@ -1,8 +0,0 @@
/**
* @name Aliased SSA IR Sanity Check
* @description Performs sanity checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/aliased-ssa-ir-sanity-check
*/
import IRSanity

View File

@@ -0,0 +1,8 @@
/**
* @name Aliased SSA Consistency Check
* @description Performs consistency checks on the SSA construction. This query should have no results.
* @kind table
* @id cpp/aliased-ssa-consistency-check
*/
import SSAConsistency

View File

@@ -1,2 +1,2 @@
private import SSAConstruction as SSA
import SSA::SSASanity
import SSA::SSAConsistency

View File

@@ -941,7 +941,7 @@ private module CachedForDebugging {
}
}
module SSASanity {
module SSAConsistency {
query predicate multipleOperandMemoryLocations(
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText
) {

View File

@@ -1,8 +0,0 @@
/**
* @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

View File

@@ -0,0 +1,8 @@
/**
* @name Raw IR Consistency Check
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/raw-ir-consistency-check
*/
import IRConsistency

View File

@@ -1,8 +1,8 @@
private import IR
import InstructionSanity // module is below
import IRTypeSanity // module is in IRType.qll
import InstructionConsistency // module is below
import IRTypeConsistency // module is in IRType.qll
module InstructionSanity {
module InstructionConsistency {
private import internal.InstructionImports as Imports
private import Imports::OperandTag
private import Imports::Overlap

View File

@@ -1,8 +0,0 @@
/**
* @name Raw IR Sanity Check
* @description Performs sanity checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/raw-ir-sanity-check
*/
import IRSanity

View File

@@ -0,0 +1,8 @@
/**
* @name SSA IR Consistency Check
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/ssa-ir-consistency-check
*/
import IRConsistency

View File

@@ -1,8 +1,8 @@
private import IR
import InstructionSanity // module is below
import IRTypeSanity // module is in IRType.qll
import InstructionConsistency // module is below
import IRTypeConsistency // module is in IRType.qll
module InstructionSanity {
module InstructionConsistency {
private import internal.InstructionImports as Imports
private import Imports::OperandTag
private import Imports::Overlap

View File

@@ -1,8 +0,0 @@
/**
* @name SSA IR Sanity Check
* @description Performs sanity checks on the Intermediate Representation. This query should have no results.
* @kind table
* @id cpp/ssa-ir-sanity-check
*/
import IRSanity

View File

@@ -0,0 +1,8 @@
/**
* @name Unaliased SSA Consistency Check
* @description Performs consistency checks on the SSA construction. This query should have no results.
* @kind table
* @id cpp/unaliased-ssa-consistency-check
*/
import SSAConsistency

View File

@@ -1,2 +1,2 @@
private import SSAConstruction as SSA
import SSA::SSASanity
import SSA::SSAConsistency

View File

@@ -941,7 +941,7 @@ private module CachedForDebugging {
}
}
module SSASanity {
module SSAConsistency {
query predicate multipleOperandMemoryLocations(
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText
) {

View File

@@ -1,8 +0,0 @@
/**
* @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

View File

@@ -544,9 +544,9 @@ string getOpaqueTagIdentityString(Type tag) {
result = getTypeIdentityString(tag)
}
module LanguageTypeSanity {
module LanguageTypeConsistency {
/**
* Sanity query to detect C++ `Type` objects which have no corresponding `CppType` object.
* Consistency query to detect C++ `Type` objects which have no corresponding `CppType` object.
*/
query predicate missingCppType(Type type, string message) {
not exists(getTypeForPRValue(type)) and

View File

@@ -1,14 +1,14 @@
/**
* @name Padding Sanity Check
* @description Performs sanity checks for the padding library. This query should have no results.
* @name Padding Consistency Check
* @description Performs consistency checks for the padding library. This query should have no results.
* @kind table
* @id cpp/padding-sanity-check
* @id cpp/padding-consistency-check
*/
import Padding
/*
* Sanity-check: Find discrepancies between computed and actual size on LP64.
* Consistency-check: Find discrepancies between computed and actual size on LP64.
*/
/*

View File

@@ -0,0 +1 @@
semmle/code/cpp/ASTConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ASTSanity.ql

View File

@@ -0,0 +1,2 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.IRConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/IRConsistency.ql

View File

@@ -1,2 +0,0 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.IRSanity
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/IRSanity.ql

View File

@@ -1,2 +1,2 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSASanity
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.ql

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/raw/IRConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/raw/IRSanity.ql

View File

@@ -0,0 +1,2 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.IRConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRConsistency.ql

View File

@@ -1,2 +0,0 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.IRSanity
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.ql

View File

@@ -1,2 +1,2 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSASanity
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.ql

View File

@@ -0,0 +1,2 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.IRConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/IRConsistency.ql

View File

@@ -1,2 +0,0 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.IRSanity
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/IRSanity.ql

View File

@@ -1,2 +1,2 @@
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSASanity
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.ql

View File

@@ -0,0 +1,2 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.IRConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRConsistency.ql

View File

@@ -1,2 +0,0 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.IRSanity
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.ql

View File

@@ -1,2 +1,2 @@
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSASanity
import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SSAConsistency
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.ql

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/IRConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/IRSanity.ql

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/raw/IRConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/raw/IRSanity.ql

View File

@@ -0,0 +1 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRConsistency.ql

View File

@@ -1 +0,0 @@
semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.ql