Debian Codegraph @

clang/test/Analysis/pch_macro.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4
5 // DEFINE: %{emit-pch-action} = \
6 // DEFINE: %clang_cc1 -x c++ -emit-pch -o %t/header.pch %t/header.h
7
8 // DEFINE: %{analyze-action} = \
9 // DEFINE: %clang_analyze_cc1 -include-pch %t/header.pch \
10 // DEFINE: -analyzer-checker=core,apiModeling,unix.StdCLibraryFunctions \
11 // DEFINE: -verify %t/main.cpp
12
13 // RUN: %{emit-pch-action} -triple x86_64-apple-macosx10.15.0
14 // RUN: %{analyze-action} -triple x86_64-apple-macosx10.15.0
15 // RUN: %{emit-pch-action}
16 // RUN: %{analyze-action}
17
18
19 //--- header.h
20
21
22 // Pre-compiled header
23
24 int foo();
25
26 // Literal data for macro values will be null as they are defined in a PCH
27 #define EOF -1
28 #define AT_FDCWD -2
29
30
31 //--- main.cpp
32
33
34 // Source file
35 // expected-no-diagnostics
36 int test() {
37 // we need a function call here to initiate erroneous routine
38 return foo(); // no-crash
39 }
40
41 // Test that StdLibraryFunctionsChecker can obtain the definition of
42 // AT_FDCWD even if it is from a PCH:
43 int faccessat(int, const char *, int, int);
44
45 void test_faccessat() {
46 char fileSystemPath[10] = { 0 };
47
48 if (0 != faccessat(AT_FDCWD, fileSystemPath, 2, 0x0030)) {}
49 }
50