mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Add barrier for fieldless enum types
This commit is contained in:
@@ -140,6 +140,9 @@ class EnumType extends Type, TEnum {
|
||||
|
||||
EnumType() { this = TEnum(enum) }
|
||||
|
||||
/** Gets the enum that this enum type represents. */
|
||||
Enum getEnum() { result = enum }
|
||||
|
||||
override TypeParameter getPositionalTypeParameter(int i) {
|
||||
result = TTypeParamTypeParameter(enum.getGenericParamList().getTypeParam(i))
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ class IntegralTypeBarrier extends DataFlow::Node {
|
||||
}
|
||||
}
|
||||
|
||||
/** A node whose type is a fieldless enum. */
|
||||
class FieldlessEnumTypeBarrier extends DataFlow::Node {
|
||||
FieldlessEnumTypeBarrier() {
|
||||
TypeInference::inferType(this.asExpr()).(EnumType).getEnum().isFieldless()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if guard expression `g` having result `branch` indicates that the
|
||||
* sub-expression `e` is not null. For example when `ptr.is_null()` is
|
||||
|
||||
Reference in New Issue
Block a user