]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
Vendor import of clang trunk r300422:
[FreeBSD/FreeBSD.git] / test / Analysis / inlining / dyn-dispatch-bifurcate.cpp
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify -Wno-reinterpret-base-class %s
2
3 void clang_analyzer_eval(bool);
4
5 class A {
6 public:
7   virtual int get() { return 0; }
8 };
9
10 void testBifurcation(A *a) {
11   clang_analyzer_eval(a->get() == 0); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
12 }
13
14 void testKnown() {
15   A a;
16   clang_analyzer_eval(a.get() == 0); // expected-warning{{TRUE}}
17 }
18
19 void testNew() {
20   A *a = new A();
21   clang_analyzer_eval(a->get() == 0); // expected-warning{{TRUE}}
22 }
23
24
25 namespace ReinterpretDisruptsDynamicTypeInfo {
26   class Parent {};
27
28   class Child : public Parent {
29   public:
30     virtual int foo() { return 42; }
31   };
32
33   void test(Parent *a) {
34     Child *b = reinterpret_cast<Child *>(a);
35     if (!b) return;
36     clang_analyzer_eval(b->foo() == 42); // expected-warning{{UNKNOWN}}
37   }
38 }