aprantl updated this revision to Diff 148241.
aprantl added a comment.
Updated patch according to Zachary's suggestion.
https://reviews.llvm.org/D47235
Files:
include/lldb/Core/ModuleList.h
include/lldb/Host/HostInfoBase.h
source/API/SystemInitializerFull.cpp
source/Core/ModuleList.cpp
source/Host/CMakeLists.txt
tools/lldb-test/CMakeLists.txt
tools/lldb-test/lldb-test.cpp
Index: tools/lldb-test/lldb-test.cpp
===================================================================
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -34,6 +34,9 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/WithColor.h"
+
+#include "clang/Driver/Driver.h"
+
#include <thread>
using namespace lldb;
@@ -467,6 +470,11 @@
cl::ParseCommandLineOptions(argc, argv, "LLDB Testing Utility\n");
+ // Retrieve the default modulecache path from clang.
+ llvm::SmallString<128> path;
+ clang::driver::Driver::getDefaultModuleCachePath(path);
+ ModuleListProperties::Initialize(path);
+
SystemLifetimeManager DebuggerLifetime;
DebuggerLifetime.Initialize(llvm::make_unique<SystemInitializerTest>(),
nullptr);
Index: tools/lldb-test/CMakeLists.txt
===================================================================
--- tools/lldb-test/CMakeLists.txt
+++ tools/lldb-test/CMakeLists.txt
@@ -19,6 +19,7 @@
lldbUtility
${LLDB_ALL_PLUGINS}
${host_lib}
+ clangDriver
LINK_COMPONENTS
Support
Index: source/Host/CMakeLists.txt
===================================================================
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -185,7 +185,7 @@
lldbUtility
${LLDB_PLUGINS}
${EXTRA_LIBS}
-
+
LINK_COMPONENTS
Object
Support
Index: source/Core/ModuleList.cpp
===================================================================
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Symbols.h"
+#include "lldb/Host/HostInfoBase.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/Property.h"
@@ -34,7 +35,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h" // for fs
-#include "clang/Driver/Driver.h"
#include <chrono> // for operator!=, time_point
#include <memory> // for shared_ptr
@@ -79,15 +79,20 @@
enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath };
+std::string g_default_clang_modules_cache_path;
} // namespace
+void ModuleListProperties::Initialize(
+ llvm::StringRef clang_modules_cache_path) {
+ g_default_clang_modules_cache_path = clang_modules_cache_path.str();
+}
+
ModuleListProperties::ModuleListProperties() {
m_collection_sp.reset(new OptionValueProperties(ConstString("symbols")));
m_collection_sp->Initialize(g_properties);
- llvm::SmallString<128> path;
- clang::driver::Driver::getDefaultModuleCachePath(path);
- SetClangModulesCachePath(path);
+ assert(!g_default_clang_modules_cache_path.empty());
+ SetClangModulesCachePath(g_default_clang_modules_cache_path);
}
bool ModuleListProperties::GetEnableExternalLookup() const {
Index: source/API/SystemInitializerFull.cpp
===================================================================
--- source/API/SystemInitializerFull.cpp
+++ source/API/SystemInitializerFull.cpp
@@ -119,6 +119,7 @@
#endif
#include "llvm/Support/TargetSelect.h"
+#include "clang/Driver/Driver.h"
#include <string>
@@ -385,6 +386,11 @@
// AFTER PluginManager::Initialize is called.
Debugger::SettingsInitialize();
+
+ // Retrieve the default modulecache path from clang.
+ llvm::SmallString<128> path;
+ clang::driver::Driver::getDefaultModuleCachePath(path);
+ ModuleListProperties::Initialize(path);
}
void SystemInitializerFull::InitializeSWIG() {
Index: include/lldb/Host/HostInfoBase.h
===================================================================
--- include/lldb/Host/HostInfoBase.h
+++ include/lldb/Host/HostInfoBase.h
@@ -89,7 +89,7 @@
/// ArchSpec object.
//---------------------------------------------------------------------------
static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
-
+
protected:
static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
Index: include/lldb/Core/ModuleList.h
===================================================================
--- include/lldb/Core/ModuleList.h
+++ include/lldb/Core/ModuleList.h
@@ -79,6 +79,10 @@
public:
ModuleListProperties();
+ /// Set the default clang modules cache path.
+ /// This avoids Core depending on Clang.
+ static void Initialize(llvm::StringRef clang_modules_cache_path);
+
FileSpec GetClangModulesCachePath() const;
bool SetClangModulesCachePath(llvm::StringRef path);
bool GetEnableExternalLookup() const;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits