Remember the declarator-id.

This commit is contained in:
Roberto Raggi
2010-08-12 17:10:11 +02:00
parent bcad21e526
commit 73f1cdf3a7
2 changed files with 31 additions and 23 deletions

View File

@@ -67,7 +67,8 @@ Bind::Bind(TranslationUnit *unit)
: ASTVisitor(unit), : ASTVisitor(unit),
_scope(0), _scope(0),
_expression(0), _expression(0),
_name(0) _name(0),
_declaratorId(0)
{ {
if (unit->ast()) if (unit->ast())
translationUnit(unit->ast()->asTranslationUnit()); translationUnit(unit->ast()->asTranslationUnit());
@@ -198,7 +199,7 @@ bool Bind::visit(DeclaratorAST *ast)
return false; return false;
} }
FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType &init) FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType &init, DeclaratorIdAST **declaratorId)
{ {
FullySpecifiedType type = init; FullySpecifiedType type = init;
@@ -208,6 +209,7 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType
if (debug_todo) if (debug_todo)
translationUnit()->warning(ast->firstToken(), "TODO: %s", __func__); translationUnit()->warning(ast->firstToken(), "TODO: %s", __func__);
std::swap(_declaratorId, declaratorId);
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) { for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
@@ -223,6 +225,7 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType
} }
// unsigned equals_token = ast->equals_token; // unsigned equals_token = ast->equals_token;
ExpressionTy initializer = this->expression(ast->initializer); ExpressionTy initializer = this->expression(ast->initializer);
std::swap(_declaratorId, declaratorId);
return init; return init;
} }
@@ -982,7 +985,8 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu
for (SpecifierListAST *it = ast->type_specifiers; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifiers; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
return type; return type;
} }
@@ -1073,7 +1077,8 @@ bool Bind::visit(ForeachStatementAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
ExpressionTy initializer = this->expression(ast->initializer); ExpressionTy initializer = this->expression(ast->initializer);
// unsigned comma_token = ast->comma_token; // unsigned comma_token = ast->comma_token;
ExpressionTy expression = this->expression(ast->expression); ExpressionTy expression = this->expression(ast->expression);
@@ -1223,7 +1228,8 @@ bool Bind::visit(ObjCFastEnumerationAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
ExpressionTy initializer = this->expression(ast->initializer); ExpressionTy initializer = this->expression(ast->initializer);
// unsigned in_token = ast->in_token; // unsigned in_token = ast->in_token;
ExpressionTy fast_enumeratable_expression = this->expression(ast->fast_enumeratable_expression); ExpressionTy fast_enumeratable_expression = this->expression(ast->fast_enumeratable_expression);
@@ -1283,7 +1289,8 @@ bool Bind::visit(QtMethodAST *ast)
// unsigned method_token = ast->method_token; // unsigned method_token = ast->method_token;
// unsigned lparen_token = ast->lparen_token; // unsigned lparen_token = ast->lparen_token;
FullySpecifiedType type; FullySpecifiedType type;
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
// unsigned rparen_token = ast->rparen_token; // unsigned rparen_token = ast->rparen_token;
return false; return false;
} }
@@ -1317,7 +1324,8 @@ bool Bind::visit(ConditionAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
return false; return false;
} }
@@ -1499,7 +1507,8 @@ bool Bind::visit(TypeIdAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
return false; return false;
} }
@@ -1592,7 +1601,8 @@ bool Bind::visit(SimpleDeclarationAST *ast)
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) { for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) {
FullySpecifiedType declTy = this->declarator(it->value, type); DeclaratorIdAST *declaratorId = 0;
FullySpecifiedType declTy = this->declarator(it->value, type, &declaratorId);
} }
// unsigned semicolon_token = ast->semicolon_token; // unsigned semicolon_token = ast->semicolon_token;
// List<Declaration *> *symbols = ast->symbols; // List<Declaration *> *symbols = ast->symbols;
@@ -1639,7 +1649,8 @@ bool Bind::visit(QtPrivateSlotAST *ast)
for (SpecifierListAST *it = ast->type_specifiers; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifiers; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
// unsigned rparen_token = ast->rparen_token; // unsigned rparen_token = ast->rparen_token;
return false; return false;
} }
@@ -1718,7 +1729,8 @@ bool Bind::visit(ExceptionDeclarationAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token; // unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
return false; return false;
} }
@@ -1732,7 +1744,8 @@ bool Bind::visit(FunctionDefinitionAST *ast)
for (SpecifierListAST *it = ast->decl_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->decl_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
this->ctorInitializer(ast->ctor_initializer); this->ctorInitializer(ast->ctor_initializer);
this->statement(ast->function_body); this->statement(ast->function_body);
// Function *symbol = ast->symbol; // Function *symbol = ast->symbol;
@@ -1796,7 +1809,8 @@ bool Bind::visit(ParameterDeclarationAST *ast)
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) { for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
type = this->specifier(it->value, type); type = this->specifier(it->value, type);
} }
type = this->declarator(ast->declarator, type); DeclaratorIdAST *declaratorId = 0;
type = this->declarator(ast->declarator, type, &declaratorId);
// unsigned equal_token = ast->equal_token; // unsigned equal_token = ast->equal_token;
ExpressionTy expression = this->expression(ast->expression); ExpressionTy expression = this->expression(ast->expression);
// Argument *symbol = ast->symbol; // Argument *symbol = ast->symbol;
@@ -2292,21 +2306,14 @@ bool Bind::visit(MemberAccessAST *ast)
// CoreDeclaratorAST // CoreDeclaratorAST
bool Bind::visit(DeclaratorIdAST *ast) bool Bind::visit(DeclaratorIdAST *ast)
{ {
if (debug_todo)
translationUnit()->warning(ast->firstToken(), "TODO: %s", __func__);
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
/*const Name *name =*/ this->name(ast->name); /*const Name *name =*/ this->name(ast->name);
*_declaratorId = ast;
return false; return false;
} }
bool Bind::visit(NestedDeclaratorAST *ast) bool Bind::visit(NestedDeclaratorAST *ast)
{ {
if (debug_todo) _type = this->declarator(ast->declarator, _type, _declaratorId);
translationUnit()->warning(ast->firstToken(), "TODO: %s", __func__);
// unsigned lparen_token = ast->lparen_token;
FullySpecifiedType type;
type = this->declarator(ast->declarator, type);
// unsigned rparen_token = ast->rparen_token;
return false; return false;
} }

View File

@@ -80,7 +80,7 @@ protected:
const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg); const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg);
void attribute(AttributeAST *ast); void attribute(AttributeAST *ast);
FullySpecifiedType declarator(DeclaratorAST *ast, const FullySpecifiedType &init); FullySpecifiedType declarator(DeclaratorAST *ast, const FullySpecifiedType &init, DeclaratorIdAST **declaratorId);
void qtPropertyDeclarationItem(QtPropertyDeclarationItemAST *ast); void qtPropertyDeclarationItem(QtPropertyDeclarationItemAST *ast);
void qtInterfaceName(QtInterfaceNameAST *ast); void qtInterfaceName(QtInterfaceNameAST *ast);
void baseSpecifier(BaseSpecifierAST *ast); void baseSpecifier(BaseSpecifierAST *ast);
@@ -273,6 +273,7 @@ private:
ExpressionTy _expression; ExpressionTy _expression;
const Name *_name; const Name *_name;
FullySpecifiedType _type; FullySpecifiedType _type;
DeclaratorIdAST **_declaratorId;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus