Skip to content

Commit

Permalink
Introduce an API for LLDB to compute the default module cache path
Browse files Browse the repository at this point in the history
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

llvm-svn: 324761
  • Loading branch information
adrian-prantl committed Feb 9, 2018
1 parent 58914ec commit 7059903
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions clang/include/clang/Driver/Driver.h
Expand Up @@ -572,6 +572,8 @@ class Driver {
/// no extra characters remaining at the end.
static bool GetReleaseVersion(StringRef Str,
MutableArrayRef<unsigned> Digits);
/// Compute the default -fmodule-cache-path.
static void getDefaultModuleCachePath(SmallVectorImpl<char> &Result);
};

/// \return True if the last defined optimization level is -Ofast.
Expand Down
12 changes: 8 additions & 4 deletions clang/lib/Driver/ToolChains/Clang.cpp
Expand Up @@ -2500,6 +2500,13 @@ static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T,
CmdArgs.push_back("-fno-math-builtin");
}

void Driver::getDefaultModuleCachePath(SmallVectorImpl<char> &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,
Expand Down Expand Up @@ -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=";
Expand Down

0 comments on commit 7059903

Please sign in to comment.