Reduce indentation using early exits and add a couple of comments. No

functionality changed.

llvm-svn: 128396
This commit is contained in:
Chandler Carruth 2011-03-27 21:26:48 +00:00
parent 82701204a4
commit 86d17d3f76
1 changed files with 20 additions and 15 deletions

View File

@ -6091,24 +6091,29 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD,
} }
void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
if (VD->isInvalidDecl()) return;
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl()); CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl());
if (!ClassDecl->isInvalidDecl() && !VD->isInvalidDecl() && if (ClassDecl->isInvalidDecl()) return;
!ClassDecl->hasTrivialDestructor() && !ClassDecl->isDependentContext()) { if (ClassDecl->hasTrivialDestructor()) return;
CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl); if (ClassDecl->isDependentContext()) return;
MarkDeclarationReferenced(VD->getLocation(), Destructor);
CheckDestructorAccess(VD->getLocation(), Destructor,
PDiag(diag::err_access_dtor_var)
<< VD->getDeclName()
<< VD->getType());
if (!VD->isInvalidDecl() && VD->hasGlobalStorage()) { CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
// TODO: this should be re-enabled for static locals by !CXAAtExit MarkDeclarationReferenced(VD->getLocation(), Destructor);
if (!VD->isStaticLocal()) CheckDestructorAccess(VD->getLocation(), Destructor,
Diag(VD->getLocation(), diag::warn_global_destructor); PDiag(diag::err_access_dtor_var)
<< VD->getDeclName()
<< VD->getType());
Diag(VD->getLocation(), diag::warn_exit_time_destructor); if (!VD->hasGlobalStorage()) return;
}
} // Emit warning for non-trivial dtor in global scope (a real global,
// class-static, function-static).
Diag(VD->getLocation(), diag::warn_exit_time_destructor);
// TODO: this should be re-enabled for static locals by !CXAAtExit
if (!VD->isStaticLocal())
Diag(VD->getLocation(), diag::warn_global_destructor);
} }
/// AddCXXDirectInitializerToDecl - This action is called immediately after /// AddCXXDirectInitializerToDecl - This action is called immediately after