Git Product home page Git Product logo

dead1's Introduction

Clang plugin: dead-method

Scans every compilation unit looking for private C++ class methods. Warns if there are ones that are not referenced (and the class seems to be fully defined, including all the methods and friends).

Installation

First download LLVM/Clang sources (version 3.2). Then

cd tools/clang/examples
mkdir dead-method
cd dead-method

and copy all the files here. After building the whole LLVM with Clang, issue inside the dead-method directory

make

You can find the plugin library in LLVM build directory (e.g. Debug+Asserts/lib/libDeadMethod.so).

Use

Assume libDeadMethod.so could be found by ld (for example is in one of the directories in LD_LIBRARY_PATH). Then call

clang -Xclang -load -Xclang libDeadMethod.so -Xclang -add-plugin -Xclang dead-method a.cpp

will attempt to compile your code with dead-method plugin active.

  • -Xclang means that the following argument should be passed to Clang frontend.
  • to provide additional arguments to the plugin use -plugin-arg-dead-method (also preceded by -Xclang)
  • if you want just check (no compilation) provide -fsyntax-only as well (without -Xclang)

The currently accepted arguments:

  • include-template-methods - try to find unused private template methods also (many false-positives)
  • ignore <file path> - do not warn about unused methods declared in <file path>; it must be the exact path as used by the compiler
  • help - you will probably guess what it causes

I suggest you first run the compiler+plugin without ignore flag and later copy/paste the unwanted paths from warnings. Remember to provide -Xclang before every parameter that is to be passed to Clang and -plugin-arg-dead-method before every plugin argument. Example that would ignore header file /usr/include/bla.h

clang -Xclang -load -Xclang libDeadMethod.so -Xclang -add-plugin -Xclang dead-method -Xclang -plugin-arg-dead-method -Xclang ignore -Xclang -plugin-arg-dead-method -Xclang /usr/include/bla.h a.cpp

As you see it quickly becomes very long, so you'd better write a script that invokes the compiler.

dead1's People

Watchers

 avatar  avatar  avatar

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.