[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / unix-api.cpp
blob2b07d8807c1f2d757f85a1cbb10a70d032ab5063
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -verify %s
2 extern "C" {
3 #ifndef O_RDONLY
4 #define O_RDONLY 0
5 #endif
7 #ifndef NULL
8 #define NULL ((void*) 0)
9 #endif
11 int open(const char *, int, ...);
12 int close(int fildes);
14 } // extern "C"
16 namespace MyNameSpace {
17 int open(const char *a, int b, int c, int d);
20 void unix_open(const char *path) {
21 int fd;
22 fd = open(path, O_RDONLY); // no-warning
23 if (fd > -1)
24 close(fd);
27 void unix_open_misuse(const char *path) {
28 int fd;
29 int mode = 0x0;
30 fd = open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' with more than 3 arguments}}
31 if (fd > -1)
32 close(fd);
35 // Don't treat open() in namespaces as the POSIX open()
36 void namespaced_open(const char *path) {
37 MyNameSpace::open("Hi", 2, 3, 4); // no-warning
39 using namespace MyNameSpace;
41 open("Hi", 2, 3, 4); // no-warning
43 int fd;
44 int mode = 0x0;
45 fd = ::open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' with more than 3 arguments}}
46 if (fd > -1)
47 close(fd);
50 class MyClass {
51 public:
52 static int open(const char *a, int b, int c, int d);
54 int open(int a, int, int c, int d);
57 void class_qualified_open() {
58 MyClass::open("Hi", 2, 3, 4); // no-warning
60 MyClass mc;
61 mc.open(1, 2, 3, 4); // no-warning