aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/InitPreprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-05 21:21:32 +0000
committerChris Lattner <sabre@nondot.org>2009-11-05 21:21:32 +0000
commit9099e7bcda3922cee0cffcdf21332ac4aa193cea (patch)
tree0538b1525f620a43e901b260355cd84b3f1af6d7 /lib/Frontend/InitPreprocessor.cpp
parent632d772a78db7e2cd9b36f8a22aee49d44486fbf (diff)
clean up integer preprocessor type definitions, patch by Ken Dyck!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/InitPreprocessor.cpp')
-rw-r--r--lib/Frontend/InitPreprocessor.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index 7139e55f0b..b4b31c359f 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -216,6 +216,14 @@ static void DefineTypeSize(const char *MacroName, unsigned TypeWidth,
DefineBuiltinMacro(Buf, MacroBuf);
}
+/// DefineTypeSize - An overloaded helper that uses TargetInfo to determine
+/// the width, suffix, and signedness of the given type
+static void DefineTypeSize(const char *MacroName, TargetInfo::IntType Ty,
+ const TargetInfo &TI, std::vector<char> &Buf) {
+ DefineTypeSize(MacroName, TI.getTypeWidth(Ty), TI.getTypeConstantSuffix(Ty),
+ TI.isTypeSigned(Ty), Buf);
+}
+
static void DefineType(const char *MacroName, TargetInfo::IntType Ty,
std::vector<char> &Buf) {
char MacroBuf[60];
@@ -346,14 +354,16 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
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("__SHRT_MAX__", TargetInfo::SignedShort, TI, Buf);
+ DefineTypeSize("__INT_MAX__", TargetInfo::SignedInt, TI, Buf);
+ DefineTypeSize("__LONG_MAX__", TargetInfo::SignedLong, TI, Buf);
+ DefineTypeSize("__LONG_LONG_MAX__", TargetInfo::SignedLongLong, TI, Buf);
+ // FIXME: TI.getWCharWidth() and TI.getTypeWidth(TI.getWCharType()) return
+ // different values on PIC16 and MSP430. TargetInfo needs to be corrected
+ // and the following line substituted for the one below it.
+ // DefineTypeSize("__WCHAR_MAX__", TI.getWCharType(), TI, Buf);
DefineTypeSize("__WCHAR_MAX__", TI.getWCharWidth(), "", true, Buf);
- TargetInfo::IntType IntMaxType = TI.getIntMaxType();
- DefineTypeSize("__INTMAX_MAX__", TI.getTypeWidth(IntMaxType),
- TI.getTypeConstantSuffix(IntMaxType), true, Buf);
+ DefineTypeSize("__INTMAX_MAX__", TI.getIntMaxType(), TI, Buf);
DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf);
DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf);
@@ -378,14 +388,16 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
assert(TI.getCharWidth() == 8 && "unsupported target types");
assert(TI.getShortWidth() == 16 && "unsupported target types");
DefineBuiltinMacro(Buf, "__INT8_TYPE__=char");
- DefineBuiltinMacro(Buf, "__INT16_TYPE__=short");
+ DefineType("__INT16_TYPE__", TargetInfo::SignedShort, Buf);
+ TargetInfo::IntType Int32Type;
if (TI.getIntWidth() == 32)
- DefineBuiltinMacro(Buf, "__INT32_TYPE__=int");
+ Int32Type = TargetInfo::SignedInt;
else {
assert(TI.getLongLongWidth() == 32 && "unsupported target types");
- DefineBuiltinMacro(Buf, "__INT32_TYPE__=long long");
+ Int32Type = TargetInfo::SignedLongLong;
}
+ DefineType("__INT32_TYPE__", Int32Type, Buf);
// 16-bit targets doesn't necessarily have a 64-bit type.
if (TI.getLongLongWidth() == 64)