diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-08-04 12:34:30 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-08-04 12:34:30 +0000 |
commit | efe283dc5a615f582e98b9a9bf37ab546e3854b0 (patch) | |
tree | 84a7268017e2c01e78325f6495709a22d62fd7fe /lib/CodeGen/CGCleanup.cpp | |
parent | e7406a25aa29fa53623b15ad41c195ce46727427 (diff) |
[CodeGen] Don't write into a SmallVector's uninitialized memory.
That's just ugly and not needed in this case. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCleanup.cpp')
-rw-r--r-- | lib/CodeGen/CGCleanup.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp index ef5a98ead9..5666a689af 100644 --- a/lib/CodeGen/CGCleanup.cpp +++ b/lib/CodeGen/CGCleanup.cpp @@ -685,13 +685,10 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // Copy the cleanup emission data out. Note that SmallVector // guarantees maximal alignment for its buffer regardless of its // type parameter. - SmallVector<char, 8*sizeof(void*)> CleanupBuffer; - CleanupBuffer.reserve(Scope.getCleanupSize()); - memcpy(CleanupBuffer.data(), - Scope.getCleanupBuffer(), Scope.getCleanupSize()); - CleanupBuffer.set_size(Scope.getCleanupSize()); - EHScopeStack::Cleanup *Fn = - reinterpret_cast<EHScopeStack::Cleanup*>(CleanupBuffer.data()); + auto *CleanupSource = reinterpret_cast<char *>(Scope.getCleanupBuffer()); + SmallVector<char, 8 * sizeof(void *)> CleanupBuffer( + CleanupSource, CleanupSource + Scope.getCleanupSize()); + auto *Fn = reinterpret_cast<EHScopeStack::Cleanup *>(CleanupBuffer.data()); EHScopeStack::Cleanup::Flags cleanupFlags; if (Scope.isNormalCleanup()) |