diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2014-07-17 20:12:32 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2014-07-17 20:12:32 +0000 |
commit | 587deea8755b5adab19350b30c71ec5d2c765bf2 (patch) | |
tree | 8cb9cbed040c6461f870c4b508b670c5ce15b63a /clang/lib/Basic | |
parent | 11698180c336ea4a077a896b79ab2621fb36585f (diff) | |
download | bcm5719-llvm-587deea8755b5adab19350b30c71ec5d2c765bf2.tar.gz bcm5719-llvm-587deea8755b5adab19350b30c71ec5d2c765bf2.zip |
If char/short are shorter than int, do not use U as suffix for
constants. Comparing int against a constant of the given type like
UINT8_MAX will otherwise force a promotion to unsigned int, which is
typically not expected.
llvm-svn: 213301
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/TargetInfo.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 8d81035ce80..94ebeb85dea 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -118,7 +118,7 @@ const char *TargetInfo::getTypeName(IntType T) { /// getTypeConstantSuffix - Return the constant suffix for the specified /// integer type enum. For example, SignedLong -> "L". -const char *TargetInfo::getTypeConstantSuffix(IntType T) { +const char *TargetInfo::getTypeConstantSuffix(IntType T) const { switch (T) { default: llvm_unreachable("not an integer!"); case SignedChar: @@ -127,7 +127,11 @@ const char *TargetInfo::getTypeConstantSuffix(IntType T) { case SignedLong: return "L"; case SignedLongLong: return "LL"; case UnsignedChar: + if (getCharWidth() < getIntWidth()) + return ""; case UnsignedShort: + if (getShortWidth() < getIntWidth()) + return ""; case UnsignedInt: return "U"; case UnsignedLong: return "UL"; case UnsignedLongLong: return "ULL"; |