diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-25 23:25:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-25 23:25:43 +0000 |
commit | 3f59c975aa5d047f7edd1b900b5e885c38af0ef7 (patch) | |
tree | 2fbe959271ee3bfd09aeaf5b035507fc87f13ba2 /lib/AST/Type.cpp | |
parent | af6530c938bfc60902f0dfec1c0808aedbee1663 (diff) |
The -fshort-wchar option causes wchar_t to become unsigned, in addition to being
16-bits in size. Implement this by splitting WChar into two enums, like we have
for char. This fixes a miscompmilation of XULRunner, PR8856.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 9dbbfaa733..257d114f25 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -524,20 +524,28 @@ bool Type::isCharType() const { bool Type::isWideCharType() const { if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) - return BT->getKind() == BuiltinType::WChar; + return BT->getKind() == BuiltinType::WChar_S || + BT->getKind() == BuiltinType::WChar_U; return false; } /// \brief Determine whether this type is any of the built-in character /// types. bool Type::isAnyCharacterType() const { - if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) - return (BT->getKind() >= BuiltinType::Char_U && - BT->getKind() <= BuiltinType::Char32) || - (BT->getKind() >= BuiltinType::Char_S && - BT->getKind() <= BuiltinType::WChar); - - return false; + const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType); + if (BT == 0) return false; + switch (BT->getKind()) { + default: return false; + case BuiltinType::Char_U: + case BuiltinType::UChar: + case BuiltinType::WChar_U: + case BuiltinType::Char16: + case BuiltinType::Char32: + case BuiltinType::Char_S: + case BuiltinType::SChar: + case BuiltinType::WChar_S: + return true; + } } /// isSignedIntegerType - Return true if this is an integer type that is @@ -1048,7 +1056,8 @@ const char *BuiltinType::getName(const LangOptions &LO) const { case Float: return "float"; case Double: return "double"; case LongDouble: return "long double"; - case WChar: return "wchar_t"; + case WChar_S: + case WChar_U: return "wchar_t"; case Char16: return "char16_t"; case Char32: return "char32_t"; case NullPtr: return "nullptr_t"; |