Commit 1d971716 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

QString=>QStringView in ParamIterator and related code

This should improve performance by not creating unnecessary QString
objects. A QString is never more useful than a QStringView in the
changed code.

Provide forwarding const QString& overloads of IndexedString, Identifier
and QualifiedIdentifier constructors for two reasons:
1. A QStringView is not constructible from a QStringBuilder expression.
   So explicit casting to QString would be necessary:
   -    return Identifier(QLatin1Char('~') + str);
   +    return Identifier(QString{QLatin1Char('~') + str});
2. In kdev-php and possibly in other plugins QString arguments would
   have to be explicitly casted to QStringView in order to avoid
   ambiguous calls of overloaded IndexedString(const QString&) with
   const QUrl& and QStringView candidates. This reason can be eliminated
   by adding -DQT_NO_URL_CAST_FROM_STRING definition to CMakeLists.txt.
parent 9af3d4a3
Pipeline #246825 passed with stage
in 13 minutes and 6 seconds
......@@ -234,7 +234,7 @@ public:
}
//Constructs m_identifiers
void splitIdentifiers(const QString& str, int start)
void splitIdentifiers(QStringView str, int start)
{
Q_ASSERT(dynamic);
uint currentStart = start;
......@@ -387,7 +387,7 @@ Identifier::Identifier(const IndexedString& str)
}
}
Identifier::Identifier(const QString& id, uint start, uint* takenRange)
Identifier::Identifier(QStringView id, uint start, uint* takenRange)
{
if (id.isEmpty()) {
m_index = emptyConstantIdentifierPrivateIndex();
......@@ -399,7 +399,7 @@ Identifier::Identifier(const QString& id, uint start, uint* takenRange)
dd = new IdentifierPrivate<true>;
///Extract template-parameters
ParamIterator paramIt(QStringLiteral("<>:"), id, start);
ParamIterator paramIt(u"<>:", id, start);
dd->m_identifier = IndexedString(paramIt.prefix().trimmed());
while (paramIt) {
appendTemplateIdentifier(IndexedTypeIdentifier(IndexedQualifiedIdentifier(QualifiedIdentifier(*paramIt))));
......@@ -533,7 +533,7 @@ const IndexedString Identifier::identifier() const
return cd->m_identifier;
}
void Identifier::setIdentifier(const QString& identifier)
void Identifier::setIdentifier(QStringView identifier)
{
IndexedString id(identifier);
if (id != this->identifier()) {
......@@ -679,7 +679,7 @@ QualifiedIdentifier::QualifiedIdentifier(uint index)
{
}
QualifiedIdentifier::QualifiedIdentifier(const QString& id, bool isExpression)
QualifiedIdentifier::QualifiedIdentifier(QStringView id, bool isExpression)
{
if (id.isEmpty()) {
m_index = emptyConstantQualifiedIdentifierPrivateIndex();
......@@ -1294,7 +1294,7 @@ IndexedTypeIdentifier::IndexedTypeIdentifier(const IndexedQualifiedIdentifier& i
, m_pointerConstMask(0)
{ }
IndexedTypeIdentifier::IndexedTypeIdentifier(const QString& identifier, bool isExpression)
IndexedTypeIdentifier::IndexedTypeIdentifier(QStringView identifier, bool isExpression)
: m_identifier(QualifiedIdentifier(identifier, isExpression))
, m_isConstant(false)
, m_isReference(false)
......
......@@ -10,6 +10,8 @@
#include <QList>
#include <QMetaType>
#include <QStringView>
#include <util/kdevvarlengtharray.h>
#include <language/languageexport.h>
......@@ -156,7 +158,12 @@ public:
* @warning The identifier is parsed in a C++-similar way, and the result may not be what you expect.
* If you want to prevent that parsing, use the constructor that takes IndexedString.
*/
explicit Identifier(const QString& str, uint start = 0, uint* takenRange = nullptr);
explicit Identifier(QStringView str, uint start = 0, uint* takenRange = nullptr);
explicit Identifier(const QString& str, uint start = 0, uint* takenRange = nullptr)
: Identifier(QStringView{str}, start, takenRange)
{
}
/**
* Preferred constructor, use this if you already have an IndexedString available. This does not decompose the given string.
*/
......@@ -183,7 +190,7 @@ public:
void setUnique(int token);
const IndexedString identifier() const;
void setIdentifier(const QString& identifier);
void setIdentifier(QStringView identifier);
/**
* Should be preferred over the other version
*/
......@@ -241,7 +248,12 @@ private:
class KDEVPLATFORMLANGUAGE_EXPORT QualifiedIdentifier
{
public:
explicit QualifiedIdentifier(const QString& id, bool isExpression = false);
explicit QualifiedIdentifier(QStringView id, bool isExpression = false);
explicit QualifiedIdentifier(const QString& id, bool isExpression = false)
: QualifiedIdentifier(QStringView{id}, isExpression)
{
}
explicit QualifiedIdentifier(const Identifier& id);
QualifiedIdentifier(const QualifiedIdentifier& id);
explicit QualifiedIdentifier(uint index);
......@@ -381,7 +393,7 @@ public:
* Variables like pointerDepth, isReference, etc. are not parsed from the string, so this parsing is quite limited.
*/
explicit IndexedTypeIdentifier(const IndexedQualifiedIdentifier& identifier = IndexedQualifiedIdentifier());
explicit IndexedTypeIdentifier(const QString& identifer, bool isExpression = false);
explicit IndexedTypeIdentifier(QStringView identifer, bool isExpression = false);
bool isReference() const;
void setIsReference(bool);
......
......@@ -20,7 +20,7 @@ bool endsWithWordBoundary(QStringView str)
return !boundary.isLetterOrNumber() && boundary != QLatin1Char('_');
}
bool isOperator(const QString& str, int pos)
bool isOperator(QStringView str, int pos)
{
Q_ASSERT(pos >= 0 && pos < str.size());
......@@ -48,7 +48,7 @@ bool isOperator(const QString& str, int pos)
--pos;
}
auto prefix = QStringView(str).left(pos + 1);
auto prefix = str.left(pos + 1);
if (!prefix.endsWith(op)) {
return false;
}
......@@ -58,7 +58,7 @@ bool isOperator(const QString& str, int pos)
}
// check for operator-> but don't get confused by operator-->
bool isArrowOperator(const QString& str, int pos)
bool isArrowOperator(QStringView str, int pos)
{
Q_ASSERT(pos >= 0 && pos < str.size());
......@@ -66,7 +66,7 @@ bool isArrowOperator(const QString& str, int pos)
return pos > 0 && str[pos - 1] == QLatin1Char('-') && (pos == 1 || str[pos - 2] != QLatin1Char('-'));
}
int skipStringOrCharLiteral(const QString& str, int pos)
int skipStringOrCharLiteral(QStringView str, int pos)
{
Q_ASSERT(pos >= 0 && pos < str.size());
......@@ -85,20 +85,26 @@ int skipStringOrCharLiteral(const QString& str, int pos)
namespace KDevelop {
class ParamIteratorPrivate
{
Q_DISABLE_COPY_MOVE(ParamIteratorPrivate)
public:
explicit ParamIteratorPrivate(const QString& parens, const QString& source)
explicit ParamIteratorPrivate(QStringView parens, QStringView source)
: m_parens(parens)
, m_source(source)
{
}
const QString m_parens;
const QString m_source;
QString m_prefix;
const QStringView m_parens;
const QStringView m_source;
QStringView m_prefix;
int m_cur;
int m_curEnd;
int m_end;
QStringView sourceRange(int first, int last) const
{
return m_source.mid(first, last - first);
}
int next() const
{
return findCommaOrEnd(m_source, m_cur, m_parens[1]);
......@@ -119,7 +125,7 @@ bool parenFits(QChar c1, QChar c2)
return false;
}
int findClose(const QString& str, int pos)
int findClose(QStringView str, int pos)
{
Q_ASSERT(pos >= 0 && pos < str.size());
......@@ -166,7 +172,7 @@ int findClose(const QString& str, int pos)
return -1;
}
int findCommaOrEnd(const QString& str, int pos, QChar validEnd)
int findCommaOrEnd(QStringView str, int pos, QChar validEnd)
{
const auto size = str.size();
Q_ASSERT(pos >= 0 && pos <= size);
......@@ -310,7 +316,7 @@ QString removeWhitespace(const QString& str)
ParamIterator::~ParamIterator() = default;
ParamIterator::ParamIterator(const QString& parens, const QString& source, int offset)
ParamIterator::ParamIterator(QStringView parens, QStringView source, int offset)
: d_ptr(new ParamIteratorPrivate{parens, source})
{
Q_D(ParamIterator);
......@@ -332,7 +338,7 @@ ParamIterator::ParamIterator(const QString& parens, const QString& source, int o
if (foundEnd != -1) {
//We have to stop the search, because we found an interrupting end-sign before the opening-paren
d->m_prefix = d->m_source.mid(offset, foundEnd - offset);
d->m_prefix = d->sourceRange(offset, foundEnd);
d->m_curEnd = d->m_end = d->m_cur = foundEnd;
} else {
......@@ -341,7 +347,7 @@ ParamIterator::ParamIterator(const QString& parens, const QString& source, int o
d->m_cur = parenBegin + 1;
d->m_curEnd = d->next();
if (d->m_curEnd != d->m_source.length()) {
d->m_prefix = d->m_source.mid(offset, parenBegin - offset);
d->m_prefix = d->sourceRange(offset, parenBegin);
return;
} // else: the paren was not closed. It might be an identifier like "operator<", so count everything as prefix.
} // else: we have neither found an ending-character, nor an opening-paren, so take the whole input and end.
......@@ -373,13 +379,13 @@ ParamIterator& ParamIterator::operator ++()
return *this;
}
QString ParamIterator::operator*() const
QStringView ParamIterator::operator*() const
{
Q_D(const ParamIterator);
Q_ASSERT(*this);
return d->m_source.mid(d->m_cur, d->m_curEnd - d->m_cur).trimmed();
return d->sourceRange(d->m_cur, d->m_curEnd).trimmed();
}
ParamIterator::operator bool() const
......@@ -389,7 +395,7 @@ ParamIterator::operator bool() const
return d->m_cur < d->m_end;
}
QString ParamIterator::prefix() const
QStringView ParamIterator::prefix() const
{
Q_D(const ParamIterator);
......
......@@ -14,6 +14,7 @@
class QByteArray;
class QString;
class QStringView;
namespace KDevelop {
class ParamIteratorPrivate;
......@@ -21,7 +22,7 @@ class ParamIteratorPrivate;
/**
* Searches a fitting closing brace from left to right: a ')' for '(', ']' for '[', ...
*/
int KDEVPLATFORMLANGUAGE_EXPORT findClose(const QString& str, int pos);
int KDEVPLATFORMLANGUAGE_EXPORT findClose(QStringView str, int pos);
/**
* Searches in the given string for a ',' or closing brace,
......@@ -31,7 +32,7 @@ int KDEVPLATFORMLANGUAGE_EXPORT findClose(const QString& str, int pos);
* @param validEnd when this is set differently, the function will stop when it finds a comma or the given character, and not at closing-braces.
* @return On fail, str.length() is returned, else the position of the closing character.
*/
int KDEVPLATFORMLANGUAGE_EXPORT findCommaOrEnd(const QString& str, int pos, QChar validEnd = QLatin1Char( ' ' ));
int KDEVPLATFORMLANGUAGE_EXPORT findCommaOrEnd(QStringView str, int pos, QChar validEnd = QLatin1Char(' '));
/**
* Extracts the interesting information out of a comment.
......@@ -62,8 +63,10 @@ public:
* If that end-character is encountered in the prefix, the iteration will be stopped.
*
* Example: When "<>:" is given, ParamIterator will only parse the first identifier of a C++ scope
*
* @warning The QStringView arguments must remain valid and unchanged during ParamIterator's lifetime.
*/
ParamIterator(const QString& parens, const QString& source, int start = 0);
explicit ParamIterator(QStringView parens, QStringView source, int start = 0);
~ParamIterator();
ParamIterator& operator ++();
......@@ -71,7 +74,7 @@ public:
/**
* Returns current found parameter
*/
QString operator*() const;
QStringView operator*() const;
/**
* Returns whether there is a current found parameter
......@@ -81,7 +84,7 @@ public:
/**
* Returns the text in front of the first opening-paren(if none found then the whole text)
*/
QString prefix() const;
QStringView prefix() const;
uint position() const;
......
......@@ -182,7 +182,7 @@ void TestStringHelpers::testParamIterator()
QFETCH(QString, source);
QFETCH(QStringList, params);
const auto parens = QStringLiteral("<>:");
const auto parens = u"<>:";
auto it = KDevelop::ParamIterator(parens, source);
......
......@@ -236,7 +236,7 @@ IndexedString::IndexedString(const QUrl& url)
Q_ASSERT(url == url.adjusted(QUrl::NormalizePathSegments));
}
IndexedString::IndexedString(const QString& string)
IndexedString::IndexedString(QStringView string)
: IndexedString(string.toUtf8())
{}
......
......@@ -10,6 +10,7 @@
//krazy:excludeall=dpointer,inline
#include <QMetaType>
#include <QStringView>
#include <QUrl>
#include "referencecounting.h"
......@@ -76,7 +77,11 @@ public:
*
* @note This is expensive.
*/
explicit IndexedString(const QString& str);
explicit IndexedString(QStringView str);
explicit IndexedString(const QString& str)
: IndexedString(QStringView{str})
{
}
/**
* When the information is already available, try using the other constructor.
......
......@@ -37,6 +37,8 @@
#include <clang-c/Documentation.h>
#include <QVarLengthArray>
#include <unordered_map>
#include <typeinfo>
......@@ -622,7 +624,7 @@ struct Visitor
AbstractType *createType(CXType, CXCursor /*parent*/)
{
auto t = new DelayedType;
static const IndexedTypeIdentifier id(QLatin1String(CursorKindTraits::delayedTypeName(TK)));
static const IndexedTypeIdentifier id(CursorKindTraits::delayedTypeName(TK));
t->setIdentifier(id);
return t;
}
......@@ -737,12 +739,12 @@ struct Visitor
return createDelayedType(type);
}
QStringList typesStr;
QString tStr = ClangString(clang_getTypeSpelling(type)).toString();
ParamIterator iter(QStringLiteral("<>"), tStr);
const QString tStr = ClangString(clang_getTypeSpelling(type)).toString();
QVarLengthArray<QStringView, 8> typesStr;
ParamIterator iter(u"<>", tStr);
while (iter) {
typesStr.append(*iter);
typesStr.push_back(*iter);
++iter;
}
......@@ -1061,8 +1063,8 @@ void Visitor::setDeclData(CXCursor cursor, MacroDefinition* decl) const
start = closingParen + 2; // + ')' + ' '
// extract macro function parameters
const QString parameters = contents.mid(firstOpeningParen, closingParen - firstOpeningParen + 1);
ParamIterator paramIt(QStringLiteral("():"), parameters, 0);
const auto parameters = QStringView{contents}.mid(firstOpeningParen, closingParen - firstOpeningParen + 1);
ParamIterator paramIt(u"():", parameters, 0);
while (paramIt) {
decl->addParameter(IndexedString(*paramIt));
++paramIt;
......
......@@ -288,14 +288,14 @@ constexpr bool isIdentifiedType(CXCursorKind CK)
return isClass(CK) || isAliasType(CK) || CK == CXCursor_EnumDecl || CK == CXCursor_EnumConstantDecl;
}
constexpr const char* delayedTypeName(CXTypeKind TK)
constexpr const char16_t* delayedTypeName(CXTypeKind TK)
{
return TK == CXType_Int128 ? "__int128"
: TK == CXType_UInt128 ? "unsigned __int128"
: TK == CXType_ObjCId ? "id"
: TK == CXType_ObjCSel ? "SEL"
: TK == CXType_NullPtr ? "nullptr_t"
: nullptr;
return TK == CXType_Int128 ? u"__int128"
: TK == CXType_UInt128 ? u"unsigned __int128"
: TK == CXType_ObjCId ? u"id"
: TK == CXType_ObjCSel ? u"SEL"
: TK == CXType_NullPtr ? u"nullptr_t"
: nullptr;
}
}
......
......@@ -424,8 +424,8 @@ void TestDUChain::testTemplate()
QVERIFY(fooDecl->internalContext());
QCOMPARE(fooDecl->internalContext()->localDeclarations().size(), 2);
QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier("foo< T >")).size(), 1);
QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier("foo< T >::bar")).size(), 1);
QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier(u"foo< T >")).size(), 1);
QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier(u"foo< T >::bar")).size(), 1);
auto mainCtx = file.topContext()->localDeclarations().last()->internalContext()->childContexts().first();
QVERIFY(mainCtx);
......@@ -469,9 +469,9 @@ void TestDUChain::testNamespace()
QCOMPARE(baz->qualifiedIdentifier().toString(), QString("foo::bar::baz"));
for (auto ctx : {top, mainCtx}) {
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier("foo")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier("foo::bar")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier("foo::bar::baz")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier(u"foo")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier(u"foo::bar")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier(u"foo::bar::baz")).size(), 1);
}
}
......@@ -490,9 +490,9 @@ void TestDUChain::testAutoTypeDeduction()
DUContext* ctx = file.topContext().data();
QVERIFY(ctx);
QCOMPARE(ctx->localDeclarations().size(), 4);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier("foo")).size(), 1);
QCOMPARE(ctx->findDeclarations(QualifiedIdentifier(u"foo")).size(), 1);
Declaration* decl = ctx->findDeclarations(QualifiedIdentifier(QStringLiteral("foo")))[0];
QCOMPARE(decl->identifier(), Identifier("foo"));
QCOMPARE(decl->identifier(), Identifier(u"foo"));
#if CINDEX_VERSION_MINOR < 31
QEXPECT_FAIL("", "No type deduction here unfortunately, missing API in Clang", Continue);
#endif
......@@ -528,7 +528,7 @@ void TestDUChain::testTypeDeductionInTemplateInstantiation()
// check 'foo' declaration
decl = ctx->localDeclarations()[0];
QVERIFY(decl);
QCOMPARE(decl->identifier(), Identifier("foo< T >"));
QCOMPARE(decl->identifier(), Identifier(u"foo< T >"));
// check type of 'member' inside declaration-scope
QCOMPARE(ctx->childContexts().size(), 1);
......@@ -537,13 +537,13 @@ void TestDUChain::testTypeDeductionInTemplateInstantiation()
// Should there really be two declarations?
QCOMPARE(fooCtx->localDeclarations().size(), 2);
decl = fooCtx->localDeclarations()[1];
QCOMPARE(decl->identifier(), Identifier("member"));
QCOMPARE(decl->identifier(), Identifier(u"member"));
// check type of 'member' in definition of 'f'
decl = ctx->localDeclarations()[1];
QCOMPARE(decl->identifier(), Identifier("f"));
QCOMPARE(decl->identifier(), Identifier(u"f"));
decl = ctx->localDeclarations()[2];
QCOMPARE(decl->identifier(), Identifier("i"));
QCOMPARE(decl->identifier(), Identifier(u"i"));
#if CINDEX_VERSION_MINOR < 31
QEXPECT_FAIL("", "No type deduction here unfortunately, missing API in Clang", Continue);
#endif
......@@ -564,7 +564,7 @@ void TestDUChain::testVirtualMemberFunction()
QCOMPARE(top->localDeclarations().count(), 3);
QCOMPARE(top->childContexts()[2]->localDeclarations().count(), 1);
Declaration* decl = top->childContexts()[2]->localDeclarations()[0];
QCOMPARE(decl->identifier(), Identifier("ret"));
QCOMPARE(decl->identifier(), Identifier(u"ret"));
QVERIFY(DUChainUtils::overridden(decl));
}
......@@ -579,10 +579,10 @@ void TestDUChain::testBaseClasses()
QCOMPARE(top->localDeclarations().count(), 2);
Declaration* baseDecl = top->localDeclarations().first();
QCOMPARE(baseDecl->identifier(), Identifier("Base"));
QCOMPARE(baseDecl->identifier(), Identifier(u"Base"));
ClassDeclaration* inheritedDecl = dynamic_cast<ClassDeclaration*>(top->localDeclarations()[1]);
QCOMPARE(inheritedDecl->identifier(), Identifier("Inherited"));
QCOMPARE(inheritedDecl->identifier(), Identifier(u"Inherited"));
QVERIFY(inheritedDecl);
QCOMPARE(inheritedDecl->baseClassesSize(), 1u);
......@@ -671,14 +671,14 @@ void TestDUChain::testGetInheriters()
QCOMPARE(top->localDeclarations().count(), 2);
Declaration* baseDecl = top->localDeclarations().first();
QCOMPARE(baseDecl->identifier(), Identifier("Base"));
QCOMPARE(baseDecl->identifier(), Identifier(u"Base"));
DUContext* baseCtx = baseDecl->internalContext();
QVERIFY(baseCtx);
QCOMPARE(baseCtx->localDeclarations().count(), 1);
Declaration* innerDecl = baseCtx->localDeclarations().first();
QCOMPARE(innerDecl->identifier(), Identifier("Inner"));
QCOMPARE(innerDecl->identifier(), Identifier(u"Inner"));
if (auto forward = dynamic_cast<ForwardDeclaration*>(innerDecl)) {
innerDecl = forward->resolve(top);
}
......@@ -686,7 +686,7 @@ void TestDUChain::testGetInheriters()
Declaration* inheritedDecl = top->localDeclarations().last();
QVERIFY(inheritedDecl);
QCOMPARE(inheritedDecl->identifier(), Identifier("Inherited"));
QCOMPARE(inheritedDecl->identifier(), Identifier(u"Inherited"));
uint maxAllowedSteps = uint(-1);
auto baseInheriters = DUChainUtils::inheriters(baseDecl, maxAllowedSteps);
......@@ -1213,20 +1213,20 @@ void TestDUChain::testMacroDependentHeader()
// validate uses:
QCOMPARE(top->usesCount(), 14);
QCOMPARE(top->uses()[0].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("A"));
QCOMPARE(top->uses()[1].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("A"));
QCOMPARE(top->uses()[2].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("A::Q"));
QCOMPARE(top->uses()[3].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("B"));
QCOMPARE(top->uses()[4].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("B"));
QCOMPARE(top->uses()[5].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("B::Q"));
QCOMPARE(top->uses()[6].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(top->uses()[7].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("A::m"));
QCOMPARE(top->uses()[8].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("aq"));
QCOMPARE(top->uses()[9].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("A::Q::m"));
QCOMPARE(top->uses()[10].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("b"));
QCOMPARE(top->uses()[11].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("B::m"));
QCOMPARE(top->uses()[12].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("bq"));
QCOMPARE(top->uses()[13].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier("B::Q::m"));
QCOMPARE(top->uses()[0].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"A"));
QCOMPARE(top->uses()[1].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"A"));
QCOMPARE(top->uses()[2].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"A::Q"));
QCOMPARE(top->uses()[3].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"B"));
QCOMPARE(top->uses()[4].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"B"));
QCOMPARE(top->uses()[5].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"B::Q"));
QCOMPARE(top->uses()[6].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
QCOMPARE(top->uses()[7].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"A::m"));
QCOMPARE(top->uses()[8].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"aq"));
QCOMPARE(top->uses()[9].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"A::Q::m"));
QCOMPARE(top->uses()[10].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"b"));
QCOMPARE(top->uses()[11].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"B::m"));
QCOMPARE(top->uses()[12].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"bq"));
QCOMPARE(top->uses()[13].usedDeclaration(top)->qualifiedIdentifier(), QualifiedIdentifier(u"B::Q::m"));
}
void TestDUChain::testHeaderParsingOrder1()
......@@ -1668,7 +1668,7 @@ void TestDUChain::testExternC()
DUChainReadLocker lock;
auto top = file.topContext();
QVERIFY(top);
QVERIFY(!top->findDeclarations(QualifiedIdentifier("foo")).isEmpty());
QVERIFY(!top->findDeclarations(QualifiedIdentifier(u"foo")).isEmpty());
}
void TestDUChain::testIncludeExternC()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment