mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Addressing review comments
Reduced the category to minorAnalysis. Handled bools via a instanceof with BoolType. Formatted the query correctly.
This commit is contained in:
@@ -12,8 +12,11 @@
|
||||
import cpp
|
||||
|
||||
predicate allowedTypedefs(TypedefType t) {
|
||||
t.getName() = ["I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32",
|
||||
"int64_t", "uint64_t", "int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t"]
|
||||
t.getName() =
|
||||
[
|
||||
"I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32", "int64_t", "uint64_t",
|
||||
"int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t"
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,14 +42,16 @@ Type getAUsedType(Type t) {
|
||||
}
|
||||
|
||||
predicate problematic(IntegralType t) {
|
||||
// 'bool' is allowed as it represents a 'true' or 'false' value
|
||||
t.getName() != ["bool"]
|
||||
// List any exceptions that should be allowed.
|
||||
any()
|
||||
}
|
||||
|
||||
from Declaration d, Type usedType
|
||||
where
|
||||
usedType = getAUsedType*(getAnImmediateUsedType(d)) and
|
||||
problematic(usedType) and
|
||||
// Allow uses of boolean types where defined by the language.
|
||||
not usedType instanceof BoolType and
|
||||
// Ignore violations for which we do not have a valid location.
|
||||
not d.getLocation() instanceof UnknownLocation
|
||||
select d,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---
|
||||
category: majorAnalysis
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The query "Basic Integral Types" in JPL_C has been updated to allow C standard integer types (uint8_t etc.) and 'bool'.
|
||||
* The query "Use of basic integral type" (`cpp/jpl-c/basic-int-types`) no longer produces alerts for the standard fixed width integer types (`int8_t`, `uint8_t`, etc.), and the `_Bool` and `bool` types.
|
||||
Reference in New Issue
Block a user