[lld] r240061 - COFF: Handle /failifmismatch in the same manner as other options.
Rui Ueyama
ruiu at google.com
Thu Jun 18 14:23:34 PDT 2015
Author: ruiu
Date: Thu Jun 18 16:23:34 2015
New Revision: 240061
URL: http://llvm.org/viewvc/llvm-project?rev=240061&view=rev
Log:
COFF: Handle /failifmismatch in the same manner as other options.
No functionality change intended.
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Driver.h
lld/trunk/COFF/DriverUtils.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=240061&r1=240060&r2=240061&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu Jun 18 16:23:34 2015
@@ -105,8 +105,9 @@ LinkerDriver::parseDirectives(StringRef
return EC;
// Handle /failifmismatch
- if (auto EC = checkFailIfMismatch(Args.get()))
- return EC;
+ for (auto *Arg : Args->filtered(OPT_failifmismatch))
+ if (auto EC = checkFailIfMismatch(Arg->getValue()))
+ return EC;
// Handle /defaultlib
for (auto *Arg : Args->filtered(OPT_defaultlib)) {
@@ -366,10 +367,9 @@ bool LinkerDriver::link(int Argc, const
}
// Handle /failifmismatch
- if (auto EC = checkFailIfMismatch(Args.get())) {
- llvm::errs() << "/failifmismatch: " << EC.message() << "\n";
- return false;
- }
+ for (auto *Arg : Args->filtered(OPT_failifmismatch))
+ if (checkFailIfMismatch(Arg->getValue()))
+ return false;
// Handle /def
if (auto *Arg = Args->getLastArg(OPT_deffile)) {
Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=240061&r1=240060&r2=240061&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Thu Jun 18 16:23:34 2015
@@ -139,7 +139,7 @@ std::error_code fixupExports();
// if value matches previous values for the key.
// This feature used in the directive section to reject
// incompatible objects.
-std::error_code checkFailIfMismatch(llvm::opt::InputArgList *Args);
+std::error_code checkFailIfMismatch(StringRef Arg);
// Convert Windows resource files (.res files) to a .obj file
// using cvtres.exe.
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=240061&r1=240060&r2=240061&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Thu Jun 18 16:23:34 2015
@@ -425,24 +425,20 @@ std::error_code fixupExports() {
// Parses a string in the form of "key=value" and check
// if value matches previous values for the same key.
-std::error_code checkFailIfMismatch(llvm::opt::InputArgList *Args) {
- for (auto *Arg : Args->filtered(OPT_failifmismatch)) {
- StringRef K, V;
- std::tie(K, V) = StringRef(Arg->getValue()).split('=');
- if (K.empty() || V.empty()) {
- llvm::errs() << "/failifmismatch: invalid argument: "
- << Arg->getValue() << "\n";
- return make_error_code(LLDError::InvalidOption);
- }
- StringRef Existing = Config->MustMatch[K];
- if (!Existing.empty() && V != Existing) {
- llvm::errs() << "/failifmismatch: mismatch detected: "
- << Existing << " and " << V
- << " for key " << K << "\n";
- return make_error_code(LLDError::InvalidOption);
- }
- Config->MustMatch[K] = V;
+std::error_code checkFailIfMismatch(StringRef Arg) {
+ StringRef K, V;
+ std::tie(K, V) = Arg.split('=');
+ if (K.empty() || V.empty()) {
+ llvm::errs() << "/failifmismatch: invalid argument: " << Arg << "\n";
+ return make_error_code(LLDError::InvalidOption);
}
+ StringRef Existing = Config->MustMatch[K];
+ if (!Existing.empty() && V != Existing) {
+ llvm::errs() << "/failifmismatch: mismatch detected: "
+ << Existing << " and " << V << " for key " << K << "\n";
+ return make_error_code(LLDError::InvalidOption);
+ }
+ Config->MustMatch[K] = V;
return std::error_code();
}
More information about the llvm-commits
mailing list