aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/AST.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/cplusplus/AST.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/AST.cpp158
1 files changed, 135 insertions, 23 deletions
diff --git a/src/libs/3rdparty/cplusplus/AST.cpp b/src/libs/3rdparty/cplusplus/AST.cpp
index 3b91838eec..5c59bb683c 100644
--- a/src/libs/3rdparty/cplusplus/AST.cpp
+++ b/src/libs/3rdparty/cplusplus/AST.cpp
@@ -73,6 +73,16 @@ int GnuAttributeSpecifierAST::firstToken() const
return attribute_token;
}
+int MsvcDeclspecSpecifierAST::firstToken() const
+{
+ return attribute_token;
+}
+
+int StdAttributeSpecifierAST::firstToken() const
+{
+ return first_lbracket_token;
+}
+
int BaseSpecifierAST::firstToken() const
{
if (virtual_token && access_specifier_token)
@@ -901,6 +911,8 @@ int DeclaratorAST::lastToken() const
return candidate;
if (equal_token)
return equal_token + 1;
+ if (requiresClause)
+ return requiresClause->lastToken();
if (post_attribute_list)
if (int candidate = post_attribute_list->lastToken())
return candidate;
@@ -1383,7 +1395,6 @@ int ForeachStatementAST::lastToken() const
return 1;
}
-/** \generated */
int FunctionDeclaratorAST::firstToken() const
{
if (lparen_token)
@@ -1393,40 +1404,50 @@ int FunctionDeclaratorAST::firstToken() const
return candidate;
if (rparen_token)
return rparen_token;
- if (cv_qualifier_list)
- if (int candidate = cv_qualifier_list->firstToken())
- return candidate;
- if (ref_qualifier_token)
+ const int firstQualListToken = cv_qualifier_list ? cv_qualifier_list->firstToken() : 0;
+ const auto isBeforeFirstQualListToken = [firstQualListToken](int token) {
+ return token && (!firstQualListToken || token < firstQualListToken);
+ };
+ if (isBeforeFirstQualListToken(ref_qualifier_token))
return ref_qualifier_token;
- if (exception_specification)
- if (int candidate = exception_specification->firstToken())
- return candidate;
- if (trailing_return_type)
- if (int candidate = trailing_return_type->firstToken())
- return candidate;
+ if (exception_specification) {
+ const int candidate = exception_specification->firstToken();
+ if (isBeforeFirstQualListToken(candidate))
+ return candidate;
+ }
+ if (trailing_return_type) {
+ const int candidate = trailing_return_type->firstToken();
+ if (isBeforeFirstQualListToken(candidate))
+ return candidate;
+ }
+ if (firstQualListToken)
+ return firstQualListToken;
if (as_cpp_initializer)
if (int candidate = as_cpp_initializer->firstToken())
return candidate;
return 0;
}
-/** \generated */
int FunctionDeclaratorAST::lastToken() const
{
if (as_cpp_initializer)
if (int candidate = as_cpp_initializer->lastToken())
return candidate;
- if (trailing_return_type)
- if (int candidate = trailing_return_type->lastToken())
- return candidate;
- if (exception_specification)
- if (int candidate = exception_specification->lastToken())
- return candidate;
- if (ref_qualifier_token)
- return ref_qualifier_token + 1;
- if (cv_qualifier_list)
- if (int candidate = cv_qualifier_list->lastToken())
- return candidate;
+ const int lastQualListToken = cv_qualifier_list ? cv_qualifier_list->lastToken() : 0;
+ const auto tokenOrLastQualListToken = [lastQualListToken](int token) {
+ return std::max(token ? token + 1 : 0, lastQualListToken);
+ };
+ const auto tokenFromAstOrLastQualListToken = [lastQualListToken](const AST *ast) {
+ return std::max(ast ? ast->lastToken() : 0, lastQualListToken);
+ };
+ if (int candidate = tokenFromAstOrLastQualListToken(trailing_return_type))
+ return candidate;
+ if (int candidate = tokenFromAstOrLastQualListToken(exception_specification))
+ return candidate;
+ if (int candidate = tokenOrLastQualListToken(ref_qualifier_token))
+ return candidate;
+ if (lastQualListToken)
+ return lastQualListToken;
if (rparen_token)
return rparen_token + 1;
if (parameter_declaration_clause)
@@ -1524,6 +1545,8 @@ int IfStatementAST::firstToken() const
{
if (if_token)
return if_token;
+ if (constexpr_token)
+ return constexpr_token;
if (lparen_token)
return lparen_token;
if (condition)
@@ -1560,6 +1583,8 @@ int IfStatementAST::lastToken() const
return candidate;
if (lparen_token)
return lparen_token + 1;
+ if (constexpr_token)
+ return constexpr_token + 1;
if (if_token)
return if_token + 1;
return 1;
@@ -1634,12 +1659,18 @@ int LambdaDeclaratorAST::firstToken() const
if (trailing_return_type)
if (int candidate = trailing_return_type->firstToken())
return candidate;
+ if (requiresClause)
+ if (int candidate = requiresClause->firstToken())
+ return candidate;
return 0;
}
/** \generated */
int LambdaDeclaratorAST::lastToken() const
{
+ if (requiresClause)
+ if (int candidate = requiresClause->firstToken())
+ return candidate;
if (trailing_return_type)
if (int candidate = trailing_return_type->lastToken())
return candidate;
@@ -1667,6 +1698,15 @@ int LambdaExpressionAST::firstToken() const
if (lambda_introducer)
if (int candidate = lambda_introducer->firstToken())
return candidate;
+ if (templateParameters)
+ if (int candidate = templateParameters->firstToken())
+ return candidate;
+ if (requiresClause)
+ if (int candidate = requiresClause->firstToken())
+ return candidate;
+ if (attributes)
+ if (int candidate = attributes->firstToken())
+ return candidate;
if (lambda_declarator)
if (int candidate = lambda_declarator->firstToken())
return candidate;
@@ -1685,6 +1725,15 @@ int LambdaExpressionAST::lastToken() const
if (lambda_declarator)
if (int candidate = lambda_declarator->lastToken())
return candidate;
+ if (attributes)
+ if (int candidate = attributes->firstToken())
+ return candidate;
+ if (requiresClause)
+ if (int candidate = requiresClause->firstToken())
+ return candidate;
+ if (templateParameters)
+ if (int candidate = templateParameters->firstToken())
+ return candidate;
if (lambda_introducer)
if (int candidate = lambda_introducer->lastToken())
return candidate;
@@ -3738,6 +3787,8 @@ int TemplateTypeParameterAST::firstToken() const
{
if (template_token)
return template_token;
+ if (typeConstraint)
+ return typeConstraint->firstToken();
if (less_token)
return less_token;
if (template_parameter_list)
@@ -3782,6 +3833,8 @@ int TemplateTypeParameterAST::lastToken() const
return candidate;
if (less_token)
return less_token + 1;
+ if (typeConstraint)
+ return typeConstraint->lastToken();
if (template_token)
return template_token + 1;
return 1;
@@ -4214,6 +4267,36 @@ int GnuAttributeSpecifierAST::lastToken() const
return 1;
}
+int MsvcDeclspecSpecifierAST::lastToken() const
+{
+ if (rparen_token)
+ return rparen_token + 1;
+ if (attribute_list)
+ if (int candidate = attribute_list->lastToken())
+ return candidate;
+ if (lparen_token)
+ return lparen_token + 1;
+ if (attribute_token)
+ return attribute_token + 1;
+ return 1;
+}
+
+int StdAttributeSpecifierAST::lastToken() const
+{
+ if (second_rbracket_token)
+ return second_rbracket_token + 1;
+ if (first_rbracket_token)
+ return first_rbracket_token + 1;
+ if (attribute_list)
+ if (int candidate = attribute_list->lastToken())
+ return candidate;
+ if (second_lbracket_token)
+ return second_lbracket_token + 1;
+ if (first_lbracket_token)
+ return first_lbracket_token + 1;
+ return 1;
+}
+
/** \generated */
int PointerLiteralAST::firstToken() const
{
@@ -4582,3 +4665,32 @@ int NoExceptOperatorExpressionAST::lastToken() const
return 1;
}
+int TypeConstraintAST::firstToken() const
+{
+ if (nestedName)
+ return nestedName->firstToken();
+ return conceptName->firstToken();
+}
+
+int TypeConstraintAST::lastToken() const
+{
+ if (greaterToken)
+ return greaterToken + 1;
+ return conceptName->lastToken();
+}
+
+int PlaceholderTypeSpecifierAST::firstToken() const
+{
+ if (typeConstraint)
+ return typeConstraint->firstToken();
+ if (declTypetoken)
+ return declTypetoken;
+ return autoToken;
+}
+
+int PlaceholderTypeSpecifierAST::lastToken() const
+{
+ if (rparenToken)
+ return rparenToken + 1;
+ return autoToken + 1;
+}