dyn-dispatch-bifurcate.cpp revision fbc4444eb2675934b44f3720ef9a5f368ecbeb0a
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s
2
3void clang_analyzer_eval(bool);
4
5class A {
6public:
7  virtual int get() { return 0; }
8};
9
10void testBifurcation(A *a) {
11  clang_analyzer_eval(a->get() == 0); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
12}
13
14void testKnown() {
15  A a;
16  clang_analyzer_eval(a.get() == 0); // expected-warning{{TRUE}}
17}
18
19void testNew() {
20  A *a = new A();
21  clang_analyzer_eval(a->get() == 0); // expected-warning{{TRUE}}
22}
23
24
25namespace 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}
39