@@ -6203,28 +6203,35 @@ std::string Driver::GetStdModuleManifestPath(const Compilation &C,
6203
6203
6204
6204
switch (TC.GetCXXStdlibType (C.getArgs ())) {
6205
6205
case ToolChain::CST_Libcxx: {
6206
- std::string lib = GetFilePath (" libc++.so" , TC);
6207
-
6208
- // Note when there are multiple flavours of libc++ the module json needs to
6209
- // look at the command-line arguments for the proper json.
6210
- // These flavours do not exist at the moment, but there are plans to
6211
- // provide a variant that is built with sanitizer instrumentation enabled.
6212
-
6213
- // For example
6214
- // StringRef modules = [&] {
6215
- // const SanitizerArgs &Sanitize = TC.getSanitizerArgs(C.getArgs());
6216
- // if (Sanitize.needsAsanRt())
6217
- // return "modules-asan.json";
6218
- // return "modules.json";
6219
- // }();
6220
-
6221
- SmallString<128 > path (lib.begin (), lib.end ());
6222
- llvm::sys::path::remove_filename (path);
6223
- llvm::sys::path::append (path, " modules.json" );
6224
- if (TC.getVFS ().exists (path))
6225
- return static_cast <std::string>(path);
6206
+ auto evaluate = [&](const char *library) -> std::optional<std::string> {
6207
+ std::string lib = GetFilePath (library, TC);
6208
+
6209
+ // Note when there are multiple flavours of libc++ the module json needs
6210
+ // to look at the command-line arguments for the proper json. These
6211
+ // flavours do not exist at the moment, but there are plans to provide a
6212
+ // variant that is built with sanitizer instrumentation enabled.
6213
+
6214
+ // For example
6215
+ // StringRef modules = [&] {
6216
+ // const SanitizerArgs &Sanitize = TC.getSanitizerArgs(C.getArgs());
6217
+ // if (Sanitize.needsAsanRt())
6218
+ // return "libc++.modules-asan.json";
6219
+ // return "libc++.modules.json";
6220
+ // }();
6221
+
6222
+ SmallString<128 > path (lib.begin (), lib.end ());
6223
+ llvm::sys::path::remove_filename (path);
6224
+ llvm::sys::path::append (path, " libc++.modules.json" );
6225
+ if (TC.getVFS ().exists (path))
6226
+ return static_cast <std::string>(path);
6227
+
6228
+ return {};
6229
+ };
6226
6230
6227
- return error;
6231
+ if (std::optional<std::string> result = evaluate (" libc++.so" ); result)
6232
+ return *result;
6233
+
6234
+ return evaluate (" libc++.a" ).value_or (error);
6228
6235
}
6229
6236
6230
6237
case ToolChain::CST_Libstdcxx:
0 commit comments