forked from qt-creator/qt-creator
Cleanup ptr operators.
This commit is contained in:
@@ -483,10 +483,8 @@ unsigned ConversionFunctionIdAST::firstToken() const
|
||||
|
||||
unsigned ConversionFunctionIdAST::lastToken() const
|
||||
{
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
|
||||
if (! it->next)
|
||||
return it->lastToken();
|
||||
}
|
||||
if (ptr_operators)
|
||||
return ptr_operators->lastToken();
|
||||
|
||||
for (SpecifierAST *it = type_specifier; it; it = it->next) {
|
||||
if (! it->next)
|
||||
@@ -566,10 +564,8 @@ unsigned DeclaratorAST::lastToken() const
|
||||
if (core_declarator)
|
||||
return core_declarator->lastToken();
|
||||
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
|
||||
if (! it->next)
|
||||
return it->lastToken();
|
||||
}
|
||||
if (ptr_operators)
|
||||
return ptr_operators->lastToken();
|
||||
|
||||
for (SpecifierAST *it = attributes; it; it = it->next) {
|
||||
if (! it->next)
|
||||
@@ -1176,12 +1172,10 @@ unsigned NewTypeIdAST::lastToken() const
|
||||
if (new_array_declarators)
|
||||
return new_array_declarators->lastToken();
|
||||
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
|
||||
if (it->next)
|
||||
return it->lastToken();
|
||||
}
|
||||
else if (ptr_operators)
|
||||
return ptr_operators->lastToken();
|
||||
|
||||
if (type_specifier)
|
||||
else if (type_specifier)
|
||||
return type_specifier->lastToken();
|
||||
|
||||
// ### assert?
|
||||
|
||||
@@ -371,7 +371,7 @@ class CPLUSPLUS_EXPORT DeclaratorAST: public AST
|
||||
{
|
||||
public:
|
||||
SpecifierAST *attributes;
|
||||
PtrOperatorAST *ptr_operators;
|
||||
PtrOperatorListAST *ptr_operators;
|
||||
CoreDeclaratorAST *core_declarator;
|
||||
PostfixDeclaratorListAST *postfix_declarators;
|
||||
SpecifierAST *post_attributes;
|
||||
@@ -1198,7 +1198,7 @@ class CPLUSPLUS_EXPORT ConversionFunctionIdAST: public NameAST
|
||||
public:
|
||||
unsigned operator_token;
|
||||
SpecifierAST *type_specifier;
|
||||
PtrOperatorAST *ptr_operators;
|
||||
PtrOperatorListAST *ptr_operators;
|
||||
|
||||
public:
|
||||
virtual ConversionFunctionIdAST *asConversionFunctionId() { return this; }
|
||||
@@ -1379,7 +1379,7 @@ class CPLUSPLUS_EXPORT NewTypeIdAST: public AST
|
||||
{
|
||||
public:
|
||||
SpecifierAST *type_specifier;
|
||||
PtrOperatorAST *ptr_operators;
|
||||
PtrOperatorListAST *ptr_operators;
|
||||
NewArrayDeclaratorListAST *new_array_declarators;
|
||||
|
||||
public:
|
||||
@@ -1591,12 +1591,8 @@ protected:
|
||||
|
||||
class CPLUSPLUS_EXPORT PtrOperatorAST: public AST
|
||||
{
|
||||
public:
|
||||
PtrOperatorAST *next;
|
||||
|
||||
public:
|
||||
virtual PtrOperatorAST *asPtrOperator() { return this; }
|
||||
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT PointerToMemberAST: public PtrOperatorAST
|
||||
|
||||
@@ -69,8 +69,7 @@ void DeclaratorAST::accept0(ASTVisitor *visitor)
|
||||
if (visitor->visit(this)) {
|
||||
for (SpecifierAST *it = attributes; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
accept(ptr_operators, visitor);
|
||||
accept(core_declarator, visitor);
|
||||
accept(postfix_declarators, visitor);
|
||||
for (SpecifierAST *it = post_attributes; it; it = it->next)
|
||||
@@ -472,8 +471,7 @@ void ConversionFunctionIdAST::accept0(ASTVisitor *visitor)
|
||||
if (visitor->visit(this)) {
|
||||
for (SpecifierAST *it = type_specifier; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
accept(ptr_operators, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
@@ -560,8 +558,7 @@ void NewTypeIdAST::accept0(ASTVisitor *visitor)
|
||||
if (visitor->visit(this)) {
|
||||
for (SpecifierAST *it = type_specifier; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
for (PtrOperatorAST *it = ptr_operators; it; it = it->next)
|
||||
accept(it, visitor);
|
||||
accept(ptr_operators, visitor);
|
||||
accept(new_array_declarators, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
|
||||
@@ -204,6 +204,7 @@ typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
|
||||
typedef List<AttributeAST *> AttributeListAST;
|
||||
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
|
||||
typedef List<CatchClauseAST *> CatchClauseListAST;
|
||||
typedef List<PtrOperatorAST *> PtrOperatorListAST;
|
||||
|
||||
typedef List<NameAST *> ObjCIdentifierListAST;
|
||||
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
|
||||
|
||||
@@ -68,9 +68,9 @@ CheckDeclarator::~CheckDeclarator()
|
||||
{ }
|
||||
|
||||
FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
|
||||
FullySpecifiedType type,
|
||||
Scope *scope,
|
||||
Name **name)
|
||||
const FullySpecifiedType &type,
|
||||
Scope *scope,
|
||||
Name **name)
|
||||
{
|
||||
FullySpecifiedType previousType = switchFullySpecifiedType(type);
|
||||
Scope *previousScope = switchScope(scope);
|
||||
@@ -83,9 +83,9 @@ FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
|
||||
return switchFullySpecifiedType(previousType);
|
||||
}
|
||||
|
||||
FullySpecifiedType CheckDeclarator::check(PtrOperatorAST *ptrOperators,
|
||||
FullySpecifiedType type,
|
||||
Scope *scope)
|
||||
FullySpecifiedType CheckDeclarator::check(PtrOperatorListAST *ptrOperators,
|
||||
const FullySpecifiedType &type,
|
||||
Scope *scope)
|
||||
{
|
||||
FullySpecifiedType previousType = switchFullySpecifiedType(type);
|
||||
Scope *previousScope = switchScope(scope);
|
||||
@@ -110,7 +110,7 @@ DeclaratorAST *CheckDeclarator::switchDeclarator(DeclaratorAST *declarator)
|
||||
return previousDeclarator;
|
||||
}
|
||||
|
||||
FullySpecifiedType CheckDeclarator::switchFullySpecifiedType(FullySpecifiedType type)
|
||||
FullySpecifiedType CheckDeclarator::switchFullySpecifiedType(const FullySpecifiedType &type)
|
||||
{
|
||||
FullySpecifiedType previousType = _fullySpecifiedType;
|
||||
_fullySpecifiedType = type;
|
||||
|
||||
@@ -63,20 +63,20 @@ public:
|
||||
virtual ~CheckDeclarator();
|
||||
|
||||
FullySpecifiedType check(DeclaratorAST *declarator,
|
||||
FullySpecifiedType type,
|
||||
Scope *scope,
|
||||
Name **name);
|
||||
const FullySpecifiedType &type,
|
||||
Scope *scope,
|
||||
Name **name);
|
||||
|
||||
FullySpecifiedType check(PtrOperatorAST *ptrOperators,
|
||||
FullySpecifiedType type,
|
||||
Scope *scope);
|
||||
FullySpecifiedType check(PtrOperatorListAST *ptrOperators,
|
||||
const FullySpecifiedType &type,
|
||||
Scope *scope);
|
||||
|
||||
FullySpecifiedType check(ObjCMethodPrototypeAST *methodPrototype,
|
||||
Scope *scope);
|
||||
|
||||
protected:
|
||||
DeclaratorAST *switchDeclarator(DeclaratorAST *declarator);
|
||||
FullySpecifiedType switchFullySpecifiedType(FullySpecifiedType type);
|
||||
FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
|
||||
Scope *switchScope(Scope *scope);
|
||||
Name **switchName(Name **name);
|
||||
|
||||
|
||||
@@ -661,7 +661,7 @@ bool Parser::parseConversionFunctionId(NameAST *&node)
|
||||
if (! parseTypeSpecifier(type_specifier)) {
|
||||
return false;
|
||||
}
|
||||
PtrOperatorAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
while (parsePtrOperator(*ptr_operators_tail))
|
||||
ptr_operators_tail = &(*ptr_operators_tail)->next;
|
||||
|
||||
@@ -956,19 +956,19 @@ bool Parser::parseCvQualifiers(SpecifierAST *&node)
|
||||
return start != cursor();
|
||||
}
|
||||
|
||||
bool Parser::parsePtrOperator(PtrOperatorAST *&node)
|
||||
bool Parser::parsePtrOperator(PtrOperatorListAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T_AMPER) {
|
||||
ReferenceAST *ast = new (_pool) ReferenceAST;
|
||||
ast->amp_token = consumeToken();
|
||||
node = ast;
|
||||
node = new (_pool) PtrOperatorListAST(ast);
|
||||
return true;
|
||||
} else if (LA() == T_STAR) {
|
||||
PointerAST *ast = new (_pool) PointerAST;
|
||||
ast->star_token = consumeToken();
|
||||
parseCvQualifiers(ast->cv_qualifier_seq);
|
||||
node = ast;
|
||||
node = new (_pool) PtrOperatorListAST(ast);
|
||||
return true;
|
||||
} else if (LA() == T_COLON_COLON || LA() == T_IDENTIFIER) {
|
||||
unsigned scope_or_identifier_token = cursor();
|
||||
@@ -985,7 +985,7 @@ bool Parser::parsePtrOperator(PtrOperatorAST *&node)
|
||||
ast->nested_name_specifier = nested_name_specifiers;
|
||||
ast->star_token = consumeToken();
|
||||
parseCvQualifiers(ast->cv_qualifier_seq);
|
||||
node = ast;
|
||||
node = new (_pool) PtrOperatorListAST(ast);
|
||||
return true;
|
||||
}
|
||||
rewind(scope_or_identifier_token);
|
||||
@@ -1082,7 +1082,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
|
||||
attribute_ptr = &(*attribute_ptr)->next;
|
||||
}
|
||||
|
||||
PtrOperatorAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
while (parsePtrOperator(*ptr_operators_tail))
|
||||
ptr_operators_tail = &(*ptr_operators_tail)->next;
|
||||
|
||||
@@ -1219,7 +1219,8 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
|
||||
bool Parser::parseAbstractCoreDeclarator(DeclaratorAST *&node)
|
||||
{
|
||||
DEBUG_THIS_RULE();
|
||||
PtrOperatorAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
|
||||
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
|
||||
while (parsePtrOperator(*ptr_operators_tail))
|
||||
ptr_operators_tail = &(*ptr_operators_tail)->next;
|
||||
|
||||
@@ -3799,12 +3800,15 @@ bool Parser::parseNewTypeId(NewTypeIdAST *&node)
|
||||
|
||||
NewTypeIdAST *ast = new (_pool) NewTypeIdAST;
|
||||
ast->type_specifier = typeSpec;
|
||||
PtrOperatorAST **ptrop_it = &ast->ptr_operators;
|
||||
|
||||
PtrOperatorListAST **ptrop_it = &ast->ptr_operators;
|
||||
while (parsePtrOperator(*ptrop_it))
|
||||
ptrop_it = &(*ptrop_it)->next;
|
||||
|
||||
NewArrayDeclaratorListAST **it = &ast->new_array_declarators;
|
||||
while (parseNewArrayDeclarator(*it))
|
||||
it = &(*it)->next;
|
||||
|
||||
node = ast;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
bool parsePostfixExpressionInternal(ExpressionAST *&node);
|
||||
bool parsePrimaryExpression(ExpressionAST *&node);
|
||||
bool parseNestedExpression(ExpressionAST *&node);
|
||||
bool parsePtrOperator(PtrOperatorAST *&node);
|
||||
bool parsePtrOperator(PtrOperatorListAST *&node);
|
||||
bool parseRelationalExpression(ExpressionAST *&node);
|
||||
bool parseShiftExpression(ExpressionAST *&node);
|
||||
bool parseStatement(StatementAST *&node);
|
||||
|
||||
@@ -130,7 +130,7 @@ FullySpecifiedType Semantic::check(DeclaratorAST *declarator, FullySpecifiedType
|
||||
Scope *scope, Name **name)
|
||||
{ return d->checkDeclarator->check(declarator, type, scope, name); }
|
||||
|
||||
FullySpecifiedType Semantic::check(PtrOperatorAST *ptrOperators, FullySpecifiedType type,
|
||||
FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, FullySpecifiedType type,
|
||||
Scope *scope)
|
||||
{ return d->checkDeclarator->check(ptrOperators, type, scope); }
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
FullySpecifiedType check(DeclaratorAST *declarator, FullySpecifiedType type,
|
||||
Scope *scope, Name **name = 0); // ### ugly
|
||||
|
||||
FullySpecifiedType check(PtrOperatorAST *ptrOperators, FullySpecifiedType type,
|
||||
FullySpecifiedType check(PtrOperatorListAST *ptrOperators, FullySpecifiedType type,
|
||||
Scope *scope);
|
||||
|
||||
FullySpecifiedType check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope);
|
||||
|
||||
Reference in New Issue
Block a user