[clang] Add -fuse-lipo option (PR #121231)

Ashley Hauck via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 28 00:56:29 PST 2024


================
@@ -910,7 +910,10 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(II.getFilename());
   }
 
-  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
+  std::string LipoName =
+      std::string(Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo"));
+  const char *Exec =
+      Args.MakeArgString(getToolChain().GetProgramPath(LipoName.c_str()));
----------------
khyperia wrote:

Ah, StringRef::data() is documented as "data - Get a pointer to the start of the string (which may not be null terminated)". Because we're using it as a null-terminated string, I thought that making a copy is necessary to ensure it's null terminated, in case getLastArgValue ever changes to not return a null-terminated string. Depending on it always returning a null terminated string seems like what a lot of other code does already, though, I'll make that change.

https://github.com/llvm/llvm-project/pull/121231


More information about the cfe-commits mailing list