diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index c5bc96eb9..146cb2944 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -1740,12 +1740,9 @@ gb_internal void lb_generate_code(lbGenerator *gen) { if (m->debug_builder) { // Debug Info for (auto const &file_entry : info->files) { AstFile *f = file_entry.value; - String fullpath = f->fullpath; - String filename = remove_directory_from_path(fullpath); - String directory = directory_from_path(fullpath); LLVMMetadataRef res = LLVMDIBuilderCreateFile(m->debug_builder, - cast(char const *)filename.text, filename.len, - cast(char const *)directory.text, directory.len); + cast(char const *)f->filename.text, f->filename.len, + cast(char const *)f->directory.text, f->directory.len); lb_set_llvm_metadata(m, f, res); } diff --git a/src/parser.cpp b/src/parser.cpp index ad22ce5ff..436498c51 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4768,8 +4768,10 @@ gb_internal Array parse_stmt_list(AstFile *f) { gb_internal ParseFileError init_ast_file(AstFile *f, String const &fullpath, TokenPos *err_pos) { GB_ASSERT(f != nullptr); - f->fullpath = string_trim_whitespace(fullpath); // Just in case - set_file_path_string(f->id, fullpath); + f->fullpath = string_trim_whitespace(fullpath); // Just in case + f->filename = remove_directory_from_path(f->fullpath); + f->directory = directory_from_path(f->fullpath); + set_file_path_string(f->id, f->fullpath); thread_safe_set_ast_file_from_id(f->id, f); if (!string_ends_with(f->fullpath, str_lit(".odin"))) { return ParseFile_WrongExtension; diff --git a/src/parser.hpp b/src/parser.hpp index f7b3e51ae..7d292ffce 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -99,7 +99,11 @@ struct AstFile { Scope * scope; Ast * pkg_decl; + String fullpath; + String filename; + String directory; + Tokenizer tokenizer; Array tokens; isize curr_token_index; @@ -109,6 +113,7 @@ struct AstFile { Token package_token; String package_name; + // >= 0: In Expression // < 0: In Control Clause // NOTE(bill): Used to prevent type literals in control clauses