C#: If a type (or any child of a type) is a pointer like type then it is unsafe.

This commit is contained in:
Michael Nebel
2023-03-02 14:16:49 +01:00
parent a4c0a0353f
commit 67e7b8fc23

View File

@@ -98,10 +98,21 @@ class Modifiable extends Declaration, @modifiable {
/** Holds if this declaration is `unsafe`. */
predicate isUnsafe() {
this.hasModifier("unsafe") or
this.(Parameterizable).getAParameter().getType() instanceof PointerType or
this.(Property).getType() instanceof PointerType or
this.(Callable).getReturnType() instanceof PointerType
this.hasModifier("unsafe")
or
exists(Type t, Type child |
t = this.(Parameterizable).getAParameter().getType() or
t = this.(Property).getType() or
t = this.(Callable).getReturnType() or
t = this.(DelegateType).getReturnType()
|
child = t.getAChild*() and
(
child instanceof PointerType
or
child instanceof FunctionPointerType
)
)
}
/** Holds if this declaration is `async`. */