Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Fix C++ SEGV: NULL deref in LSP type resolver on large header files
Martin Vogel007980c0ebd0
diff --git a/internal/cbm/extract_env_accesses.c b/internal/cbm/extract_env_accesses.cindex 59b79fd35..71389786e 100644--- a/internal/cbm/extract_env_accesses.c+++ b/internal/cbm/extract_env_accesses.c@@ -131,8 +131,13 @@ static bool is_env_var_name(const char *s) {return has_upper;}+#define WALK_ENV_MAX_DEPTH 4096+// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_env_accesses(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {+static void walk_env_inner(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth) {+ if (depth > WALK_ENV_MAX_DEPTH) {+ return;+ }const char *kind = ts_node_type(node);const char *env_key = NULL;@@ -158,10 +163,14 @@ static void walk_env_accesses(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec// Recurseuint32_t count = ts_node_child_count(node);for (uint32_t i = 0; i < count; i++) {- walk_env_accesses(ctx, ts_node_child(node, i), spec);+ walk_env_inner(ctx, ts_node_child(node, i), spec, depth + 1);}}+static void walk_env_accesses(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {+ walk_env_inner(ctx, node, spec, 0);+}+void cbm_extract_env_accesses(CBMExtractCtx *ctx) {const CBMLangSpec *spec = cbm_lang_spec(ctx->language);if (!spec) {diff --git a/internal/cbm/extract_usages.c b/internal/cbm/extract_usages.cindex ab76abbfe..84a35fd3d 100644--- a/internal/cbm/extract_usages.c+++ b/internal/cbm/extract_usages.c@@ -76,7 +76,14 @@ static bool is_reference_node(TSNode node, CBMLanguage lang) {}// NOLINTNEXTLINE(misc-no-recursion) — intentional AST tree walk-static void walk_usages(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {+/* Max recursion depth — prevents stack overflow on deeply nested C++ templates.+ * 8MB stack / ~256 bytes per frame ≈ 32K max, use 4K as safe limit. */+#define WALK_USAGES_MAX_DEPTH 4096++static void walk_usages_inner(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, int depth) {+ if (depth > WALK_USAGES_MAX_DEPTH) {+ return;+ }if (is_reference_node(node, ctx->language)) {// Skip if inside a call (already counted as CALLS edge)if (is_inside_call(node, spec)) {@@ -110,10 +117,14 @@ static void walk_usages(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *specrecurse:;uint32_t count = ts_node_child_count(node);for (uint32_t i = 0; i < count; i++) {- walk_usages(ctx, ts_node_child(node, i), spec);+ walk_usages_inner(ctx, ts_node_child(node, i), spec, depth + 1);}}+static void walk_usages(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) {+ walk_usages_inner(ctx, node, spec, 0);+}+void cbm_extract_usages(CBMExtractCtx *ctx) {const CBMLangSpec *spec = cbm_lang_spec(ctx->language);if (!spec) {diff --git a/internal/cbm/lsp/c_lsp.c b/internal/cbm/lsp/c_lsp.cindex 29af77816..d2c901fed 100644--- a/internal/cbm/lsp/c_lsp.c+++ b/internal/cbm/lsp/c_lsp.c@@ -5,6 +5,12 @@#include <stdlib.h>#include <ctype.h>+/* Safe kind accessor — returns CBM_TYPE_UNKNOWN for NULL types.+ * Prevents SEGV in c_eval_expr_type_inner on unusual C++ AST shapes. */+static inline CBMTypeKind safe_kind(const CBMType* t) {+ return t ? t->kind : CBM_TYPE_UNKNOWN;+}+// Forward declarationsstatic void c_resolve_calls_in_node(CLSPContext* ctx, TSNode node);static void c_emit_resolved_call(CLSPContext* ctx, const char* callee_qn, const char* strategy, float confidence);@@ -1196,8 +1202,22 @@ static const char* type_to_qn(const CBMType* t) {// c_eval_expr_type: recursive expression type evaluator// ============================================================================+static const CBMType* c_eval_expr_type_inner(CLSPContext* ctx, TSNode node);+const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (ts_node_is_null(node)) return cbm_type_unknown();+ /* Guard against unbounded recursion on deeply nested C++ templates.+ * Prevents stack overflow and NULL-deref from unusual AST shapes. */+ if (ctx->eval_depth > 256) {+ return cbm_type_unknown();+ }+ ctx->eval_depth++;+ const CBMType* result = c_eval_expr_type_inner(ctx, node);+ ctx->eval_depth--;+ return result ? result : cbm_type_unknown();+}++static const CBMType* c_eval_expr_type_inner(CLSPContext* ctx, TSNode node) {const char* kind = ts_node_type(node);// --- identifier: scope lookup ---@@ -1219,7 +1239,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// Check if it's a type name (for constructor calls / casts)const CBMType* type = c_resolve_name_to_type(ctx, name);- if (type && type->kind == CBM_TYPE_NAMED) {+ if (type && safe_kind(type) == CBM_TYPE_NAMED) {// Could be a constructor call — return as typereturn type;}@@ -1283,11 +1303,11 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// a template param name) and receiver is a TEMPLATE type, substitute using// receiver's template args.// e.g., pair<int, Foo>.second where second has type V → substitute V=Foo- bool is_tparam = (field_type->kind == CBM_TYPE_TYPE_PARAM);+ bool is_tparam = (safe_kind(field_type) == CBM_TYPE_TYPE_PARAM);// Also check NAMED types that match template param names (extract_defs// may register template fields as NAMED("V") rather than TYPE_PARAM("V"))- if (!is_tparam && field_type->kind == CBM_TYPE_NAMED &&- base->kind == CBM_TYPE_TEMPLATE) {+ if (!is_tparam && safe_kind(field_type) == CBM_TYPE_NAMED &&+ safe_kind(base) == CBM_TYPE_TEMPLATE) {const CBMRegisteredType* trt = cbm_registry_lookup_type(ctx->registry, type_qn);if (!trt && ctx->module_qn) {trt = cbm_registry_lookup_type(ctx->registry,@@ -1308,7 +1328,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {}}}- if (is_tparam && base->kind == CBM_TYPE_TEMPLATE &&+ if (is_tparam && safe_kind(base) == CBM_TYPE_TEMPLATE &&base->data.template_type.template_args) {const CBMRegisteredType* rt = cbm_registry_lookup_type(ctx->registry, type_qn);if (!rt && ctx->module_qn) {@@ -1386,7 +1406,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (f && f->signature) {// If template args present, substitute into return typeif (qi_has_tmpl_args && !ts_node_is_null(qi_tmpl_args) &&- f->signature->kind == CBM_TYPE_FUNC &&+ safe_kind(f->signature) == CBM_TYPE_FUNC &&f->signature->data.func.return_types &&f->signature->data.func.return_types[0]) {const CBMType* base_ret = f->signature->data.func.return_types[0];@@ -1418,7 +1438,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// (e.g., smart pointer dereference) can extract inner types.// e.g., make_shared<Widget> returns NAMED("std.shared_ptr") →// TEMPLATE("std.shared_ptr", [Widget])- if (base_ret->kind == CBM_TYPE_NAMED) {+ if (safe_kind(base_ret) == CBM_TYPE_NAMED) {const CBMType** final_targs = (const CBMType**)cbm_arena_alloc(ctx->arena, (targ_count + 1) * sizeof(const CBMType*));for (int i = 0; i < targ_count; i++) final_targs[i] = targs[i];@@ -1526,7 +1546,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// Get the base return type from the function signatureconst CBMType* base_ret = NULL;- if (f->signature->kind == CBM_TYPE_FUNC &&+ if (safe_kind(f->signature) == CBM_TYPE_FUNC &&f->signature->data.func.return_types &&f->signature->data.func.return_types[0]) {base_ret = f->signature->data.func.return_types[0];@@ -1605,19 +1625,19 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {const CBMType* func_type = c_eval_expr_type(ctx, func_node);if (!func_type) return cbm_type_unknown();// FUNC type -> return its return type- if (func_type->kind == CBM_TYPE_FUNC &&+ if (safe_kind(func_type) == CBM_TYPE_FUNC &&func_type->data.func.return_types && func_type->data.func.return_types[0]) {const CBMType* ret = func_type->data.func.return_types[0];// Template param substitution: try receiver's template args (method calls)// then try TAD from call-site argument types (free function calls)- bool needs_subst = (ret->kind == CBM_TYPE_TYPE_PARAM ||- ret->kind == CBM_TYPE_NAMED ||- ret->kind == CBM_TYPE_POINTER ||- ret->kind == CBM_TYPE_REFERENCE ||- ret->kind == CBM_TYPE_RVALUE_REF ||- ret->kind == CBM_TYPE_TEMPLATE ||- ret->kind == CBM_TYPE_SLICE);+ bool needs_subst = (safe_kind(ret) == CBM_TYPE_TYPE_PARAM ||+ safe_kind(ret) == CBM_TYPE_NAMED ||+ safe_kind(ret) == CBM_TYPE_POINTER ||+ safe_kind(ret) == CBM_TYPE_REFERENCE ||+ safe_kind(ret) == CBM_TYPE_RVALUE_REF ||+ safe_kind(ret) == CBM_TYPE_TEMPLATE ||+ safe_kind(ret) == CBM_TYPE_SLICE);if (needs_subst) {bool substituted = false;@@ -1630,7 +1650,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// Use false to preserve TEMPLATE type — we need template args// for substitution, not the pointed-to type from operator->obj_type = c_simplify_type(ctx, obj_type, false);- if (obj_type && obj_type->kind == CBM_TYPE_TEMPLATE &&+ if (obj_type && safe_kind(obj_type) == CBM_TYPE_TEMPLATE &&obj_type->data.template_type.template_args) {// Use registered type_param_names if availableTSNode field_node = ts_node_child_by_field_name(func_node, "field", 5);@@ -1695,7 +1715,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {}if (rf && rf->type_param_names && rf->signature &&- rf->signature->kind == CBM_TYPE_FUNC &&+ safe_kind(rf->signature) == CBM_TYPE_FUNC &&rf->signature->data.func.param_types) {// Deduce: match call-site arg types against param types// to bind type_param_names@@ -1714,22 +1734,22 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (cbm_type_is_unknown(arg_t)) { pi++; continue; }// Unwrap ref/ptr from param typeconst CBMType* param_t = rf->signature->data.func.param_types[pi];- while (param_t && (param_t->kind == CBM_TYPE_REFERENCE ||- param_t->kind == CBM_TYPE_RVALUE_REF ||- param_t->kind == CBM_TYPE_POINTER)) {- if (param_t->kind == CBM_TYPE_POINTER) param_t = param_t->data.pointer.elem;+ while (param_t && (safe_kind(param_t) == CBM_TYPE_REFERENCE ||+ safe_kind(param_t) == CBM_TYPE_RVALUE_REF ||+ safe_kind(param_t) == CBM_TYPE_POINTER)) {+ if (safe_kind(param_t) == CBM_TYPE_POINTER) param_t = param_t->data.pointer.elem;else param_t = param_t->data.reference.elem;}// If param type is TYPE_PARAM, bind it- if (param_t && param_t->kind == CBM_TYPE_TYPE_PARAM) {+ if (param_t && safe_kind(param_t) == CBM_TYPE_TYPE_PARAM) {for (int ti = 0; ti < tp_count; ti++) {if (strcmp(rf->type_param_names[ti], param_t->data.type_param.name) == 0) {// Unwrap ref/ptr from actual arg tooconst CBMType* unwrapped = arg_t;- while (unwrapped && (unwrapped->kind == CBM_TYPE_REFERENCE ||- unwrapped->kind == CBM_TYPE_RVALUE_REF ||- unwrapped->kind == CBM_TYPE_POINTER)) {- if (unwrapped->kind == CBM_TYPE_POINTER) unwrapped = unwrapped->data.pointer.elem;+ while (unwrapped && (safe_kind(unwrapped) == CBM_TYPE_REFERENCE ||+ safe_kind(unwrapped) == CBM_TYPE_RVALUE_REF ||+ safe_kind(unwrapped) == CBM_TYPE_POINTER)) {+ if (safe_kind(unwrapped) == CBM_TYPE_POINTER) unwrapped = unwrapped->data.pointer.elem;else unwrapped = unwrapped->data.reference.elem;}if (!deduced[ti]) deduced[ti] = unwrapped;@@ -1755,13 +1775,13 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {}// Unwrap references in return type- if (ret->kind == CBM_TYPE_REFERENCE || ret->kind == CBM_TYPE_RVALUE_REF)+ if (safe_kind(ret) == CBM_TYPE_REFERENCE || safe_kind(ret) == CBM_TYPE_RVALUE_REF)ret = ret->data.reference.elem;return ret;}// Constructor call: Type(args) — if func_node resolves to a named type- if (func_type->kind == CBM_TYPE_NAMED) {+ if (safe_kind(func_type) == CBM_TYPE_NAMED) {return func_type;}@@ -1800,20 +1820,20 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (!arr_type) return cbm_type_unknown();// Array/slice: return element- if (arr_type->kind == CBM_TYPE_SLICE) return arr_type->data.slice.elem;- if (arr_type->kind == CBM_TYPE_POINTER) return arr_type->data.pointer.elem;+ if (safe_kind(arr_type) == CBM_TYPE_SLICE) return arr_type->data.slice.elem;+ if (safe_kind(arr_type) == CBM_TYPE_POINTER) return arr_type->data.pointer.elem;// Template with operator[]: return via method lookupconst char* qn = type_to_qn(c_simplify_type(ctx, arr_type, false));if (qn) {const CBMRegisteredFunc* op = cbm_registry_lookup_method(ctx->registry, qn, "operator[]");- if (op && op->signature && op->signature->kind == CBM_TYPE_FUNC &&+ if (op && op->signature && safe_kind(op->signature) == CBM_TYPE_FUNC &&op->signature->data.func.return_types && op->signature->data.func.return_types[0]) {const CBMType* ret = op->signature->data.func.return_types[0];- if (ret->kind == CBM_TYPE_REFERENCE) ret = ret->data.reference.elem;+ if (safe_kind(ret) == CBM_TYPE_REFERENCE) ret = ret->data.reference.elem;// Substitute template params- if (ret->kind == CBM_TYPE_TYPE_PARAM && arr_type->kind == CBM_TYPE_TEMPLATE) {+ if (safe_kind(ret) == CBM_TYPE_TYPE_PARAM && safe_kind(arr_type) == CBM_TYPE_TEMPLATE) {const char* params[] = {"T", "K", "V", NULL};const CBMType* args[3] = {NULL};int nargs = arr_type->data.template_type.arg_count;@@ -1868,10 +1888,10 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {const CBMType* inner = c_eval_expr_type(ctx, operand);inner = c_simplify_type(ctx, inner, false);// TEMPLATE with operator*(): look up and substitute return type- if (inner && inner->kind == CBM_TYPE_TEMPLATE) {+ if (inner && safe_kind(inner) == CBM_TYPE_TEMPLATE) {const char* tqn = inner->data.template_type.template_name;const CBMRegisteredFunc* opf = c_lookup_member(ctx, tqn, "operator*");- if (opf && opf->signature && opf->signature->kind == CBM_TYPE_FUNC &&+ if (opf && opf->signature && safe_kind(opf->signature) == CBM_TYPE_FUNC &&opf->signature->data.func.return_types &&opf->signature->data.func.return_types[0]) {const CBMType* ret = opf->signature->data.func.return_types[0];@@ -1894,7 +1914,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (na > 2) fa[2] = inner->data.template_type.template_args[2];ret = cbm_type_substitute(ctx->arena, ret, fb, fa);}- if (ret->kind == CBM_TYPE_REFERENCE)+ if (safe_kind(ret) == CBM_TYPE_REFERENCE)ret = ret->data.reference.elem;return ret;}@@ -1928,10 +1948,10 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (op && strcmp(op, "*") == 0) {const CBMType* inner = c_eval_expr_type(ctx, arg);inner = c_simplify_type(ctx, inner, false);- if (inner && inner->kind == CBM_TYPE_TEMPLATE) {+ if (inner && safe_kind(inner) == CBM_TYPE_TEMPLATE) {const char* tqn = inner->data.template_type.template_name;const CBMRegisteredFunc* opf = c_lookup_member(ctx, tqn, "operator*");- if (opf && opf->signature && opf->signature->kind == CBM_TYPE_FUNC &&+ if (opf && opf->signature && safe_kind(opf->signature) == CBM_TYPE_FUNC &&opf->signature->data.func.return_types &&opf->signature->data.func.return_types[0]) {const CBMType* ret = opf->signature->data.func.return_types[0];@@ -1954,7 +1974,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {if (na > 2) fa[2] = inner->data.template_type.template_args[2];ret = cbm_type_substitute(ctx->arena, ret, fb, fa);}- if (ret->kind == CBM_TYPE_REFERENCE)+ if (safe_kind(ret) == CBM_TYPE_REFERENCE)ret = ret->data.reference.elem;return ret;}@@ -2079,7 +2099,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {// co_await returns the result of operator co_await or the awaitable's await_resume// Heuristic: if operand is a template type (e.g., Task<T>), return first template argop_type = c_simplify_type(ctx, op_type, false);- if (op_type && op_type->kind == CBM_TYPE_TEMPLATE &&+ if (op_type && safe_kind(op_type) == CBM_TYPE_TEMPLATE &&op_type->data.template_type.arg_count > 0) {return op_type->data.template_type.template_args[0];}@@ -2087,7 +2107,7 @@ const CBMType* c_eval_expr_type(CLSPContext* ctx, TSNode node) {const char* op_qn = type_to_qn(op_type);if (op_qn) {const CBMRegisteredFunc* ar = c_lookup_member(ctx, op_qn, "await_resume");- if (ar && ar->signature && ar->signature->kind == CBM_TYPE_FUNC &&+ if (ar && ar->signature && safe_kind(ar->signature) == CBM_TYPE_FUNC &&ar->signature->data.func.return_types &&ar->signature->data.func.return_types[0]) {return ar->signature->data.func.return_types[0];diff --git a/internal/cbm/lsp/c_lsp.h b/internal/cbm/lsp/c_lsp.hindex d8560ef39..51f10b3e5 100644--- a/internal/cbm/lsp/c_lsp.h+++ b/internal/cbm/lsp/c_lsp.h@@ -74,6 +74,7 @@ typedef struct {bool cpp_mode; // C++ features enabledbool in_template; // currently inside template declarationbool debug;+ int eval_depth; // recursion depth for c_eval_expr_type (crash guard)} CLSPContext;// --- API ---diff --git a/internal/cbm/lsp/type_rep.c b/internal/cbm/lsp/type_rep.cindex c5552eea4..2dfee7ce8 100644--- a/internal/cbm/lsp/type_rep.c+++ b/internal/cbm/lsp/type_rep.c@@ -231,7 +231,8 @@ const CBMType* cbm_type_resolve_alias(const CBMType* t) {// Generic substitution: recursively replace TYPE_PARAM with concrete types.const CBMType* cbm_type_substitute(CBMArena* a, const CBMType* t,const char** type_params, const CBMType** type_args) {- if (!t || !type_params || !type_args) return t;+ if (!t) return cbm_type_unknown();+ if (!type_params || !type_args) return t;switch (t->kind) {case CBM_TYPE_TYPE_PARAM: {diff --git a/scripts/benchmark-index.sh b/scripts/benchmark-index.shnew file mode 100755index 000000000..756bda06e--- /dev/null+++ b/scripts/benchmark-index.sh@@ -0,0 +1,82 @@+#!/usr/bin/env bash+set -euo pipefail++# Index a single benchmark repository and capture metrics.+# Usage: benchmark-index.sh <binary> <lang> <repo_path> <results_dir>++BINARY="${1:?Usage: benchmark-index.sh <binary> <lang> <repo_path> <results_dir>}"+LANG="${2:?}"+REPO="${3:?}"+RESULTS_DIR="${4:?}"++# Resolve symlinks+REPO=$(cd "$REPO" && pwd -P)++OUT="$RESULTS_DIR/$LANG"+mkdir -p "$OUT"++echo "INDEX: $LANG ($REPO)"++# Count source files and LOC (exclude .git, vendor, node_modules, build dirs)+FILE_COUNT=$(find "$REPO" -type f \+ ! -path '*/.git/*' ! -path '*/node_modules/*' ! -path '*/vendor/*' \+ ! -path '*/target/*' ! -path '*/build/*' ! -path '*/dist/*' \+ ! -path '*/__pycache__/*' ! -path '*/.cache/*' \+ | wc -l | tr -d ' ')++LOC=$(find "$REPO" -type f \+ ! -path '*/.git/*' ! -path '*/node_modules/*' ! -path '*/vendor/*' \+ ! -path '*/target/*' ! -path '*/build/*' ! -path '*/dist/*' \+ ! -path '*/__pycache__/*' ! -path '*/.cache/*' \+ -exec cat {} + 2>/dev/null | wc -l | tr -d ' ')++echo "$FILE_COUNT" > "$OUT/file-count.txt"+echo "$LOC" > "$OUT/loc.txt"++# Index via CLI and capture timing+START_MS=$(python3 -c "import time; print(int(time.time()*1000))")++INDEX_JSON=$("$BINARY" cli index_repository "{\"repo_path\":\"$REPO\",\"mode\":\"full\"}" 2>/dev/null || echo '{"error":"index failed"}')++END_MS=$(python3 -c "import time; print(int(time.time()*1000))")+ELAPSED=$((END_MS - START_MS))++echo "$INDEX_JSON" > "$OUT/00-index.json"+echo "$ELAPSED" > "$OUT/index-time.txt"++# Extract node/edge counts (CLI wraps in MCP content envelope)+NODES=$(echo "$INDEX_JSON" | python3 -c "+import json,sys+d=json.load(sys.stdin)+# Unwrap MCP content envelope if present+if 'content' in d:+ inner=json.loads(d['content'][0]['text'])+else:+ inner=d+print(inner.get('nodes',0))+" 2>/dev/null || echo "0")+EDGES=$(echo "$INDEX_JSON" | python3 -c "+import json,sys+d=json.load(sys.stdin)+if 'content' in d:+ inner=json.loads(d['content'][0]['text'])+else:+ inner=d+print(inner.get('edges',0))+" 2>/dev/null || echo "0")+PROJECT=$(echo "$INDEX_JSON" | python3 -c "+import json,sys+d=json.load(sys.stdin)+if 'content' in d:+ inner=json.loads(d['content'][0]['text'])+else:+ inner=d+print(inner.get('project',''))+" 2>/dev/null || echo "")++echo "$NODES" > "$OUT/nodes.txt"+echo "$EDGES" > "$OUT/edges.txt"+echo "$PROJECT" > "$OUT/project.txt"++printf " %s: %s files, %s LOC, %sms, %s nodes, %s edges\n" \+ "$LANG" "$FILE_COUNT" "$LOC" "$ELAPSED" "$NODES" "$EDGES"diff --git a/scripts/clone-bench-repos.sh b/scripts/clone-bench-repos.shindex a29729660..1361273a1 100755--- a/scripts/clone-bench-repos.sh+++ b/scripts/clone-bench-repos.sh@@ -32,7 +32,7 @@ symlink() {mkdir -p "$BENCH_DIR"-# Programming languages — Tier 1 (39 languages, 27 original + 12 new)+# Programming languages — Tier 1 (44 languages)clone go "go-chi/chi"clone python "httpie/cli"clone javascript "expressjs/express"@@ -43,7 +43,7 @@ clone kotlin "JetBrains/Exposed"clone scala "playframework/play-samples"clone rust "meilisearch/meilisearch"clone c "redis/redis"-clone cpp "nlohmann/json"+clone cpp "google/leveldb"clone csharp "ardalis/CleanArchitecture"clone php "koel/koel"clone ruby "sinatra/sinatra"@@ -71,8 +71,12 @@ clone fortran "cp2k/cp2k"clone cobol "OCamlPro/gnucobol"clone verilog "YosysHQ/yosys"clone emacslisp "emacs-mirror/emacs"+clone matlab "acristoffers/tree-sitter-matlab"+clone lean "leanprover-community/mathlib4"+clone form "vermaseren/form"+clone wolfram "WolframResearch/WolframLanguageForJupyter"-# Helper languages — Tier 2 (20 languages, 8 original + 12 new)+# Helper languages — Tier 2 (22 languages)clone yaml "kubernetes/examples"clone hcl "terraform-aws-modules/terraform-aws-eks"clone scss "twbs/bootstrap"@@ -96,6 +100,9 @@ symlink markdown python # httpie docssymlink makefile c # redis Makefileclone glsl "repalash/Open-Shaders"symlink ini python # httpie .cfg/.ini files+symlink magma lean # .m files — disambiguated via content markers+symlink kubernetes yaml # YAML subtype — Deployment/Service manifests+symlink kustomize yaml # YAML subtype — kustomization.yamlecho ""echo "=== Clone complete ==="