[clang] [clang][modules] Print library module manifest path. (PR #76451)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 11:14:51 PST 2024


================
@@ -6135,6 +6141,42 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
   return std::string(Name);
 }
 
+std::string Driver::GetStdModuleManifestPath(const Compilation &C,
+                                             const ToolChain &TC) const {
+
+  std::string error = "<NOT PRESENT>";
+
+  switch (TC.GetCXXStdlibType(C.getArgs())) {
+  case ToolChain::CST_Libcxx: {
+    std::string lib = "libc++.so";
+    std::string path = GetFilePath(lib, TC);
+
+    // Note when there are multiple flavours of libc++ the module json needs to
+    // look at the command-line arguments for the proper json.
+	// These flavours do not exist at the moment, but there are plans to
+	// provide a variant that is built with sanitizer instrumentation enabled.
+
+    // For example
+    //  const SanitizerArgs &Sanitize = TC.getSanitizerArgs(C.getArgs());
+    //  if (Sanitize.needsAsanRt())
+    //    return path.replace(path.size() - lib.size(), lib.size(),
+    //                        "modules-asan.json");
+
+    path = path.replace(path.size() - lib.size(), lib.size(), "modules.json");
----------------
MaskRay wrote:

`llvm::sys::path::remove_filename` + `appen`

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


More information about the cfe-commits mailing list