diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-01-30 23:19:41 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-01-30 23:19:41 +0000 |
| commit | 98323d29b6175cb1739506624542c8f642547c01 (patch) | |
| tree | 36ac327d4f03d94b16c47e1036e1c548b00f388d /clang/lib | |
| parent | 9a020f9a3aa84b385e144badc249ec9329d939a7 (diff) | |
| download | bcm5719-llvm-98323d29b6175cb1739506624542c8f642547c01.tar.gz bcm5719-llvm-98323d29b6175cb1739506624542c8f642547c01.zip | |
Remove the SmallVectors from AsmStmt. Fixes PR6105.
llvm-svn: 94926
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Stmt.cpp | 70 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 6 |
2 files changed, 52 insertions, 24 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index c2c2f0a4096..26121e24855 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -167,16 +167,25 @@ void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, unsigned NumClobbers) { this->NumOutputs = NumOutputs; this->NumInputs = NumInputs; - this->Names.clear(); - this->Names.insert(this->Names.end(), Names, Names + NumOutputs + NumInputs); - this->Constraints.clear(); - this->Constraints.insert(this->Constraints.end(), - Constraints, Constraints + NumOutputs + NumInputs); - this->Exprs.clear(); - this->Exprs.insert(this->Exprs.end(), Exprs, Exprs + NumOutputs + NumInputs); + this->NumClobbers = NumClobbers; + + unsigned NumExprs = NumOutputs + NumInputs; + + C.Deallocate(this->Names); + this->Names = new (C) IdentifierInfo*[NumExprs]; + std::copy(Names, Names + NumExprs, this->Names); + + C.Deallocate(this->Exprs); + this->Exprs = new (C) Stmt*[NumExprs]; + std::copy(Exprs, Exprs + NumExprs, this->Exprs); + + C.Deallocate(this->Constraints); + this->Constraints = new (C) StringLiteral*[NumExprs]; + std::copy(Constraints, Constraints + NumExprs, this->Constraints); - this->Clobbers.clear(); - this->Clobbers.insert(this->Clobbers.end(), Clobbers, Clobbers + NumClobbers); + C.Deallocate(this->Clobbers); + this->Clobbers = new (C) StringLiteral*[NumClobbers]; + std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers); } /// getNamedOperand - Given a symbolic operand reference like %[foo], @@ -333,22 +342,29 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces, // Constructors //===----------------------------------------------------------------------===// -AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, - bool msasm, unsigned numoutputs, unsigned numinputs, +AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, + bool isvolatile, bool msasm, + unsigned numoutputs, unsigned numinputs, IdentifierInfo **names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, SourceLocation rparenloc) : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr) , IsSimple(issimple), IsVolatile(isvolatile), MSAsm(msasm) - , NumOutputs(numoutputs), NumInputs(numinputs) { - for (unsigned i = 0, e = numinputs + numoutputs; i != e; i++) { - Names.push_back(names[i]); - Exprs.push_back(exprs[i]); - Constraints.push_back(constraints[i]); - } + , NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) { + + unsigned NumExprs = NumOutputs +NumInputs; + + Names = new (C) IdentifierInfo*[NumExprs]; + std::copy(names, names + NumExprs, Names); + + Exprs = new (C) Stmt*[NumExprs]; + std::copy(exprs, exprs + NumExprs, Exprs); + + Constraints = new (C) StringLiteral*[NumExprs]; + std::copy(constraints, constraints + NumExprs, Constraints); - for (unsigned i = 0; i != numclobbers; i++) - Clobbers.push_back(clobbers[i]); + Clobbers = new (C) StringLiteral*[NumClobbers]; + std::copy(clobbers, clobbers + NumClobbers, Clobbers); } ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, @@ -450,6 +466,18 @@ void WhileStmt::DoDestroy(ASTContext &C) { BranchDestroy(C, this, SubExprs, END_EXPR); } +void AsmStmt::DoDestroy(ASTContext &C) { + DestroyChildren(C); + + C.Deallocate(Names); + C.Deallocate(Constraints); + C.Deallocate(Exprs); + C.Deallocate(Clobbers); + + this->~Stmt(); + C.Deallocate((void *)this); +} + //===----------------------------------------------------------------------===// // Child Iterators for iterating over subexpressions/substatements //===----------------------------------------------------------------------===// @@ -563,10 +591,10 @@ Stmt::child_iterator ReturnStmt::child_end() { // AsmStmt Stmt::child_iterator AsmStmt::child_begin() { - return Exprs.empty() ? 0 : &Exprs[0]; + return NumOutputs + NumInputs == 0 ? 0 : &Exprs[0]; } Stmt::child_iterator AsmStmt::child_end() { - return Exprs.empty() ? 0 : &Exprs[0] + Exprs.size(); + return NumOutputs + NumInputs == 0 ? 0 : &Exprs[0] + NumOutputs + NumInputs; } // ObjCAtCatchStmt diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index fc0fc4f9b24..7fefcf2764d 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -1282,9 +1282,9 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, asmString.release(); clobbers.release(); AsmStmt *NS = - new (Context) AsmStmt(AsmLoc, IsSimple, IsVolatile, MSAsm, NumOutputs, - NumInputs, Names, Constraints, Exprs, AsmString, - NumClobbers, Clobbers, RParenLoc); + new (Context) AsmStmt(Context, AsmLoc, IsSimple, IsVolatile, MSAsm, + NumOutputs, NumInputs, Names, Constraints, Exprs, + AsmString, NumClobbers, Clobbers, RParenLoc); // Validate the asm string, ensuring it makes sense given the operands we // have. llvm::SmallVector<AsmStmt::AsmStringPiece, 8> Pieces; |

