[cfe-commits] r39625 - in /cfe/cfe/trunk/CodeGen: CodeGenFunction.cpp CodeGenFunction.h

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:46:23 PDT 2007


Author: clattner
Date: Wed Jul 11 11:46:22 2007
New Revision: 39625

URL: http://llvm.org/viewvc/llvm-project?rev=39625&view=rev
Log:
Convert argument types over, which works for trivial scalars.

Modified:
    cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp
    cfe/cfe/trunk/CodeGen/CodeGenFunction.h

Modified: cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp?rev=39625&r1=39624&r2=39625&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp Wed Jul 11 11:46:22 2007
@@ -121,11 +121,16 @@
       ResultType = ConvertType(FP.getResultType(), Loc);
     
     // FIXME: Convert argument types.
+    bool isVarArg;
+    std::vector<const llvm::Type*> ArgTys;
+    if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(&FP)) {
+      DecodeArgumentTypes(*FTP, ArgTys, Loc);
+      isVarArg = FTP->isVariadic();
+    } else {
+      isVarArg = true;
+    }
     
-    return llvm::FunctionType::get(ResultType,
-                                   std::vector<const llvm::Type*>(),
-                                   false,
-                                   0);
+    return llvm::FunctionType::get(ResultType, ArgTys, isVarArg, 0);
   }
   case Type::TypeName:
   case Type::Tagged:
@@ -136,6 +141,12 @@
   return OpaqueType::get();
 }
 
+void  CodeGenFunction::DecodeArgumentTypes(const FunctionTypeProto &FTP, 
+                                           std::vector<const llvm::Type*> &
+                                           ArgTys, SourceLocation Loc) {
+  for (unsigned i = 0, e = FTP.getNumArgs(); i != e; ++i)
+    ArgTys.push_back(ConvertType(FTP.getArgType(i), Loc));
+}
 
 void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
   LLVMIntTy = ConvertType(getContext().IntTy, FD->getLocation());

Modified: cfe/cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CodeGenFunction.h?rev=39625&r1=39624&r2=39625&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/cfe/trunk/CodeGen/CodeGenFunction.h Wed Jul 11 11:46:22 2007
@@ -16,16 +16,18 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/LLVMBuilder.h"
+#include <vector>
 
 namespace llvm {
   class Module;
 namespace clang {
+  class SourceLocation;
+  class TargetInfo;
   class ASTContext;
   class Decl;
   class FunctionDecl;
   class QualType;
-  class SourceLocation;
-  class TargetInfo;
+  class FunctionTypeProto;
   
   class Stmt;
   class CompoundStmt;
@@ -142,6 +144,9 @@
   ASTContext &getContext() const;
 
   const llvm::Type *ConvertType(QualType T, SourceLocation Loc);
+  void DecodeArgumentTypes(const FunctionTypeProto &FTP, 
+                           std::vector<const llvm::Type*> &ArgTys,
+                           SourceLocation Loc);
   
   void GenerateCode(const FunctionDecl *FD);
   





More information about the cfe-commits mailing list