diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-04 17:03:41 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-04 17:03:41 +0000 |
commit | e2a929df73cb453504f16d4d5c546052d9a775db (patch) | |
tree | a6be03af8d67a3b6705ab1db5ba39c19c01f5200 /clang/lib/AST/Stmt.cpp | |
parent | 300c063db3ab65134b3de3f3137e9d266343bfcf (diff) | |
download | bcm5719-llvm-e2a929df73cb453504f16d4d5c546052d9a775db.tar.gz bcm5719-llvm-e2a929df73cb453504f16d4d5c546052d9a775db.zip |
Split out the "empty" case for compound statement into a separate ctor.
Move the ASTContext-dependent version out of line.
llvm-svn: 159717
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 97eb4d579e4..b6bb5282204 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -244,6 +244,22 @@ SourceLocation Stmt::getLocEnd() const { llvm_unreachable("unknown statement kind"); } +CompoundStmt::CompoundStmt(ASTContext &C, Stmt **StmtStart, unsigned NumStmts, + SourceLocation LB, SourceLocation RB) + : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) { + CompoundStmtBits.NumStmts = NumStmts; + assert(CompoundStmtBits.NumStmts == NumStmts && + "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!"); + + if (NumStmts == 0) { + Body = 0; + return; + } + + Body = new (C) Stmt*[NumStmts]; + memcpy(Body, StmtStart, NumStmts * sizeof(*Body)); +} + void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { if (this->Body) C.Deallocate(Body); |