bool CheckDeclaration::visit(ParameterDeclarationAST *ast) { unsigned sourceLocation = locationOfDeclaratorId(ast->declarator); if (! sourceLocation) { if (ast->declarator) sourceLocation = ast->declarator->firstToken(); else sourceLocation = ast->firstToken(); } const Name *argName = 0; FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(), _scope, &argName); FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope); Argument *arg = control()->newArgument(sourceLocation, argName); ast->symbol = arg; if (ast->expression) { unsigned startOfExpression = ast->expression->firstToken(); unsigned endOfExpression = ast->expression->lastToken(); std::string buffer; for (unsigned index = startOfExpression; index != endOfExpression; ++index) { const Token &tk = tokenAt(index); if (tk.whitespace() || tk.newline()) buffer += ' '; buffer += tk.spell(); } const StringLiteral *initializer = control()->findOrInsertStringLiteral(buffer.c_str(), buffer.size()); arg->setInitializer(initializer); } arg->setType(argTy); _scope->enterSymbol(arg); return false; }
bool CheckDeclaration::visit(ParameterDeclarationAST *ast) { unsigned sourceLocation = locationOfDeclaratorId(ast->declarator); if (! sourceLocation) { if (ast->declarator) sourceLocation = ast->declarator->firstToken(); else sourceLocation = ast->firstToken(); } Name *argName = 0; FullySpecifiedType ty = semantic()->check(ast->type_specifier, _scope); FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(), _scope, &argName); FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope); Argument *arg = control()->newArgument(sourceLocation, argName); ast->symbol = arg; if (ast->expression) arg->setInitializer(true); arg->setType(argTy); _scope->enterSymbol(arg); return false; }