COFF: Handle /alternatename in .drectve section.
llvm-svn: 240037
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 4cb10a7..05dd62f 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -154,6 +154,25 @@
   return std::error_code();
 }
 
+// Parse a string of the form of "<from>=<to>".
+// Results are directly written to Config.
+std::error_code parseAlternateName(StringRef S) {
+  StringRef From, To;
+  std::tie(From, To) = S.split('=');
+  if (From.empty() || To.empty()) {
+    llvm::errs() << "/alternatename: invalid argument: " << S << "\n";
+    return make_error_code(LLDError::InvalidOption);
+  }
+  for (std::pair<StringRef, StringRef> &P : Config->AlternateNames) {
+    if (From == P.first) {
+      llvm::errs() << "/alternatename: conflicts: " << S << "\n";
+      return make_error_code(LLDError::InvalidOption);
+    }
+  }
+  Config->AlternateNames.push_back(std::make_pair(From, To));
+  return std::error_code();
+}
+
 // Parses a string in the form of "EMBED[,=<integer>]|NO".
 // Results are directly written to Config.
 std::error_code parseManifest(StringRef Arg) {