]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/CodeGen/CGTemporaries.cpp
Upgrade of base gcc and libstdc++ to the last GPLv2-licensed revision
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / CodeGen / CGTemporaries.cpp
1 //===--- CGTemporaries.cpp - Emit LLVM Code for C++ temporaries -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This contains code dealing with C++ code generation of temporaries
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "CodeGenFunction.h"
15 using namespace clang;
16 using namespace CodeGen;
17
18 namespace {
19   struct DestroyTemporary {
20     static void Emit(CodeGenFunction &CGF, bool forEH,
21                      const CXXDestructorDecl *dtor, llvm::Value *addr) {
22       CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*ForVirtualBase=*/false,
23                                 addr);
24     }
25   };
26 }
27
28 /// Emits all the code to cause the given temporary to be cleaned up.
29 void CodeGenFunction::EmitCXXTemporary(const CXXTemporary *Temporary,
30                                        llvm::Value *Ptr) {
31   pushFullExprCleanup<DestroyTemporary>(NormalAndEHCleanup,
32                                         Temporary->getDestructor(),
33                                         Ptr);
34 }
35
36 RValue
37 CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
38                                       AggValueSlot Slot) {
39   RunCleanupsScope Scope(*this);
40   return EmitAnyExpr(E->getSubExpr(), Slot);
41 }
42
43 LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
44   RunCleanupsScope Scope(*this);
45   return EmitLValue(E->getSubExpr());
46 }