C++: Introduce unicode char/strings support

Those are the types char16_t and char32_t along with the new
char/string literals u'', U'', u"", u8"", and U"".

This is particularly important for the use of QStringLiteral
since in some platforms it relies on expansion such as above.

Note: The string literals quickfixes still need some tunning.

Task-number: QTCREATORBUG-7449
Change-Id: Iebcfea15677dc8e0ebb6143def89a5477e1be7d4
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Leandro Melo
2012-06-06 13:41:22 +02:00
committed by hjk
parent b88a5f5d38
commit 23c637c4f6
17 changed files with 242 additions and 146 deletions

View File

@@ -170,7 +170,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
const Token &token = tk[index - 1];
if (text.at(0) == QLatin1Char('"') && (token.is(T_STRING_LITERAL) || token.is(T_WIDE_STRING_LITERAL))) {
if (text.at(0) == QLatin1Char('"') && token.isStringLiteral()) {
if (text.length() != 1)
qWarning() << Q_FUNC_INFO << "handle event compression";
@@ -178,7 +178,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
return QLatin1String("\"");
return QString();
} else if (text.at(0) == QLatin1Char('\'') && (token.is(T_CHAR_LITERAL) || token.is(T_WIDE_CHAR_LITERAL))) {
} else if (text.at(0) == QLatin1Char('\'') && token.isCharLiteral()) {
if (text.length() != 1)
qWarning() << Q_FUNC_INFO << "handle event compression";

View File

@@ -289,13 +289,16 @@ bool ResolveExpression::visit(NumericLiteralAST *ast)
Type *type = 0;
bool isUnsigned = false;
if (tk.is(T_CHAR_LITERAL))
if (tk.is(T_CHAR_LITERAL)) {
type = control()->integerType(IntegerType::Char);
else if (tk.is(T_WIDE_CHAR_LITERAL))
} else if (tk.is(T_WIDE_CHAR_LITERAL)) {
type = control()->integerType(IntegerType::WideChar);
else if (const NumericLiteral *literal = numericLiteral(ast->literal_token)) {
} else if (tk.is(T_UTF16_CHAR_LITERAL)) {
type = control()->integerType(IntegerType::Char16);
} else if (tk.is(T_UTF32_CHAR_LITERAL)) {
type = control()->integerType(IntegerType::Char32);
} else if (const NumericLiteral *literal = numericLiteral(ast->literal_token)) {
isUnsigned = literal->isUnsigned();
if (literal->isInt())
type = control()->integerType(IntegerType::Int);
else if (literal->isLong())

View File

@@ -185,6 +185,12 @@ void TypePrettyPrinter::visit(IntegerType *type)
case IntegerType::Char:
_text.prepend(QLatin1String("char"));
break;
case IntegerType::Char16:
_text.prepend(QLatin1String("char16_t"));
break;
case IntegerType::Char32:
_text.prepend(QLatin1String("char32_t"));
break;
case IntegerType::WideChar:
_text.prepend(QLatin1String("wchar_t"));
break;