]> granicus.if.org Git - clang/commitdiff
Implement the MSABI and SysVABI calling conventions for Objective-C method declaratio...
authorAaron Ballman <aaron@aaronballman.com>
Wed, 18 Dec 2013 16:23:37 +0000 (16:23 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 18 Dec 2013 16:23:37 +0000 (16:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197584 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
test/CodeGenObjC/attr-callconv.m

index 50cbdb1b07171238fa289fafeca848cce1484b08..8cc61e99bf575d6262c13c22ee97e409ba21510d 100644 (file)
@@ -123,7 +123,7 @@ CodeGenTypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> FTP) {
   return ::arrangeFreeFunctionType(*this, argTypes, FTP);
 }
 
-static CallingConv getCallingConventionForDecl(const Decl *D) {
+static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) {
   // Set the appropriate calling convention for the Function.
   if (D->hasAttr<StdCallAttr>())
     return CC_X86StdCall;
@@ -146,6 +146,12 @@ static CallingConv getCallingConventionForDecl(const Decl *D) {
   if (D->hasAttr<IntelOclBiccAttr>())
     return CC_IntelOclBicc;
 
+  if (D->hasAttr<MSABIAttr>())
+    return IsWindows ? CC_C : CC_X86_64Win64;
+
+  if (D->hasAttr<SysVABIAttr>())
+    return IsWindows ? CC_X86_64SysV : CC_C;
+
   return CC_C;
 }
 
@@ -293,7 +299,8 @@ CodeGenTypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
   }
 
   FunctionType::ExtInfo einfo;
-  einfo = einfo.withCallingConv(getCallingConventionForDecl(MD));
+  bool IsWindows = getContext().getTargetInfo().getTriple().isOSWindows();
+  einfo = einfo.withCallingConv(getCallingConventionForDecl(MD, IsWindows));
 
   if (getContext().getLangOpts().ObjCAutoRefCount &&
       MD->hasAttr<NSReturnsRetainedAttr>())
index bfc8a191cdd6ba07980e9fa42bbe64ad84eb6dde..b0a41f74381d448262288a35c0bac602906abfbc 100644 (file)
@@ -5,7 +5,9 @@
 @end
 
 @implementation Test
-- (void)test __attribute__((stdcall)) {
+- (void)test __attribute__((stdcall)) {}
     // CHECK: define{{.*}}x86_stdcallcc{{.*}}Test test
-}
+    
+- (void)test2 __attribute__((ms_abi)) {}
+    // CHECK: define{{.*}}x86_64_win64cc{{.*}}Test test2
 @end