diff options
author | Anders Carlsson <andersca@mac.com> | 2010-03-30 03:14:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-03-30 03:14:41 +0000 |
commit | b9fd57f1989ef9343678ba04558c074eabd8f28b (patch) | |
tree | bbd5f30d1f97207e989f6c0ad1db4e3392f246dd /clang/lib/CodeGen/CodeGenFunction.h | |
parent | 10834b8d5689a1ed0c1989295d3f1e8ffa67da4c (diff) | |
download | bcm5719-llvm-b9fd57f1989ef9343678ba04558c074eabd8f28b.tar.gz bcm5719-llvm-b9fd57f1989ef9343678ba04558c074eabd8f28b.zip |
Introduce a CXXTemporariesCleanupScope RAII object and use it to cleanup the temporaries code.
llvm-svn: 99865
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 31ab1011b41..373c46be96e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -254,6 +254,27 @@ public: } }; + /// CXXTemporariesCleanupScope - Enters a new scope for catching live + /// temporaries, all of which will be popped once the scope is exited. + class CXXTemporariesCleanupScope { + CodeGenFunction &CGF; + size_t NumLiveTemporaries; + + // DO NOT IMPLEMENT + CXXTemporariesCleanupScope(const CXXTemporariesCleanupScope &); + CXXTemporariesCleanupScope &operator=(const CXXTemporariesCleanupScope &); + + public: + explicit CXXTemporariesCleanupScope(CodeGenFunction &CGF) + : CGF(CGF), NumLiveTemporaries(CGF.LiveTemporaries.size()) { } + + ~CXXTemporariesCleanupScope() { + while (CGF.LiveTemporaries.size() > NumLiveTemporaries) + CGF.PopCXXTemporary(); + } + }; + + /// EmitCleanupBlocks - Takes the old cleanup stack size and emits the cleanup /// blocks that have been added. void EmitCleanupBlocks(size_t OldCleanupStackSize); |