diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-06 04:55:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-06 04:55:18 +0000 |
commit | 86d85b8e5e55db3079c9c22aecdb30d830793a50 (patch) | |
tree | 7f422f6c436b5696108a05e9c052f6272c8fc4ac /lib/Lex/Preprocessor.cpp | |
parent | 996feccdec6c865a2f9d11faac7e0970e7aebb1b (diff) |
remove some ad-hocery and use DefineTypeSize for more things.
Now you too can have a 47 bit long long!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 1386cc5ab7..69761c824a 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -510,43 +510,17 @@ static void InitializePredefinedMacros(Preprocessor &PP, DefineBuiltinMacro(Buf, "__int64=long long"); } - // Initialize target-specific preprocessor defines. const TargetInfo &TI = PP.getTargetInfo(); // Define type sizing macros based on the target properties. assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far"); DefineBuiltinMacro(Buf, "__CHAR_BIT__=8"); - DefineBuiltinMacro(Buf, "__SCHAR_MAX__=127"); - assert(TI.getWCharWidth() == 32 && "Only support 32-bit wchar so far"); - DefineBuiltinMacro(Buf, "__WCHAR_MAX__=2147483647"); DefineBuiltinMacro(Buf, "__WCHAR_TYPE__=int"); DefineBuiltinMacro(Buf, "__WINT_TYPE__=int"); - assert(TI.getShortWidth() == 16 && "Only support 16-bit short so far"); - DefineBuiltinMacro(Buf, "__SHRT_MAX__=32767"); - - if (TI.getIntWidth() == 32) - DefineBuiltinMacro(Buf, "__INT_MAX__=2147483647"); - else if (TI.getIntWidth() == 16) - DefineBuiltinMacro(Buf, "__INT_MAX__=32767"); - else - assert(0 && "Unknown integer size"); - - if (TI.getLongLongWidth() == 64) - DefineBuiltinMacro(Buf, "__LONG_LONG_MAX__=9223372036854775807LL"); - else if (TI.getLongLongWidth() == 32) - DefineBuiltinMacro(Buf, "__LONG_LONG_MAX__=2147483647L"); - - if (TI.getLongWidth() == 32) - DefineBuiltinMacro(Buf, "__LONG_MAX__=2147483647L"); - else if (TI.getLongWidth() == 64) - DefineBuiltinMacro(Buf, "__LONG_MAX__=9223372036854775807L"); - else if (TI.getLongWidth() == 16) - DefineBuiltinMacro(Buf, "__LONG_MAX__=32767L"); - else - assert(0 && "Unknown long size"); + unsigned IntMaxWidth; const char *IntMaxSuffix; @@ -562,6 +536,12 @@ static void InitializePredefinedMacros(Preprocessor &PP, IntMaxSuffix = ""; } + DefineTypeSize("__SCHAR_MAX__", TI.getCharWidth(), "", true, Buf); + DefineTypeSize("__SHRT_MAX__", TI.getShortWidth(), "", true, Buf); + DefineTypeSize("__INT_MAX__", TI.getIntWidth(), "", true, Buf); + DefineTypeSize("__LONG_MAX__", TI.getLongWidth(), "L", true, Buf); + DefineTypeSize("__LONG_LONG_MAX__", TI.getLongLongWidth(), "LL", true, Buf); + DefineTypeSize("__WCHAR_MAX__", TI.getWCharWidth(), "", true, Buf); DefineTypeSize("__INTMAX_MAX__", IntMaxWidth, IntMaxSuffix, true, Buf); if (TI.getIntMaxType() == TargetInfo::UnsignedLongLong) |