Giter Site home page Giter Site logo

dmikushin / xunused Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stailgot/xunused

0.0 0.0 0.0 69 KB

xunused is a tool to find unused C/C++ functions and methods across source files in the whole project.

License: Apache License 2.0

C++ 89.55% CMake 10.45%

xunused's Introduction

Find unused C/C++ functions with 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.

xunused is compatible with LLVM and Clang version 12.

Prerequisites

sudo apt install llvm-12-dev clang-12 libclang-12-dev libtbb-dev

Building

mkdir build
cd build
cmake ..
make

Testing

To run the tool, provide a compilation database. By default, it will analyze all files that are mentioned in it.

In order to generate compile_commands.json for a CMake project, add the following line into CMakeLists.txt:

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

An example compile_commands.json file is create in the build folder:

cd build
./xunused ./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/10/include (or similar) to the arguments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.