aprantl updated this revision to Diff 148265.
aprantl added a comment.
Remove unused include.
https://reviews.llvm.org/D47235
Files:
include/lldb/API/SystemInitializerFull.h
include/lldb/Core/ModuleList.h
source/API/SystemInitializerFull.cpp
source/Core/ModuleList.cpp
tools/lldb-test/CMakeLists.txt
tools/lldb-test/lldb-test.cpp
unittests/Host/SymbolsTest.cpp
unittests/Target/ModuleCacheTest.cpp
Index: unittests/Target/ModuleCacheTest.cpp
===================================================================
--- unittests/Target/ModuleCacheTest.cpp
+++ unittests/Target/ModuleCacheTest.cpp
@@ -5,7 +5,9 @@
#include "llvm/Support/Path.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "lldb/API/SystemInitializerFull.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -67,6 +69,7 @@
void ModuleCacheTest::SetUpTestCase() {
HostInfo::Initialize();
ObjectFileELF::Initialize();
+ ModuleListProperties::Initialize("dummy");
FileSpec tmpdir_spec;
HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir);
Index: unittests/Host/SymbolsTest.cpp
===================================================================
--- unittests/Host/SymbolsTest.cpp
+++ unittests/Host/SymbolsTest.cpp
@@ -9,20 +9,24 @@
#include "gtest/gtest.h"
+#include "lldb/API/SystemInitializerFull.h"
#include "lldb/Host/Symbols.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
using namespace lldb_private;
TEST(SymbolsTest,
LocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
+ ModuleListProperties::Initialize("dummy");
ModuleSpec module_spec;
FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec);
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
}
TEST(SymbolsTest,
LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
+ ModuleListProperties::Initialize("dummy");
ModuleSpec module_spec;
// using a GUID here because the symbol file shouldn't actually exist on disk
module_spec.GetSymbolFileSpec().SetFile(
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/Core/ModuleList.cpp
===================================================================
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -34,7 +34,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 +78,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,13 @@
// AFTER PluginManager::Initialize is called.
Debugger::SettingsInitialize();
+ InitializeClang();
+}
+
+void SystemInitializerFull::InitializeClang() {
+ llvm::SmallString<128> path;
+ clang::driver::Driver::getDefaultModuleCachePath(path);
+ ModuleListProperties::Initialize(path);
}
void SystemInitializerFull::InitializeSWIG() {
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;
Index: include/lldb/API/SystemInitializerFull.h
===================================================================
--- include/lldb/API/SystemInitializerFull.h
+++ include/lldb/API/SystemInitializerFull.h
@@ -29,6 +29,8 @@
void Initialize() override;
void Terminate() override;
+ /// Retrieve the default clang module cache path.
+ static void InitializeClang();
private:
void InitializeSWIG();
};
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits