Skip to content

Commit 451ae7b

Browse files
authored
Merge pull request github#3444 from dbartol/codeql-c-analysis-team/68
Rename `sanity` -> `consistency`
2 parents 8ce9c9d + e5bd668 commit 451ae7b

File tree

127 files changed

+590
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+590
-544
lines changed

config/identical-files.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@
111111
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IR.qll",
112112
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IR.qll"
113113
],
114-
"IR IRSanity": [
115-
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll",
116-
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.qll",
117-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll",
118-
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRSanity.qll",
119-
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRSanity.qll"
114+
"IR IRConsistency": [
115+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRConsistency.qll",
116+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRConsistency.qll",
117+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRConsistency.qll",
118+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRConsistency.qll",
119+
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRConsistency.qll"
120120
],
121121
"IR PrintIR": [
122122
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/PrintIR.qll",
@@ -157,10 +157,10 @@
157157
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
158158
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
159159
],
160-
"IR SSASanity": [
161-
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.qll",
162-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.qll",
163-
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSASanity.qll"
160+
"IR SSAConsistency": [
161+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll",
162+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll",
163+
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll"
164164
],
165165
"C++ IR InstructionImports": [
166166
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @name AST Consistency Check
3+
* @description Performs consistency checks on the Abstract Syntax Tree. This query should have no results.
4+
* @kind table
5+
* @id cpp/ast-consistency-check
6+
*/
7+
8+
import cpp
9+
import CastConsistency

cpp/ql/src/semmle/code/cpp/ASTSanity.ql

Lines changed: 0 additions & 9 deletions
This file was deleted.

cpp/ql/src/semmle/code/cpp/exprs/Cast.qll

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,33 @@ class Cast extends Conversion, @cast {
4848
/**
4949
* INTERNAL: Do not use.
5050
* Query predicates used to check invariants that should hold for all `Cast`
51-
* nodes. To run all sanity queries for the ASTs, including the ones below,
52-
* run "semmle/code/cpp/ASTSanity.ql".
51+
* nodes. To run all consistency queries for the ASTs, including the ones below,
52+
* run "semmle/code/cpp/ASTConsistency.ql".
5353
*/
54-
module CastSanity {
54+
module CastConsistency {
55+
/**
56+
* Holds if the cast has more than one result for `Cast.getSemanticConversionString()`.
57+
*/
5558
query predicate multipleSemanticConversionStrings(Cast cast, Type fromType, string kind) {
5659
// Every cast should have exactly one semantic conversion kind
5760
count(cast.getSemanticConversionString()) > 1 and
5861
kind = cast.getSemanticConversionString() and
5962
fromType = cast.getExpr().getUnspecifiedType()
6063
}
6164

65+
/**
66+
* Holds if the cast has no result for `Cast.getSemanticConversionString()`.
67+
*/
6268
query predicate missingSemanticConversionString(Cast cast, Type fromType) {
6369
// Every cast should have exactly one semantic conversion kind
6470
not exists(cast.getSemanticConversionString()) and
6571
fromType = cast.getExpr().getUnspecifiedType()
6672
}
6773

74+
/**
75+
* Holds if the cast has a result for `Cast.getSemanticConversionString()` that indicates that the
76+
* kind of its semantic conversion is not known.
77+
*/
6878
query predicate unknownSemanticConversionString(Cast cast, Type fromType) {
6979
// Every cast should have a known semantic conversion kind
7080
cast.getSemanticConversionString() = "unknown conversion" and
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @name IR Consistency Check
3+
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
4+
* @kind table
5+
* @id cpp/ir-consistency-check
6+
*/
7+
8+
import implementation.aliased_ssa.IRConsistency

cpp/ql/src/semmle/code/cpp/ir/IRSanity.ql

Lines changed: 0 additions & 8 deletions
This file was deleted.

cpp/ql/src/semmle/code/cpp/ir/implementation/IRType.qll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,30 +275,48 @@ class IROpaqueType extends IRSizedType, TIROpaqueType {
275275
final override int getByteSize() { result = byteSize }
276276
}
277277

278-
module IRTypeSanity {
278+
/**
279+
* INTERNAL: Do not use.
280+
* Query predicates used to check invariants that should hold for all `IRType` objects. To run all
281+
* consistency queries for the IR, including the ones below, run
282+
* "semmle/code/cpp/IR/IRConsistency.ql".
283+
*/
284+
module IRTypeConsistency {
285+
/**
286+
* Holds if the type has no result for `IRType.getCanonicalLanguageType()`.
287+
*/
279288
query predicate missingCanonicalLanguageType(IRType type, string message) {
280289
not exists(type.getCanonicalLanguageType()) and
281290
message = "Type does not have a canonical `LanguageType`"
282291
}
283292

293+
/**
294+
* Holds if the type has more than one result for `IRType.getCanonicalLanguageType()`.
295+
*/
284296
query predicate multipleCanonicalLanguageTypes(IRType type, string message) {
285297
strictcount(type.getCanonicalLanguageType()) > 1 and
286298
message =
287299
"Type has multiple canonical `LanguageType`s: " +
288300
concat(type.getCanonicalLanguageType().toString(), ", ")
289301
}
290302

303+
/**
304+
* Holds if the type has no result for `LanguageType.getIRType()`.
305+
*/
291306
query predicate missingIRType(Language::LanguageType type, string message) {
292307
not exists(type.getIRType()) and
293308
message = "`LanguageType` does not have a corresponding `IRType`."
294309
}
295310

311+
/**
312+
* Holds if the type has more than one result for `LanguageType.getIRType()`.
313+
*/
296314
query predicate multipleIRTypes(Language::LanguageType type, string message) {
297315
strictcount(type.getIRType()) > 1 and
298316
message =
299317
"`LanguageType` " + type.getAQlClass() + " has multiple `IRType`s: " +
300318
concat(type.getIRType().toString(), ", ")
301319
}
302320

303-
import Language::LanguageTypeSanity
321+
import Language::LanguageTypeConsistency
304322
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @name Aliased SSA IR Consistency Check
3+
* @description Performs consistency checks on the Intermediate Representation. This query should have no results.
4+
* @kind table
5+
* @id cpp/aliased-ssa-ir-consistency-check
6+
*/
7+
8+
import IRConsistency

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll renamed to cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRConsistency.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
private import IR
2-
import InstructionSanity // module is below
3-
import IRTypeSanity // module is in IRType.qll
2+
import InstructionConsistency // module is below
3+
import IRTypeConsistency // module is in IRType.qll
44

5-
module InstructionSanity {
5+
module InstructionConsistency {
66
private import internal.InstructionImports as Imports
77
private import Imports::OperandTag
88
private import Imports::Overlap

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.ql

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)