# xunused **Repository Path**: mirrors_Esri/xunused ## Basic Information - **Project Name**: xunused - **Description**: xunused is a tool to find unused C/C++ functions and methods across source files in the whole project. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-11-11 - **Last Updated**: 2026-01-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xunused `xunused` is a tool to find unused C/C++ functions and methods across source files in the whole project. It is built upon clang to parse the source code (in parallel). It then shows all functions that had a definition but no use. Templates, virtual functions, constructors, functions with `static` linkage are all taken into account. If you find an issue, please open a issue on https://github.com/mgehre/xunused or file a pull request. xunused is compatible with LLVM and Clang versions 14 to 18. ## Building and Installation First download or build the necessary versions of LLVM and Clang with development headers. On Debian and Ubuntu, this can easily be done via [http://apt.llvm.org](http://apt.llvm.org) and `apt install llvm-18-dev libclang-18-dev`. Then build via ``` mkdir build cd build cmake .. make ``` ## Run it To run the tool, provide a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html). By default, it will analyze all files that are mentioned in it. ``` cd build ./xunused /path/to/your/project/compile_commands.json ``` You can specify the option `-filter` together with a regular expressions. Only files who's path is matching the regular expression will be analyzed. You might want to exclude your test's source code to find functions that are only used by tests but not any other code. If `xunused` complains about missing include files such as `stddef.h`, try adding `-extra-arg=-I/usr/include/clang/17/include` (or similar) to the arguments. ## Development ### Running Tests xunused includes a test suite using LLVM's lit testing framework. To run the tests: ```bash cmake --build build --target check ``` For more information on running and writing tests, see [tests/README.md](tests/README.md).