aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-03-27 21:26:48 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-03-27 21:26:48 +0000
commit1d71cbf21ad8882192d0d88a76f0243b7cf490c9 (patch)
tree816d82833778c911ff542bad434eff0ebbcc8841
parent5b8e0d80dcebd5946f36c1a1b25431616a5735bb (diff)
Reduce indentation using early exits and add a couple of comments. No
functionality changed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128396 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 07d60caf43..ee7e447641 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -6091,24 +6091,29 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD,
}
void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
- CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl());
- if (!ClassDecl->isInvalidDecl() && !VD->isInvalidDecl() &&
- !ClassDecl->hasTrivialDestructor() && !ClassDecl->isDependentContext()) {
- CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
- MarkDeclarationReferenced(VD->getLocation(), Destructor);
- CheckDestructorAccess(VD->getLocation(), Destructor,
- PDiag(diag::err_access_dtor_var)
- << VD->getDeclName()
- << VD->getType());
-
- if (!VD->isInvalidDecl() && VD->hasGlobalStorage()) {
- // TODO: this should be re-enabled for static locals by !CXAAtExit
- if (!VD->isStaticLocal())
- Diag(VD->getLocation(), diag::warn_global_destructor);
+ if (VD->isInvalidDecl()) return;
- Diag(VD->getLocation(), diag::warn_exit_time_destructor);
- }
- }
+ CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl());
+ if (ClassDecl->isInvalidDecl()) return;
+ if (ClassDecl->hasTrivialDestructor()) return;
+ if (ClassDecl->isDependentContext()) return;
+
+ CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
+ MarkDeclarationReferenced(VD->getLocation(), Destructor);
+ CheckDestructorAccess(VD->getLocation(), Destructor,
+ PDiag(diag::err_access_dtor_var)
+ << VD->getDeclName()
+ << VD->getType());
+
+ 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