From 62a76d0ae349f53d4ebd911412591ec1bb74f4e7 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Fri, 23 Aug 2019 03:24:01 +0000 Subject: [analyzer] CastValueChecker: Provide DynamicTypeMap with pointer types only. The idea to drop this requirement is good, but for now every other user of DynamicTypeInfo expects pointer types. Fixes a crash. llvm-svn: 369728 --- clang/test/Analysis/cast-value-logic.cpp | 8 ++++++++ clang/test/Analysis/cast-value-state-dump.cpp | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'clang/test/Analysis') diff --git a/clang/test/Analysis/cast-value-logic.cpp b/clang/test/Analysis/cast-value-logic.cpp index c5083ef57c9..531772825f9 100644 --- a/clang/test/Analysis/cast-value-logic.cpp +++ b/clang/test/Analysis/cast-value-logic.cpp @@ -15,6 +15,8 @@ struct Shape { template const T *getAs() const; + + virtual double area(); }; class Triangle : public Shape {}; class Circle : public Shape {}; @@ -141,4 +143,10 @@ void test_non_reference_temporary_crash() { auto P = foo(); auto Q = cast(std::move(P)); // no-crash } + +double test_virtual_method_after_call(Shape *S) { + if (isa(S)) + return S->area(); + return S->area() / 2; +} } // namespace crashes diff --git a/clang/test/Analysis/cast-value-state-dump.cpp b/clang/test/Analysis/cast-value-state-dump.cpp index 890fa189335..b8152d46da4 100644 --- a/clang/test/Analysis/cast-value-state-dump.cpp +++ b/clang/test/Analysis/cast-value-state-dump.cpp @@ -35,8 +35,8 @@ void evalNonNullParamNonNullReturn(const Shape *S) { // CHECK-NEXT: ], // CHECK-NEXT: "dynamic_casts": [ // CHECK: { "region": "SymRegion{reg_$0}", "casts": [ - // CHECK-NEXT: { "from": "struct clang::Shape", "to": "class clang::Circle", "kind": "success" }, - // CHECK-NEXT: { "from": "struct clang::Shape", "to": "class clang::Square", "kind": "fail" } + // CHECK-NEXT: { "from": "const struct clang::Shape *", "to": "const class clang::Circle *", "kind": "success" }, + // CHECK-NEXT: { "from": "const struct clang::Shape *", "to": "const class clang::Square *", "kind": "fail" } // CHECK-NEXT: ]} (void)(1 / !C); -- cgit v1.2.3