From 2bc9674b0a1e5c4f64835124eb77da041e0161a2 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 6 Sep 2012 20:37:08 +0000 Subject: [analyzer] Don't attempt to devirtualize calls to base class destructors. CXXDestructorCall now has a flag for when it is a base destructor call. Other kinds of destructor calls (locals, fields, temporaries, and 'delete') all behave as "whole-object" destructors and do not behave differently from one another (specifically, in these cases we /should/ try to devirtualize a call to a virtual destructor). This was causing crashes in both our internal buildbot, the crash still being tracked in PR13765, and some of the crashes being tracked in PR13763, due to a assertion failure. (The behavior under -Asserts happened to be correct anyway.) Adding this knowledge also allows our DynamicTypePropagation checker to do a bit less work; the special rules about virtual method calls during a destructor only require extra handling during base destructors. llvm-svn: 163348 --- clang/test/Analysis/dtor.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'clang/test') diff --git a/clang/test/Analysis/dtor.cpp b/clang/test/Analysis/dtor.cpp index a762ebed122..99c47d59206 100644 --- a/clang/test/Analysis/dtor.cpp +++ b/clang/test/Analysis/dtor.cpp @@ -251,3 +251,33 @@ namespace DestructorsShouldNotAffectReturnValues { free(p); // no-warning } } + +namespace MultipleInheritanceVirtualDtors { + class VirtualDtor { + protected: + virtual ~VirtualDtor() { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + } + }; + + class NonVirtualDtor { + protected: + ~NonVirtualDtor() { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + } + }; + + class SubclassA : public VirtualDtor, public NonVirtualDtor { + public: + virtual ~SubclassA() {} + }; + class SubclassB : public NonVirtualDtor, public VirtualDtor { + public: + virtual ~SubclassB() {} + }; + + void test() { + SubclassA a; + SubclassB b; + } +} -- cgit v1.2.3