canAlias improvement (#15773)

* canAlias improvement

* fix comment
This commit is contained in:
cooldome 2020-10-30 11:42:06 +00:00 • committed by GitHub
commit 6fe2e8977d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,16 @@ proc canAlias(arg, ret: PType; marker: var IntSet): bool =
else: else:
result = false result = false
proc isValueOnlyType(t: PType): bool =
# t doesn't contain pointers and references
proc wrap(t: PType): bool {.nimcall.} = t.kind in {tyRef, tyPtr, tyVar, tyLent}
result = not types.searchTypeFor(t, wrap)
proc canAlias*(arg, ret: PType): bool = proc canAlias*(arg, ret: PType): bool =
if isValueOnlyType(arg):
# can alias only with unsafeAddr(arg.x) and we don't care if it is not safe
result = false
else:
var marker = initIntSet() var marker = initIntSet()
result = canAlias(arg, ret, marker) result = canAlias(arg, ret, marker)