aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-27 00:01:49 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-27 00:01:49 -0700
commit0278468479d52d6ea64521ab78574b593a6832ae (patch)
treed7438d5c45de76b453efa7d3fab5a33ea27db347 /src/codegen.cpp
parentac085a869d068ca60548ad5298682ff054e91141 (diff)
downloadzig-0278468479d52d6ea64521ab78574b593a6832ae.tar.gz
zig-0278468479d52d6ea64521ab78574b593a6832ae.zip
upgrade to the libclang C++ API
c_import creates a tmp .h file and parses it with libclang, reporting any errors found. See #88
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp23
1 files changed, 3 insertions, 20 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 98dbfd03e5..e99baf66ff 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -3051,15 +3051,8 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path,
tokenize(source_code, &tokenization);
if (tokenization.err) {
- ErrorMsg *err = allocate<ErrorMsg>(1);
- err->line_start = tokenization.err_line;
- err->column_start = tokenization.err_column;
- err->line_end = -1;
- err->column_end = -1;
- err->msg = tokenization.err;
- err->path = full_path;
- err->source = source_code;
- err->line_offsets = tokenization.line_offsets;
+ ErrorMsg *err = err_msg_create_with_line(full_path, tokenization.err_line, tokenization.err_column,
+ source_code, tokenization.line_offsets, tokenization.err);
print_err_msg(err, g->err_color);
exit(1);
@@ -3401,19 +3394,9 @@ static void generate_h_file(CodeGen *g) {
zig_panic("unable to close h file: %s", strerror(errno));
}
-static void find_libc_path(CodeGen *g) {
- if (g->libc_path && buf_len(g->libc_path))
- return;
- g->libc_path = buf_create_from_str(ZIG_LIBC_DIR);
- if (g->libc_path && buf_len(g->libc_path))
- return;
- fprintf(stderr, "Unable to determine libc path. Consider using `--libc-path [path]`\n");
- exit(1);
-}
-
static const char *get_libc_file(CodeGen *g, const char *file) {
Buf *out_buf = buf_alloc();
- os_path_join(g->libc_path, buf_create_from_str(file), out_buf);
+ os_path_join(g->libc_lib_path, buf_create_from_str(file), out_buf);
return buf_ptr(out_buf);
}