diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/cplusplus/CppDocument.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/CppRewriter.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/FindUsages.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 5 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.h | 1 | ||||
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/TypePrettyPrinter.cpp | 22 | ||||
-rw-r--r-- | src/libs/cplusplus/TypePrettyPrinter.h | 1 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 2 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckDeclaration.cpp | 2 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckName.cpp | 2 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckStatement.cpp | 6 | ||||
-rw-r--r-- | src/shared/cplusplus/Control.cpp | 40 | ||||
-rw-r--r-- | src/shared/cplusplus/Control.h | 12 | ||||
-rw-r--r-- | src/shared/cplusplus/Lexer.cpp | 14 | ||||
-rw-r--r-- | src/shared/cplusplus/TranslationUnit.cpp | 6 |
17 files changed, 78 insertions, 49 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index e6197884d2..e86cb18b2e 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -215,7 +215,7 @@ Document::Document(const QString &fileName) _control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages)); const QByteArray localFileName = fileName.toUtf8(); - const StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(), + const StringLiteral *fileId = _control->stringLiteral(localFileName.constData(), localFileName.size()); _translationUnit = new TranslationUnit(_control, fileId); _translationUnit->setQtMocRunEnabled(true); diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index a4440652b8..ca4acd4412 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -220,7 +220,7 @@ public: if (! other) return 0; - return control()->findOrInsertIdentifier(other->chars(), other->size()); + return control()->identifier(other->chars(), other->size()); } public: diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index bd2b72bff9..762e197e33 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -262,7 +262,7 @@ private: return name; else if (const Name *nameId = name->asNameId()) { - const Identifier *id = control()->findOrInsertIdentifier(nameId->identifier()->chars(), + const Identifier *id = control()->identifier(nameId->identifier()->chars(), nameId->identifier()->size()); return control()->nameId(id); @@ -272,7 +272,7 @@ private: FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex); arguments[templateArgIndex] = q->apply(argTy); } - const Identifier *id = control()->findOrInsertIdentifier(templId->identifier()->chars(), + const Identifier *id = control()->identifier(templId->identifier()->chars(), templId->identifier()->size()); return control()->templateNameId(id, arguments.data(), arguments.size()); diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index ace7692097..dc182a1117 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -91,7 +91,7 @@ void FindUsages::operator()(Symbol *symbol) _declSymbolFullyQualifiedName = LookupContext::fullyQualifiedName(symbol); // get the canonical id - _id = _doc->control()->findOrInsertIdentifier(_id->chars(), _id->size()); + _id = _doc->control()->identifier(_id->chars(), _id->size()); if (AST *ast = _doc->translationUnit()->ast()) translationUnit(ast->asTranslationUnit()); diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 91f1888ac4..79d6f2d573 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -788,6 +788,11 @@ ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol) return switchCurrentClassOrNamespace(entity); } +bool CreateBindings::visit(Template *templ) +{ + return false; +} + bool CreateBindings::visit(Namespace *ns) { ClassOrNamespace *previous = enterClassOrNamespaceBinding(ns); diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 966fd37284..23cb8b3fbe 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -162,6 +162,7 @@ protected: /// Creates bindings for the symbols reachable from the \a root symbol. void process(Symbol *root); + virtual bool visit(Template *templ); virtual bool visit(Namespace *ns); virtual bool visit(Class *klass); virtual bool visit(ForwardClassDeclaration *klass); diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index edd03641ee..18c6f4d60a 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -234,8 +234,8 @@ bool ResolveExpression::visit(NewExpressionAST *ast) bool ResolveExpression::visit(TypeidExpressionAST *) { - const Name *stdName = control()->nameId(control()->findOrInsertIdentifier("std")); - const Name *tiName = control()->nameId(control()->findOrInsertIdentifier("type_info")); + const Name *stdName = control()->nameId(control()->identifier("std")); + const Name *tiName = control()->nameId(control()->identifier("type_info")); const Name *q = control()->qualifiedNameId(control()->qualifiedNameId(/* :: */ 0, stdName), tiName); FullySpecifiedType ty(control()->namedType(q)); diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 61e18f5e7e..30b9e040cb 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -140,6 +140,28 @@ void TypePrettyPrinter::visit(Namespace *type) prependCv(_fullySpecifiedType); } +void TypePrettyPrinter::visit(Template *type) +{ + const unsigned argc = type->templateParameterCount(); + QString decl; + decl += QLatin1String("template <"); + for (unsigned i = 0; i < argc; ++i) { + if (i != 0) + decl += QLatin1String(", "); + + decl += QLatin1String("T"); + decl += QString::number(i + 1); + } + decl += QLatin1Char('<'); + if (Symbol *d = type->declaration()) { + decl += QLatin1Char(' '); + decl += overview()->prettyType(d->type(), d->name()); + } + _text.prepend(decl); + qWarning() << "here:" << decl; + prependCv(_fullySpecifiedType); +} + void TypePrettyPrinter::visit(Class *classTy) { _text.prepend(overview()->prettyName(classTy->name())); diff --git a/src/libs/cplusplus/TypePrettyPrinter.h b/src/libs/cplusplus/TypePrettyPrinter.h index aed93e0e75..29470ad1aa 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.h +++ b/src/libs/cplusplus/TypePrettyPrinter.h @@ -68,6 +68,7 @@ protected: virtual void visit(NamedType *type); virtual void visit(Function *type); virtual void visit(Namespace *type); + virtual void visit(Template *type); virtual void visit(Class *type); virtual void visit(Enum *type); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 36fbb5a380..c2c33eaa17 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -976,7 +976,7 @@ public: } QSharedPointer<Control> control = state.context().control(); - const Name *trName = control->nameId(control->findOrInsertIdentifier("tr")); + const Name *trName = control->nameId(control->identifier("tr")); // Check whether we are in a method: for (int i = path.size() - 1; i >= 0; --i) diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index 607fd75ef3..39a98f6c2f 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -437,7 +437,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast) buffer += ' '; buffer += tk.spell(); } - const StringLiteral *initializer = control()->findOrInsertStringLiteral(buffer.c_str(), buffer.size()); + const StringLiteral *initializer = control()->stringLiteral(buffer.c_str(), buffer.size()); arg->setInitializer(initializer); } arg->setType(argTy); diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp index 4fccbcd759..c1a27b2166 100644 --- a/src/shared/cplusplus/CheckName.cpp +++ b/src/shared/cplusplus/CheckName.cpp @@ -377,7 +377,7 @@ bool CheckName::visit(ObjCSelectorAST *ast) bool hasArgs = false; for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) { if (it->value->name_token) { - const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token)); + const Identifier *id = control()->identifier(spell(it->value->name_token)); const NameId *nameId = control()->nameId(id); names.push_back(nameId); diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index b61ba97a9e..fc63434bb6 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -377,9 +377,9 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast) const Name *name = 0; if (tokenKind(ast->q_token) == T_Q_D) - name = control()->nameId(control()->findOrInsertIdentifier("d")); + name = control()->nameId(control()->identifier("d")); else - name = control()->nameId(control()->findOrInsertIdentifier("q")); + name = control()->nameId(control()->identifier("q")); FullySpecifiedType declTy = semantic()->check(ast->type_id, _scope); @@ -390,7 +390,7 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast) privateClass += nameId->identifier()->chars(); privateClass += "Private"; - const Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(), + const Name *privName = control()->nameId(control()->identifier(privateClass.c_str(), privateClass.size())); declTy.setType(control()->namedType(privName)); } diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp index 5bdadabba1..050171eb6a 100644 --- a/src/shared/cplusplus/Control.cpp +++ b/src/shared/cplusplus/Control.cpp @@ -536,17 +536,17 @@ Control::Control() { d = new Data(this); - d->deprecatedId = findOrInsertIdentifier("deprecated"); - d->unavailableId = findOrInsertIdentifier("unavailable"); - - d->objcGetterId = findOrInsertIdentifier("getter"); - d->objcSetterId = findOrInsertIdentifier("setter"); - d->objcReadwriteId = findOrInsertIdentifier("readwrite"); - d->objcReadonlyId = findOrInsertIdentifier("readonly"); - d->objcAssignId = findOrInsertIdentifier("assign"); - d->objcRetainId = findOrInsertIdentifier("retain"); - d->objcCopyId = findOrInsertIdentifier("copy"); - d->objcNonatomicId = findOrInsertIdentifier("nonatomic"); + d->deprecatedId = identifier("deprecated"); + d->unavailableId = identifier("unavailable"); + + d->objcGetterId = identifier("getter"); + d->objcSetterId = identifier("setter"); + d->objcReadwriteId = identifier("readwrite"); + d->objcReadonlyId = identifier("readonly"); + d->objcAssignId = identifier("assign"); + d->objcRetainId = identifier("retain"); + d->objcCopyId = identifier("copy"); + d->objcNonatomicId = identifier("nonatomic"); } Control::~Control() @@ -571,13 +571,13 @@ void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient) const Identifier *Control::findIdentifier(const char *chars, unsigned size) const { return d->identifiers.findLiteral(chars, size); } -const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size) +const Identifier *Control::identifier(const char *chars, unsigned size) { return d->identifiers.findOrInsertLiteral(chars, size); } -const Identifier *Control::findOrInsertIdentifier(const char *chars) +const Identifier *Control::identifier(const char *chars) { unsigned length = std::strlen(chars); - return findOrInsertIdentifier(chars, length); + return identifier(chars, length); } Control::IdentifierIterator Control::firstIdentifier() const @@ -598,22 +598,22 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const Control::NumericLiteralIterator Control::lastNumericLiteral() const { return d->numericLiterals.end(); } -const StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size) +const StringLiteral *Control::stringLiteral(const char *chars, unsigned size) { return d->stringLiterals.findOrInsertLiteral(chars, size); } -const StringLiteral *Control::findOrInsertStringLiteral(const char *chars) +const StringLiteral *Control::stringLiteral(const char *chars) { unsigned length = std::strlen(chars); - return findOrInsertStringLiteral(chars, length); + return stringLiteral(chars, length); } -const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size) +const NumericLiteral *Control::numericLiteral(const char *chars, unsigned size) { return d->numericLiterals.findOrInsertLiteral(chars, size); } -const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars) +const NumericLiteral *Control::numericLiteral(const char *chars) { unsigned length = std::strlen(chars); - return findOrInsertNumericLiteral(chars, length); + return numericLiteral(chars, length); } const NameId *Control::nameId(const Identifier *id) diff --git a/src/shared/cplusplus/Control.h b/src/shared/cplusplus/Control.h index c5c871a793..034e4d583c 100644 --- a/src/shared/cplusplus/Control.h +++ b/src/shared/cplusplus/Control.h @@ -190,8 +190,8 @@ public: const Identifier *objcNonatomicId() const; const Identifier *findIdentifier(const char *chars, unsigned size) const; - const Identifier *findOrInsertIdentifier(const char *chars, unsigned size); - const Identifier *findOrInsertIdentifier(const char *chars); + const Identifier *identifier(const char *chars, unsigned size); + const Identifier *identifier(const char *chars); typedef const Identifier *const *IdentifierIterator; typedef const StringLiteral *const *StringLiteralIterator; @@ -206,11 +206,11 @@ public: NumericLiteralIterator firstNumericLiteral() const; NumericLiteralIterator lastNumericLiteral() const; - const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size); - const StringLiteral *findOrInsertStringLiteral(const char *chars); + const StringLiteral *stringLiteral(const char *chars, unsigned size); + const StringLiteral *stringLiteral(const char *chars); - const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size); - const NumericLiteral *findOrInsertNumericLiteral(const char *chars); + const NumericLiteral *numericLiteral(const char *chars, unsigned size); + const NumericLiteral *numericLiteral(const char *chars); bool hasSymbol(Symbol *symbol) const; diff --git a/src/shared/cplusplus/Lexer.cpp b/src/shared/cplusplus/Lexer.cpp index 3b75c68421..605551e070 100644 --- a/src/shared/cplusplus/Lexer.cpp +++ b/src/shared/cplusplus/Lexer.cpp @@ -281,7 +281,7 @@ void Lexer::scan_helper(Token *tok) yyinp(); if (control()) - tok->string = control()->findOrInsertStringLiteral(yytext, yylen); + tok->string = control()->stringLiteral(yytext, yylen); } break; case '{': @@ -361,7 +361,7 @@ void Lexer::scan_helper(Token *tok) int yylen = _currentChar - yytext; tok->f.kind = T_NUMERIC_LITERAL; if (control()) - tok->number = control()->findOrInsertNumericLiteral(yytext, yylen); + tok->number = control()->numericLiteral(yytext, yylen); } else { tok->f.kind = T_DOT; } @@ -564,7 +564,7 @@ void Lexer::scan_helper(Token *tok) if (_yychar == '>') yyinp(); if (control()) - tok->string = control()->findOrInsertStringLiteral(yytext, yylen); + tok->string = control()->stringLiteral(yytext, yylen); tok->f.kind = T_ANGLE_STRING_LITERAL; } else if (_yychar == '<') { yyinp(); @@ -642,7 +642,7 @@ void Lexer::scan_helper(Token *tok) yyinp(); if (control()) - tok->string = control()->findOrInsertStringLiteral(yytext, yylen); + tok->string = control()->stringLiteral(yytext, yylen); break; } @@ -679,7 +679,7 @@ void Lexer::scan_helper(Token *tok) yyinp(); if (control()) - tok->string = control()->findOrInsertStringLiteral(yytext, yylen); + tok->string = control()->stringLiteral(yytext, yylen); } else if (std::isalpha(ch) || ch == '_' || ch == '$') { const char *yytext = _currentChar - 1; while (std::isalnum(_yychar) || _yychar == '_' || _yychar == '$') @@ -694,7 +694,7 @@ void Lexer::scan_helper(Token *tok) tok->f.kind = classifyOperator(yytext, yylen); if (control()) - tok->identifier = control()->findOrInsertIdentifier(yytext, yylen); + tok->identifier = control()->identifier(yytext, yylen); } break; } else if (std::isdigit(ch)) { @@ -715,7 +715,7 @@ void Lexer::scan_helper(Token *tok) int yylen = _currentChar - yytext; tok->f.kind = T_NUMERIC_LITERAL; if (control()) - tok->number = control()->findOrInsertNumericLiteral(yytext, yylen); + tok->number = control()->numericLiteral(yytext, yylen); break; } else { tok->f.kind = T_ERROR; diff --git a/src/shared/cplusplus/TranslationUnit.cpp b/src/shared/cplusplus/TranslationUnit.cpp index a3ba0714d7..6b3f77c536 100644 --- a/src/shared/cplusplus/TranslationUnit.cpp +++ b/src/shared/cplusplus/TranslationUnit.cpp @@ -188,8 +188,8 @@ void TranslationUnit::tokenize() pushLineOffset(0); pushPreprocessorLine(0, 1, fileId()); - const Identifier *lineId = control()->findOrInsertIdentifier("line"); - const Identifier *genId = control()->findOrInsertIdentifier("gen"); + const Identifier *lineId = control()->identifier("line"); + const Identifier *genId = control()->identifier("gen"); bool generated = false; Token tk; @@ -218,7 +218,7 @@ void TranslationUnit::tokenize() unsigned line = (unsigned) strtoul(tk.spell(), 0, 0); lex(&tk); if (! tk.f.newline && tk.is(T_STRING_LITERAL)) { - const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(), + const StringLiteral *fileName = control()->stringLiteral(tk.string->chars(), tk.string->size()); pushPreprocessorLine(offset, line, fileName); lex(&tk); |