[PATCH] D34055: Be more strict when checking the -flto option value
Yuka Takahashi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 08:37:50 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305392: Be more strict when checking the -flto option value (authored by yamaguchi).
Changed prior to commit:
https://reviews.llvm.org/D34055?vs=102551&id=102555#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34055
Files:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/thinlto-backend-option.ll
Index: cfe/trunk/test/CodeGen/thinlto-backend-option.ll
===================================================================
--- cfe/trunk/test/CodeGen/thinlto-backend-option.ll
+++ cfe/trunk/test/CodeGen/thinlto-backend-option.ll
@@ -8,6 +8,8 @@
; RUN: %clang -flto=thin -c -o %t.o %s
; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,14 @@
Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
- const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
- Opts.EmitSummaryIndex = A && A->containsValue("thin");
+ Opts.EmitSummaryIndex = false;
+ if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+ StringRef S = A->getValue();
+ if (S == "thin")
+ Opts.EmitSummaryIndex = true;
+ else if (S != "full")
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+ }
Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
if (IK.getLanguage() != InputKind::LLVM_IR)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34055.102555.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170614/fba715ee/attachment.bin>
More information about the cfe-commits
mailing list