fix: definite loop when show tip for rand

This commit is contained in:
Roy Qu 2022-03-16 16:36:25 +08:00
parent 47212c2716
commit 69ca9f3a79
1 changed files with 12 additions and 12 deletions

View File

@ -335,10 +335,8 @@ PStatement CppParser::findStatementOf(const QString &fileName,
}
//using alias like 'using std::vector;'
if ((statement->kind == StatementKind::skAlias) &&
(phrase!=statement->type)) {
statement = findStatementOf(fileName, statement->type,
currentScope, parentScopeType, force);
if (statement->kind == StatementKind::skAlias) {
statement = findAliasedStatement(statement);
if (!statement)
return PStatement();
}
@ -1828,14 +1826,18 @@ PStatement CppParser::getTypeDef(const PStatement& statement,
|| statement->kind == StatementKind::skEnumType
|| statement->kind == StatementKind::skEnumClassType) {
return statement;
} else if (statement->kind == StatementKind::skTypedef
|| statement->kind == StatementKind::skAlias) {
} else if (statement->kind == StatementKind::skTypedef) {
if (statement->type == aType) // prevent infinite loop
return statement;
PStatement result = findTypeDefinitionOf(fileName,statement->type, statement->parentScope.lock());
if (!result) // found end of typedef trail, return result
return statement;
return result;
} else if (statement->kind == StatementKind::skAlias) {
PStatement result = findAliasedStatement(statement);
if (!result) // found end of typedef trail, return result
return statement;
return result;
} else
return PStatement();
}
@ -3266,9 +3268,9 @@ void CppParser::internalParse(const QString &fileName)
//reduce memory usage
internalClear();
#ifdef QT_DEBUG
mTokenizer.dumpTokens("r:\\tokens.txt");
mStatementList.dump("r:\\stats.txt");
mStatementList.dumpAll("r:\\all-stats.txt");
// mTokenizer.dumpTokens("r:\\tokens.txt");
// mStatementList.dump("r:\\stats.txt");
// mStatementList.dumpAll("r:\\all-stats.txt");
#endif
//reduce memory usage
mTokenizer.reset();
@ -3946,9 +3948,7 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
result = doCreateEvalNamespace(statement);
break;
case StatementKind::skAlias: {
PStatement parentScopeType;
statement = findStatementOf(fileName, statement->type,
scope, parentScopeType, true);
statement = findAliasedStatement(statement);
if (statement)
result = doCreateEvalNamespace(statement);
}