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/ASTContext.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/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index b145683ce5..eb6a821783 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -316,9 +316,12 @@ void ASTContext::InitBuiltinTypes() { InitBuiltinType(Int128Ty, BuiltinType::Int128); InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128); - if (LangOpts.CPlusPlus) // C++ 3.9.1p5 - InitBuiltinType(WCharTy, BuiltinType::WChar); - else // C99 + if (LangOpts.CPlusPlus) { // C++ 3.9.1p5 + if (!LangOpts.ShortWChar) + InitBuiltinType(WCharTy, BuiltinType::WChar_S); + else // -fshort-wchar makes wchar_t be unsigned. + InitBuiltinType(WCharTy, BuiltinType::WChar_U); + } else // C99 WCharTy = getFromTargetType(Target.getWCharType()); if (LangOpts.CPlusPlus) // C++0x 3.9.1p5, extension for C++ @@ -676,7 +679,8 @@ ASTContext::getTypeInfo(const Type *T) { Width = Target.getCharWidth(); Align = Target.getCharAlign(); break; - case BuiltinType::WChar: + case BuiltinType::WChar_S: + case BuiltinType::WChar_U: Width = Target.getWCharWidth(); Align = Target.getWCharAlign(); break; @@ -2946,7 +2950,8 @@ unsigned ASTContext::getIntegerRank(Type *T) { if (EnumType* ET = dyn_cast<EnumType>(T)) T = ET->getDecl()->getPromotionType().getTypePtr(); - if (T->isSpecificBuiltinType(BuiltinType::WChar)) + if (T->isSpecificBuiltinType(BuiltinType::WChar_S) || + T->isSpecificBuiltinType(BuiltinType::WChar_U)) T = getFromTargetType(Target.getWCharType()).getTypePtr(); if (T->isSpecificBuiltinType(BuiltinType::Char16)) @@ -3731,7 +3736,8 @@ static char ObjCEncodingForPrimitiveKind(const ASTContext *C, QualType T) { case BuiltinType::Char_S: case BuiltinType::SChar: return 'c'; case BuiltinType::Short: return 's'; - case BuiltinType::WChar: + case BuiltinType::WChar_S: + case BuiltinType::WChar_U: case BuiltinType::Int: return 'i'; case BuiltinType::Long: return |