diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index 8bba41c07acd76d1388fd336b524a65683f8f0ec..bd2b72bff9cc114d0d0323a0139f1425bbe820fe 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -399,6 +399,8 @@ FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol) FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *className, Symbol *candidate, QSharedPointer<Control> control) { +#warning robe: enable template instantiation +#if 0 if (className) { if (const TemplateNameId *templId = className->asTemplateNameId()) { if (Class *klass = candidate->scope()->asClass()) { @@ -422,6 +424,6 @@ FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *classN } } } - +#endif return candidate->type(); } diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index e56ffcbc074502dc83eca7988b848a6d0aabf35c..91f1888ac4cfe04a2b6d7750285f93660f0ab922 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -283,8 +283,11 @@ 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); +#warning robe: lookup in template parameters +#if 0 for (TemplateParameters *it = fun->templateParameters(); it && candidates.isEmpty(); it = it->previous()) bindings()->lookupInScope(name, it->scope(), &candidates, /* templateId = */ 0, /*binding=*/ 0); +#endif if (! candidates.isEmpty()) break; // it's an argument or a template parameter. @@ -307,8 +310,11 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const break; // it's a formal argument. } else if (Class *klass = scope->asClass()) { +#warning robe: lookup in template parameters +#if 0 for (TemplateParameters *it = klass->templateParameters(); it && candidates.isEmpty(); it = it->previous()) bindings()->lookupInScope(name, it->scope(), &candidates, /* templateId = */ 0, /*binding=*/ 0); +#endif if (! candidates.isEmpty()) break; // it's an argument or a template parameter. diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 55c4c3ac42acd4a260e09932a263b0f00ccfa93a..edd03641ee48de0b6fd62eb06d2d31c0334de644 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -550,7 +550,8 @@ bool ResolveExpression::visit(ArrayAccessAST *ast) QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const Name *memberName) const { QList<LookupItem> members; - +#warning robe: enable template instantiation +#if 0 const QList<LookupItem> originalMembers = binding->find(memberName); foreach (const LookupItem &m, originalMembers) { @@ -593,7 +594,7 @@ QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const } } } - +#endif return members; } diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp index 83aa5bca0a893c08039e503c43c592473d895e62..e683fd6719831eb72cef867de05d7741ebb268e6 100644 --- a/src/plugins/cppeditor/cppchecksymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -179,12 +179,6 @@ protected: if (symbol->isVirtual()) addVirtualMethod(symbol->name()); - for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) { - Scope *scope = p->scope(); - for (unsigned i = 0; i < scope->memberCount(); ++i) - accept(scope->memberAt(i)); - } - return true; } @@ -237,24 +231,12 @@ protected: virtual bool visit(Class *symbol) { - for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) { - Scope *scope = p->scope(); - for (unsigned i = 0; i < scope->memberCount(); ++i) - accept(scope->memberAt(i)); - } - addType(symbol->name()); return true; } virtual bool visit(ForwardClassDeclaration *symbol) { - for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) { - Scope *scope = p->scope(); - for (unsigned i = 0; i < scope->memberCount(); ++i) - accept(scope->memberAt(i)); - } - addType(symbol->name()); return true; } diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 178c7e84b55f11fd6d724572c3d61c81bcb8a216..a3f328f0856d9659d2f1cde896da0441c160c66a 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1852,11 +1852,14 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item, QChar t if (! function->hasReturnType() && (function->identity() && !function->identity()->isDestructorNameId())) { // Don't insert any magic, since the user might have just wanted to select the class +#warning robe: "don't insert matching ( when the selected symbol is a template" +#if 0 } else if (function->templateParameterCount() != 0 && typedChar != QLatin1Char('(')) { // If there are no arguments, then we need the template specification if (function->argumentCount() == 0) { extraChars += QLatin1Char('<'); } +#endif } else if (! function->isAmbiguous()) { if (completionSettings().m_spaceAfterFunctionName) extraChars += QLatin1Char(' '); diff --git a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h index 9b8f7a19765c16c1c5b8e19ddd2ee4d081460a34..1eeeba68b4602d7d86d324c6ba759bcc4836b574 100644 --- a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h +++ b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h @@ -80,7 +80,6 @@ class StringLiteral; class NumericLiteral; class SymbolTable; -class TemplateParameters; // names class NameVisitor; diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index f431ca9db5de05ad1368c5a6b8bb29b32f3d9933..595d549a48cdbf0195d73c0a7e33bc9d7745843b 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -66,22 +66,18 @@ CheckDeclaration::CheckDeclaration(Semantic *semantic) : SemanticCheck(semantic), _declaration(0), _scope(0), - _templateParameters(0), _checkAnonymousArguments(false) { } CheckDeclaration::~CheckDeclaration() { } -void CheckDeclaration::check(DeclarationAST *declaration, - Scope *scope, TemplateParameters *templateParameters) +void CheckDeclaration::check(DeclarationAST *declaration, Scope *scope) { Scope *previousScope = switchScope(scope); - TemplateParameters *previousTemplateParameters = switchTemplateParameters(templateParameters); DeclarationAST *previousDeclaration = switchDeclaration(declaration); accept(declaration); (void) switchDeclaration(previousDeclaration); - (void) switchTemplateParameters(previousTemplateParameters); (void) switchScope(previousScope); } @@ -106,13 +102,6 @@ Scope *CheckDeclaration::switchScope(Scope *scope) return previousScope; } -TemplateParameters *CheckDeclaration::switchTemplateParameters(TemplateParameters *templateParameters) -{ - TemplateParameters *previousTemplateParameters = _templateParameters; - _templateParameters = templateParameters; - return previousTemplateParameters; -} - void CheckDeclaration::setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers) { if (! symbol) @@ -172,13 +161,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) FullySpecifiedType declSpecifiers = semantic()->check(ast->decl_specifier_list, _scope); FullySpecifiedType qualTy = declSpecifiers.qualifiedType(); - if (_templateParameters && declSpecifiers) { - if (Class *klass = declSpecifiers->asClassType()) { - klass->setTemplateParameters(_templateParameters); - _templateParameters = 0; // consume the template parameters - } - } - if (ast->decl_specifier_list && ! ast->declarator_list) { ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_list->value->asElaboratedTypeSpecifier(); @@ -194,11 +176,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) ForwardClassDeclaration *symbol = control()->newForwardClassDeclaration(sourceLocation, name); - if (_templateParameters) { - symbol->setTemplateParameters(_templateParameters); - _templateParameters = 0; - } - setDeclSpecifiers(symbol, declSpecifiers); _scope->addMember(symbol); @@ -247,11 +224,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) setDeclSpecifiers(symbol, declSpecifiers); - if (_templateParameters && it == ast->declarator_list) { - symbol->setTemplateParameters(_templateParameters); - _templateParameters = 0; // consume the template parameters - } - symbol->setVisibility(semantic()->currentVisibility()); if (it->value && it->value->initializer) { @@ -345,7 +317,6 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) fun->setSourceLocation(loc, translationUnit()); } fun->setName(name); - fun->setTemplateParameters(_templateParameters); fun->setVisibility(semantic()->currentVisibility()); fun->setMethodKey(semantic()->currentMethodKey()); diff --git a/src/shared/cplusplus/CheckDeclaration.h b/src/shared/cplusplus/CheckDeclaration.h index 562b17012374f02648d03ea9b80444c7f202a459..1ba825dfbee5442df7a2bb06849b17be777874e7 100644 --- a/src/shared/cplusplus/CheckDeclaration.h +++ b/src/shared/cplusplus/CheckDeclaration.h @@ -61,13 +61,12 @@ public: CheckDeclaration(Semantic *semantic); virtual ~CheckDeclaration(); - void check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters); + void check(DeclarationAST *declaration, Scope *scope); void check(CtorInitializerAST *ast, Scope *scope); protected: DeclarationAST *switchDeclaration(DeclarationAST *declaration); Scope *switchScope(Scope *scope); - TemplateParameters *switchTemplateParameters(TemplateParameters *templateParameters); void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers); @@ -117,7 +116,6 @@ private: private: DeclarationAST *_declaration; Scope *_scope; - TemplateParameters *_templateParameters; bool _checkAnonymousArguments: 1; }; diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp index 91376d3a255a8af7a9b26dcafc2aa6155024c69e..46c9648d38bf36d8d6d471199002f136af097f28 100644 --- a/src/shared/cplusplus/Semantic.cpp +++ b/src/shared/cplusplus/Semantic.cpp @@ -155,15 +155,14 @@ FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope, const FullySpecifiedType &type) { return d->checkSpecifier->check(specifier, scope, type); } -void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters) -{ d->checkDeclaration->check(declaration, scope, templateParameters); } +void Semantic::check(DeclarationAST *declaration, Scope *scope) +{ d->checkDeclaration->check(declaration, scope); } FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type, Scope *scope, const Name **name) { return d->checkDeclarator->check(declarator, type, scope, name); } -FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, - Scope *scope) +FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, Scope *scope) { return d->checkDeclarator->check(ptrOperators, type, scope); } FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope) diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h index 69d5dce0b61976906c32bdde8c1c9ec4faeaad07..71e72b2ee02e85747ce07acbbe1ba1f6142cdb2d 100644 --- a/src/shared/cplusplus/Semantic.h +++ b/src/shared/cplusplus/Semantic.h @@ -99,7 +99,7 @@ public: FullySpecifiedType check(ExpressionAST *expression, Scope *scope); - void check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters = 0); + void check(DeclarationAST *declaration, Scope *scope); FullySpecifiedType check(StatementAST *statement, Scope *scope); diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index 5ad7d815db8de1d8815cce7ccb35b092afb544fd..f7477a4b14062c12e04996f264216491b605252d 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -55,26 +55,6 @@ using namespace CPlusPlus; -TemplateParameters::TemplateParameters(Scope *scope) - : _previous(0), _scope(scope) -{ } - -TemplateParameters::TemplateParameters(TemplateParameters *previous, Scope *scope) - : _previous(previous), _scope(scope) -{ } - -TemplateParameters::~TemplateParameters() -{ - delete _previous; - delete _scope; -} - -TemplateParameters *TemplateParameters::previous() const -{ return _previous; } - -Scope *TemplateParameters::scope() const -{ return _scope; } - UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Symbol(translationUnit, sourceLocation, name) @@ -125,18 +105,11 @@ void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor) { visitor->visit(this); } Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) - : Symbol(translationUnit, sourceLocation, name), - _templateParameters(0) + : Symbol(translationUnit, sourceLocation, name) { } Declaration::~Declaration() -{ delete _templateParameters; } - -TemplateParameters *Declaration::templateParameters() const -{ return _templateParameters; } - -void Declaration::setTemplateParameters(TemplateParameters *templateParameters) -{ _templateParameters = templateParameters; } +{ } void Declaration::setType(const FullySpecifiedType &type) { _type = type; } @@ -191,15 +164,12 @@ void TypenameArgument::visitSymbol0(SymbolVisitor *visitor) Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Scope(translationUnit, sourceLocation, name), - _templateParameters(0), _block(0), _flags(0) { } Function::~Function() -{ - delete _templateParameters; -} +{ } bool Function::isNormal() const { return f._methodKey == NormalMethod; } @@ -225,23 +195,6 @@ Block *Function::block() const void Function::setBlock(Block *block) { _block = block; } -unsigned Function::templateParameterCount() const -{ - if (! _templateParameters) - return 0; - - return _templateParameters->scope()->memberCount(); -} - -Symbol *Function::templateParameterAt(unsigned index) const -{ return _templateParameters->scope()->memberAt(index); } - -TemplateParameters *Function::templateParameters() const -{ return _templateParameters; } - -void Function::setTemplateParameters(TemplateParameters *templateParameters) -{ _templateParameters = templateParameters; } - bool Function::isEqualTo(const Type *other) const { const Function *o = other->asFunctionType(); @@ -544,18 +497,11 @@ void BaseClass::visitSymbol0(SymbolVisitor *visitor) ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) - : Symbol(translationUnit, sourceLocation, name), - _templateParameters(0) + : Symbol(translationUnit, sourceLocation, name) { } ForwardClassDeclaration::~ForwardClassDeclaration() -{ delete _templateParameters; } - -TemplateParameters *ForwardClassDeclaration::templateParameters() const -{ return _templateParameters; } - -void ForwardClassDeclaration::setTemplateParameters(TemplateParameters *templateParameters) -{ _templateParameters = templateParameters; } +{ } FullySpecifiedType ForwardClassDeclaration::type() const { return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); } @@ -589,12 +535,11 @@ bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *mat Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : Scope(translationUnit, sourceLocation, name), - _key(ClassKey), - _templateParameters(0) + _key(ClassKey) { } Class::~Class() -{ delete _templateParameters; } +{ } bool Class::isClass() const { return _key == ClassKey; } @@ -611,23 +556,6 @@ Class::Key Class::classKey() const void Class::setClassKey(Key key) { _key = key; } -unsigned Class::templateParameterCount() const -{ - if (! _templateParameters) - return 0; - - return _templateParameters->scope()->memberCount(); -} - -Symbol *Class::templateParameterAt(unsigned index) const -{ return _templateParameters->scope()->memberAt(index); } - -TemplateParameters *Class::templateParameters() const -{ return _templateParameters; } - -void Class::setTemplateParameters(TemplateParameters *templateParameters) -{ _templateParameters = templateParameters; } - void Class::accept0(TypeVisitor *visitor) { visitor->visit(this); } diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h index a52b7cb373a7d10c668a1ba84c165404725ff6d1..bc2b6b8330cd346406a1c56defed9561b4329e86 100644 --- a/src/shared/cplusplus/Symbols.h +++ b/src/shared/cplusplus/Symbols.h @@ -58,21 +58,6 @@ namespace CPlusPlus { -class CPLUSPLUS_EXPORT TemplateParameters -{ -public: - TemplateParameters(Scope *scope); - TemplateParameters(TemplateParameters *previous, Scope *scope); - ~TemplateParameters(); - - TemplateParameters *previous() const; - Scope *scope() const; - -private: - TemplateParameters *_previous; - Scope *_scope; -}; - class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol { public: @@ -142,9 +127,6 @@ public: Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~Declaration(); - TemplateParameters *templateParameters() const; - void setTemplateParameters(TemplateParameters *templateParameters); - void setType(const FullySpecifiedType &type); // Symbol's interface @@ -161,7 +143,6 @@ protected: private: FullySpecifiedType _type; - TemplateParameters *_templateParameters; }; class CPLUSPLUS_EXPORT Argument: public Symbol @@ -243,9 +224,6 @@ public: ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); virtual ~ForwardClassDeclaration(); - TemplateParameters *templateParameters() const; - void setTemplateParameters(TemplateParameters *templateParameters); - virtual FullySpecifiedType type() const; virtual bool isEqualTo(const Type *other) const; @@ -266,9 +244,6 @@ protected: virtual void visitSymbol0(SymbolVisitor *visitor); virtual void accept0(TypeVisitor *visitor); virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const; - -private: - TemplateParameters *_templateParameters; }; class CPLUSPLUS_EXPORT Enum: public Scope, public Type @@ -325,12 +300,6 @@ public: Block *block() const; void setBlock(Block *block); - unsigned templateParameterCount() const; // ### remove me - Symbol *templateParameterAt(unsigned index) const; // ### remove me - - TemplateParameters *templateParameters() const; - void setTemplateParameters(TemplateParameters *templateParameters); - FullySpecifiedType returnType() const; void setReturnType(const FullySpecifiedType &returnType); @@ -391,7 +360,6 @@ protected: private: FullySpecifiedType _returnType; - TemplateParameters *_templateParameters; Block *_block; struct Flags { unsigned _isVirtual: 1; @@ -483,12 +451,6 @@ public: Key classKey() const; void setClassKey(Key key); - unsigned templateParameterCount() const; // ### remove me - Symbol *templateParameterAt(unsigned index) const; // ### remove me - - TemplateParameters *templateParameters() const; - void setTemplateParameters(TemplateParameters *templateParameters); - unsigned baseClassCount() const; BaseClass *baseClassAt(unsigned index) const; void addBaseClass(BaseClass *baseClass); @@ -518,7 +480,6 @@ protected: private: Key _key; - TemplateParameters *_templateParameters; std::vector<BaseClass *> _baseClasses; };