Add Cyclomatic complexity GCC plugin

Add a very simple plugin to demonstrate the GCC plugin infrastructure. This GCC
plugin computes the cyclomatic complexity of each function.

The complexity M of a function's control flow graph is defined as:
M = E - N + 2P
where
E = the number of edges
N = the number of nodes
P = the number of connected components (exit nodes).

Signed-off-by: Emese Revfy <re.emese@gmail.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michal Marek <mmarek@suse.com>
This commit is contained in:
Emese Revfy
2016-05-24 00:10:35 +02:00
committed by Michal Marek
parent 6b90bd4ba4
commit 0dae776c6b
4 changed files with 87 additions and 0 deletions

View File

@@ -17,4 +17,5 @@ export GCCPLUGINS_DIR HOSTLIBS
$(HOSTLIBS)-y := $(GCC_PLUGIN)
always := $($(HOSTLIBS)-y)
cyc_complexity_plugin-objs := cyc_complexity_plugin.o
clean-files += *.so