summaryrefslogtreecommitdiffstats
path: root/clang/lib
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
commit8279ceab121d722919a27799db9f584f835484c3 (patch)
tree54baa450b3a925e151b61c7a4c2576697054e489 /clang/lib
parent423bcb53f736cc6250f4106c98d6c1cbe267dd46 (diff)
downloadbcm5719-llvm-8279ceab121d722919a27799db9f584f835484c3.tar.gz
bcm5719-llvm-8279ceab121d722919a27799db9f584f835484c3.zip
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. llvm-svn: 68908
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 278d8ecd901..72611ef08b0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud