forked from qt-creator/qt-creator
		
	CPlusPlus: Compile with QT_NO_CAST_FROM_ASCII
Change-Id: I1cfb413b7e88e91e9c4719a8a7b81c752c40767e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
		
				
					committed by
					
						
						Erik Verbruggen
					
				
			
			
				
	
			
			
			
						parent
						
							ad7d3a9dbb
						
					
				
				
					commit
					abc8567198
				
			@@ -519,15 +519,15 @@ static inline QString fixNestedTemplates(QString s)
 | 
			
		||||
CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
 | 
			
		||||
{
 | 
			
		||||
    QString type = typeIn;
 | 
			
		||||
    if (type.startsWith("class ")) // MSVC prepends class,struct
 | 
			
		||||
    if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct
 | 
			
		||||
        type.remove(0, 6);
 | 
			
		||||
    if (type.startsWith("struct "))
 | 
			
		||||
    if (type.startsWith(QLatin1String("struct ")))
 | 
			
		||||
        type.remove(0, 7);
 | 
			
		||||
 | 
			
		||||
    type.replace(QLatin1Char('*'), QLatin1Char('@'));
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < 10; ++i) {
 | 
			
		||||
        int start = type.indexOf("std::allocator<");
 | 
			
		||||
        int start = type.indexOf(QLatin1String("std::allocator<"));
 | 
			
		||||
        if (start == -1)
 | 
			
		||||
            break;
 | 
			
		||||
        // search for matching '>'
 | 
			
		||||
@@ -575,7 +575,7 @@ CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
 | 
			
		||||
            type.replace(setRE.cap(0), QString::fromLatin1("set<%1>").arg(inner));
 | 
			
		||||
 | 
			
		||||
        // std::map
 | 
			
		||||
        if (inner.startsWith("std::pair<")) {
 | 
			
		||||
        if (inner.startsWith(QLatin1String("std::pair<"))) {
 | 
			
		||||
            // search for outermost ',', split key and value
 | 
			
		||||
            int pos;
 | 
			
		||||
            int level = 0;
 | 
			
		||||
@@ -595,18 +595,18 @@ CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
 | 
			
		||||
                pos++;
 | 
			
		||||
            const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
 | 
			
		||||
            const QString valueEsc = QRegExp::escape(value);
 | 
			
		||||
            QRegExp mapRE1(QString("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>")
 | 
			
		||||
            QRegExp mapRE1(QString::fromLatin1("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>")
 | 
			
		||||
                .arg(keyEsc, valueEsc, keyEsc, allocEsc));
 | 
			
		||||
            mapRE1.setMinimal(true);
 | 
			
		||||
            QTC_ASSERT(mapRE1.isValid(), return typeIn);
 | 
			
		||||
            if (mapRE1.indexIn(type) != -1) {
 | 
			
		||||
                type.replace(mapRE1.cap(0), QString("map<%1, %2>").arg(key, value));
 | 
			
		||||
                type.replace(mapRE1.cap(0), QString::fromLatin1("map<%1, %2>").arg(key, value));
 | 
			
		||||
            } else {
 | 
			
		||||
                QRegExp mapRE2(QString("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>")
 | 
			
		||||
                QRegExp mapRE2(QString::fromLatin1("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>")
 | 
			
		||||
                    .arg(keyEsc, valueEsc, keyEsc, allocEsc));
 | 
			
		||||
                mapRE2.setMinimal(true);
 | 
			
		||||
                if (mapRE2.indexIn(type) != -1) {
 | 
			
		||||
                    type.replace(mapRE2.cap(0), QString("map<const %1, %2>").arg(key, value));
 | 
			
		||||
                    type.replace(mapRE2.cap(0), QString::fromLatin1("map<const %1, %2>").arg(key, value));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -55,24 +55,25 @@ static QString indent(QString s, int level = 2)
 | 
			
		||||
QString CPlusPlus::toString(const Name *name, QString id)
 | 
			
		||||
{
 | 
			
		||||
    Overview oo;
 | 
			
		||||
    return QString("%0: %1").arg(id, name ? oo.prettyName(name) : QLatin1String("(null)"));
 | 
			
		||||
    return QString::fromLatin1("%0: %1").arg(id, name ? oo.prettyName(name) : QLatin1String("(null)"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString CPlusPlus::toString(FullySpecifiedType ty, QString id)
 | 
			
		||||
{
 | 
			
		||||
    Overview oo;
 | 
			
		||||
    return QString("%0: %1 (a %2)").arg(id, oo.prettyType(ty), ty.type() ? typeid(*ty.type()).name() : "(null)");
 | 
			
		||||
    return QString::fromLatin1("%0: %1 (a %2)").arg(id, oo.prettyType(ty),
 | 
			
		||||
                                                    QLatin1String(ty.type() ? typeid(*ty.type()).name() : "(null)"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString CPlusPlus::toString(const Symbol *s, QString id)
 | 
			
		||||
{
 | 
			
		||||
    if (!s)
 | 
			
		||||
        return QString("%0: (null)").arg(id);
 | 
			
		||||
        return QString::fromLatin1("%0: (null)").arg(id);
 | 
			
		||||
 | 
			
		||||
    return QString("%0: %1 (%2) at %3:%4:%5\n%6").arg(
 | 
			
		||||
    return QString::fromLatin1("%0: %1 (%2) at %3:%4:%5\n%6").arg(
 | 
			
		||||
                id,
 | 
			
		||||
                QString::fromLatin1(typeid(*s).name()),
 | 
			
		||||
                s->identifier() ? QString::fromUtf8(s->identifier()->chars()) : "no id",
 | 
			
		||||
                s->identifier() ? QString::fromUtf8(s->identifier()->chars()) : QLatin1String("no id"),
 | 
			
		||||
                QString::fromLatin1(s->fileName()),
 | 
			
		||||
                QString::number(s->line()),
 | 
			
		||||
                QString::number(s->column()),
 | 
			
		||||
@@ -81,18 +82,18 @@ QString CPlusPlus::toString(const Symbol *s, QString id)
 | 
			
		||||
 | 
			
		||||
QString CPlusPlus::toString(LookupItem it, QString id)
 | 
			
		||||
{
 | 
			
		||||
    QString result = QString("%1:").arg(id);
 | 
			
		||||
    QString result = QString::fromLatin1("%1:").arg(id);
 | 
			
		||||
    if (it.declaration()) {
 | 
			
		||||
        result.append(QString("\n%1").arg(indent(toString(it.declaration(), QLatin1String("Decl")))));
 | 
			
		||||
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.declaration(), QLatin1String("Decl")))));
 | 
			
		||||
    }
 | 
			
		||||
    if (it.type().isValid()) {
 | 
			
		||||
        result.append(QString("\n%1").arg(indent(toString(it.type()))));
 | 
			
		||||
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.type()))));
 | 
			
		||||
    }
 | 
			
		||||
    if (it.scope()) {
 | 
			
		||||
        result.append(QString("\n%1").arg(indent(toString(it.scope(), QLatin1String("Scope")))));
 | 
			
		||||
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.scope(), QLatin1String("Scope")))));
 | 
			
		||||
    }
 | 
			
		||||
    if (it.binding()) {
 | 
			
		||||
        result.append(QString("\n%1").arg(indent(toString(it.binding(), QLatin1String("Binding")))));
 | 
			
		||||
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.binding(), QLatin1String("Binding")))));
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
@@ -100,13 +101,13 @@ QString CPlusPlus::toString(LookupItem it, QString id)
 | 
			
		||||
QString CPlusPlus::toString(const ClassOrNamespace *binding, QString id)
 | 
			
		||||
{
 | 
			
		||||
    if (!binding)
 | 
			
		||||
        return QString("%0: (null)").arg(id);
 | 
			
		||||
        return QString::fromLatin1("%0: (null)").arg(id);
 | 
			
		||||
 | 
			
		||||
    QString result = QString("%0: %1 symbols").arg(
 | 
			
		||||
    QString result = QString::fromLatin1("%0: %1 symbols").arg(
 | 
			
		||||
                id,
 | 
			
		||||
                QString::number(binding->symbols().length()));
 | 
			
		||||
    if (binding->templateId()) {
 | 
			
		||||
        result.append(QString("\n%1").arg(indent(toString(binding->templateId(), QLatin1String("Template")))));
 | 
			
		||||
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(binding->templateId(), QLatin1String("Template")))));
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -133,7 +133,7 @@ LookupContext::LookupContext()
 | 
			
		||||
 | 
			
		||||
LookupContext::LookupContext(Document::Ptr thisDocument,
 | 
			
		||||
                             const Snapshot &snapshot)
 | 
			
		||||
    : _expressionDocument(Document::create("<LookupContext>")),
 | 
			
		||||
    : _expressionDocument(Document::create(QLatin1String("<LookupContext>"))),
 | 
			
		||||
      _thisDocument(thisDocument),
 | 
			
		||||
      _snapshot(snapshot),
 | 
			
		||||
      _control(new Control()),
 | 
			
		||||
 
 | 
			
		||||
@@ -90,7 +90,7 @@ void NamePrettyPrinter::visit(const TemplateNameId *name)
 | 
			
		||||
        else
 | 
			
		||||
            _name += arg;
 | 
			
		||||
    }
 | 
			
		||||
    if (! _name.isEmpty() && _name.at(_name.length() - 1) == '>')
 | 
			
		||||
    if (! _name.isEmpty() && _name.at(_name.length() - 1) == QLatin1Char('>'))
 | 
			
		||||
        _name += QLatin1Char(' ');
 | 
			
		||||
    _name += QLatin1Char('>');
 | 
			
		||||
}
 | 
			
		||||
@@ -263,7 +263,7 @@ void NamePrettyPrinter::visit(const SelectorNameId *name)
 | 
			
		||||
            _name += QString::fromLatin1(id->chars(), id->size());
 | 
			
		||||
 | 
			
		||||
            if (name->hasArguments() || name->nameCount() > 1)
 | 
			
		||||
                _name += ':';
 | 
			
		||||
                _name += QLatin1Char(':');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -533,7 +533,7 @@ bool ResolveExpression::visit(SimpleNameAST *ast)
 | 
			
		||||
                continue;
 | 
			
		||||
 | 
			
		||||
            TypeOfExpression exprTyper;
 | 
			
		||||
            Document::Ptr doc = _context.snapshot().document(decl->fileName());
 | 
			
		||||
            Document::Ptr doc = _context.snapshot().document(QString::fromLocal8Bit(decl->fileName()));
 | 
			
		||||
            exprTyper.init(doc, _context.snapshot(), _context.bindings());
 | 
			
		||||
 | 
			
		||||
            Document::Ptr exprDoc =
 | 
			
		||||
 
 | 
			
		||||
@@ -193,7 +193,7 @@ QByteArray TypeOfExpression::preprocessedExpression(const QByteArray &utf8code)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Preprocessor preproc(0, m_environment.data());
 | 
			
		||||
    return preproc.run("<expression>", utf8code);
 | 
			
		||||
    return preproc.run(QLatin1String("<expression>"), utf8code);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace CPlusPlus {
 | 
			
		||||
 
 | 
			
		||||
@@ -365,11 +365,11 @@ void TypePrettyPrinter::visit(Function *type)
 | 
			
		||||
        _text += QLatin1Char(')');
 | 
			
		||||
        if (type->isConst()) {
 | 
			
		||||
            appendSpace();
 | 
			
		||||
            _text += "const";
 | 
			
		||||
            _text += QLatin1String("const");
 | 
			
		||||
        }
 | 
			
		||||
        if (type->isVolatile()) {
 | 
			
		||||
            appendSpace();
 | 
			
		||||
            _text += "volatile";
 | 
			
		||||
            _text += QLatin1String("volatile");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -394,7 +394,7 @@ void TypePrettyPrinter::prependSpaceUnlessBracket()
 | 
			
		||||
    const QChar ch = _text.at(0);
 | 
			
		||||
 | 
			
		||||
    if (ch != QLatin1Char('['))
 | 
			
		||||
        _text.prepend(" ");
 | 
			
		||||
        _text.prepend(QLatin1Char(' '));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TypePrettyPrinter::prependWordSeparatorSpace()
 | 
			
		||||
@@ -405,19 +405,19 @@ void TypePrettyPrinter::prependWordSeparatorSpace()
 | 
			
		||||
    const QChar ch = _text.at(0);
 | 
			
		||||
 | 
			
		||||
    if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
 | 
			
		||||
        _text.prepend(" ");
 | 
			
		||||
        _text.prepend(QLatin1Char(' '));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TypePrettyPrinter::prependCv(const FullySpecifiedType &ty)
 | 
			
		||||
{
 | 
			
		||||
    if (ty.isVolatile()) {
 | 
			
		||||
        prependWordSeparatorSpace();
 | 
			
		||||
        _text.prepend("volatile");
 | 
			
		||||
        _text.prepend(QLatin1String("volatile"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (ty.isConst()) {
 | 
			
		||||
        prependWordSeparatorSpace();
 | 
			
		||||
        _text.prepend("const");
 | 
			
		||||
        _text.prepend(QLatin1String("const"));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ include(../3rdparty/cplusplus/cplusplus.pri)
 | 
			
		||||
 | 
			
		||||
greaterThan(QT_MAJOR_VERSION, 4): QT += concurrent
 | 
			
		||||
 | 
			
		||||
DEFINES += QT_NO_CAST_FROM_ASCII
 | 
			
		||||
 | 
			
		||||
contains(QT, gui) {
 | 
			
		||||
HEADERS += \
 | 
			
		||||
    $$PWD/Icons.h \
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,8 @@ QtcLibrary {
 | 
			
		||||
    cpp.includePaths: base.concat("../3rdparty/cplusplus")
 | 
			
		||||
    cpp.defines: base.concat([
 | 
			
		||||
        "NDEBUG",
 | 
			
		||||
        "CPLUSPLUS_BUILD_LIB"
 | 
			
		||||
        "CPLUSPLUS_BUILD_LIB",
 | 
			
		||||
        "QT_NO_CAST_FROM_ASCII"
 | 
			
		||||
    ])
 | 
			
		||||
    cpp.optimization: "fast"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user