correctly deduce type for stl container iterators

This commit is contained in:
Roy Qu 2022-11-29 12:17:41 +08:00
parent 0d0332aa7d
commit e845c7474b
1 changed files with 17 additions and 1 deletions

View File

@ -3689,6 +3689,15 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
addedVar->type = aliasStatement->effectiveTypeStatement->fullName; addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
if (!addedVar->type.endsWith(">")) if (!addedVar->type.endsWith(">"))
addedVar->type += aliasStatement->templateParams; addedVar->type += aliasStatement->templateParams;
if (aliasStatement->typeStatement
&& STLIterators.contains(aliasStatement->typeStatement->command)
&& !aliasStatement->templateParams.isEmpty()) {
PStatement parentStatement = aliasStatement->typeStatement->parentScope.lock();
if (parentStatement
&& STLContainers.contains(parentStatement->fullName)) {
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
}
}
} else } else
addedVar->type = aliasStatement->baseType; addedVar->type = aliasStatement->baseType;
if (aliasStatement->pointerLevel>0) if (aliasStatement->pointerLevel>0)
@ -3734,6 +3743,14 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
addedVar->type = aliasStatement->effectiveTypeStatement->fullName; addedVar->type = aliasStatement->effectiveTypeStatement->fullName;
if (!addedVar->type.endsWith(">")) if (!addedVar->type.endsWith(">"))
addedVar->type += aliasStatement->templateParams; addedVar->type += aliasStatement->templateParams;
if (aliasStatement->typeStatement
&& STLIterators.contains(aliasStatement->typeStatement->command)) {
PStatement parentStatement = aliasStatement->typeStatement->parentScope.lock();
if (parentStatement
&& STLContainers.contains(parentStatement->fullName)) {
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
}
}
} else } else
addedVar->type = aliasStatement->baseType; addedVar->type = aliasStatement->baseType;
if (aliasStatement->pointerLevel>0) if (aliasStatement->pointerLevel>0)
@ -4505,7 +4522,6 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
PStatement parentStatement = result->typeStatement->parentScope.lock(); PStatement parentStatement = result->typeStatement->parentScope.lock();
if (parentStatement if (parentStatement
&& STLContainers.contains(parentStatement->fullName)) { && STLContainers.contains(parentStatement->fullName)) {
// result->baseType = parentStatement->fullName+previousResult->templateParams+result->typeStatement->command;
result->templateParams = previousResult->templateParams; result->templateParams = previousResult->templateParams;
} }
} }