CPlusPlus: Store concept name as QualifiedNameAST

This simplifies the code and improves handling of nested template type
parameters in some contexts.

Fixes: QTCREATORBUG-32079
Change-Id: Ifb28fc19ab3cb1747df097589027bb8e33cf037a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2024-12-04 17:09:08 +01:00
parent db11237dd5
commit 3f6522c38b
6 changed files with 4 additions and 14 deletions

View File

@@ -4667,8 +4667,6 @@ int NoExceptOperatorExpressionAST::lastToken() const
int TypeConstraintAST::firstToken() const
{
if (nestedName)
return nestedName->firstToken();
return conceptName->firstToken();
}

View File

@@ -646,8 +646,7 @@ protected:
class CPLUSPLUS_EXPORT TypeConstraintAST: public AST
{
public:
NestedNameSpecifierListAST *nestedName = nullptr;
NameAST *conceptName = nullptr;
QualifiedNameAST *conceptName = nullptr;
int lessToken = 0;
ExpressionListAST *templateArgs = nullptr;
int greaterToken = 0;

View File

@@ -144,9 +144,6 @@ DecltypeSpecifierAST *DecltypeSpecifierAST::clone(MemoryPool *pool) const
TypeConstraintAST *TypeConstraintAST::clone(MemoryPool *pool) const
{
const auto ast = new (pool) TypeConstraintAST;
for (NestedNameSpecifierListAST *iter = nestedName, **ast_iter = &ast->nestedName; iter;
iter = iter->next, ast_iter = &(*ast_iter)->next)
*ast_iter = new (pool) NestedNameSpecifierListAST((iter->value) ? iter->value->clone(pool) : nullptr);
if (conceptName)
ast->conceptName = conceptName->clone(pool);
ast->lessToken = lessToken;

View File

@@ -218,10 +218,6 @@ bool ASTMatcher::match(DecltypeSpecifierAST *node, DecltypeSpecifierAST *pattern
bool ASTMatcher::match(TypeConstraintAST *node, TypeConstraintAST *pattern)
{
if (!pattern->nestedName)
pattern->nestedName = node->nestedName;
else if (!AST::match(node->nestedName, pattern->nestedName, this))
return false;
if (!pattern->conceptName)
pattern->conceptName = node->conceptName;
else if (!AST::match(node->conceptName, pattern->conceptName, this))

View File

@@ -113,7 +113,6 @@ void DecltypeSpecifierAST::accept0(ASTVisitor *visitor)
void TypeConstraintAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(nestedName, visitor);
accept(conceptName, visitor);
accept(templateArgs, visitor);
}

View File

@@ -1338,8 +1338,9 @@ bool Parser::parseTypeConstraint(TypeConstraintAST *&node)
if (!parseUnqualifiedName(conceptName, false))
return false;
const auto typeConstraint = new (_pool) TypeConstraintAST;
typeConstraint->nestedName = nestedName;
typeConstraint->conceptName = conceptName;
typeConstraint->conceptName = new (_pool) QualifiedNameAST;
typeConstraint->conceptName->nested_name_specifier_list = nestedName;
typeConstraint->conceptName->unqualified_name = conceptName;
if (LA() != T_LESS) {
node = typeConstraint;
return true;