diff options
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index a060be11371..10434463b88 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -731,30 +731,29 @@ void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr, assert(NumAsmToks == asmtoks.size()); assert(NumClobbers == clobbers.size()); - unsigned NumExprs = exprs.size(); - assert(NumExprs == NumOutputs + NumInputs); - assert(NumExprs == constraints.size()); + assert(exprs.size() == NumOutputs + NumInputs); + assert(exprs.size() == constraints.size()); AsmStr = copyIntoContext(C, asmstr); - Exprs = new (C) Stmt*[NumExprs]; - for (unsigned i = 0, e = NumExprs; i != e; ++i) - Exprs[i] = exprs[i]; + Exprs = new (C) Stmt*[exprs.size()]; + std::copy(exprs.begin(), exprs.end(), Exprs); - AsmToks = new (C) Token[NumAsmToks]; - for (unsigned i = 0, e = NumAsmToks; i != e; ++i) - AsmToks[i] = asmtoks[i]; + AsmToks = new (C) Token[asmtoks.size()]; + std::copy(asmtoks.begin(), asmtoks.end(), AsmToks); - Constraints = new (C) StringRef[NumExprs]; - for (unsigned i = 0, e = NumExprs; i != e; ++i) { - Constraints[i] = copyIntoContext(C, constraints[i]); - } + Constraints = new (C) StringRef[exprs.size()]; + std::transform(constraints.begin(), constraints.end(), Constraints, + [&](StringRef Constraint) { + return copyIntoContext(C, Constraint); + }); Clobbers = new (C) StringRef[NumClobbers]; - for (unsigned i = 0, e = NumClobbers; i != e; ++i) { - // FIXME: Avoid the allocation/copy if at all possible. - Clobbers[i] = copyIntoContext(C, clobbers[i]); - } + // FIXME: Avoid the allocation/copy if at all possible. + std::transform(clobbers.begin(), clobbers.end(), Clobbers, + [&](StringRef Clobber) { + return copyIntoContext(C, Clobber); + }); } IfStmt::IfStmt(const ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, |