summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-22 01:28:48 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-22 01:28:48 +0300
commitd9b06623487a1ab5155b9d7fc06576999fa1acd3 (patch)
treec8f25db118211cd2c7e0bfc9896a72469d9e2ad5
parent8b3465367e89a07e8f15de08b2f5599ed30a4e4b (diff)
downloadparanucker-d9b06623487a1ab5155b9d7fc06576999fa1acd3.tar.gz
paranucker-d9b06623487a1ab5155b9d7fc06576999fa1acd3.tar.bz2
paranucker-d9b06623487a1ab5155b9d7fc06576999fa1acd3.tar.xz
paranucker-d9b06623487a1ab5155b9d7fc06576999fa1acd3.zip
Add examples.
-rw-r--r--examples/cexample.c205
-rwxr-xr-xexamples/cexample.sh3
-rw-r--r--examples/cppexample.cpp77
-rwxr-xr-xexamples/cppexample.sh3
4 files changed, 288 insertions, 0 deletions
diff --git a/examples/cexample.c b/examples/cexample.c
new file mode 100644
index 0000000..c450ffb
--- /dev/null
+++ b/examples/cexample.c
@@ -0,0 +1,205 @@
+int k;
+
+int main(void)
+{
+}
+
+void func1(int *ptr1, int *ptr2)
+{
+ if (ptr1 || ptr2)
+ {
+ *ptr2 = 400;
+ }
+ else
+ {
+ *ptr1 = 100;
+ }
+ *ptr1 = 200;
+ *ptr2 = 300;
+}
+
+void func2(int *ptr1, int *ptr2)
+{
+ if (ptr1 || ptr2)
+ {
+ *ptr2 = 400;
+ return;
+ }
+ else
+ {
+ *ptr1 = 100;
+ }
+
+ *ptr1 = 200;
+ *ptr2 = 300;
+}
+
+void func3(int *ptr1, int *ptr2)
+{
+ int c;
+ if (k == c || !ptr1)
+ {
+ return;
+ }
+ else
+ {
+ *ptr1 = 100;
+ }
+
+ *ptr1 = 200;
+ *ptr2 = 300;
+}
+
+void func4(int *ptr1, int *ptr2)
+{
+ int c;
+ if (k == c || !ptr1 || !ptr2)
+ {
+ return;
+ }
+ else
+ {
+ *ptr1 = 100;
+ }
+
+ *ptr1 = 200;
+ *ptr2 = 300;
+}
+
+void func5(int *ptr1, int *ptr2)
+{
+ int c;
+ if (!ptr1 || !ptr2 || k == c)
+ {
+ c = 3;
+ }
+ else
+ {
+ *ptr1 = 100;
+ }
+
+ *ptr1 = 200;
+ *ptr2 = 300;
+}
+
+void func6(int *ptr1, int *ptr2)
+{
+ if (ptr1 && ptr2)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ }
+ else
+ {
+ return;
+ }
+
+ *ptr1 = 300;
+ *ptr2 = 400;
+}
+
+void func7(int *ptr1, int *ptr2)
+{
+ if (!ptr1 && !ptr2)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ }
+ else
+ {
+ return;
+ }
+
+ *ptr1 = 300;
+ *ptr2 = 400;
+}
+
+void func8(int *ptr1, int *ptr2)
+{
+ if (ptr1 && ptr2)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ return;
+ }
+ else
+ {
+ *ptr1 = 300;
+ *ptr2 = 400;
+ return;
+ }
+
+ *ptr1 = 500;
+ *ptr2 = 600;
+}
+
+void func9(int *ptr1, int *ptr2)
+{
+ if (ptr1 || ptr2)
+ {
+ *ptr2 = 100;
+ return;
+ }
+ else
+ {
+ *ptr1 = 200;
+ return;
+ }
+
+ *ptr1 = 300;
+ *ptr2 = 400;
+}
+
+void func10(int *ptr1, int *ptr2)
+{
+ if (ptr1 && ptr2 && k)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ return;
+ }
+ else
+ {
+ *ptr1 = 300;
+ *ptr2 = 400;
+ }
+
+ *ptr1 = 500;
+ *ptr2 = 600;
+}
+
+void func11(int *ptr1, int *ptr2)
+{
+ if (ptr1 && ptr2 || ptr1)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ return;
+ }
+ else
+ {
+ *ptr1 = 300;
+ *ptr2 = 400;
+ }
+
+ *ptr1 = 500;
+ *ptr2 = 600;
+}
+
+void func12(int *ptr1, int *ptr2)
+{
+ if (ptr1 || !ptr1)
+ {
+ *ptr1 = 100;
+ *ptr2 = 200;
+ return;
+ }
+ else
+ {
+ *ptr1 = 300;
+ *ptr2 = 400;
+ }
+
+ *ptr1 = 500;
+ *ptr2 = 600;
+}
diff --git a/examples/cexample.sh b/examples/cexample.sh
new file mode 100755
index 0000000..eff04e5
--- /dev/null
+++ b/examples/cexample.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+gcc-5 -fplugin=../astdumper.so -fplugin-arg-astdumper-command=detectnullpointers cexample.c
diff --git a/examples/cppexample.cpp b/examples/cppexample.cpp
new file mode 100644
index 0000000..46b3c01
--- /dev/null
+++ b/examples/cppexample.cpp
@@ -0,0 +1,77 @@
+class Data1
+{
+ public:
+ int val;
+};
+
+int main(int)
+{
+}
+
+class Object1
+{
+ int k;
+
+ void func1(Data1 *ptr1, Data1 *ptr2)
+ {
+ if (!ptr1 || ptr1->val == 100)
+ {
+ return;
+ }
+
+ ptr1->val = 200;
+ }
+
+ void func2(Data1 *ptr1, Data1 *ptr2)
+ {
+ if (ptr1 && ptr1->val == 100)
+ {
+ ptr1->val = 200;
+ return;
+ }
+
+ ptr1->val = 300;
+ }
+
+ void func3(Data1 *ptr1, Data1 *ptr2)
+ {
+ if (ptr1 || ptr1->val == 100)
+ {
+ return;
+ }
+
+ ptr1->val = 200;
+ }
+
+ void func4(Data1 *ptr1, Data1 *ptr2)
+ {
+ if (!ptr1 && ptr1->val == 100)
+ {
+ return;
+ }
+
+ ptr1->val = 200;
+ }
+
+ void func5(Data1 *ptr1, Data1 *ptr2)
+ {
+ if ((!ptr1 || ptr1->val == 100) || (!ptr2 || ptr2->val == 200))
+ {
+ return;
+ }
+
+ ptr1->val = 300;
+ ptr2->val = 400;
+ }
+
+ void func6(Data1 *ptr1, Data1 *ptr2)
+ {
+ if ((!ptr1 || ptr1->val == 100) && (!ptr2 || ptr2->val == 200))
+ {
+ return;
+ }
+
+ ptr1->val = 300;
+ ptr2->val = 400;
+ }
+};
diff --git a/examples/cppexample.sh b/examples/cppexample.sh
new file mode 100755
index 0000000..d6ff401
--- /dev/null
+++ b/examples/cppexample.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+g++-5 -fplugin=../cppastdumper.so -fplugin-arg-cppastdumper-command=detectnullpointers cppexample.cpp