diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-14 12:06:21 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-14 12:06:21 +0000 |
| commit | 8001f7467a0bb00c009d209afdd864153ab71b75 (patch) | |
| tree | 4e328390feb8e92f3a43dd1abac789ced0dbc3bd /clang/lib/CodeGen/CGExprConstant.cpp | |
| parent | 0e3791efd14092b194e42ae0a384d0b6a065c26b (diff) | |
| download | bcm5719-llvm-8001f7467a0bb00c009d209afdd864153ab71b75.tar.gz bcm5719-llvm-8001f7467a0bb00c009d209afdd864153ab71b75.zip | |
Use a simpler (and more efficient) pattern to pad vectors.
llvm-svn: 150475
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 0b3ac9cbe5c..44531c0992c 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -701,9 +701,9 @@ public: // Copy initializer elements. std::vector<llvm::Constant*> Elts; Elts.reserve(NumInitableElts + NumElements); - unsigned i = 0; + bool RewriteType = false; - for (; i < NumInitableElts; ++i) { + for (unsigned i = 0; i < NumInitableElts; ++i) { Expr *Init = ILE->getInit(i); llvm::Constant *C = CGM.EmitConstantExpr(Init, Init->getType(), CGF); if (!C) @@ -722,8 +722,7 @@ public: if (!fillC) return 0; RewriteType |= (fillC->getType() != ElemTy); - for (; i < NumElements; ++i) - Elts.push_back(fillC); + Elts.resize(NumElements, fillC); if (RewriteType) { // FIXME: Try to avoid packing the array |

