[cfe-commits] r107255 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/Headers/int64-type.c test/Preprocessor/init.c test/Preprocessor/stdint.c

Daniel Dunbar daniel at zuster.org
Tue Jun 29 23:30:56 PDT 2010


Author: ddunbar
Date: Wed Jun 30 01:30:56 2010
New Revision: 107255

URL: http://llvm.org/viewvc/llvm-project?rev=107255&view=rev
Log:
Headers: Define __INT64_TYPE__ in terms of getInt64Type(), which isn't always
'long'. The practical upshot is so that the uint64_t we define in our stdint.h
ends up being compatible with that defined by gcc (at least on Darwin), which
otherwise could lead to type incompatibilities with other system headers.

Added:
    cfe/trunk/test/Headers/int64-type.c
Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Preprocessor/init.c
    cfe/trunk/test/Preprocessor/stdint.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=107255&r1=107254&r2=107255&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Jun 30 01:30:56 2010
@@ -204,6 +204,12 @@
 static void DefineExactWidthIntType(TargetInfo::IntType Ty, 
                                const TargetInfo &TI, MacroBuilder &Builder) {
   int TypeWidth = TI.getTypeWidth(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 = TI.getInt64Type();
+
   DefineType("__INT" + llvm::Twine(TypeWidth) + "_TYPE__", Ty, Builder);
 
   llvm::StringRef ConstSuffix(TargetInfo::getTypeConstantSuffix(Ty));

Added: cfe/trunk/test/Headers/int64-type.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/int64-type.c?rev=107255&view=auto
==============================================================================
--- cfe/trunk/test/Headers/int64-type.c (added)
+++ cfe/trunk/test/Headers/int64-type.c Wed Jun 30 01:30:56 2010
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -verify %s -ffreestanding
+
+#include <stdint.h>
+typedef unsigned long long uint64_t;

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=107255&r1=107254&r2=107255&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Jun 30 01:30:56 2010
@@ -838,7 +838,7 @@
 // S390X:#define __INT16_TYPE__ short
 // S390X:#define __INT32_TYPE__ int
 // S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_TYPE__ long int
+// S390X:#define __INT64_TYPE__ long long int
 // S390X:#define __INT8_TYPE__ char
 // S390X:#define __INTMAX_MAX__ 9223372036854775807LL
 // S390X:#define __INTMAX_TYPE__ long long int

Modified: cfe/trunk/test/Preprocessor/stdint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/stdint.c?rev=107255&r1=107254&r2=107255&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/stdint.c (original)
+++ cfe/trunk/test/Preprocessor/stdint.c Wed Jun 30 01:30:56 2010
@@ -738,8 +738,8 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=s390x-none-none %s | FileCheck -check-prefix S390X %s
 //
-// S390X:typedef signed long int int64_t;
-// S390X:typedef unsigned long int uint64_t;
+// S390X:typedef signed long long int int64_t;
+// S390X:typedef unsigned long long int uint64_t;
 // S390X:typedef int64_t int_least64_t;
 // S390X:typedef uint64_t uint_least64_t;
 // S390X:typedef int64_t int_fast64_t;
@@ -803,23 +803,23 @@
 // S390X:UINT_FAST32_MAX_ 4294967295U
 //
 // S390X:INT64_MAX_ 9223372036854775807L
-// S390X:INT64_MIN_ (-9223372036854775807L -1)
+// S390X:INT64_MIN_ (-9223372036854775807LL -1)
 // S390X:UINT64_MAX_ 18446744073709551615UL
-// S390X:INT_LEAST64_MIN_ (-9223372036854775807L -1)
+// S390X:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
 // S390X:INT_LEAST64_MAX_ 9223372036854775807L
 // S390X:UINT_LEAST64_MAX_ 18446744073709551615UL
-// S390X:INT_FAST64_MIN_ (-9223372036854775807L -1)
+// S390X:INT_FAST64_MIN_ (-9223372036854775807LL -1)
 // S390X:INT_FAST64_MAX_ 9223372036854775807L
 // S390X:UINT_FAST64_MAX_ 18446744073709551615UL
 //
-// S390X:INTPTR_MIN_ (-9223372036854775807L -1)
+// S390X:INTPTR_MIN_ (-9223372036854775807LL -1)
 // S390X:INTPTR_MAX_ 9223372036854775807L
 // S390X:UINTPTR_MAX_ 18446744073709551615UL
-// S390X:PTRDIFF_MIN_ (-9223372036854775807L -1)
+// S390X:PTRDIFF_MIN_ (-9223372036854775807LL -1)
 // S390X:PTRDIFF_MAX_ 9223372036854775807L
 // S390X:SIZE_MAX_ 18446744073709551615UL
 //
-// S390X:INTMAX_MIN_ (-9223372036854775807L -1)
+// S390X:INTMAX_MIN_ (-9223372036854775807LL -1)
 // S390X:INTMAX_MAX_ 9223372036854775807L
 // S390X:UINTMAX_MAX_ 18446744073709551615UL
 //





More information about the cfe-commits mailing list