]> granicus.if.org Git - clang/commitdiff
[analyzer] Re-add reinterpret_cast virtual call test case from r163644.
authorJordan Rose <jordan_rose@apple.com>
Wed, 12 Sep 2012 21:50:56 +0000 (21:50 +0000)
committerJordan Rose <jordan_rose@apple.com>
Wed, 12 Sep 2012 21:50:56 +0000 (21:50 +0000)
We mostly just don't want to crash analyzing this test case; it's likely
the code found here will actually crash if compiled and run.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163746 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/inlining/dyn-dispatch-bifurcate.cpp

index fa473aebce324f7cbf069d7ff201caf3699c2b85..37713481a48daad905d51d962c57016cd654ab58 100644 (file)
@@ -15,3 +15,19 @@ void testKnown() {
   A a;
   clang_analyzer_eval(a.get() == 0); // expected-warning{{TRUE}}
 }
+
+
+namespace ReinterpretDisruptsDynamicTypeInfo {
+  class Parent {};
+
+  class Child : public Parent {
+  public:
+    virtual int foo() { return 42; }
+  };
+
+  void test(Parent *a) {
+    Child *b = reinterpret_cast<Child *>(a);
+    if (!b) return;
+    clang_analyzer_eval(b->foo() == 42); // expected-warning{{UNKNOWN}}
+  }
+}