]> granicus.if.org Git - clang/commitdiff
Move code generation of C++ temporaries into a new file.
authorAnders Carlsson <andersca@mac.com>
Wed, 3 Jun 2009 18:40:21 +0000 (18:40 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 3 Jun 2009 18:40:21 +0000 (18:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72792 91177308-0d34-0410-b5e6-96231b3b80d8

clang.xcodeproj/project.pbxproj
lib/CodeGen/CGCXX.cpp
lib/CodeGen/CGCXXTemp.cpp [new file with mode: 0644]

index c0ccb2e79733ee4a86c3c89c9497f6bfafc1d094..9cb1c5fa47b15c852a0ccd54bf2295d669d47106 100644 (file)
@@ -33,6 +33,7 @@
                1A471AB50F437BC500753CE8 /* CGBlocks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A471AB40F437BC500753CE8 /* CGBlocks.cpp */; };
                1A5119C40FBDF71000A1FF22 /* SemaTemplateInstantiateStmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5119C30FBDF71000A1FF22 /* SemaTemplateInstantiateStmt.cpp */; };
                1A5D5E580E5E81010023C059 /* CGCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5D5E570E5E81010023C059 /* CGCXX.cpp */; };
+               1A6FE7090FD6F85800E00CA9 /* CGCXXTemp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FE7080FD6F85800E00CA9 /* CGCXXTemp.cpp */; };
                1A701B640F7C8FE400FEC4D1 /* SemaAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A701B630F7C8FE400FEC4D1 /* SemaAccess.cpp */; };
                1A7342480C7B57D500122F56 /* CGObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7342470C7B57D500122F56 /* CGObjC.cpp */; };
                1A869A700BA2164C008DA07A /* LiteralSupport.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A869A6E0BA2164C008DA07A /* LiteralSupport.h */; };
                1A68BC110D0CADDD001A28C8 /* PPCBuiltins.def */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; name = PPCBuiltins.def; path = clang/AST/PPCBuiltins.def; sourceTree = "<group>"; tabWidth = 2; };
                1A68BC120D0CADDD001A28C8 /* TargetBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = TargetBuiltins.h; path = clang/AST/TargetBuiltins.h; sourceTree = "<group>"; tabWidth = 2; };
                1A68BC130D0CADDD001A28C8 /* X86Builtins.def */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = text; name = X86Builtins.def; path = clang/AST/X86Builtins.def; sourceTree = "<group>"; tabWidth = 2; };
+               1A6FE7080FD6F85800E00CA9 /* CGCXXTemp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGCXXTemp.cpp; path = lib/CodeGen/CGCXXTemp.cpp; sourceTree = "<group>"; };
                1A7019E90F79BC1100FEC4D1 /* DiagnosticAnalysisKinds.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DiagnosticAnalysisKinds.td; sourceTree = "<group>"; };
                1A7019EA0F79BC1100FEC4D1 /* DiagnosticASTKinds.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DiagnosticASTKinds.td; sourceTree = "<group>"; };
                1A7019EB0F79BC1100FEC4D1 /* DiagnosticCommonKinds.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DiagnosticCommonKinds.td; sourceTree = "<group>"; };
                                35475B220E7997680000BFE4 /* CGCall.h */,
                                1A5D5E570E5E81010023C059 /* CGCXX.cpp */,
                                1A649E1E0F9599DA005B965E /* CGCXX.h */,
+                               1A6FE7080FD6F85800E00CA9 /* CGCXXTemp.cpp */,
                                35A3E7000DD3874400757F74 /* CGDebugInfo.cpp */,
                                35A3E7010DD3874400757F74 /* CGDebugInfo.h */,
                                DE4264FB0C113592005A861D /* CGDecl.cpp */,
                                1A2A54C30FD1DD1C00F4CE45 /* RewriteTest.cpp in Sources */,
                                1A2A54C40FD1DD1C00F4CE45 /* StmtXML.cpp in Sources */,
                                1A2A54C50FD1DD1C00F4CE45 /* Warnings.cpp in Sources */,
+                               1A6FE7090FD6F85800E00CA9 /* CGCXXTemp.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 731e38c5146d061b460e157f4af097926f3f8f42..4f9a4caee69520116f39b64b61ca9876f2c171b1 100644 (file)
@@ -189,43 +189,6 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
                          E->arg_begin(), E->arg_end());
 }
 
-void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary, 
-                                       llvm::Value *Ptr) {
-  LiveTemporaries.push_back(Temporary);
-  
-  // Make a cleanup scope and emit the destructor.
-  {
-    CleanupScope Scope(*this);
-   
-    EmitCXXDestructorCall(Temporary->getDestructor(), Dtor_Complete, Ptr);
-  }
-}
-
-RValue 
-CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
-                                            llvm::Value *AggLoc,
-                                            bool isAggLocVolatile) {
-  // Keep track of the current cleanup stack depth.
-  size_t CleanupStackDepth = CleanupEntries.size();
-
-  unsigned OldNumLiveTemporaries = LiveTemporaries.size();
-  
-  RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile);
-  
-  // Go through the temporaries backwards.
-  for (unsigned i = E->getNumTemporaries(); i != 0; --i) {
-    assert(LiveTemporaries.back() == E->getTemporary(i - 1));
-    LiveTemporaries.pop_back();
-  }
-
-  assert(OldNumLiveTemporaries == LiveTemporaries.size() &&
-         "Live temporary stack mismatch!");
-  
-  EmitCleanupBlocks(CleanupStackDepth);
-
-  return RV;
-}
-
 llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
   if (E->isArray()) {
     ErrorUnsupported(E, "new[] expression");
diff --git a/lib/CodeGen/CGCXXTemp.cpp b/lib/CodeGen/CGCXXTemp.cpp
new file mode 100644 (file)
index 0000000..4511078
--- /dev/null
@@ -0,0 +1,53 @@
+//===--- CGCXXTemp.cpp - Emit LLVM Code for C++ temporaries ---------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This contains code dealing with C++ code generation of temporaries
+//
+//===----------------------------------------------------------------------===//
+
+#include "CodeGenFunction.h"
+using namespace clang;
+using namespace CodeGen;
+
+void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary, 
+                                       llvm::Value *Ptr) {
+  LiveTemporaries.push_back(Temporary);
+  
+  // Make a cleanup scope and emit the destructor.
+  {
+    CleanupScope Scope(*this);
+   
+    EmitCXXDestructorCall(Temporary->getDestructor(), Dtor_Complete, Ptr);
+  }
+}
+
+RValue 
+CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
+                                            llvm::Value *AggLoc,
+                                            bool isAggLocVolatile) {
+  // Keep track of the current cleanup stack depth.
+  size_t CleanupStackDepth = CleanupEntries.size();
+
+  unsigned OldNumLiveTemporaries = LiveTemporaries.size();
+  
+  RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile);
+  
+  // Go through the temporaries backwards.
+  for (unsigned i = E->getNumTemporaries(); i != 0; --i) {
+    assert(LiveTemporaries.back() == E->getTemporary(i - 1));
+    LiveTemporaries.pop_back();
+  }
+
+  assert(OldNumLiveTemporaries == LiveTemporaries.size() &&
+         "Live temporary stack mismatch!");
+  
+  EmitCleanupBlocks(CleanupStackDepth);
+
+  return RV;
+}