1 // RUN: mkdir -p %T/ctudir
2 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
3 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
4 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
5 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
6 
7 void clang_analyzer_eval(int);
8 
9 int f(int);
10 int g(int);
11 int h(int);
12 
13 int callback_to_main(int x) { return x + 1; }
14 
15 namespace myns {
16 int fns(int x);
17 
18 namespace embed_ns {
19 int fens(int x);
20 }
21 
22 class embed_cls {
23 public:
24   int fecl(int x);
25 };
26 }
27 
28 class mycls {
29 public:
30   int fcl(int x);
31   static int fscl(int x);
32 
33   class embed_cls2 {
34   public:
35     int fecl2(int x);
36   };
37 };
38 
39 namespace chns {
40 int chf1(int x);
41 }
42 
43 int fun_using_anon_struct(int);
44 
45 int main() {
46   clang_analyzer_eval(f(3) == 2); // expected-warning{{TRUE}}
47   clang_analyzer_eval(f(4) == 3); // expected-warning{{TRUE}}
48   clang_analyzer_eval(f(5) == 3); // expected-warning{{FALSE}}
49   clang_analyzer_eval(g(4) == 6); // expected-warning{{TRUE}}
50   clang_analyzer_eval(h(2) == 8); // expected-warning{{TRUE}}
51 
52   clang_analyzer_eval(myns::fns(2) == 9);                   // expected-warning{{TRUE}}
53   clang_analyzer_eval(myns::embed_ns::fens(2) == -1);       // expected-warning{{TRUE}}
54   clang_analyzer_eval(mycls().fcl(1) == 6);                 // expected-warning{{TRUE}}
55   clang_analyzer_eval(mycls::fscl(1) == 7);                 // expected-warning{{TRUE}}
56   clang_analyzer_eval(myns::embed_cls().fecl(1) == -6);     // expected-warning{{TRUE}}
57   clang_analyzer_eval(mycls::embed_cls2().fecl2(0) == -11); // expected-warning{{TRUE}}
58 
59   clang_analyzer_eval(chns::chf1(4) == 12); // expected-warning{{TRUE}}
60   clang_analyzer_eval(fun_using_anon_struct(8) == 8); // expected-warning{{TRUE}}
61 }
62