From 02e5309b3502082399f0c5f616f7ce3f8ee57f28 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 10 Aug 2012 22:26:46 +0000 Subject: [analyzer] Strip CXXBaseObjectRegions when devirtualizing method calls. This was causing a crash when we tried to re-apply a base object region to itself. It probably also caused incorrect offset calculations in RegionStore. PR13569 / llvm-svn: 161710 --- clang/test/Analysis/inline.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'clang/test/Analysis/inline.cpp') diff --git a/clang/test/Analysis/inline.cpp b/clang/test/Analysis/inline.cpp index 4298e1aac82..9a867849e5c 100644 --- a/clang/test/Analysis/inline.cpp +++ b/clang/test/Analysis/inline.cpp @@ -71,3 +71,41 @@ namespace PureVirtualParent { } +namespace PR13569 { + class Parent { + protected: + int m_parent; + virtual int impl() const = 0; + + Parent() : m_parent(0) {} + + public: + int interface() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return impl(); + } + }; + + class Child : public Parent { + protected: + virtual int impl() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return m_parent + m_child; + } + + public: + Child() : m_child(0) {} + + int m_child; + }; + + void testVirtual() { + Child x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } +} + + -- cgit v1.2.3