Add UnixAPIChecker, a meta checker to include various precondition checks for calls
to various unix/posix functions, e.g. 'open()'.
As a first check, check that when 'open()' is passed 'O_CREAT' that it has
a third argument.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97086 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c
new file mode 100644
index 0000000..2bc2efa
--- /dev/null
+++ b/test/Analysis/unix-fns.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic
+
+#include <fcntl.h>
+
+void test_open(const char *path) {
+ int fd;
+ fd = open(path, O_RDONLY); // no-warning
+ if (!fd)
+ close(fd);
+
+ fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
+ if (!fd)
+ close(fd);
+}