[PATCH] D21825: Driver: Forbid -fthinlto-index with output formats other than object files.

Peter Collingbourne via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 28 18:00:50 PDT 2016


pcc created this revision.
pcc added a reviewer: tejohnson.
pcc added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

The other output formats aren't really useful to end users. The equivalent
functionality can still be accessed by developers with tools such as llvm-lto.

http://reviews.llvm.org/D21825

Files:
  lib/Driver/Tools.cpp
  test/Driver/thinlto_backend.c

Index: test/Driver/thinlto_backend.c
===================================================================
--- test/Driver/thinlto_backend.c
+++ test/Driver/thinlto_backend.c
@@ -6,5 +6,9 @@
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERR1
+// CHECK-ERR1: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
+
+// And for incorrect output type
+// RUN: not %clang -O2 -o %t1.o -x ir %s -S -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERR2
+// CHECK-ERR2: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-c'
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3895,6 +3895,9 @@
     if (!types::isLLVMIR(Input.getType()))
       D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
                                                        << "-x ir";
+    if (!isa<AssembleJobAction>(JA))
+      D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
+                                                       << "-c";
     Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21825.62158.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160629/f51c3ca2/attachment.bin>


More information about the cfe-commits mailing list