aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-04 04:23:07 +0000
committerChris Lattner <sabre@nondot.org>2009-03-04 04:23:07 +0000
commit24e1e707b4c362f18e371e2bbf054a8345b57bfa (patch)
tree5489d474d54bca3e549a637ddb1230a0097cf9f2 /lib/AST/Stmt.cpp
parent074dda6d81315d3e1414ce018325c166bcb02028 (diff)
Change Parser::ParseCaseStatement to use an iterative approach to parsing
multiple sequential case statements instead of doing it with recursion. This fixes a problem where we run out of stack space parsing 100K directly nested cases. There are a couple other problems that prevent this from being useful in practice (right now the example only parses correctly with -disable-free and doesn't work with -emit-llvm), but this is a start. I'm not including a testcase because it is large and uninteresting for regtesting. Sebastian, I would appreciate it if you could scrutinize the smart pointer gymnastics I do. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Stmt.cpp')
-rw-r--r--lib/AST/Stmt.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 63d3e7f7b4..749b677d91 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -43,13 +43,12 @@ const char *Stmt::getStmtClassName() const {
return getStmtInfoTableEntry(sClass).Name;
}
-void Stmt::DestroyChildren(ASTContext& C) {
- for (child_iterator I = child_begin(), E = child_end(); I !=E; ) {
+void Stmt::DestroyChildren(ASTContext &C) {
+ for (child_iterator I = child_begin(), E = child_end(); I !=E; )
if (Stmt* Child = *I++) Child->Destroy(C);
- }
}
-void Stmt::Destroy(ASTContext& C) {
+void Stmt::Destroy(ASTContext &C) {
DestroyChildren(C);
// FIXME: Eventually all Stmts should be allocated with the allocator
// in ASTContext, just like with Decls.
@@ -57,7 +56,7 @@ void Stmt::Destroy(ASTContext& C) {
C.Deallocate((void *)this);
}
-void DeclStmt::Destroy(ASTContext& C) {
+void DeclStmt::Destroy(ASTContext &C) {
this->~DeclStmt();
C.Deallocate((void *)this);
}