IMPORTS edges carry exactly one imported symbol's local_name (#768): two * named imports from the same specifier resolve to the same (source, * target) pair but are distinct symbols. Key on local_name too so the * second import doesn't dedup-collide with and overwrite the first — * every pass that walks IMPORTS edges (pass_calls.c, pass_usages.c, * pass_semantic.c, pass_lsp_cross.c) expects o
| 200 | * JSON slice (control characters must be \u-escaped in JSON), so hash keys |
| 201 | * can never collide with verbatim keys. */ |
| 202 | static void make_edge_key(char *buf, size_t bufsz, int64_t src, int64_t tgt, const char *type, |
| 203 | const char *properties_json) { |
| 204 | if (properties_json && strcmp(type, "IMPORTS") == 0) { |
| 205 | static const char local_name_key[] = "\"local_name\":\""; |
| 206 | const char *ln = strstr(properties_json, local_name_key); |
| 207 | if (ln) { |
| 208 | ln += sizeof(local_name_key) - 1; |
| 209 | const char *end = strchr(ln, '"'); |
| 210 | size_t ln_len = end ? (size_t)(end - ln) : strlen(ln); |
| 211 | int n = snprintf(buf, bufsz, "%lld:%lld:%s:%.*s", (long long)src, (long long)tgt, type, |
| 212 | (int)ln_len, ln); |
| 213 | if (n < 0 || (size_t)n >= bufsz) { |
| 214 | snprintf(buf, bufsz, "%lld:%lld:%s:\x01%016llx", (long long)src, (long long)tgt, |
| 215 | type, (unsigned long long)fnv1a64(ln, ln_len)); |
| 216 | } |
| 217 | return; |
| 218 | } |
| 219 | } |
| 220 | snprintf(buf, bufsz, "%lld:%lld:%s", (long long)src, (long long)tgt, type); |
| 221 | } |
| 222 | |
| 223 | static void make_src_type_key(char *buf, size_t bufsz, int64_t src, const char *type) { |
| 224 | snprintf(buf, bufsz, "%lld:%s", (long long)src, type); |
no test coverage detected