diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-13 22:28:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-13 22:28:55 +0000 |
commit | 6ad474f82f0cf32e13128d89fa5ad3a37ae73530 (patch) | |
tree | 2d251332b75ff717f85737af03503d5e64239a35 | |
parent | dd06e092305c9061bb270f07e0fc6d6946bbc2ad (diff) |
Give TargetInfo a new IntPtrType to hold the intptr_t type for
a target.
Make Preprocessor.cpp define a new __INTPTR_TYPE__ macro based on this.
On linux/32, set intptr_t to int, instead of long. This fixes PR3563.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64495 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 3 | ||||
-rw-r--r-- | lib/Basic/TargetInfo.cpp | 1 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 2 | ||||
-rw-r--r-- | lib/Headers/stdint.h | 21 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 1 |
5 files changed, 8 insertions, 20 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index a0bd74b421..633bacf196 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -72,7 +72,7 @@ public: UnsignedLongLong }; protected: - IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, WCharType; + IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType; public: IntType getSizeType() const { return SizeType; } IntType getIntMaxType() const { return IntMaxType; } @@ -80,6 +80,7 @@ public: IntType getPtrDiffType(unsigned AddrSpace) const { return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace); } + IntType getIntPtrType() const { return IntPtrType; } IntType getWCharType() const { return WCharType; } /// isCharSigned - Return true if 'char' is 'signed char' or false if it is diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 378a91503b..82b6c190cd 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -39,6 +39,7 @@ TargetInfo::TargetInfo(const std::string &T) : Triple(T) { PtrDiffType = SignedLong; IntMaxType = SignedLongLong; UIntMaxType = UnsignedLongLong; + IntPtrType = SignedLong; WCharType = SignedInt; FloatFormat = &llvm::APFloat::IEEEsingle; DoubleFormat = &llvm::APFloat::IEEEdouble; diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index c72982bf22..9e81ed7db2 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -629,6 +629,7 @@ public: UserLabelPrefix = ""; SizeType = UnsignedInt; PtrDiffType = SignedInt; + IntPtrType = SignedInt; } virtual void getTargetDefines(std::vector<char> &Defines) const { X86_32TargetInfo::getTargetDefines(Defines); @@ -937,6 +938,7 @@ namespace { SizeType = UnsignedInt; IntMaxType = SignedLong; UIntMaxType = UnsignedLong; + IntPtrType = SignedShort; PtrDiffType = SignedInt; DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"; } diff --git a/lib/Headers/stdint.h b/lib/Headers/stdint.h index 3eb72bb57b..9e5bfd700f 100644 --- a/lib/Headers/stdint.h +++ b/lib/Headers/stdint.h @@ -70,25 +70,8 @@ typedef uint64_t uint_fast64_t; /* C99 7.18.1.4 Integer types capable of holding object pointers. */ -#if (1LL << (__POINTER_WIDTH__-1))-1 == __LONG_MAX__ -/* If the pointer size is equal to long, use long. This is for compatibility - * with many systems which just use long and expect it to work in 32-bit and - * 64-bit mode. If long is not suitable, we use a fixed size type below. - */ -typedef long intptr_t; -typedef unsigned long uintptr_t; -#elif __POINTER_WIDTH__ == 64 -typedef int64_t intptr_t; -typedef uint64_t uintptr_t; -#elif __POINTER_WIDTH__ == 32 -typedef int32_t intptr_t; -typedef uint32_t uintptr_t; -#elif __POINTER_WIDTH__ == 16 -typedef int16_t intptr_t; -typedef uint16_t uintptr_t; -#else -#error "unknown or unset pointer width!" -#endif +typedef __INTPTR_TYPE__ intptr_t; +typedef unsigned __INTPTR_TYPE__ uintptr_t; /* C99 7.18.1.5 Greatest-width integer types. */ diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index f16d83c5a2..d769720634 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -557,6 +557,7 @@ static void InitializePredefinedMacros(Preprocessor &PP, DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf); DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf); DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Buf); + DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Buf); DefineType("__SIZE_TYPE__", TI.getSizeType(), Buf); DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf); // FIXME: TargetInfo hookize __WINT_TYPE__. |