diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -56,7 +56,7 @@ ModuleListProperties(); FileSpec GetClangModulesCachePath() const; - bool SetClangModulesCachePath(llvm::StringRef path); + bool SetClangModulesCachePath(const FileSpec &path); bool GetEnableExternalLookup() const; bool SetEnableExternalLookup(bool new_value); diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -82,8 +82,9 @@ [this] { UpdateSymlinkMappings(); }); llvm::SmallString<128> path; - clang::driver::Driver::getDefaultModuleCachePath(path); - SetClangModulesCachePath(path); + if (clang::driver::Driver::getDefaultModuleCachePath(path)) { + lldbassert(SetClangModulesCachePath(FileSpec(path))); + } } bool ModuleListProperties::GetEnableExternalLookup() const { @@ -104,8 +105,8 @@ ->GetCurrentValue(); } -bool ModuleListProperties::SetClangModulesCachePath(llvm::StringRef path) { - return m_collection_sp->SetPropertyAtIndexAsString( +bool ModuleListProperties::SetClangModulesCachePath(const FileSpec &path) { + return m_collection_sp->SetPropertyAtIndexAsFileSpec( nullptr, ePropertyClangModulesCachePath, path); } diff --git a/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test @@ -0,0 +1,9 @@ +# RUN: %lldb-noinit -x -s %s | FileCheck %s +settings show symbols.clang-modules-cache-path +q +# This test checks that we get *any* clang modules cache path by default. The +# actual path depends on the operating system. +# CHECK: symbols.clang-modules-cache-path (file) = " +# Clang treats an empty path in the same way as 'no path', so explicitly check +# that we never have an empty path by default. +# CHECK-NOT: symbols.clang-modules-cache-path (file) = "" diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -54,6 +54,10 @@ command=FindTool('lldb'), extra_args=['-S', lldb_init], unresolved='fatal'), + ToolSubst('%lldb-noinit', + command=FindTool('lldb'), + extra_args=['--no-lldbinit'], + unresolved='fatal'), ToolSubst('%lldb-server', command=FindTool("lldb-server"), extra_args=[],