r282379 - Driver: avoid failing in the backend

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 25 21:48:22 PDT 2016


Author: compnerd
Date: Sun Sep 25 23:48:22 2016
New Revision: 282379

URL: http://llvm.org/viewvc/llvm-project?rev=282379&view=rev
Log:
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.

Added:
    cfe/trunk/test/Driver/Inputs/rewrite-1.map
    cfe/trunk/test/Driver/Inputs/rewrite-2.map
    cfe/trunk/test/Driver/Inputs/rewrite.map
    cfe/trunk/test/Driver/rewrite-map-files.c
Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=282379&r1=282378&r2=282379&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Sep 25 23:48:22 2016
@@ -4213,9 +4213,14 @@ void Clang::ConstructJob(Compilation &C,
       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();
+      }
     }
   }
 

Added: cfe/trunk/test/Driver/Inputs/rewrite-1.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite-1.map?rev=282379&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/rewrite-2.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite-2.map?rev=282379&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/rewrite.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite.map?rev=282379&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/rewrite-map-files.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-map-files.c?rev=282379&view=auto
==============================================================================
--- cfe/trunk/test/Driver/rewrite-map-files.c (added)
+++ cfe/trunk/test/Driver/rewrite-map-files.c Sun Sep 25 23:48:22 2016
@@ -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:




More information about the cfe-commits mailing list