[PATCH] D50477: WIP: Ensure that the type of size_t is represended as one of the fixed width types
Sam Clegg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 8 14:10:42 PDT 2018
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin.
We recently changes `size_t` on wasm from `int` to `long` which
had the effect of making the type of size_t (long) not match either
int32_t or int64_t.
This solution is not very elegant but fixes the build issues that
resulted from this change.
Repository:
rC Clang
https://reviews.llvm.org/D50477
Files:
lib/Frontend/InitPreprocessor.cpp
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -209,6 +209,8 @@
static void DefineType(const Twine &MacroName, TargetInfo::IntType Ty,
MacroBuilder &Builder) {
+ printf("macro = %s\n", MacroName.str().c_str());
+ printf("name = %s\n", TargetInfo::getTypeName(Ty));
Builder.defineMacro(MacroName, TargetInfo::getTypeName(Ty));
}
@@ -228,6 +230,7 @@
MacroBuilder &Builder) {
int TypeWidth = TI.getTypeWidth(Ty);
bool IsSigned = TI.isTypeSigned(Ty);
+ printf("DefineExactWidthIntType\n");
// Use the target specified int64 type, when appropriate, so that [u]int64_t
// ends up being defined in terms of the correct type.
@@ -870,16 +873,18 @@
if (!TargetInfo::isTypeSigned(TI.getWIntType()))
Builder.defineMacro("__WINT_UNSIGNED__");
+ unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
+
// Define exact-width integer types for stdint.h
DefineExactWidthIntType(TargetInfo::SignedChar, TI, Builder);
if (TI.getShortWidth() > TI.getCharWidth())
DefineExactWidthIntType(TargetInfo::SignedShort, TI, Builder);
- if (TI.getIntWidth() > TI.getShortWidth())
+ if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == SizeTypeWidth && TI.getSignedSizeType() != TargetInfo::SignedInt))
DefineExactWidthIntType(TargetInfo::SignedInt, TI, Builder);
- if (TI.getLongWidth() > TI.getIntWidth())
+ if (TI.getLongWidth() > TI.getIntWidth() || TI.getSignedSizeType() == TargetInfo::SignedLong)
DefineExactWidthIntType(TargetInfo::SignedLong, TI, Builder);
if (TI.getLongLongWidth() > TI.getLongWidth())
@@ -895,13 +900,13 @@
DefineExactWidthIntTypeSize(TargetInfo::SignedShort, TI, Builder);
}
- if (TI.getIntWidth() > TI.getShortWidth()) {
+ if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == SizeTypeWidth && TI.getSizeType() != TargetInfo::UnsignedInt)) {
DefineExactWidthIntType(TargetInfo::UnsignedInt, TI, Builder);
DefineExactWidthIntTypeSize(TargetInfo::UnsignedInt, TI, Builder);
DefineExactWidthIntTypeSize(TargetInfo::SignedInt, TI, Builder);
}
- if (TI.getLongWidth() > TI.getIntWidth()) {
+ if (TI.getLongWidth() > TI.getIntWidth() || TI.getSizeType() == TargetInfo::UnsignedLong) {
DefineExactWidthIntType(TargetInfo::UnsignedLong, TI, Builder);
DefineExactWidthIntTypeSize(TargetInfo::UnsignedLong, TI, Builder);
DefineExactWidthIntTypeSize(TargetInfo::SignedLong, TI, Builder);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50477.159792.patch
Type: text/x-patch
Size: 2638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180808/6fc56b5f/attachment.bin>
More information about the cfe-commits
mailing list