Fix args when calling clang::ASTUnit::LoadFromCommandLine.

clang::ASTUnit::LoadFromCommandLine interprets the first argument as
the name of program (like the main function).
This change shifts the arguments passing "" for the first argument.
This commit is contained in:
Tamas Kenez 2021-08-14 13:58:46 +02:00 committed by Veikka Tuominen
parent bbb96e112c
commit 4c18da1ef3
2 changed files with 2 additions and 0 deletions

View File

@ -2557,6 +2557,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
var argv = std.ArrayList([]const u8).init(comp.gpa);
defer argv.deinit();
try argv.append(""); // argv[0] is program name, actual args start at [1]
try comp.addTranslateCCArgs(arena, &argv, .c, out_dep_path);
try argv.append(out_h_path);

View File

@ -2492,6 +2492,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
const digest = if (try man.hit()) man.final() else digest: {
var argv = std.ArrayList([]const u8).init(arena);
try argv.append(""); // argv[0] is program name, actual args start at [1]
var zig_cache_tmp_dir = try comp.local_cache_directory.handle.makeOpenPath("tmp", .{});
defer zig_cache_tmp_dir.close();