Repository navigation
Tags
Tags
fix(compile): clang reads a byte order mark as the compiler does (#1164) Clang now reads a file's real bytes, byte order mark included, so #embed, __has_embed and first-line columns agree with the compiler, and two units that both include and embed a file no longer reindex each other forever. clice's offsets are its text's, converted only in CompilationUnit (pixi run check-offsets keeps it so); a file's content hash covers its bytes, and an open document carries its file's mark.
perf(command): keep only the options clice's analysis reads (#1153) A normalized command keeps an option only when clice's analysis reads it, as src/command/option_classes.inc decides: commands that differ in outputs, code generation or linking alone share one command, compiler query and scan group, so huge databases load faster. Every unit is reindexed once after the upgrade. tools/options checks the table against clice, GCC and cl at each LLVM upgrade.
build: release for musl Linux and macOS 13 (#1145) clice now releases static builds for x64 and arm64 musl Linux, which run on Alpine and other musl systems, and on NixOS and Guix unpatched, with alpine-x64 and alpine-arm64 VS Code extensions beside them; CI tests them on Ubuntu and against Alpine's GCC. Every host now targets macOS 13 for the macOS builds, as the releases always did.
perf: allocate through mimalloc 2.5.3 on Linux and macOS (#1143) clice now allocates through mimalloc 2.5.3 on Linux, and its macOS releases take malloc over for the first time: the bazelrc line that turned the override on followed the build host, and CI builds macOS on Linux. On Linux a file opens to its diagnostics about 15% faster for a little more memory; the registry's mimalloc counts reused pages in the macOS footprint, and glibc's malloc_trim, which raced its own set-up once mimalloc owned malloc, no longer runs on Linux.
build: move to xclang 23.1.5.3 and kotatsu 0.1.0.283 (#1139) Background indexing no longer waits for memory forever on WSL 1, whose /proc/meminfo has no MemAvailable: kotatsu 0.1.0.283 estimates the available memory there, and the scheduler's log names where the figure comes from. xclang 23.1.5.3 brings the musl toolchain and libclang the static musl clice builds on; LLVM stays at 23.1.5.
fix(server): no project without its cache; lone files get one (#1088) ## What changed **A project never runs without its cache.** Before, a project whose cache could not be used ran without one: no PCH, no module builds, the index kept in memory and lost at exit, with a line in the log the user rarely sees. Now it serves nothing, and the user is told which directory, why, and what to do, then to restart clice: | When | Told | | --- | --- | | the cache directory cannot be created or written | give clice write access to it, or set `cache_dir` in clice.toml | | its index writer lock cannot be opened | same | | another project owns the directory | set `cache_dir` to a directory of this project's own | | it is on a remote filesystem (NFS, SMB, a Windows drive under WSL) | set `cache_dir` to a directory on a local disk | | its index database cannot be read | delete its `index` directory, or set `cache_dir` elsewhere | | every directory the project could use is taken by the server's other projects | set `cache_dir` to a directory of its own | | clice's temporary directory, for the files outside every folder, cannot be used | point TMPDIR at a directory of your own | `clice lint` without `--index` refuses an unusable cache as `clice index` already did. The reading commands (`clice query`, `clice inspect`) are unchanged. With the degraded mode gone go its code paths: the PCH, PCM and index builds' branches for a project without a store, the worker's "index too large to send" for a reply with nowhere to write, the memory-only session over an unreadable database header. Users on WSL who open a project under `/mnt/c` now get that error until they set `cache_dir` to a local directory; before, it ran with an index that was never saved. A file opened with no workspace folder and no project above it (`code test.cpp`, Neovim's single-file mode) is a quick try: it now works as a folder's file does, and leaves nothing behind. - **A cache of its own.** Such files had no cache directory, so no PCH and no module builds: go to definition into a header they include answered nothing while hover worked. Their project now keeps a cache in clice's temporary directory, `<temp>/clice-<uid>/<pid>/` (`<temp>\clice\<pid>\` on Windows), whatever `cache_dir` the editor's settings give (that is the folders'), holding only PCHs and module files. It is removed when the project goes, once nothing maps its files; a server killed before leaves it to the next one, which removes the directories of exited servers. - **One temporary directory.** clice's other temporary files go there too: the compiler query's input, the control socket when the cache directory's path is too long for one, `clice inspect`'s PCH. The directory is the user's alone (0700); one of that name another user owns is an error naming it, never written into. - **Rename.** A rename from such a file was refused outright (`a rename edits the sources of a workspace folder; open one`). One whose edits all stay in the file is now made; one that would change another file is refused, naming it. The configuration page says so now, in English and Chinese: the `cache_dir` option's description (and the schema), the paragraphs on cache fallback and network filesystems, and a sentence on the files outside every folder. ## Tests - `compile/cache/13_unusable_cache_dir` now pins the error: the server serves nothing and says why; `clice lint` exits 2 with the same message. The cases of the degraded mode go (`contexts/self_containment/08_unusable_cache`, `index/transfer/01_large_unit`'s "oversized index without store"), as does the worker's pathless unit test. - New case `project/folders/21_cache_dirs_taken`: a project whose every cache directory is taken serves nothing and says so. - New case `project/folders/20_lone_file`: go to definition into an included header (answers nothing on main), the cache removed with the server under a preamble index large enough to be mapped, a new lone file waiting for the previous one's project to go, and an unusable temporary directory reported. - `rename/refusals/04_no_workspace_folder`: the lone-file rename now succeeds; a rename of a symbol declared in a header beside the file is refused naming it. - The unit tests' served-project and indexer fixtures carry a cache store, as every project that builds now does. - Unit tests for the temporary directory's mode and the removal of exited servers' directories; the control socket's long-path test follows the socket's new place. - The case framework gives each server a temporary directory of its own under a non-ASCII root, as it does the workspace and cache.
fix(server): no project without its cache; lone files get one (#1088) ## What changed **A project never runs without its cache.** Before, a project whose cache could not be used ran without one: no PCH, no module builds, the index kept in memory and lost at exit, with a line in the log the user rarely sees. Now it serves nothing, and the user is told which directory, why, and what to do, then to restart clice: | When | Told | | --- | --- | | the cache directory cannot be created or written | give clice write access to it, or set `cache_dir` in clice.toml | | its index writer lock cannot be opened | same | | another project owns the directory | set `cache_dir` to a directory of this project's own | | it is on a remote filesystem (NFS, SMB, a Windows drive under WSL) | set `cache_dir` to a directory on a local disk | | its index database cannot be read | delete its `index` directory, or set `cache_dir` elsewhere | | every directory the project could use is taken by the server's other projects | set `cache_dir` to a directory of its own | | clice's temporary directory, for the files outside every folder, cannot be used | point TMPDIR at a directory of your own | `clice lint` without `--index` refuses an unusable cache as `clice index` already did. The reading commands (`clice query`, `clice inspect`) are unchanged. With the degraded mode gone go its code paths: the PCH, PCM and index builds' branches for a project without a store, the worker's "index too large to send" for a reply with nowhere to write, the memory-only session over an unreadable database header. Users on WSL who open a project under `/mnt/c` now get that error until they set `cache_dir` to a local directory; before, it ran with an index that was never saved. A file opened with no workspace folder and no project above it (`code test.cpp`, Neovim's single-file mode) is a quick try: it now works as a folder's file does, and leaves nothing behind. - **A cache of its own.** Such files had no cache directory, so no PCH and no module builds: go to definition into a header they include answered nothing while hover worked. Their project now keeps a cache in clice's temporary directory, `<temp>/clice-<uid>/<pid>/` (`<temp>\clice\<pid>\` on Windows), whatever `cache_dir` the editor's settings give (that is the folders'), holding only PCHs and module files. It is removed when the project goes, once nothing maps its files; a server killed before leaves it to the next one, which removes the directories of exited servers. - **One temporary directory.** clice's other temporary files go there too: the compiler query's input, the control socket when the cache directory's path is too long for one, `clice inspect`'s PCH. The directory is the user's alone (0700); one of that name another user owns is an error naming it, never written into. - **Rename.** A rename from such a file was refused outright (`a rename edits the sources of a workspace folder; open one`). One whose edits all stay in the file is now made; one that would change another file is refused, naming it. The configuration page says so now, in English and Chinese: the `cache_dir` option's description (and the schema), the paragraphs on cache fallback and network filesystems, and a sentence on the files outside every folder. ## Tests - `compile/cache/13_unusable_cache_dir` now pins the error: the server serves nothing and says why; `clice lint` exits 2 with the same message. The cases of the degraded mode go (`contexts/self_containment/08_unusable_cache`, `index/transfer/01_large_unit`'s "oversized index without store"), as does the worker's pathless unit test. - New case `project/folders/21_cache_dirs_taken`: a project whose every cache directory is taken serves nothing and says so. - New case `project/folders/20_lone_file`: go to definition into an included header (answers nothing on main), the cache removed with the server under a preamble index large enough to be mapped, a new lone file waiting for the previous one's project to go, and an unusable temporary directory reported. - `rename/refusals/04_no_workspace_folder`: the lone-file rename now succeeds; a rename of a symbol declared in a header beside the file is refused naming it. - The unit tests' served-project and indexer fixtures carry a cache store, as every project that builds now does. - Unit tests for the temporary directory's mode and the removal of exited servers' directories; the control socket's long-path test follows the socket's new place. - The case framework gives each server a temporary directory of its own under a non-ASCII root, as it does the workspace and cache.
fix(editor): completion gaps, clearer messages, slow tidy checks (#1082) ## Related issue Fixes #1017. Fixes #1080. ## What changed Editor papercuts, completion gaps and clice's own messages, each saying who reports, what is wrong, where and what to do. ### Completion - In a function template or generic lambda the code instantiates with several types, completion offers the members every instantiation has, each name's overloads across them in one item (at most eight compared; inside an `if constexpr` branch only the instantiations taking it). Before, it offered nothing. - A name a header the file does not include yet declares completes after a written namespace (`std::vec`, `::ns::inner::Na`, or `inner::Na` inside `namespace ns`), with its `#include`, also when the file does not know the namespace yet. A list after a bare qualifier (`std::`) is marked incomplete, so the first letter typed asks again. - `#` at a line start lists the directives. - Completion inside assertion macros (`EXPECT_EQ(u.|...)`) no longer reads every name of the PCH for the completion clang throws away while it parses the macro's condition tentatively: fmt's `EXPECT_EQ(..., u.⟦⟧str())` takes about half as long (A/B on one box, both orders). - `clice inspect code-completion` answers through the editor's entry, so `#include` paths, directives and module names match the server. ### Messages - A module that does not build: `module 'B' does not build: <first error> (and N more errors); imported through A → B`, source clice, code `module-not-built`, a note leading to the error; a cycle says so (`module-cycle`). Header units say clice does not build them (`header-unit`). - A worker crash note says it is a bug of clice, where the crash reports are, and links the issue tracker (`worker-crash`); the pool's "keeps crashing" popups too. - The inferred-command warning names the file whose command was borrowed, and says when a file lies outside the project. - A compiler that cannot be queried is named in one sentence, with what to do. - A `compile_commands.json` that is no valid JSON is not loaded, and the message gives the line and column. - A command whose directory does not exist warns at the top of the file (`missing-directory`); files the database names that do not exist are one log line per load. - A `.clang-tidy` that does not parse points at its lines; an extension written with its dot is refused instead of crashing the worker. - Project files that are not UTF-8 are named once at load, with the fix. - A client that takes only pushed diagnostics gets them anew when it saves an edited file, when a save retries a crashed compile, and when a change on disk (a saved header) leaves an open file stale: the open files recompile, as a pulling client's re-pull makes them. Saves in a row compile an open file twice at most. ### Slow clang-tidy checks (#1017) The checks too slow for an editor run on open files when `slow_clang_tidy_checks = true` under `[diagnostics]`; unset, clice names the slow checks the `.clang-tidy` enables once; `false` stays silent. `clice lint` runs them all. ### Other fixes - Hover keeps a written `constexpr` on a defaulted function and none clang adds. - Hover of an alias read from the preamble's PCH names the parameters of what it stands for (`__make_integer_seq<sequence, unsigned long, Size>`, not `value-parameter-0-0`): clang reads a dependent specialization of a builtin template back as an alias of its canonical form. - A header compiling in its host's context keeps the verdict of the self-containment check it just ran, and takes its host's include tree again when the host changed while it was read: a host saved meanwhile no longer leaves the header compiled alone, with false errors, as current. - Formatting a whole selected line leaves the next line alone. - Add #include is offered with the cursor right after the name (`printf|(`). - Define in host goes after the host's own definitions of the class's members. - Member and designated initializers highlight as writes (index format bumped). ### VS Code - clice's commands sit together in the editor's context menu below Go to Definition: Switch Header and Source (Module Interface and Implementation), Switch Compilation Context (when the file has more than one), Switch Build Configuration (when the rules declare any), Show Compile Command. The three `{}` language status items are gone. - Standard library headers without an extension open as C++ by their first line. - A header name typed after a dead end asks again (Enter on the line does not); extensionless headers get the header icon. Accepted limitations in this area are now `// LIMITATION:` comments where a fix would go. ## Tests - Unit and case suites on a Linux box (RelWithDebInfo), the full case suite five times in a row; the Windows-only cases and the VS Code e2e on a Windows box. - The header-context races, under 40 parallel copies of `project/unlisted_files/08_member_hosts_headers`: about 80 failures in 400 runs before, 1 in about 1200 after (a host read while it is being written, tracked separately). - The Zed e2e's download test reports the extension's own reason (GitHub's answer) when it starts no download. - New cases: several instantiations, written scopes, tentative parses, defaulted constexpr hover, broken JSON database, missing directory, outside the project, dotted tidy extension, other encodings named, selection through a newline, cursor after a name, host member defined twice, saves in a row, a save retrying a crashed compile; snapshots updated for the new texts and codes. - fmt A/B (`node tools/ecosystem/run.ts perf fmt/editing`, both orders): member completion in `EXPECT_EQ` 55–63 ms on main, 25–31 ms here; answers unchanged.
ci: trustworthy CI and ecosystem round, tests to one standard (#1076) ## What changed CI and the nightly ecosystem round become signals worth trusting, and the tests something to read with confidence. ### The tests say exactly what clice does - The feature unit tests that compiled a source and checked an answer (completion, semantic tokens, folding, selection, outline, navigation, document links, diagnostics, code actions, formatting, hover, inlay hints, rename, counterpart ranking) are now cases, merged by behavior into the existing ones instead of one case per old test. A review of every deleted test restored the checks the move had lost. The unit tests that stay check what no product boundary shows cheaply. They have exact expectations, no duplicates, names of at most four words, and they wait on events instead of polling. Each anomaly trap asserts the anomalies its test provokes. Fixtures skip the toolchain query and run under a watchdog. - Cases show blocks and exact checks instead of partial matches, and anchors instead of literal positions. Known-wrong reasons are written so a docs reader can follow them. Crash spacing and slot revival use test hooks instead of waiting it out (a crash case went from 33 s to 6 s). The modularize cases compile the build their plan describes, every configuration of a merged plan included, through one framework helper. - The teardown gate reads every process a test started: servers, commands, `inspect` runs. Each process's session is found by pid, and stderr is read for one that wrote none. One classifier of clice's log lines serves the cases, the editors and the ecosystem round: a worker death counts once, anomalies by id, any other error-level line. A declared error that no line matches fails, and so does a command killed by a signal the test did not send. - Coverage of the product surface (every method, command, flag and config key) is recorded on the linux-x64 shards, and a CI job fails on what nothing exercised (`pixi run coverage-test`). - The editor clients run end-to-end on fixtures of their own, `tests/editors/NN_*` with one `scenario.json` read by both Neovim and VS Code: contexts and paging, source/header switching, refactoring, build configurations, restarts, VS Code's check for conflicting C++ extensions. The servers' logs are gated afterwards. Zed's test installs this build as the extension's newest version. - Recorded LSP sessions and their replay are gone. `CLICE_LSP_TRACE=1` writes the LSP messages of a server an editor starts to `trace.log` beside the other logs instead. ### CI - Every target builds on x64 Linux, macOS included (cross-compiled with xclang), and runs its suites on its own OS. - `main.yml` runs on `merge_group` with every filter on, the docs-site check included, and the commit-message check reads the queued commit, ready for a merge queue on main. Main pushes keep their full run: releases promote the packages a green main run tested. - Every job and the slow install steps have a time bound. Windows runners turn Defender's real-time scan off before installing. On main pushes, old cache entries are pruned to the newest one per key. - The unit runner takes zest's own command line and runs one test at a time. ### Product fixes the stricter tests and the round found - **Shutdown**: the background index stops before the workers. A stopping pool used to fail every dispatch, so a pass walked its whole queue through it before the stop could save. The include-tree runs are cancelled with it and awaited once the pool has stopped. Shutdown is also bounded: stuck for 60 s, the server logs the step it is stuck at and exits. - **Toolchain queries**: a compiler query that has not answered within 5 s is stopped, along with the programs it started, and clang reads the command itself. On Windows, what a program of the Cygwin or MSYS2 runtime starts leaves the query's job and outlives the stop; native drivers' programs do not. - **Self-containment**: a header is judged by which compile has fewer errors, alone or in its includer's context, counting the compiler's errors in every file and in the preamble. A tie keeps the header self-contained. C's warning about a struct first named in a prototype counts as an error, clang-tidy's findings do not. Without a synthesized context there is no comparison, and a comparison an edit cuts short is made again. This replaces the list of "missing context" diagnostics. - **Hover**: macro expansions that clang-format cannot lay out quickly (blocks inside expressions, deep nesting) keep their own line breaks instead of stalling the hover. The index card of an Objective-C class shows its `@interface`, attributes included. - **Template parameters**: lookups of a substituted parameter across merged patterns are bounds-checked (index, signature help, hover, unification, bindings). The crash needs clice's own module layering to reproduce; the ecosystem round's clice regression job covers it. - **Rename**: a declaration in a file outside the project refuses the rename as "not a source of the project" whether or not the background index has reached that file yet. Before, a rename right after opening said the file "changed since it was indexed". - **Logging**: `CLICE_LOG_LEVEL` sets the stderr log level, replacing `--log-level` on every subcommand (Neovim's config sets it through `cmd_env`). All logging switches are now environment variables. ### Toolchain LLVM 23.1.5 (xclang 23.1.5.1), rules_cc 0.2.28, index format 63. ## Tests - Box runs on the final tree: Linux RelWithDebInfo and Debug (ASan), unit and every case, green. The Windows-specific toolchain test also ran on a Windows box. macOS arm64 RelWithDebInfo and Debug, cross-built on Linux, were green on the tree before the review's fixes. - Negative controls for the new tests: the compiler-query test fails without the process group (Linux and Windows); the rename case fails without its fix, with exactly the message an earlier CI run hit; the log classifier's new test fails on the old classifier; the known-issue matcher's new test fails on the old pattern. - Ecosystem round on this branch: [run 43289149904](https://github.com/clice-io/clice/actions/runs/43289149904), 76 jobs. - Two red jobs (abseil/clang on Windows, abseil/gcc on Linux), both the known highlights disagreement in template code: the server's answer holds more than the unit's own index. This branch had narrowed that known entry to diffs that only add lines, which missed the shape where `inspect` answers nothing. The entry is fixed here, with a test, so the next round reads them as known. - Perf: one slower row confirmed, a cold `initialize` on macOS at 1.21×, which the night before (on main) measured too. `llvm/sessions` edit-after-open is 1.01×; the 1.25× of the round before was noise. - The regression numbers that rose 1.5× or more (clice on Linux, flang on Windows) rose in every phase, the checkout's preparation included, while the perf jobs' A/B on one runner finds indexing unchanged: different runners.
refactor(index): derive symbol records from shards, fix known defects (… …#1075) ## Related issue Fixes #1066. ## What changed The index is rethought around one rule: **what the index says about a symbol is read off what it stores, never reported beside it.** That removes a class of defects instead of patching them, and several mechanisms with it. `src/index/` gets the subdirectories the other layers have. The persisted format moves to 62: an existing index is rebuilt once. ### Design - **Symbol records follow the shards.** A record's files — naming, declaring, defining the symbol, instantiating code that names it — are derived by diffing a file's old and new shard when it is replaced, instead of being a union of what units reported that never shrank. A file whose entries leave takes its symbols along; a symbol is defined exactly while some file defines it (`HasDefinition` is no longer stored anywhere); every file declaring a symbol is known, not one. - **Symbols below external scope that several files name are records of the same kind.** The per-unit sets in the manifests, their own record type, the walk over them at query time and the check at merge time go. A named namespace enclosed by an anonymous one now takes its first declaration's file into its identity, as every other internal entity does, so two units' namespaces of one name are two symbols. - **Shards, instantiation shards and manifests are kept like every other record** (changed, written, cached), with one writer each; eleven fields of hand-kept state go. - **A preamble's index is a container of the worker layer** around a plain TU index. The TU index loses its preamble fields and accessors, the query layer no longer judges whether a preamble matches a buffer, and `DocumentLink` moves to the feature layer. ### `src/index/` `shard/`, `indexing/`, `project_index/`, `database/`, `search/`, `query/`, each with its persisted layout beside its reader; `symbol`, `format` and `columns` are what they share. The first commit is the move alone. ### Defects fixed - The index of a project including library templates grew by half: an overload set a library template names without a resolver was recorded from what the unit happened to declare before the header, a variant per unit. - A header moved or copied unchanged — every update of the VS Code extension moves clang's own headers — made each unit's first index result be rejected and run again: the variants and instantiation keys a unit may leave out are now told per file. - A symbol several places define (a weak and a strong function, a `main` per program) showed once in `workspace/symbol` and `clice query symbol-search`; `clice query definition` gave one. Each definition is listed now. - `path:` found a symbol only by the file of its definition, not by the headers declaring it. - A macro of the compile command (`-D`) or of the compiler answered "symbol not found" to `clice query`: references, definition and symbol search answer, naming `<command line>` or `<built-in>`. - A save the database refused was retried forever without a word: the user is told once, and past 256 MB of unsaved index a server stops indexing until a save commits. - References and the hierarchies asked from one file silently lacked the uses in another open file edited since its last compile: they wait for that compile. - A compile with errors that read a file whose open document has unsaved text says so at the top of the file. - An evicted document answered document symbols, folding ranges and semantic tokens with null when none was asked before the eviction. - A file turned to compiling after its index attempt failed kept the empty tokens and folds it was answered meanwhile until the next edit. - Semantic tokens of a file with code its context skips classified every name of the file from the index on each request; only the skipped code is, now. - Opening a file again read and hashed its preamble's index whole each time; once per process is enough. - An open file's references missed what its preamble's headers instantiate until the background index reached them: the preamble's index holds those records. - With `skip_header_bodies = false`, an open source kept its headers out of project-wide answers until it closed: open documents are indexed in the background like closed ones. ### New option `project.index_library_bodies` (default `false`): the index leaves out the bodies of the functions system headers define. The compile is unchanged — diagnostics and instantiations are what they were; only the names used inside those bodies are not walked, in every unit that includes the library. A header opened in the editor is indexed whole. On abseil (425 units) the default stores 20.2 MB of file shards in 209 s where the option stores 22.4 MB in 218 s. ### Known limitations Written where a fix would go, as `// LIMITATION:` comments: a symbol flag only some units report, the cost of merging a header that differs in every unit, the stall of preparing a save, instantiation keys that resolve to nothing, a database whose lock file the reader may not write, hover from the index without type facts, and the two prices of `skip_header_bodies`. ## Tests Unit tests and cases pass on Linux in RelWithDebInfo and Debug. New cases: `query/names/15_declaring_header_path`, `16_several_definitions`, `17_predefined_macros`; `workspace_symbols/results/07_several_definitions`; `navigation/projects/13_unsaved_edit_references`, `14_preamble_instantiations`; `index/read_only/12_failed_attempt_refresh`; `index/batch/10_library_bodies`. New and rewritten unit tests cover the derived records (a definition leaving its file, definitions of several files, a symbol moving between two files of one unit, a local symbol across files and behind a precompiled header, whichever unit merges first), a copied header, a library template's overload set, the preamble index container, library bodies, a refused save, and the rerun after a variant left. Not covered by a test: the wait of the background index past 256 MB of unsaved index, which needs that much index and a database refusing it.
PreviousNext