- fix: parse error for definition of functions whose return type is pointer

This commit is contained in:
Roy Qu 2022-04-18 16:56:31 +08:00
parent 5743991152
commit 56c71f321f
3 changed files with 26 additions and 19 deletions

View File

@ -15,6 +15,7 @@ Red Panda C++ Version 1.0.4
- enhancement: add Traditional Chinese translation - enhancement: add Traditional Chinese translation
- fix: index of the longest line not correctly updated ( which will cause selection errors) - fix: index of the longest line not correctly updated ( which will cause selection errors)
- fix: scroll bar not correctly updated when collapse/uncollapse folders - fix: scroll bar not correctly updated when collapse/uncollapse folders
- fix: parse error for definition of functions whose return type is pointer
Red Panda C++ Version 1.0.3 Red Panda C++ Version 1.0.3
- fix: when oj problem grabbed by competitive companion received, - fix: when oj problem grabbed by competitive companion received,

View File

@ -1158,27 +1158,30 @@ PStatement CppParser::addStatement(const PStatement& parent,
if (kind == StatementKind::skConstructor if (kind == StatementKind::skConstructor
|| kind == StatementKind::skFunction || kind == StatementKind::skFunction
|| kind == StatementKind::skDestructor || kind == StatementKind::skDestructor
|| kind == StatementKind::skVariable) { || kind == StatementKind::skVariable
) {
noNameArgs = removeArgNames(args); noNameArgs = removeArgNames(args);
//find //find
PStatement oldStatement = findStatementInScope(command,noNameArgs,kind,parent); if (isDefinition) {
if (oldStatement && isDefinition && !oldStatement->hasDefinition) { PStatement oldStatement = findStatementInScope(newCommand,noNameArgs,kind,parent);
oldStatement->hasDefinition = true; if (oldStatement && !oldStatement->hasDefinition) {
if (oldStatement->fileName!=fileName) { oldStatement->hasDefinition = true;
PFileIncludes fileIncludes1=mPreprocessor.includesList().value(fileName); if (oldStatement->fileName!=fileName) {
if (fileIncludes1) { PFileIncludes fileIncludes1=mPreprocessor.includesList().value(fileName);
fileIncludes1->statements.insert(oldStatement->fullName, if (fileIncludes1) {
oldStatement); fileIncludes1->statements.insert(oldStatement->fullName,
fileIncludes1->dependingFiles.insert(oldStatement->fileName); oldStatement);
PFileIncludes fileIncludes2=mPreprocessor.includesList().value(oldStatement->fileName); fileIncludes1->dependingFiles.insert(oldStatement->fileName);
if (fileIncludes2) { PFileIncludes fileIncludes2=mPreprocessor.includesList().value(oldStatement->fileName);
fileIncludes2->dependedFiles.insert(fileName); if (fileIncludes2) {
fileIncludes2->dependedFiles.insert(fileName);
}
} }
} }
oldStatement->definitionLine = line;
oldStatement->definitionFileName = fileName;
return oldStatement;
} }
oldStatement->definitionLine = line;
oldStatement->definitionFileName = fileName;
return oldStatement;
} }
} }
PStatement result = std::make_shared<Statement>(); PStatement result = std::make_shared<Statement>();
@ -3246,9 +3249,9 @@ void CppParser::internalParse(const QString &fileName)
//reduce memory usage //reduce memory usage
internalClear(); internalClear();
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mTokenizer.dumpTokens("r:\\tokens.txt"); // mTokenizer.dumpTokens("z:\\tokens.txt");
// mStatementList.dump("r:\\stats.txt"); //
// mStatementList.dumpAll("r:\\all-stats.txt"); // mStatementList.dumpAll("r:\\all-stats.txt");
#endif #endif
//reduce memory usage //reduce memory usage
mTokenizer.reset(); mTokenizer.reset();

View File

@ -138,12 +138,15 @@ void StatementModel::dumpStatementMap(StatementMap &map, QTextStream &out, int l
out<<indent<<QString("%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12") out<<indent<<QString("%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12")
.arg(statement->command).arg(int(statement->kind)) .arg(statement->command).arg(int(statement->kind))
.arg(statement->type,statement->fullName) .arg(statement->type,statement->fullName)
.arg(statement->noNameArgs)
.arg(statement->args)
.arg((size_t)(statement->parentScope.lock().get())) .arg((size_t)(statement->parentScope.lock().get()))
.arg((int)statement->classScope) .arg((int)statement->classScope)
.arg(statement->fileName) .arg(statement->fileName)
.arg(statement->line) .arg(statement->line)
.arg(statement->definitionFileName) .arg(statement->definitionFileName)
.arg(statement->definitionLine); .arg(statement->definitionLine);
out<<endl;
if (statement->children.isEmpty()) if (statement->children.isEmpty())
continue; continue;
out<<indent<<statement->command<<" {"<<endl; out<<indent<<statement->command<<" {"<<endl;