diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 931c058670b..4552d544b9c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3982,13 +3982,12 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD, return false; } -void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType) { - CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>( - DeclInitType->getAs<RecordType>()->getDecl()); +void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { + CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl()); if (!ClassDecl->hasTrivialDestructor()) { CXXDestructorDecl *Destructor = ClassDecl->getDestructor(Context); MarkDeclarationReferenced(VD->getLocation(), Destructor); - CheckDestructorAccess(VD->getLocation(), VD->getType()); + CheckDestructorAccess(VD->getLocation(), Record); } } @@ -4093,8 +4092,8 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, VDecl->setInit(Context, Result.takeAs<Expr>()); VDecl->setCXXDirectInitializer(true); - if (VDecl->getType()->getAs<RecordType>()) - FinalizeVarWithDestructor(VDecl, DeclInitType); + if (const RecordType *Record = VDecl->getType()->getAs<RecordType>()) + FinalizeVarWithDestructor(VDecl, Record); } /// \brief Add the applicable constructor candidates for an initialization |