[cfe-commits] r68411 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CodeGenTypes.h

Anders Carlsson andersca at mac.com
Fri Apr 3 15:48:58 PDT 2009


Author: andersca
Date: Fri Apr  3 17:48:58 2009
New Revision: 68411

URL: http://llvm.org/viewvc/llvm-project?rev=68411&view=rev
Log:
Add a getFunctionInfo that takes a CXXMethodDecl.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=68411&r1=68410&r2=68411&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Apr  3 17:48:58 2009
@@ -18,6 +18,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RecordLayout.h"
 #include "llvm/ADT/StringExtras.h"
@@ -52,7 +53,23 @@
   return getFunctionInfo(FTP->getResultType(), ArgTys);
 }
 
+const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
+  llvm::SmallVector<QualType, 16> ArgTys;
+  // Add the 'this' pointer.
+  ArgTys.push_back(MD->getThisType(Context));
+  
+  const FunctionProtoType *FTP = MD->getType()->getAsFunctionProtoType();
+  for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
+    ArgTys.push_back(FTP->getArgType(i));
+  return getFunctionInfo(FTP->getResultType(), ArgTys);
+}
+
 const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
+  if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+    if (MD->isInstance())
+      return getFunctionInfo(MD);
+  }
+  
   const FunctionType *FTy = FD->getType()->getAsFunctionType();
   if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FTy))
     return getFunctionInfo(FTP);

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=68411&r1=68410&r2=68411&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Fri Apr  3 17:48:58 2009
@@ -32,6 +32,7 @@
 namespace clang {
   class ABIInfo;
   class ASTContext;
+  class CXXMethodDecl;
   class FieldDecl;
   class FunctionProtoType;
   class ObjCInterfaceDecl;
@@ -172,6 +173,7 @@
   const CGFunctionInfo &getFunctionInfo(const FunctionNoProtoType *FTNP);
   const CGFunctionInfo &getFunctionInfo(const FunctionProtoType *FTP);
   const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
+  const CGFunctionInfo &getFunctionInfo(const CXXMethodDecl *MD);
   const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);
   const CGFunctionInfo &getFunctionInfo(QualType ResTy, 
                                         const CallArgList &Args);





More information about the cfe-commits mailing list