When a function is defined, set its symbol's position to the code position.
Before, if the function was declared before being defined, then the symbol's SourcePos would be left set to the position of the declaration. This ended up getting the debugging symbols mixed up in this case, which was undesirable.
This commit is contained in:
@@ -792,11 +792,13 @@ void
|
||||
Module::AddFunctionDefinition(const std::string &name, const FunctionType *type,
|
||||
Stmt *code) {
|
||||
Symbol *sym = symbolTable->LookupFunction(name.c_str(), type);
|
||||
if (sym == NULL) {
|
||||
if (sym == NULL || code == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return;
|
||||
}
|
||||
|
||||
sym->pos = code->pos;
|
||||
|
||||
// FIXME: because we encode the parameter names in the function type,
|
||||
// we need to override the function type here in case the function had
|
||||
// earlier been declared with anonymous parameter names but is now
|
||||
|
||||
7
parse.yy
7
parse.yy
@@ -1862,8 +1862,11 @@ function_definition
|
||||
dynamic_cast<const FunctionType *>($2->type);
|
||||
if (funcType == NULL)
|
||||
Assert(m->errorCount > 0);
|
||||
else
|
||||
m->AddFunctionDefinition($2->name, funcType, $4);
|
||||
else {
|
||||
Stmt *code = $4;
|
||||
if (code == NULL) code = new StmtList(@4);
|
||||
m->AddFunctionDefinition($2->name, funcType, code);
|
||||
}
|
||||
}
|
||||
m->symbolTable->PopScope(); // push in lAddFunctionParams();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user