All Projects → firolino → clang-tool

firolino / clang-tool

Licence: MIT license
Simple and powerful standalone project for clang-based tools using libtooling (e.g. refactoring, auto-completion, etc.)

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to clang-tool

flextool
C++ compile-time programming (serialization, reflection, code modification, enum to string, better enum, enum to json, extend or parse language, etc.)
Stars: ✭ 32 (-8.57%)
Mutual labels:  refactoring, clang, libtooling
mutator
mutator is an experimental suite of tools aimed at analysis and automation of C/C++ code development
Stars: ✭ 62 (+77.14%)
Mutual labels:  clang, libtooling
Violations Lib
Java library for parsing report files from static code analysis.
Stars: ✭ 94 (+168.57%)
Mutual labels:  static-code-analysis, clang
Vim Clang
Clang completion plugin for vim
Stars: ✭ 335 (+857.14%)
Mutual labels:  clang, code-completion
Sharpen
Visual Studio extension that intelligently introduces new C# features into your existing codebase
Stars: ✭ 351 (+902.86%)
Mutual labels:  refactoring, static-code-analysis
Cxxctp
DEPRECATED. USE INSTEAD github.com/blockspacer/flextool
Stars: ✭ 58 (+65.71%)
Mutual labels:  refactoring, clang
Easyclangcomplete
💥 Robust C/C++ code completion for Sublime Text 3
Stars: ✭ 537 (+1434.29%)
Mutual labels:  clang, code-completion
Clang Expand
🐉 A clang tool for happy refactoring without source-code gymnastics
Stars: ✭ 182 (+420%)
Mutual labels:  refactoring, clang
autoprogrammer
C++ to C++ code generation tool (enum2string conversion, serialization, reflection etc.)
Stars: ✭ 77 (+120%)
Mutual labels:  clang, libtooling
refactoringtopatterns
A place to practice Refactoring To Patterns that Kerievsky wrote about in his book
Stars: ✭ 46 (+31.43%)
Mutual labels:  refactoring
colisper
Check and transform Lisp code with Comby (beta)
Stars: ✭ 18 (-48.57%)
Mutual labels:  refactoring
Boostnote-packages
Repo containing .rpm, .deb and Boostnote app folder
Stars: ✭ 31 (-11.43%)
Mutual labels:  standalone
seamer
refactoring tool that aims at making it easy to create characterization tests
Stars: ✭ 16 (-54.29%)
Mutual labels:  refactoring
phpstan-nette
Nette Framework class reflection extension for PHPStan & framework-specific rules
Stars: ✭ 87 (+148.57%)
Mutual labels:  static-code-analysis
python-tools
🔧 Atom plugin which uses jedi to provide numerous tools useful for developing python code in atom.
Stars: ✭ 96 (+174.29%)
Mutual labels:  code-completion
Mage-Studio
Mage Studio is a Game Editor, built on top of Mage Engine, embedded in Electron. Mage Studio will allow to easily develop 3D apps using WebGL.
Stars: ✭ 16 (-54.29%)
Mutual labels:  standalone
ui5-schemas
🚀 UI5 Schemas allows you to develop SAPUI5/OpenUI5 XML at a maximum convenience. It downloads, upgrades and sets up SAPUI5/OpenUI5 XML schemas for a better development experience in your favorite IDE (if it is WebStorm ;).
Stars: ✭ 50 (+42.86%)
Mutual labels:  code-completion
zipapps
Package your python code into a executable zip file (with the requirements). For Python3.6+
Stars: ✭ 38 (+8.57%)
Mutual labels:  standalone
refactoring-for-testability-cpp
Hard-to-test patterns in C++ and how to refactor them
Stars: ✭ 40 (+14.29%)
Mutual labels:  refactoring
los
Los是一个c/c++语言编译型的虚拟机。它使用llvm/clang作为其前端,losld做后端对源代码进行编译,生成los指令文件。Los is a c/c++-compiled virtual machine. It uses llvm/clang as its front end, losld does the backend to compile the source code, and generates the los directive file.
Stars: ✭ 46 (+31.43%)
Mutual labels:  clang

clang-tool

clang-tool is a simple and powerful project template for clang-based tools using libtooling[1]. It helps getting started to write standalone tools useful for refactoring, static code analysis, auto-completion etc.

Installation

Install the necessary llvm and clang headers and libraries for you system an run:

git clone https://github.com/firolino/clang-tool
cd clang-tool
mkdir build
cd build
cmake ..
make

Usage

A simple example is included in src/transformers/functioncalltransformer.cc that rewriters all function calls from functionName() to fn_functionName().

bin/clang-tool ../examples/simple.cc -- -std=c++11

Another example can be found in finder/integervariablefinder.cc. Uncomment the intFinder in consumer.cc to print all integer variables.

FunctionCallTransformer fntransformer(context, rewriter);
fntransformer.start();
fntransformer.print(llvm::outs());

IntegerVariableFinder intFinder(context);
intFinder.start();

You can even specifiy more than one source file when calling clang-tool.

bin/clang-tool s1.cc s2.cc -- -std=c++11

More matchers for writing own finders and transformers are available under [2].

Specifiying compiler arguments

There are multiple ways to provide your projects' compiler arguments to a clang tool:

  • Direct

    As can be seen in the example above, compiler arguments can be placed directly after --.

  • Compilation Database

    If your project is CMake-based use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON in your cmake call. It will generate a compile_commands.json in your build directory containing your compiler arguments etc. With the json file you don't need to provide -- anymore. clang-tool will automatically use your json file.

  • Makefiles

    If you have an ordinary Makefile based project, use rizsottos awesome tool from https://github.com/rizsotto/Bear and run bear make on a cleanded project directory. It will generate a compile_commands.json for you!

TODOs

Inlude PPCallbacks

References

[1] http://clang.llvm.org/docs/LibTooling.html

[2] http://clang.llvm.org/docs/LibASTMatchersReference.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].