aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-12 20:09:42 +0000
committerChris Lattner <sabre@nondot.org>2009-04-12 20:09:42 +0000
commitbfc861e703895cc6d1ec2403dfebf68b90ae0992 (patch)
tree9f25c01e9c91e6470e0bba6c4fac86bf0a0d9c83 /lib/Sema/SemaDecl.cpp
parent115cafcafec3572756635ca81ef83999ae0c8af7 (diff)
a few cleanups to StatementCreatesScope: unnest the whole thing,
exit at the first decl found that creates a scope, don't evaluate decl_end() every iteration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 278d8ecd90..72611ef08b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2865,22 +2865,25 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
}
static bool StatementCreatesScope(Stmt* S) {
- bool result = false;
- if (DeclStmt* DS = dyn_cast<DeclStmt>(S)) {
- for (DeclStmt::decl_iterator i = DS->decl_begin();
- i != DS->decl_end(); ++i) {
- if (VarDecl* D = dyn_cast<VarDecl>(*i)) {
- result |= D->getType()->isVariablyModifiedType();
- result |= !!D->getAttr<CleanupAttr>();
- } else if (TypedefDecl* D = dyn_cast<TypedefDecl>(*i)) {
- result |= D->getUnderlyingType()->isVariablyModifiedType();
- }
+ DeclStmt *DS = dyn_cast<DeclStmt>(S);
+ if (DS == 0) return false;
+
+ for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
+ I != E; ++I) {
+ if (VarDecl *D = dyn_cast<VarDecl>(*I)) {
+ if (D->getType()->isVariablyModifiedType() ||
+ D->hasAttr<CleanupAttr>())
+ return true;
+ } else if (TypedefDecl *D = dyn_cast<TypedefDecl>(*I)) {
+ if (D->getUnderlyingType()->isVariablyModifiedType())
+ return true;
}
}
-
- return result;
+
+ return false;
}
+
void Sema::RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
std::vector<void*>& ScopeStack,