C++/C#: Add QLDoc for renamed queries

This commit is contained in:
Dave Bartolomeo
2020-05-11 14:16:21 -04:00
parent 3987267f26
commit e5bd66809a
3 changed files with 46 additions and 0 deletions

View File

@@ -52,6 +52,9 @@ class Cast extends Conversion, @cast {
* run "semmle/code/cpp/ASTConsistency.ql".
*/
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 CastConsistency {
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

@@ -275,12 +275,24 @@ class IROpaqueType extends IRSizedType, TIROpaqueType {
final override int getByteSize() { result = byteSize }
}
/**
* 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 IRTypeConsistency {
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 =

View File

@@ -275,12 +275,24 @@ class IROpaqueType extends IRSizedType, TIROpaqueType {
final override int getByteSize() { result = byteSize }
}
/**
* 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 IRTypeConsistency {
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 =