diff options
author | Anders Carlsson <andersca@mac.com> | 2009-04-03 22:48:58 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-04-03 22:48:58 +0000 |
commit | b15b55c2d07d8394b157edef4e140833e9db7ba5 (patch) | |
tree | 5e99a3d742ce5801aef598df4b2972b00c0661d4 /clang/lib/CodeGen | |
parent | f69985511dd52ea0a53b57ec52f2be08284bc7a9 (diff) | |
download | bcm5719-llvm-b15b55c2d07d8394b157edef4e140833e9db7ba5.tar.gz bcm5719-llvm-b15b55c2d07d8394b157edef4e140833e9db7ba5.zip |
Add a getFunctionInfo that takes a CXXMethodDecl.
llvm-svn: 68411
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 17 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4db36d9140c..19f66b16715 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/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<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); diff --git a/clang/lib/CodeGen/CodeGenTypes.h b/clang/lib/CodeGen/CodeGenTypes.h index 813ff8b2a2c..33417e5f01b 100644 --- a/clang/lib/CodeGen/CodeGenTypes.h +++ b/clang/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); |