[PATCH] Allow clang-cl to automatically use lld instead of forcing the MSVC linker

Reid Kleckner rnk at google.com
Mon Dec 1 13:53:50 PST 2014


I'm kind of bummed that we have to special case lld, but I guess that's the spirit of the gcc flag anyway. This seems like the right direction.

================
Comment at: lib/Driver/Tools.cpp:7982
@@ +7981,3 @@
+  // linker, we need to use a special search algorithm.
+  llvm::SmallString<128> linkPath;
+  Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
----------------
Clang code uses StudlyCaps for variable names. (Yaaay!)

================
Comment at: lib/Driver/Tools.cpp:7983
@@ +7982,3 @@
+  llvm::SmallString<128> linkPath;
+  Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+  const char *ld_value = nullptr;
----------------
There are some idioms that can make this code more concise. getLastArgValue() exists and takes a default value, and const char * converts implicitly to StringRef. This can probably be:
  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
  if (Linker.equals_lower("lld"))
    Linker = "lld-link";

  if (Linker.equals_lower("link")) {
    ...

http://reviews.llvm.org/D6428






More information about the cfe-commits mailing list