Skip to content
UNDER THE HOOD

Unsafe regions

WEAVEC_UNSAFE on a function definition or a compound statement makes its source range unsafe (RFC 0035 §2.6). It is the only annotation weavec.h defines; its spelling, annotate("weavec.unsafe"), is UnsafeAnnotation in include/weavec/Frontend/UnsafeRegions.h. UnsafeRegions collects the ranges by file over the AST before code generation, only when the unit expanded the macro or spelled the annotation, and also records as unsafe every function its author keeps from AddressSanitizer: no_sanitize("address"), no_sanitize_address and disable_sanitizer_instrumentation (RFC 0035 amendment 8), so a conservative collector’s stack scan needs no source change. GuardInsert leaves each access whose instruction’s location lies in a region unguarded (it gets a ledger row with reason unsafe and no marker), and its array-bounds checks are removed. An access inlined from an unsafe function keeps the location of its source, and so stays unguarded.