diff options
| author | Vexu <15308111+Vexu@users.noreply.github.com> | 2019-07-17 01:22:20 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-17 01:22:20 +0300 |
| commit | 34d2a1465c1b4869b70df07d735b0364506d484d (patch) | |
| tree | f6f7ad8e8802efc888a357fb524d4cc33dcaf2ea /src/analyze.cpp | |
| parent | de369de312584c64ec162972ba14e95b7a17e531 (diff) | |
| parent | 158e2312ea5f680b7c8598ef578aefb6cbdd3372 (diff) | |
| download | zig-34d2a1465c1b4869b70df07d735b0364506d484d.tar.gz zig-34d2a1465c1b4869b70df07d735b0364506d484d.zip | |
Merge branch 'master' into fmt-comment-fix
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 935ced9491..3ec839464e 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3896,22 +3896,21 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu Buf *pkg_root_src_dir = &package->root_src_dir; Buf resolved_root_src_dir = os_path_resolve(&pkg_root_src_dir, 1); - Buf namespace_name = BUF_INIT; - buf_init_from_buf(&namespace_name, &package->pkg_path); + Buf *namespace_name = buf_create_from_buf(&package->pkg_path); if (source_kind == SourceKindNonRoot) { assert(buf_starts_with_buf(resolved_path, &resolved_root_src_dir)); - if (buf_len(&namespace_name) != 0) { - buf_append_char(&namespace_name, NAMESPACE_SEP_CHAR); + if (buf_len(namespace_name) != 0) { + buf_append_char(namespace_name, NAMESPACE_SEP_CHAR); } // The namespace components are obtained from the relative path to the // source directory if (buf_len(&noextname) > buf_len(&resolved_root_src_dir)) { // Skip the trailing separator - buf_append_mem(&namespace_name, + buf_append_mem(namespace_name, buf_ptr(&noextname) + buf_len(&resolved_root_src_dir) + 1, buf_len(&noextname) - buf_len(&resolved_root_src_dir) - 1); } - buf_replace(&namespace_name, ZIG_OS_SEP_CHAR, NAMESPACE_SEP_CHAR); + buf_replace(namespace_name, ZIG_OS_SEP_CHAR, NAMESPACE_SEP_CHAR); } Buf *bare_name = buf_alloc(); os_path_extname(src_basename, bare_name, nullptr); @@ -3922,7 +3921,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu root_struct->line_offsets = tokenization.line_offsets; root_struct->path = resolved_path; root_struct->di_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(src_basename), buf_ptr(src_dirname)); - ZigType *import_entry = get_root_container_type(g, buf_ptr(&namespace_name), bare_name, root_struct); + ZigType *import_entry = get_root_container_type(g, buf_ptr(namespace_name), bare_name, root_struct); if (source_kind == SourceKindRoot) { assert(g->root_import == nullptr); g->root_import = import_entry; @@ -3966,7 +3965,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu } TldContainer *tld_container = allocate<TldContainer>(1); - init_tld(&tld_container->base, TldIdContainer, &namespace_name, VisibModPub, root_node, nullptr); + init_tld(&tld_container->base, TldIdContainer, namespace_name, VisibModPub, root_node, nullptr); tld_container->type_entry = import_entry; tld_container->decls_scope = import_entry->data.structure.decls_scope; g->resolve_queue.append(&tld_container->base); |
