From f6f8ae561ef78af169cbd2c067cae7ee4b2044e9 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 3 Apr 2009 22:48:58 +0000 Subject: [PATCH] Add a getFunctionInfo that takes a CXXMethodDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68411 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCall.cpp | 17 +++++++++++++++++ lib/CodeGen/CodeGenTypes.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 4db36d9140..19f66b1671 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -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 @@ CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionProtoType *FTP) { return getFunctionInfo(FTP->getResultType(), ArgTys); } +const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) { + llvm::SmallVector 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(FD)) { + if (MD->isInstance()) + return getFunctionInfo(MD); + } + const FunctionType *FTy = FD->getType()->getAsFunctionType(); if (const FunctionProtoType *FTP = dyn_cast(FTy)) return getFunctionInfo(FTP); diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index 813ff8b2a2..33417e5f01 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -32,6 +32,7 @@ namespace llvm { namespace clang { class ABIInfo; class ASTContext; + class CXXMethodDecl; class FieldDecl; class FunctionProtoType; class ObjCInterfaceDecl; @@ -172,6 +173,7 @@ public: 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); -- 2.40.0