From: Saleem Abdulrasool Date: Sat, 28 Oct 2017 06:00:43 +0000 (+0000) Subject: Basic: improve coverage for Darwin targets and fix ABI X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fd1377b9138ac71f8aca6e8251c655caf549406;p=clang Basic: improve coverage for Darwin targets and fix ABI The existing coverage for the Darwin targets wasn't enough to catch all the variations. Improve the coverage a bit further and fix a few cases for Darwin targets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316826 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets/ARM.cpp b/lib/Basic/Targets/ARM.cpp index bbbe75b483..def490b99f 100644 --- a/lib/Basic/Targets/ARM.cpp +++ b/lib/Basic/Targets/ARM.cpp @@ -214,18 +214,23 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple, bool IsOpenBSD = Triple.getOS() == llvm::Triple::OpenBSD; bool IsNetBSD = Triple.getOS() == llvm::Triple::NetBSD; - PtrDiffType = IntPtrType = - (Triple.isOSDarwin() || IsOpenBSD || IsNetBSD) ? SignedLong : SignedInt; - // FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like // environment where size_t is `unsigned long` rather than `unsigned int` + + PtrDiffType = IntPtrType = + (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD || + IsNetBSD) + ? SignedLong + : SignedInt; + SizeType = (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD || IsNetBSD) ? UnsignedLong : UnsignedInt; // ptrdiff_t is inconsistent on Darwin - if (Triple.isOSDarwin() && !Triple.isWatchABI()) + if ((Triple.isOSDarwin() || Triple.isOSBinFormatMachO()) && + !Triple.isWatchABI()) PtrDiffType = SignedInt; // Cache arch related info. diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 228ae2d701..87a591923b 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -9925,3 +9925,65 @@ // RUN: | FileCheck -check-prefix=DARWIN %s // DARWIN:#define __STDC_NO_THREADS__ 1 + +// RUN: %clang_cc1 -triple i386-apple-macosx -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix MACOS-32 %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix MACOS-64 %s + +// MACOS-32: #define __INTPTR_TYPE__ long int +// MACOS-32: #define __PTRDIFF_TYPE__ int +// MACOS-32: #define __SIZE_TYPE__ long unsigned int + +// MACOS-64: #define __INTPTR_TYPE__ long int +// MACOS-64: #define __PTRDIFF_TYPE__ long int +// MACOS-64: #define __SIZE_TYPE__ long unsigned int + +// RUN: %clang_cc1 -triple i386-apple-ios-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-32 %s +// RUN: %clang_cc1 -triple armv7-apple-ios -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-32 %s +// RUN: %clang_cc1 -triple x86_64-apple-ios-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-64 %s +// RUN: %clang_cc1 -triple arm64-apple-ios -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-64 %s + +// IOS-32: #define __INTPTR_TYPE__ long int +// IOS-32: #define __PTRDIFF_TYPE__ int +// IOS-32: #define __SIZE_TYPE__ long unsigned int + +// IOS-64: #define __INTPTR_TYPE__ long int +// IOS-64: #define __PTRDIFF_TYPE__ long int +// IOS-64: #define __SIZE_TYPE__ long unsigned int + +// RUN: %clang_cc1 -triple i386-apple-tvos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-32 %s +// RUN: %clang_cc1 -triple armv7-apple-tvos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-32 %s +// RUN: %clang_cc1 -triple x86_64-apple-tvos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-64 %s +// RUN: %clang_cc1 -triple arm64-apple-tvos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-64 %s + +// TVOS-32: #define __INTPTR_TYPE__ long int +// TVOS-32: #define __PTRDIFF_TYPE__ int +// TVOS-32: #define __SIZE_TYPE__ long unsigned int + +// TVOS-64: #define __INTPTR_TYPE__ long int +// TVOS-64: #define __PTRDIFF_TYPE__ long int +// TVOS-64: #define __SIZE_TYPE__ long unsigned int + +// RUN: %clang_cc1 -triple i386-apple-watchos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-32 %s +// RUN: %clang_cc1 -triple armv7k-apple-watchos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s +// RUN: %clang_cc1 -triple x86_64-apple-watchos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s +// RUN: %clang_cc1 -triple arm64-apple-watchos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s + +// WATCHOS-32: #define __INTPTR_TYPE__ long int +// WATCHOS-32: #define __PTRDIFF_TYPE__ int +// WATCHOS-32: #define __SIZE_TYPE__ long unsigned int + +// WATCHOS-64: #define __INTPTR_TYPE__ long int +// WATCHOS-64: #define __PTRDIFF_TYPE__ long int +// WATCHOS-64: #define __SIZE_TYPE__ long unsigned int + +// RUN: %clang_cc1 -triple armv7-apple-none-macho -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-DARWIN-BAREMETAL-32 %s +// RUN: %clang_cc1 -triple arm64-apple-none-macho -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-DARWIN-BAREMETAL-64 %s + +// ARM-DARWIN-BAREMETAL-32: #define __INTPTR_TYPE__ long int +// ARM-DARWIN-BAREMETAL-32: #define __PTRDIFF_TYPE__ int +// ARM-DARWIN-BAREMETAL-32: #define __SIZE_TYPE__ long unsigned int + +// ARM-DARWIN-BAREMETAL-64: #define __INTPTR_TYPE__ long int +// ARM-DARWIN-BAREMETAL-64: #define __PTRDIFF_TYPE__ long int +// ARM-DARWIN-BAREMETAL-64: #define __SIZE_TYPE__ long unsigned int +