xaizek / unused-funcs (License: GPLv2+) (since 2018-12-07)
Clang-based standalone tool that detects unused external functions in a set of source files.
Commit 2ade60f0a5bf11a27da09217949e605a58820914

replace std stream by LLVM stream
Author: Raphael Knaus
Author date (UTC): 2018-01-14 17:26
Committer name: Raphael Knaus
Committer date (UTC): 2018-01-15 21:07
Parent(s): 2fcb42b44eedff48435e901dd71bb98186e96cd8
Signing key:
Tree: 29cc2f41b9e8462f6136e8b72f6019de57d7a170
File Lines added Lines deleted
src/Finder.cpp 2 3
src/FuncInfo.cpp 1 3
src/FuncInfo.hpp 4 3
File src/Finder.cpp changed (mode: 100644) (index 47e420f..a654233)
20 20
21 21 #include "Finder.hpp" #include "Finder.hpp"
22 22
23 #include <iostream>
24 23 #include <map> #include <map>
25 24 #include <string> #include <string>
26 25
 
... ... Finder::Impl::~Impl() {
123 122
124 123 if (funcInfo.isFullyDeclared()) { if (funcInfo.isFullyDeclared()) {
125 124 if (funcInfo.isUnused()) { if (funcInfo.isUnused()) {
126 std::cout << funcInfo << ": unused\n";
125 llvm::outs() << funcInfo << ": unused\n";
127 126 } else if (funcInfo.canBeMadeStatic()) { } else if (funcInfo.canBeMadeStatic()) {
128 std::cout << funcInfo << ": can be made static\n";
127 llvm::outs() << funcInfo << ": can be made static\n";
129 128 } }
130 129 } }
131 130 } }
File src/FuncInfo.cpp changed (mode: 100644) (index 0175e72..1e60f05)
25 25 #include <clang/Basic/SourceLocation.h> #include <clang/Basic/SourceLocation.h>
26 26 #include <clang/Basic/SourceManager.h> #include <clang/Basic/SourceManager.h>
27 27
28 #include <iostream>
29
30 28 FuncInfo::FuncInfo(const clang::FunctionDecl *func, FuncInfo::FuncInfo(const clang::FunctionDecl *func,
31 29 const clang::SourceManager *sm) const clang::SourceManager *sm)
32 30 : name(func->getNameAsString()), lineNum(0U) { : name(func->getNameAsString()), lineNum(0U) {
 
... ... bool FuncInfo::canBeMadeStatic() const {
62 60 return true; return true;
63 61 } }
64 62
65 std::ostream &operator<<(std::ostream &os, const FuncInfo &fi) {
63 llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const FuncInfo &fi) {
66 64 return os << fi.fileName << ':' << fi.lineNum << ':' << fi.name; return os << fi.fileName << ':' << fi.lineNum << ':' << fi.name;
67 65 } }
File src/FuncInfo.hpp changed (mode: 100644) (index 08d2e24..f457706)
21 21 #ifndef UNUSED_FUNCS__FUNCINFO_HPP__ #ifndef UNUSED_FUNCS__FUNCINFO_HPP__
22 22 #define UNUSED_FUNCS__FUNCINFO_HPP__ #define UNUSED_FUNCS__FUNCINFO_HPP__
23 23
24 #include <iosfwd>
24 #include <llvm/Support/raw_ostream.h>
25
25 26 #include <string> #include <string>
26 27 #include <vector> #include <vector>
27 28
 
... ... class SourceManager;
36 37
37 38
38 39 class FuncInfo { class FuncInfo {
39 friend std::ostream &operator<<(std::ostream &os, const FuncInfo &fi);
40 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const FuncInfo &fi);
40 41
41 42 public: public:
42 43 FuncInfo(const clang::FunctionDecl *func, const clang::SourceManager *sm); FuncInfo(const clang::FunctionDecl *func, const clang::SourceManager *sm);
 
... ... private:
57 58 Refs calls; Refs calls;
58 59 }; };
59 60
60 std::ostream &operator<<(std::ostream &os, const FuncInfo &fi);
61 llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const FuncInfo &fi);
61 62
62 63 #endif // UNUSED_FUNCS__FUNCINFO_HPP__ #endif // UNUSED_FUNCS__FUNCINFO_HPP__
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/unused-funcs

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/unused-funcs

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master