forked from qt-creator/qt-creator
C++: Remove DeprecatedGenTemplateInstance
It's, well, deprecated... Change-Id: Ie9d7e80345a8d9404f702dd877b3e940a1a49d93 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
e5d8dbd070
commit
29ac9fc65f
@@ -1,430 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DeprecatedGenTemplateInstance.h"
|
||||
#include "Overview.h"
|
||||
|
||||
#include <cplusplus/Control.h>
|
||||
#include <cplusplus/Scope.h>
|
||||
#include <cplusplus/Names.h>
|
||||
#include <cplusplus/Symbols.h>
|
||||
#include <cplusplus/CoreTypes.h>
|
||||
#include <cplusplus/Literals.h>
|
||||
|
||||
#include <QVarLengthArray>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
namespace {
|
||||
|
||||
class ApplySubstitution
|
||||
{
|
||||
public:
|
||||
ApplySubstitution(Control *control, Symbol *symbol, const DeprecatedGenTemplateInstance::Substitution &substitution);
|
||||
~ApplySubstitution();
|
||||
|
||||
inline Control *control() const { return _control; }
|
||||
|
||||
FullySpecifiedType apply(const Name *name);
|
||||
FullySpecifiedType apply(const FullySpecifiedType &type);
|
||||
|
||||
int findSubstitution(const Identifier *id) const;
|
||||
FullySpecifiedType applySubstitution(int index) const;
|
||||
|
||||
private:
|
||||
class ApplyToType: protected TypeVisitor
|
||||
{
|
||||
public:
|
||||
ApplyToType(ApplySubstitution *q)
|
||||
: q(q) {}
|
||||
|
||||
FullySpecifiedType operator()(const FullySpecifiedType &ty)
|
||||
{
|
||||
FullySpecifiedType previousType = switchType(ty);
|
||||
accept(ty.type());
|
||||
return switchType(previousType);
|
||||
}
|
||||
|
||||
protected:
|
||||
using TypeVisitor::visit;
|
||||
|
||||
Control *control() const
|
||||
{ return q->control(); }
|
||||
|
||||
FullySpecifiedType switchType(const FullySpecifiedType &type)
|
||||
{
|
||||
FullySpecifiedType previousType = _type;
|
||||
_type = type;
|
||||
return previousType;
|
||||
}
|
||||
|
||||
virtual void visit(VoidType *)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
virtual void visit(IntegerType *)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
virtual void visit(FloatType *)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
virtual void visit(PointerToMemberType *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO; // ### TODO
|
||||
}
|
||||
|
||||
virtual void visit(PointerType *ptrTy)
|
||||
{
|
||||
_type.setType(control()->pointerType(q->apply(ptrTy->elementType())));
|
||||
}
|
||||
|
||||
virtual void visit(ReferenceType *refTy)
|
||||
{
|
||||
_type.setType(control()->referenceType(q->apply(refTy->elementType()), refTy->isRvalueReference()));
|
||||
}
|
||||
|
||||
virtual void visit(ArrayType *arrayTy)
|
||||
{
|
||||
_type.setType(control()->arrayType(q->apply(arrayTy->elementType()), arrayTy->size()));
|
||||
}
|
||||
|
||||
virtual void visit(NamedType *ty)
|
||||
{
|
||||
FullySpecifiedType n = q->apply(ty->name());
|
||||
_type.setType(n.type());
|
||||
}
|
||||
|
||||
virtual void visit(Function *funTy)
|
||||
{
|
||||
Function *fun = control()->newFunction(/*sourceLocation=*/ 0, funTy->name());
|
||||
fun->setEnclosingScope(funTy->enclosingScope());
|
||||
fun->setConst(funTy->isConst());
|
||||
fun->setVolatile(funTy->isVolatile());
|
||||
fun->setVirtual(funTy->isVirtual());
|
||||
fun->setOverride(funTy->isOverride());
|
||||
fun->setFinal(funTy->isFinal());
|
||||
fun->setAmbiguous(funTy->isAmbiguous());
|
||||
fun->setVariadic(funTy->isVariadic());
|
||||
|
||||
fun->setReturnType(q->apply(funTy->returnType()));
|
||||
|
||||
for (unsigned i = 0, argc = funTy->argumentCount(); i < argc; ++i) {
|
||||
Argument *originalArgument = funTy->argumentAt(i)->asArgument();
|
||||
Argument *arg = control()->newArgument(/*sourceLocation*/ 0,
|
||||
originalArgument->name());
|
||||
|
||||
arg->setType(q->apply(originalArgument->type()));
|
||||
arg->setInitializer(originalArgument->initializer());
|
||||
fun->addMember(arg);
|
||||
}
|
||||
|
||||
_type.setType(fun);
|
||||
}
|
||||
|
||||
virtual void visit(Namespace *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(Class *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(Enum *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ForwardClassDeclaration *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ObjCClass *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ObjCProtocol *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ObjCMethod *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ObjCForwardClassDeclaration *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
virtual void visit(ObjCForwardProtocolDeclaration *)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
private:
|
||||
ApplySubstitution *q;
|
||||
FullySpecifiedType _type;
|
||||
QHash<Symbol *, FullySpecifiedType> _processed;
|
||||
};
|
||||
|
||||
class ApplyToName: protected NameVisitor
|
||||
{
|
||||
public:
|
||||
ApplyToName(ApplySubstitution *q): q(q) {}
|
||||
|
||||
FullySpecifiedType operator()(const Name *name)
|
||||
{
|
||||
FullySpecifiedType previousType = switchType(FullySpecifiedType());
|
||||
accept(name);
|
||||
return switchType(previousType);
|
||||
}
|
||||
|
||||
protected:
|
||||
Control *control() const
|
||||
{ return q->control(); }
|
||||
|
||||
int findSubstitution(const Identifier *id) const
|
||||
{ return q->findSubstitution(id); }
|
||||
|
||||
FullySpecifiedType applySubstitution(int index) const
|
||||
{ return q->applySubstitution(index); }
|
||||
|
||||
FullySpecifiedType switchType(const FullySpecifiedType &type)
|
||||
{
|
||||
FullySpecifiedType previousType = _type;
|
||||
_type = type;
|
||||
return previousType;
|
||||
}
|
||||
|
||||
virtual void visit(const Identifier *name)
|
||||
{
|
||||
int index = findSubstitution(name->identifier());
|
||||
|
||||
if (index != -1)
|
||||
_type = applySubstitution(index);
|
||||
|
||||
else
|
||||
_type = control()->namedType(name);
|
||||
}
|
||||
|
||||
virtual void visit(const TemplateNameId *name)
|
||||
{
|
||||
QVarLengthArray<FullySpecifiedType, 8> arguments(name->templateArgumentCount());
|
||||
for (unsigned i = 0; i < name->templateArgumentCount(); ++i) {
|
||||
FullySpecifiedType argTy = name->templateArgumentAt(i);
|
||||
arguments[i] = q->apply(argTy);
|
||||
}
|
||||
|
||||
const TemplateNameId *templId = control()->templateNameId(name->identifier(),
|
||||
name->isSpecialization(),
|
||||
arguments.data(),
|
||||
arguments.size());
|
||||
_type = control()->namedType(templId);
|
||||
}
|
||||
|
||||
const Name *instantiate(const Name *name)
|
||||
{
|
||||
if (! name)
|
||||
return name;
|
||||
|
||||
if (const Identifier *nameId = name->asNameId()) {
|
||||
const Identifier *id = control()->identifier(nameId->chars(), nameId->size());
|
||||
return id;
|
||||
|
||||
} else if (const TemplateNameId *templId = name->asTemplateNameId()) {
|
||||
QVarLengthArray<FullySpecifiedType, 8> arguments(templId->templateArgumentCount());
|
||||
for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount();
|
||||
++templateArgIndex) {
|
||||
FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex);
|
||||
arguments[templateArgIndex] = q->apply(argTy);
|
||||
}
|
||||
const Identifier *id = control()->identifier(templId->identifier()->chars(),
|
||||
templId->identifier()->size());
|
||||
return control()->templateNameId(id, templId->isSpecialization(), arguments.data(),
|
||||
arguments.size());
|
||||
|
||||
} else if (const QualifiedNameId *qq = name->asQualifiedNameId()) {
|
||||
const Name *base = instantiate(qq->base());
|
||||
const Name *name = instantiate(qq->name());
|
||||
|
||||
return control()->qualifiedNameId(base, name);
|
||||
|
||||
} else if (const OperatorNameId *op = name->asOperatorNameId()) {
|
||||
return control()->operatorNameId(op->kind());
|
||||
|
||||
} else if (const ConversionNameId *c = name->asConversionNameId()) {
|
||||
FullySpecifiedType ty = q->apply(c->type());
|
||||
return control()->conversionNameId(ty);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void visit(const QualifiedNameId *name)
|
||||
{
|
||||
if (const Name *n = instantiate(name))
|
||||
_type = control()->namedType(n);
|
||||
}
|
||||
|
||||
virtual void visit(const DestructorNameId *name)
|
||||
{
|
||||
Overview oo;
|
||||
qWarning() << "ignored name:" << oo.prettyName(name);
|
||||
}
|
||||
|
||||
virtual void visit(const OperatorNameId *name)
|
||||
{
|
||||
Overview oo;
|
||||
qWarning() << "ignored name:" << oo.prettyName(name);
|
||||
}
|
||||
|
||||
virtual void visit(const ConversionNameId *name)
|
||||
{
|
||||
Overview oo;
|
||||
qWarning() << "ignored name:" << oo.prettyName(name);
|
||||
}
|
||||
|
||||
virtual void visit(const SelectorNameId *name)
|
||||
{
|
||||
Overview oo;
|
||||
qWarning() << "ignored name:" << oo.prettyName(name);
|
||||
}
|
||||
|
||||
private:
|
||||
ApplySubstitution *q;
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
public: // attributes
|
||||
Control *_control;
|
||||
Symbol *symbol;
|
||||
DeprecatedGenTemplateInstance::Substitution substitution;
|
||||
ApplyToType applyToType;
|
||||
ApplyToName applyToName;
|
||||
};
|
||||
|
||||
ApplySubstitution::ApplySubstitution(Control *control, Symbol *symbol,
|
||||
const DeprecatedGenTemplateInstance::Substitution &substitution)
|
||||
: _control(control), symbol(symbol),
|
||||
substitution(substitution),
|
||||
applyToType(this), applyToName(this)
|
||||
{ }
|
||||
|
||||
ApplySubstitution::~ApplySubstitution()
|
||||
{
|
||||
}
|
||||
|
||||
FullySpecifiedType ApplySubstitution::apply(const Name *name)
|
||||
{
|
||||
FullySpecifiedType ty = applyToName(name);
|
||||
return ty;
|
||||
}
|
||||
|
||||
FullySpecifiedType ApplySubstitution::apply(const FullySpecifiedType &type)
|
||||
{
|
||||
FullySpecifiedType ty = applyToType(type);
|
||||
return ty;
|
||||
}
|
||||
|
||||
int ApplySubstitution::findSubstitution(const Identifier *id) const
|
||||
{
|
||||
Q_ASSERT(id != 0);
|
||||
|
||||
for (int index = 0; index < substitution.size(); ++index) {
|
||||
QPair<const Identifier *, FullySpecifiedType> s = substitution.at(index);
|
||||
|
||||
if (id->match(s.first))
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
FullySpecifiedType ApplySubstitution::applySubstitution(int index) const
|
||||
{
|
||||
Q_ASSERT(index != -1);
|
||||
Q_ASSERT(index < substitution.size());
|
||||
|
||||
return substitution.at(index).second;
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
DeprecatedGenTemplateInstance::DeprecatedGenTemplateInstance(QSharedPointer<Control> control, const Substitution &substitution)
|
||||
: _control(control),
|
||||
_substitution(substitution)
|
||||
{ }
|
||||
|
||||
FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol)
|
||||
{
|
||||
ApplySubstitution o(_control.data(), symbol, _substitution);
|
||||
return o.apply(symbol->type());
|
||||
}
|
||||
|
||||
FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *className, Symbol *candidate,
|
||||
QSharedPointer<Control> control)
|
||||
{
|
||||
if (className) {
|
||||
if (const TemplateNameId *templId = className->asTemplateNameId()) {
|
||||
if (Template *templ = candidate->enclosingTemplate()) {
|
||||
DeprecatedGenTemplateInstance::Substitution subst;
|
||||
|
||||
for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) {
|
||||
FullySpecifiedType templArgTy = templId->templateArgumentAt(i);
|
||||
|
||||
if (i < templ->templateParameterCount()) {
|
||||
const Name *templArgName = templ->templateParameterAt(i)->name();
|
||||
|
||||
if (templArgName && templArgName->identifier()) {
|
||||
const Identifier *templArgId = templArgName->identifier();
|
||||
subst.append(qMakePair(templArgId, templArgTy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedGenTemplateInstance inst(control, subst);
|
||||
return inst.gen(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
return candidate->type();
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
|
||||
#define CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
|
||||
|
||||
#include <cplusplus/TypeVisitor.h>
|
||||
#include <cplusplus/NameVisitor.h>
|
||||
#include <cplusplus/FullySpecifiedType.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT DeprecatedGenTemplateInstance
|
||||
{
|
||||
public:
|
||||
typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution;
|
||||
|
||||
public:
|
||||
static FullySpecifiedType instantiate(const Name *className, Symbol *candidate, QSharedPointer<Control> control);
|
||||
|
||||
private:
|
||||
DeprecatedGenTemplateInstance(QSharedPointer<Control> control, const Substitution &substitution);
|
||||
FullySpecifiedType gen(Symbol *symbol);
|
||||
|
||||
private:
|
||||
QSharedPointer<Control> _control;
|
||||
const Substitution _substitution;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_DEPRECATEDGENTEMPLATEINSTANCE_H
|
||||
@@ -105,8 +105,6 @@ QString CPlusPlus::toString(const ClassOrNamespace *binding, QString id)
|
||||
QString result = QString::fromLatin1("%0: %1 symbols").arg(
|
||||
id,
|
||||
QString::number(binding->symbols().length()));
|
||||
if (binding->templateId())
|
||||
result.append(QString::fromLatin1("\n%1").arg(indent(toString(binding->templateId(), QLatin1String("Template")))));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "ResolveExpression.h"
|
||||
#include "Overview.h"
|
||||
#include "DeprecatedGenTemplateInstance.h"
|
||||
#include "CppRewriter.h"
|
||||
|
||||
#include <cplusplus/CoreTypes.h>
|
||||
@@ -399,7 +398,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
|
||||
for (; scope; scope = scope->enclosingScope()) {
|
||||
if (name->identifier() != 0 && scope->isBlock()) {
|
||||
bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, scope, &candidates);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's a local.
|
||||
@@ -435,7 +434,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
}
|
||||
|
||||
} else if (Function *fun = scope->asFunction()) {
|
||||
bindings()->lookupInScope(name, fun, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, fun, &candidates);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's an argument or a template parameter.
|
||||
@@ -462,13 +461,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
||||
// continue, and look at the enclosing scope.
|
||||
|
||||
} else if (ObjCMethod *method = scope->asObjCMethod()) {
|
||||
bindings()->lookupInScope(name, method, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, method, &candidates);
|
||||
|
||||
if (! candidates.isEmpty())
|
||||
break; // it's a formal argument.
|
||||
|
||||
} else if (Template *templ = scope->asTemplate()) {
|
||||
bindings()->lookupInScope(name, templ, &candidates, /*templateId = */ 0, /*binding=*/ 0);
|
||||
bindings()->lookupInScope(name, templ, &candidates);
|
||||
|
||||
if (! candidates.isEmpty()) {
|
||||
// it's a template parameter.
|
||||
@@ -555,7 +554,6 @@ ClassOrNamespace::ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *pa
|
||||
: _factory(factory)
|
||||
, _parent(parent)
|
||||
, _scopeLookupCache(0)
|
||||
, _templateId(0)
|
||||
, _instantiationOrigin(0)
|
||||
, _rootClass(0)
|
||||
, _name(0)
|
||||
@@ -568,11 +566,6 @@ ClassOrNamespace::~ClassOrNamespace()
|
||||
delete _scopeLookupCache;
|
||||
}
|
||||
|
||||
const TemplateNameId *ClassOrNamespace::templateId() const
|
||||
{
|
||||
return _templateId;
|
||||
}
|
||||
|
||||
ClassOrNamespace *ClassOrNamespace::instantiationOrigin() const
|
||||
{
|
||||
return _instantiationOrigin;
|
||||
@@ -672,7 +665,7 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
||||
if (processedOwnParents.contains(binding))
|
||||
break;
|
||||
processedOwnParents.insert(binding);
|
||||
lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
|
||||
lookup_helper(name, binding, &result, &processed);
|
||||
binding = binding->_parent;
|
||||
} while (searchInEnclosingScope && binding);
|
||||
}
|
||||
@@ -681,9 +674,8 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
||||
}
|
||||
|
||||
void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding,
|
||||
QList<LookupItem> *result,
|
||||
QSet<ClassOrNamespace *> *processed,
|
||||
const TemplateNameId *templateId)
|
||||
QList<LookupItem> *result,
|
||||
QSet<ClassOrNamespace *> *processed)
|
||||
{
|
||||
if (binding && ! processed->contains(binding)) {
|
||||
processed->insert(binding);
|
||||
@@ -708,15 +700,15 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
|
||||
}
|
||||
}
|
||||
}
|
||||
_factory->lookupInScope(name, scope, result, templateId, binding);
|
||||
_factory->lookupInScope(name, scope, result, binding);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Enum *e, binding->unscopedEnums())
|
||||
_factory->lookupInScope(name, e, result, templateId, binding);
|
||||
_factory->lookupInScope(name, e, result, binding);
|
||||
|
||||
foreach (ClassOrNamespace *u, binding->usings())
|
||||
lookup_helper(name, u, result, processed, binding->_templateId);
|
||||
lookup_helper(name, u, result, processed);
|
||||
|
||||
Anonymouses::const_iterator cit = binding->_anonymouses.constBegin();
|
||||
Anonymouses::const_iterator citEnd = binding->_anonymouses.constEnd();
|
||||
@@ -724,14 +716,13 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
|
||||
const AnonymousNameId *anonymousNameId = cit.key();
|
||||
ClassOrNamespace *a = cit.value();
|
||||
if (!binding->_declaredOrTypedefedAnonymouses.contains(anonymousNameId))
|
||||
lookup_helper(name, a, result, processed, binding->_templateId);
|
||||
lookup_helper(name, a, result, processed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateBindings::lookupInScope(const Name *name, Scope *scope,
|
||||
QList<LookupItem> *result,
|
||||
const TemplateNameId *templateId,
|
||||
ClassOrNamespace *binding)
|
||||
{
|
||||
if (! name) {
|
||||
@@ -782,11 +773,6 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
|
||||
}
|
||||
}
|
||||
|
||||
if (templateId && (s->isDeclaration() || s->isFunction())) {
|
||||
FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, control());
|
||||
item.setType(ty); // override the type.
|
||||
}
|
||||
|
||||
// instantiate function template
|
||||
if (name->isTemplateNameId() && s->isTemplate() && s->asTemplate()->declaration()
|
||||
&& s->asTemplate()->declaration()->isFunction()) {
|
||||
@@ -933,21 +919,6 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
|
||||
if (ClassOrNamespace *e = nestedType(name, origin))
|
||||
return e;
|
||||
|
||||
if (_templateId) {
|
||||
if (_usings.size() == 1) {
|
||||
ClassOrNamespace *delegate = _usings.first();
|
||||
|
||||
if (ClassOrNamespace *r = delegate->lookupType_helper(name,
|
||||
processed,
|
||||
/*searchInEnclosingScope = */ true,
|
||||
origin))
|
||||
return r;
|
||||
} else if (Q_UNLIKELY(debug)) {
|
||||
qWarning() << "expected one using declaration. Number of using declarations is:"
|
||||
<< _usings.size();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ClassOrNamespace *u, usings()) {
|
||||
if (ClassOrNamespace *r = u->lookupType_helper(name,
|
||||
processed,
|
||||
@@ -1159,7 +1130,6 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
|
||||
ClassOrNamespace *instantiation = _factory->allocClassOrNamespace(baseTemplateClassReference);
|
||||
if (Q_UNLIKELY(debug))
|
||||
instantiation->_name = templId;
|
||||
instantiation->_templateId = templId;
|
||||
|
||||
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock())
|
||||
origin = origin->parent();
|
||||
|
||||
@@ -71,7 +71,6 @@ class CPLUSPLUS_EXPORT ClassOrNamespace
|
||||
public:
|
||||
~ClassOrNamespace();
|
||||
|
||||
const TemplateNameId *templateId() const;
|
||||
ClassOrNamespace *instantiationOrigin() const;
|
||||
|
||||
ClassOrNamespace *parent() const;
|
||||
@@ -118,8 +117,7 @@ private:
|
||||
|
||||
void lookup_helper(const Name *name, ClassOrNamespace *binding,
|
||||
QList<LookupItem> *result,
|
||||
QSet<ClassOrNamespace *> *processed,
|
||||
const TemplateNameId *templateId);
|
||||
QSet<ClassOrNamespace *> *processed);
|
||||
|
||||
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed,
|
||||
bool searchInEnclosingScope, ClassOrNamespace *origin);
|
||||
@@ -149,7 +147,6 @@ private:
|
||||
QHash<Internal::FullyQualifiedName, Symbol *> *_scopeLookupCache;
|
||||
|
||||
// it's an instantiation.
|
||||
const TemplateNameId *_templateId;
|
||||
ClassOrNamespace *_instantiationOrigin;
|
||||
|
||||
AlreadyConsideredClassContainer<Class> _alreadyConsideredClasses;
|
||||
@@ -195,7 +192,7 @@ public:
|
||||
/// Store the result in \a results.
|
||||
/// \internal
|
||||
void lookupInScope(const Name *name, Scope *scope, QList<LookupItem> *result,
|
||||
const TemplateNameId *templateId, ClassOrNamespace *binding);
|
||||
ClassOrNamespace *binding = 0);
|
||||
|
||||
/// Create bindings for the symbols reachable from \a rootSymbol.
|
||||
/// \internal
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "LookupContext.h"
|
||||
#include "Overview.h"
|
||||
#include "DeprecatedGenTemplateInstance.h"
|
||||
#include "CppRewriter.h"
|
||||
#include "TypeOfExpression.h"
|
||||
#include "TypeResolver.h"
|
||||
@@ -493,14 +492,12 @@ bool ResolveExpression::visit(UnaryExpressionAST *ast)
|
||||
Symbol *overload = r.declaration();
|
||||
if (Function *funTy = overload->type()->asFunctionType()) {
|
||||
if (maybeValidPrototype(funTy, 0)) {
|
||||
if (Function *proto = instantiate(b->templateId(), funTy)->asFunctionType()) {
|
||||
FullySpecifiedType retTy = proto->returnType().simplified();
|
||||
p.setType(retTy);
|
||||
p.setScope(proto->enclosingScope());
|
||||
it.setValue(p);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
FullySpecifiedType retTy = funTy->returnType().simplified();
|
||||
p.setType(retTy);
|
||||
p.setScope(funTy->enclosingScope());
|
||||
it.setValue(p);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -753,10 +750,8 @@ bool ResolveExpression::visit(CallAST *ast)
|
||||
foreach (const LookupItem &r, b->find(functionCallOp)) {
|
||||
Symbol *overload = r.declaration();
|
||||
if (Function *funTy = overload->type()->asFunctionType()) {
|
||||
if (maybeValidPrototype(funTy, actualArgumentCount)) {
|
||||
if (Function *proto = instantiate(namedTy->name(), funTy)->asFunctionType())
|
||||
addResult(proto->returnType().simplified(), scope);
|
||||
}
|
||||
if (maybeValidPrototype(funTy, actualArgumentCount))
|
||||
addResult(funTy->returnType().simplified(), scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -806,9 +801,8 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
|
||||
foreach (const LookupItem &r, b->find(arrayAccessOp)) {
|
||||
Symbol *overload = r.declaration();
|
||||
if (Function *funTy = overload->type()->asFunctionType()) {
|
||||
if (Function *proto = instantiate(namedTy->name(), funTy)->asFunctionType())
|
||||
// ### TODO: check the actual arguments
|
||||
addResult(proto->returnType().simplified(), scope);
|
||||
// ### TODO: check the actual arguments
|
||||
addResult(funTy->returnType().simplified(), scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,14 +961,8 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
|
||||
continue;
|
||||
Scope *functionScope = overload->enclosingScope();
|
||||
|
||||
if (overload->type()->isFunctionType()) {
|
||||
FullySpecifiedType overloadTy
|
||||
= instantiate(binding->templateId(), overload);
|
||||
Function *instantiatedFunction = overloadTy->asFunctionType();
|
||||
Q_ASSERT(instantiatedFunction != 0);
|
||||
|
||||
FullySpecifiedType retTy
|
||||
= instantiatedFunction->returnType().simplified();
|
||||
if (Function *funTy = overload->type()->asFunctionType()) {
|
||||
FullySpecifiedType retTy = funTy->returnType().simplified();
|
||||
|
||||
typeResolver.resolve(&retTy, &functionScope, r.binding());
|
||||
|
||||
@@ -1052,12 +1040,6 @@ ClassOrNamespace *ResolveExpression::findClassForTemplateParameterInExpressionSc
|
||||
return 0;
|
||||
}
|
||||
|
||||
FullySpecifiedType ResolveExpression::instantiate(const Name *className, Symbol *candidate) const
|
||||
{
|
||||
return DeprecatedGenTemplateInstance::instantiate(className, candidate,
|
||||
_context.bindings()->control());
|
||||
}
|
||||
|
||||
bool ResolveExpression::visit(PostIncrDecrAST *ast)
|
||||
{
|
||||
const QList<LookupItem> baseResults = resolve(ast->base_expression, _scope);
|
||||
|
||||
@@ -66,7 +66,6 @@ protected:
|
||||
QList<LookupItem> expression(ExpressionAST *ast);
|
||||
|
||||
QList<LookupItem> switchResults(const QList<LookupItem> &symbols);
|
||||
FullySpecifiedType instantiate(const Name *className, Symbol *candidate) const;
|
||||
|
||||
QList<LookupItem> getMembers(ClassOrNamespace *binding, const Name *memberName) const;
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ HEADERS += \
|
||||
$$PWD/ASTPath.h \
|
||||
$$PWD/SnapshotSymbolVisitor.h \
|
||||
$$PWD/SymbolNameVisitor.h \
|
||||
$$PWD/DeprecatedGenTemplateInstance.h \
|
||||
$$PWD/FindUsages.h \
|
||||
$$PWD/DependencyTable.h \
|
||||
$$PWD/PreprocessorClient.h \
|
||||
@@ -77,7 +76,6 @@ SOURCES += \
|
||||
$$PWD/ASTPath.cpp \
|
||||
$$PWD/SnapshotSymbolVisitor.cpp \
|
||||
$$PWD/SymbolNameVisitor.cpp \
|
||||
$$PWD/DeprecatedGenTemplateInstance.cpp \
|
||||
$$PWD/FindUsages.cpp \
|
||||
$$PWD/DependencyTable.cpp \
|
||||
$$PWD/PreprocessorClient.cpp \
|
||||
|
||||
@@ -97,7 +97,6 @@ QtcLibrary {
|
||||
"CppRewriter.cpp", "CppRewriter.h",
|
||||
"cppmodelmanagerbase.cpp", "cppmodelmanagerbase.h",
|
||||
"DependencyTable.cpp", "DependencyTable.h",
|
||||
"DeprecatedGenTemplateInstance.cpp", "DeprecatedGenTemplateInstance.h",
|
||||
"ExpressionUnderCursor.cpp", "ExpressionUnderCursor.h",
|
||||
"FastPreprocessor.cpp", "FastPreprocessor.h",
|
||||
"FindUsages.cpp", "FindUsages.h",
|
||||
|
||||
Reference in New Issue
Block a user