From: Saleem Abdulrasool Date: Mon, 26 Sep 2016 04:48:22 +0000 (+0000) Subject: Driver: avoid failing in the backend X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7df0fd1b25469e7c5574479d1ee949dd84f54e1c;p=clang Driver: avoid failing in the backend Avoid failing in the backend when the rewrite map does not exist. Rather check that the map exists in the frontend before handing it off to the backend. Add the missing rewrite maps that the tests were referencing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282379 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7d1e0d091a..dcdc92a130 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4213,9 +4213,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.hasArg(options::OPT_frewrite_map_file_EQ)) { for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file, options::OPT_frewrite_map_file_EQ)) { - CmdArgs.push_back("-frewrite-map-file"); - CmdArgs.push_back(A->getValue()); - A->claim(); + StringRef Map = A->getValue(); + if (!llvm::sys::fs::exists(Map)) { + D.Diag(diag::err_drv_no_such_file) << Map; + } else { + CmdArgs.push_back("-frewrite-map-file"); + CmdArgs.push_back(A->getValue()); + A->claim(); + } } } diff --git a/test/Driver/Inputs/rewrite-1.map b/test/Driver/Inputs/rewrite-1.map new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/rewrite-2.map b/test/Driver/Inputs/rewrite-2.map new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/rewrite.map b/test/Driver/Inputs/rewrite.map new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/rewrite-map-files.c b/test/Driver/rewrite-map-files.c new file mode 100644 index 0000000000..fe04fbaa1f --- /dev/null +++ b/test/Driver/rewrite-map-files.c @@ -0,0 +1,2 @@ +// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s +// CHECK: error: no such file or directory: