From 581404330299d60d8e82dbbde86701910ef8fb82 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 26 Oct 2023 08:57:40 +0800 Subject: [PATCH] - enhancement: when induce type info for return value, try to select the overloaded one that doesn't have an "auto" type. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index abf47888..8855e60d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,7 @@ Red Panda C++ Version 2.26 - fix: Code suggestion for identifiers after '*' (eg. 3 * item->price) can't correct. - fix: C++ compiler atrribute '[[xxx]]' are not correctly handled. - fix: If the integrated gcc compiler is add to path, auto find compilers will find in twice. (Windows) + - enhancement: when induce type info for return value, try to select the overloaded one that doesn't have an "auto" type. Red Panda C++ Version 2.25 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 32acda4e..8c55d992 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -5003,6 +5003,13 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, } } +// qDebug()<<"baseType:"<baseType; +// if (result->baseStatement) +// qDebug()<<"baseStatement"<baseStatement->fullName; +// if (result->typeStatement) +// qDebug()<<"typeStatement"<typeStatement->fullName; +// if (result->effectiveTypeStatement) +// qDebug()<<"typeStatement"<effectiveTypeStatement->fullName; result->kind = EvalStatementKind::Variable; } else result = PEvalStatement(); @@ -5280,8 +5287,20 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName, case StatementKind::skTypedef: result = doCreateEvalType(fileName,statement); break; - case StatementKind::skFunction: + case StatementKind::skFunction: { + if (statement->type=="auto") { + PStatement scopeStatement = statement->parentScope.lock(); + if (scopeStatement) { + StatementMap children = mStatementList.childrenStatements(scopeStatement); + QList lstFuncs = children.values(statement->command); + for (const PStatement& func:lstFuncs) { + if (func->type!="auto") + statement=func; + } + } + } result = doCreateEvalFunction(fileName,statement); + } break; case StatementKind::skPreprocessor: // qDebug()<<"before"<