From: Ted Kremenek Date: Thu, 3 Mar 2011 01:01:03 +0000 (+0000) Subject: Teach CFGImplicitDtor::getDestructorDecl() about reference types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=697d42db6cba7a5994d955ce31be2c097902cf0c;p=clang Teach CFGImplicitDtor::getDestructorDecl() about reference types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126909 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index c433639ec1..fc50071a32 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -2782,9 +2782,10 @@ const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const { case CFGElement::AutomaticObjectDtor: { const VarDecl *var = cast(this)->getVarDecl(); QualType ty = var->getType(); + ty = ty.getNonReferenceType(); const RecordType *recordType = ty->getAs(); const CXXRecordDecl *classDecl = - cast(recordType->getDecl()); + cast(recordType->getDecl()); return classDecl->getDestructor(); } case CFGElement::TemporaryDtor: { @@ -2799,7 +2800,7 @@ const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const { // Not yet supported. return 0; } - assert(0 && "getKind() returned bogus value"); + llvm_unreachable("getKind() returned bogus value"); return 0; } diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp index 890fb9017c..4fb3732201 100644 --- a/test/SemaCXX/return-noreturn.cpp +++ b/test/SemaCXX/return-noreturn.cpp @@ -27,3 +27,15 @@ int pr6884_h(int x) { } } } + +// PR9380 +struct PR9380 { + ~PR9380(); +}; +struct PR9380_B : public PR9380 { + PR9380_B( const PR9380& str ); +}; +void test_PR9380(const PR9380& aKey) { + const PR9380& flatKey = PR9380_B(aKey); +} +