[cfe-commits] r68908 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Sun Apr 12 13:09:42 PDT 2009
Author: lattner
Date: Sun Apr 12 15:09:42 2009
New Revision: 68908
URL: http://llvm.org/viewvc/llvm-project?rev=68908&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=68908&r1=68907&r2=68908&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Apr 12 15:09:42 2009
@@ -2865,22 +2865,25 @@
}
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,
More information about the cfe-commits
mailing list