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

Mark de Wever via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 27 10:33:50 PST 2023


================
@@ -6135,6 +6141,40 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
   return std::string(Name);
 }
 
+std::string Driver::GetModuleManifestPath(const Compilation &C,
+                                          const ToolChain &TC) const {
+
+  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.
+
+    // 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");
+    if (TC.getVFS().exists(path))
+      return path;
+
+    return "";
----------------
mordante wrote:

I like one error value, the goal of the output is to be usable by tools. 

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


More information about the cfe-commits mailing list