]> granicus.if.org Git - clang/commitdiff
Driver: avoid failing in the backend
authorSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 26 Sep 2016 04:48:22 +0000 (04:48 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Mon, 26 Sep 2016 04:48:22 +0000 (04:48 +0000)
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

lib/Driver/Tools.cpp
test/Driver/Inputs/rewrite-1.map [new file with mode: 0644]
test/Driver/Inputs/rewrite-2.map [new file with mode: 0644]
test/Driver/Inputs/rewrite.map [new file with mode: 0644]
test/Driver/rewrite-map-files.c [new file with mode: 0644]

index 7d1e0d091aa18bdf4f335b73267f25ef39b73eb4..dcdc92a1305192245ad5e4c671f5b03fda12dc54 100644 (file)
@@ -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 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/rewrite-2.map b/test/Driver/Inputs/rewrite-2.map
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/rewrite.map b/test/Driver/Inputs/rewrite.map
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/rewrite-map-files.c b/test/Driver/rewrite-map-files.c
new file mode 100644 (file)
index 0000000..fe04fba
--- /dev/null
@@ -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: