From: Adrian Prantl Date: Fri, 9 Feb 2018 18:43:10 +0000 (+0000) Subject: Introduce an API for LLDB to compute the default module cache path X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66ee15242d9ca6dcfc59b30bed63f63c92046e31;p=clang Introduce an API for LLDB to compute the default module cache path LLDB creates Clang modules and had an incomplete copy of the clang Driver code that compute the -fmodule-cache-path. This patch makes the clang driver code accessible to LLDB. Differential Revision: https://reviews.llvm.org/D43128 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324761 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 0713430983..53eb64c5dc 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -572,6 +572,8 @@ public: /// no extra characters remaining at the end. static bool GetReleaseVersion(StringRef Str, MutableArrayRef Digits); + /// Compute the default -fmodule-cache-path. + static void getDefaultModuleCachePath(SmallVectorImpl &Result); }; /// \return True if the last defined optimization level is -Ofast. diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index ad29119c28..2a8c9c97f5 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -2500,6 +2500,13 @@ static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T, CmdArgs.push_back("-fno-math-builtin"); } +void Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) { + llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Result); + llvm::sys::path::append(Result, "org.llvm.clang."); + appendUserToPath(Result); + llvm::sys::path::append(Result, "ModuleCache"); +} + static void RenderModulesOptions(Compilation &C, const Driver &D, const ArgList &Args, const InputInfo &Input, const InputInfo &Output, @@ -2560,10 +2567,7 @@ static void RenderModulesOptions(Compilation &C, const Driver &D, llvm::sys::path::append(Path, "modules"); } else if (Path.empty()) { // No module path was provided: use the default. - llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Path); - llvm::sys::path::append(Path, "org.llvm.clang."); - appendUserToPath(Path); - llvm::sys::path::append(Path, "ModuleCache"); + Driver::getDefaultModuleCachePath(Path); } const char Arg[] = "-fmodules-cache-path=";