analyze: BlockContext has concept of module scope

This commit is contained in:
Andrew Kelley
2015-12-14 22:01:39 -07:00
parent 3049410260
commit 52e19b4a9b
5 changed files with 47 additions and 36 deletions

View File

@@ -1132,8 +1132,8 @@ static void do_code_gen(CodeGen *g) {
// Set up debug info for blocks and variables and
// allocate all local variables
for (int bc_i = 0; bc_i < codegen_fn_def->all_block_contexts.length; bc_i += 1) {
BlockContext *block_context = codegen_fn_def->all_block_contexts.at(bc_i);
for (int bc_i = 0; bc_i < fn_table_entry->all_block_contexts.length; bc_i += 1) {
BlockContext *block_context = fn_table_entry->all_block_contexts.at(bc_i);
if (block_context->parent) {
LLVMZigDILexicalBlock *di_block = LLVMZigCreateLexicalBlock(g->dbuilder,
@@ -1530,6 +1530,9 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *src_dirname, Buf *src
import_entry->di_file = LLVMZigCreateFile(g->dbuilder, buf_ptr(src_basename), buf_ptr(src_dirname));
g->import_table.put(full_path, import_entry);
import_entry->block_context = new_block_context(nullptr, nullptr);
import_entry->block_context->di_scope = LLVMZigFileToScope(import_entry->di_file);
assert(import_entry->root->type == NodeTypeRoot);
for (int decl_i = 0; decl_i < import_entry->root->data.root.top_level_decls.length; decl_i += 1) {