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);