https://github.com/mpenick/no-global-alloc-tool
A tool to detect usage of the global or system versions of operator new() and operator delete()
https://github.com/mpenick/no-global-alloc-tool
clang llvm memory-leak
Last synced: 7 months ago
JSON representation
A tool to detect usage of the global or system versions of operator new() and operator delete()
- Host: GitHub
- URL: https://github.com/mpenick/no-global-alloc-tool
- Owner: mpenick
- Created: 2018-12-27T21:30:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T22:21:50.000Z (almost 7 years ago)
- Last Synced: 2025-01-16T11:29:59.026Z (9 months ago)
- Topics: clang, llvm, memory-leak
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is a tool can be used to detect usage of the global or system versions of
`operator new()` and `operator delete()` (and their other allocating variants).
It will support `malloc()` and `free()` in the future. This tool is useful for
finding and preventing calls that go around a library's or application's custom
allocator.# To run
```
./no-global-alloc-tool /path/to/source/cluster.cpp -- -I/some/include/directory
In file included from .../Code/cpp-driver/src/cluster.cpp:17:
In file included from .../Code/cpp-driver/src/cluster.hpp:20:
In file included from .../Code/cpp-driver/src/config.hpp:20:
In file included from .../Code/cpp-driver/src/auth.hpp:22:
In file included from .../Code/cpp-driver/src/host.hpp:22:
.../Code/cpp-driver/src/copy_on_write_ptr.hpp:85:7: error: Using `operator delete()` from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/new:124:6
delete ref;
^
.../Code/cpp-driver/src/copy_on_write_ptr.hpp:74:54: error: Using `operator new()` from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/new:120:7
ptr_ = SharedRefPtr(new Referenced(new T(*(temp->ref))));
^
.../Code/cpp-driver/src/copy_on_write_ptr.hpp:85:7: error: Using `operator delete()` from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/new:124:6
delete ref;
```*Note:* Includes and other compiler flags can be specified after `--`
# To run in a cmake project
```
mkdir build && cd build
cmake -DCMAKE_CXX_CLANG_TIDY=/path/to/tool/no-global-alloc-tool ..
make
```# Dependencies
Requires LLVM and clang (w/ clang's libtooling)
## On Ubuntu
```
sudo apt install libclang-6.0-dev
```# To build
```
mkdir build && cd build
LIBCLANG_ROOT_DIR=/path/to/llvm/clang cmake ..
make
```