aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-11 20:58:28 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-11 21:02:30 -0500
commit3268276b58d8b65cb295b738d7c14174005bd84e (patch)
treec52b5524962c7ab37129318b5aba31b9d83820f6 /src/ir.cpp
parent465e75bc5a41aa899b673c0a3ff59d6da871fbe6 (diff)
downloadzig-3268276b58d8b65cb295b738d7c14174005bd84e.tar.gz
zig-3268276b58d8b65cb295b738d7c14174005bd84e.zip
the same string literal codegens to the same constant
this makes it so that you can send the same string literal as a comptime slice and get the same type
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 176e5791f8..f236910250 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -13224,9 +13224,9 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
os_path_resolve(&source_dir_path, rel_file_path, &file_path);
// load from file system into const expr
- Buf file_contents = BUF_INIT;
+ Buf *file_contents = buf_alloc();
int err;
- if ((err = os_fetch_file_path(&file_path, &file_contents))) {
+ if ((err = os_fetch_file_path(&file_path, file_contents))) {
if (err == ErrorFileNotFound) {
ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(&file_path)));
return ira->codegen->builtin_types.entry_invalid;
@@ -13240,9 +13240,9 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
// we'll have to invalidate the cache
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
- init_const_str_lit(ira->codegen, out_val, &file_contents);
+ init_const_str_lit(ira->codegen, out_val, file_contents);
- return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(&file_contents));
+ return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(file_contents));
}
static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) {