From e5b0833c65a13f1767a7424e165f470f4200ffb5 Mon Sep 17 00:00:00 2001 From: ykiko Date: Thu, 25 Jul 2024 22:38:35 +0800 Subject: [PATCH] some fix. --- src/Clang/Preamble.cpp | 82 +++++++++++++++---------------- src/{LSP => Server}/Scheduler.cpp | 6 +-- src/{LSP => Server}/Server.cpp | 6 +-- src/{LSP => Server}/Transport.cpp | 4 +- src/main.cpp | 2 +- 5 files changed, 50 insertions(+), 50 deletions(-) rename src/{LSP => Server}/Scheduler.cpp (80%) rename src/{LSP => Server}/Server.cpp (96%) rename src/{LSP => Server}/Transport.cpp (98%) diff --git a/src/Clang/Preamble.cpp b/src/Clang/Preamble.cpp index c6e61f88..8d87e005 100644 --- a/src/Clang/Preamble.cpp +++ b/src/Clang/Preamble.cpp @@ -4,46 +4,46 @@ namespace clice { -Preamble - Preamble::build(std::string_view path, std::string_view context, const CompilerInvocation& invocation) { - auto buffer = llvm::MemoryBuffer::getMemBuffer(context, path, false); - - // compute preamble bounds, if MaxLines set to false(0), it means not to limit the number of lines - auto bounds = clang::ComputePreambleBounds({}, *buffer, false); - - clang::DiagnosticsEngine* engine; - auto VFS = llvm::vfs::getRealFileSystem(); - auto dir = fs::path(path).parent_path(); - if(auto error = VFS->setCurrentWorkingDirectory(dir.string())) { - logger::error("failed to set current working directory: {}", error.message()); - } else { - engine = new clang::DiagnosticsEngine(new clang::DiagnosticIDs(), new clang::DiagnosticOptions()); - engine->setClient(new clang::TextDiagnosticPrinter(llvm::errs(), &engine->getDiagnosticOptions())); - } - - // if store the preamble in memory, if not, store it in a file(storagePath) - bool storeInMemory = true; - llvm::StringRef storagePath = ""; - - // use to collect information in the process of building preamble, such as include files and macros - // TODO: inherit from clang::PreambleCallbacks and collect the information - clang::PreambleCallbacks callbacks = {}; - - auto result = clang::PrecompiledPreamble::Build(invocation, - buffer.get(), - bounds, - *engine, - VFS, - std::make_shared(), - storeInMemory, - storagePath, - callbacks); - if(result) { - logger::info("preamble built successfully"); - return Preamble{&result.get()}; - } else { - logger::error("failed to build preamble: {}", result.getError().message()); - } -} +// Preamble +// Preamble::build(std::string_view path, std::string_view context, const CompilerInvocation& invocation) +// { auto buffer = llvm::MemoryBuffer::getMemBuffer(context, path, false); +// +// // compute preamble bounds, if MaxLines set to false(0), it means not to limit the number of lines +// auto bounds = clang::ComputePreambleBounds({}, *buffer, false); +// +// clang::DiagnosticsEngine* engine; +// auto VFS = llvm::vfs::getRealFileSystem(); +// auto dir = fs::path(path).parent_path(); +// if(auto error = VFS->setCurrentWorkingDirectory(dir.string())) { +// logger::error("failed to set current working directory: {}", error.message()); +// } else { +// engine = new clang::DiagnosticsEngine(new clang::DiagnosticIDs(), new clang::DiagnosticOptions()); +// engine->setClient(new clang::TextDiagnosticPrinter(llvm::errs(), &engine->getDiagnosticOptions())); +// } +// +// // if store the preamble in memory, if not, store it in a file(storagePath) +// bool storeInMemory = true; +// llvm::StringRef storagePath = ""; +// +// // use to collect information in the process of building preamble, such as include files and macros +// // TODO: inherit from clang::PreambleCallbacks and collect the information +// clang::PreambleCallbacks callbacks = {}; +// +// auto result = clang::PrecompiledPreamble::Build(invocation, +// buffer.get(), +// bounds, +// *engine, +// VFS, +// std::make_shared(), +// storeInMemory, +// storagePath, +// callbacks); +// if(result) { +// logger::info("preamble built successfully"); +// return Preamble{&result.get()}; +// } else { +// logger::error("failed to build preamble: {}", result.getError().message()); +// } +// } } // namespace clice diff --git a/src/LSP/Scheduler.cpp b/src/Server/Scheduler.cpp similarity index 80% rename from src/LSP/Scheduler.cpp rename to src/Server/Scheduler.cpp index 11a00998..8d3adb67 100644 --- a/src/LSP/Scheduler.cpp +++ b/src/Server/Scheduler.cpp @@ -1,6 +1,6 @@ -#include "LSP/Scheduler.h" -#include "Clang/ParsedAST.h" -#include "Support/Logger.h" +#include +#include +#include namespace clice { diff --git a/src/LSP/Server.cpp b/src/Server/Server.cpp similarity index 96% rename from src/LSP/Server.cpp rename to src/Server/Server.cpp index e7e6b0ff..8e348873 100644 --- a/src/LSP/Server.cpp +++ b/src/Server/Server.cpp @@ -1,7 +1,7 @@ -#include -#include +#include +#include +#include #include -#include #include #include diff --git a/src/LSP/Transport.cpp b/src/Server/Transport.cpp similarity index 98% rename from src/LSP/Transport.cpp rename to src/Server/Transport.cpp index 2ce138b7..86f22452 100644 --- a/src/LSP/Transport.cpp +++ b/src/Server/Transport.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include namespace { diff --git a/src/main.cpp b/src/main.cpp index 246852ed..2784027d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include +#include int main(int argc, char** argv) { using namespace clice;