From: Joerg Sonnenberger Date: Tue, 15 Jul 2014 11:51:38 +0000 (+0000) Subject: Make sure int64_t and uint64_t are consistent. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c6c32712b025ce3f94b3e1531c796938f6a7939;p=clang Make sure int64_t and uint64_t are consistent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213065 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index ce9791498a..29e835014c 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -221,6 +221,9 @@ public: IntType getChar16Type() const { return Char16Type; } IntType getChar32Type() const { return Char32Type; } IntType getInt64Type() const { return Int64Type; } + IntType getUInt64Type() const { + return getCorrespondingUnsignedType(Int64Type); + } IntType getSigAtomicType() const { return SigAtomicType; } IntType getProcessIDType() const { return ProcessIDType; } diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 64b068dc75..b53fff9afc 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -232,7 +232,7 @@ static void DefineExactWidthIntType(TargetInfo::IntType Ty, // Use the target specified int64 type, when appropriate, so that [u]int64_t // ends up being defined in terms of the correct type. if (TypeWidth == 64) - Ty = IsSigned ? TI.getInt64Type() : TI.getIntTypeByWidth(64, false); + Ty = IsSigned ? TI.getInt64Type() : TI.getUInt64Type(); const char *Prefix = IsSigned ? "__INT" : "__UINT"; @@ -254,7 +254,7 @@ static void DefineExactWidthIntTypeSize(TargetInfo::IntType Ty, // Use the target specified int64 type, when appropriate, so that [u]int64_t // ends up being defined in terms of the correct type. if (TypeWidth == 64) - Ty = IsSigned ? TI.getInt64Type() : TI.getIntTypeByWidth(64, false); + Ty = IsSigned ? TI.getInt64Type() : TI.getUInt64Type(); const char *Prefix = IsSigned ? "__INT" : "__UINT"; DefineTypeSize(Prefix + Twine(TypeWidth) + "_MAX__", Ty, TI, Builder); diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 3c9caa1535..dcf9b7c6d6 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -749,9 +749,9 @@ // AARCH64-NETBSD:#define __UINT32_C_SUFFIX__ U // AARCH64-NETBSD:#define __UINT32_MAX__ 4294967295U // AARCH64-NETBSD:#define __UINT32_TYPE__ unsigned int -// AARCH64-NETBSD:#define __UINT64_C_SUFFIX__ UL -// AARCH64-NETBSD:#define __UINT64_MAX__ 18446744073709551615UL -// AARCH64-NETBSD:#define __UINT64_TYPE__ long unsigned int +// AARCH64-NETBSD:#define __UINT64_C_SUFFIX__ ULL +// AARCH64-NETBSD:#define __UINT64_MAX__ 18446744073709551615ULL +// AARCH64-NETBSD:#define __UINT64_TYPE__ long long unsigned int // AARCH64-NETBSD:#define __UINT8_C_SUFFIX__ U // AARCH64-NETBSD:#define __UINT8_MAX__ 255U // AARCH64-NETBSD:#define __UINT8_TYPE__ unsigned char @@ -2881,9 +2881,9 @@ // MIPS64BE:#define __UINT32_C_SUFFIX__ U // MIPS64BE:#define __UINT32_MAX__ 4294967295U // MIPS64BE:#define __UINT32_TYPE__ unsigned int -// MIPS64BE:#define __UINT64_C_SUFFIX__ UL -// MIPS64BE:#define __UINT64_MAX__ 18446744073709551615UL -// MIPS64BE:#define __UINT64_TYPE__ long unsigned int +// MIPS64BE:#define __UINT64_C_SUFFIX__ ULL +// MIPS64BE:#define __UINT64_MAX__ 18446744073709551615ULL +// MIPS64BE:#define __UINT64_TYPE__ long long unsigned int // MIPS64BE:#define __UINT8_C_SUFFIX__ U // MIPS64BE:#define __UINT8_MAX__ 255U // MIPS64BE:#define __UINT8_TYPE__ unsigned char @@ -3082,9 +3082,9 @@ // MIPS64EL:#define __UINT32_C_SUFFIX__ U // MIPS64EL:#define __UINT32_MAX__ 4294967295U // MIPS64EL:#define __UINT32_TYPE__ unsigned int -// MIPS64EL:#define __UINT64_C_SUFFIX__ UL -// MIPS64EL:#define __UINT64_MAX__ 18446744073709551615UL -// MIPS64EL:#define __UINT64_TYPE__ long unsigned int +// MIPS64EL:#define __UINT64_C_SUFFIX__ ULL +// MIPS64EL:#define __UINT64_MAX__ 18446744073709551615ULL +// MIPS64EL:#define __UINT64_TYPE__ long long unsigned int // MIPS64EL:#define __UINT8_C_SUFFIX__ U // MIPS64EL:#define __UINT8_MAX__ 255U // MIPS64EL:#define __UINT8_TYPE__ unsigned char @@ -3618,9 +3618,9 @@ // NVPTX32:#define __UINT32_C_SUFFIX__ U // NVPTX32:#define __UINT32_MAX__ 4294967295U // NVPTX32:#define __UINT32_TYPE__ unsigned int -// NVPTX32:#define __UINT64_C_SUFFIX__ UL -// NVPTX32:#define __UINT64_MAX__ 18446744073709551615UL -// NVPTX32:#define __UINT64_TYPE__ long unsigned int +// NVPTX32:#define __UINT64_C_SUFFIX__ ULL +// NVPTX32:#define __UINT64_MAX__ 18446744073709551615ULL +// NVPTX32:#define __UINT64_TYPE__ long long unsigned int // NVPTX32:#define __UINT8_C_SUFFIX__ U // NVPTX32:#define __UINT8_MAX__ 255U // NVPTX32:#define __UINT8_TYPE__ unsigned char @@ -3798,9 +3798,9 @@ // NVPTX64:#define __UINT32_C_SUFFIX__ U // NVPTX64:#define __UINT32_MAX__ 4294967295U // NVPTX64:#define __UINT32_TYPE__ unsigned int -// NVPTX64:#define __UINT64_C_SUFFIX__ UL -// NVPTX64:#define __UINT64_MAX__ 18446744073709551615UL -// NVPTX64:#define __UINT64_TYPE__ long unsigned int +// NVPTX64:#define __UINT64_C_SUFFIX__ ULL +// NVPTX64:#define __UINT64_MAX__ 18446744073709551615ULL +// NVPTX64:#define __UINT64_TYPE__ long long unsigned int // NVPTX64:#define __UINT8_C_SUFFIX__ U // NVPTX64:#define __UINT8_MAX__ 255U // NVPTX64:#define __UINT8_TYPE__ unsigned char @@ -5483,9 +5483,9 @@ // S390X:#define __UINT32_C_SUFFIX__ U // S390X:#define __UINT32_MAX__ 4294967295U // S390X:#define __UINT32_TYPE__ unsigned int -// S390X:#define __UINT64_C_SUFFIX__ UL -// S390X:#define __UINT64_MAX__ 18446744073709551615UL -// S390X:#define __UINT64_TYPE__ long unsigned int +// S390X:#define __UINT64_C_SUFFIX__ ULL +// S390X:#define __UINT64_MAX__ 18446744073709551615ULL +// S390X:#define __UINT64_TYPE__ long long unsigned int // S390X:#define __UINT8_C_SUFFIX__ U // S390X:#define __UINT8_MAX__ 255U // S390X:#define __UINT8_TYPE__ unsigned char