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 aea6460b1bcb7557e52048ded971ddb94fda1d67

Add example and test files
Author: xaizek
Author date (UTC): 2014-04-06 10:17
Committer name: xaizek
Committer date (UTC): 2014-04-06 10:17
Parent(s): 2bfdd55904120949c661ebcf372e9e976788928d
Signing key:
Tree: 5fd96629cf1cf68aac1571ce56038fc1687b50b2
File Lines added Lines deleted
README.md 41 0
tests/func-ptr.c 13 0
tests/main.c 35 0
tests/util.c 9 0
File README.md changed (mode: 100644) (index bcbe6b2..dc5d766)
... ... functions:
8 8 - functions declared as `extern` which are used only locally and thus can be - functions declared as `extern` which are used only locally and thus can be
9 9 made `static`. made `static`.
10 10
11 Example
12 -------
13
14 Input:
15
16 ```c
17 static void firstStatic(void);
18 static void secondStatic(void);
19
20 void firstExtern(void);
21
22 extern void secondExtern(void);
23
24 static void firstStatic(void) { }
25 static void secondStatic(void) { }
26
27 void firstExtern(void) { }
28 void secondExtern(void) { }
29
30 int
31 main(void)
32 {
33 firstExtern();
34 secondStatic();
35 return 0;
36 }
37 ```
38
39 Run command:
40
41 ```sh
42 bin/unused-funcs main.c --
43 ```
44
45 Output (paths are truncated):
46
47 ```
48 .../main.c:20:firstExtern:can be made static
49 .../main.c:25:secondExtern:unused
50 ```
51
11 52 Building Building
12 53 -------- --------
13 54
File tests/func-ptr.c added (mode: 100644) (index 0000000..25fea85)
1 void
2 func(void)
3 {
4 }
5
6 int
7 main(void)
8 {
9 void (*f)(void) = func;
10 void (*f2)(void) = &func;
11 f();
12 return 0;
13 }
File tests/main.c added (mode: 100644) (index 0000000..cbca7dc)
1 static void firstStatic(void);
2
3 static void secondStatic(void);
4
5 void firstExtern(void);
6
7 extern void secondExtern(void);
8
9 static void
10 firstStatic(void)
11 {
12 }
13
14 static void
15 secondStatic(void)
16 {
17 }
18
19 void
20 firstExtern(void)
21 {
22 }
23
24 void
25 secondExtern(void)
26 {
27 }
28
29 int
30 main(void)
31 {
32 firstExtern();
33 secondStatic();
34 return 0;
35 }
File tests/util.c added (mode: 100644) (index 0000000..d1be9e9)
1 extern void firstExtern(void);
2 void secondExtern(void);
3
4 void
5 thirdExtern(void)
6 {
7 firstExtern();
8 secondExtern();
9 }
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