[clang-tools-extra] 00e05b1 - [clangd] Reorder a little bit of init code. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 02:57:38 PDT 2020
Author: Sam McCall
Date: 2020-09-24T11:57:31+02:00
New Revision: 00e05b12c76c396688cd8d4caac09a2e96851fd9
URL: https://github.com/llvm/llvm-project/commit/00e05b12c76c396688cd8d4caac09a2e96851fd9
DIFF: https://github.com/llvm/llvm-project/commit/00e05b12c76c396688cd8d4caac09a2e96851fd9.diff
LOG: [clangd] Reorder a little bit of init code. NFC
This makes it possible to do something else (run checks) instead of
starting the server, with all config applied.
Added:
Modified:
clang-tools-extra/clangd/tool/ClangdMain.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index cf74ded93632..9660f1bd76f7 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -761,35 +761,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
Opts.ConfigProvider = Config.get();
}
- // Initialize and run ClangdLSPServer.
- // Change stdin to binary to not lose \r\n on windows.
- llvm::sys::ChangeStdinToBinary();
-
- std::unique_ptr<Transport> TransportLayer;
- if (getenv("CLANGD_AS_XPC_SERVICE")) {
-#if CLANGD_BUILD_XPC
- log("Starting LSP over XPC service");
- TransportLayer = newXPCTransport();
-#else
- llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
- return (int)ErrorResultCode::CantRunAsXPCService;
-#endif
- } else {
- log("Starting LSP over stdin/stdout");
- TransportLayer = newJSONTransport(
- stdin, llvm::outs(),
- InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
- PrettyPrint, InputStyle);
- }
- if (!PathMappingsArg.empty()) {
- auto Mappings = parsePathMappings(PathMappingsArg);
- if (!Mappings) {
- elog("Invalid -path-mappings: {0}", Mappings.takeError());
- return 1;
- }
- TransportLayer = createPathMappingTransport(std::move(TransportLayer),
- std::move(*Mappings));
- }
// Create an empty clang-tidy option.
std::mutex ClangTidyOptMu;
std::unique_ptr<tidy::ClangTidyOptionsProvider>
@@ -816,9 +787,9 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
return Opts;
};
}
+ Opts.AsyncPreambleBuilds = AsyncPreamble;
Opts.SuggestMissingIncludes = SuggestMissingIncludes;
Opts.QueryDriverGlobs = std::move(QueryDriverGlobs);
-
Opts.TweakFilter = [&](const Tweak &T) {
if (T.hidden() && !HiddenFeatures)
return false;
@@ -834,7 +805,34 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
// Shall we allow to customize the file limit?
RenameOpts.AllowCrossFile = CrossFileRename;
- Opts.AsyncPreambleBuilds = AsyncPreamble;
+ // Initialize and run ClangdLSPServer.
+ // Change stdin to binary to not lose \r\n on windows.
+ llvm::sys::ChangeStdinToBinary();
+ std::unique_ptr<Transport> TransportLayer;
+ if (getenv("CLANGD_AS_XPC_SERVICE")) {
+#if CLANGD_BUILD_XPC
+ log("Starting LSP over XPC service");
+ TransportLayer = newXPCTransport();
+#else
+ llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
+ return (int)ErrorResultCode::CantRunAsXPCService;
+#endif
+ } else {
+ log("Starting LSP over stdin/stdout");
+ TransportLayer = newJSONTransport(
+ stdin, llvm::outs(),
+ InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
+ PrettyPrint, InputStyle);
+ }
+ if (!PathMappingsArg.empty()) {
+ auto Mappings = parsePathMappings(PathMappingsArg);
+ if (!Mappings) {
+ elog("Invalid -path-mappings: {0}", Mappings.takeError());
+ return 1;
+ }
+ TransportLayer = createPathMappingTransport(std::move(TransportLayer),
+ std::move(*Mappings));
+ }
ClangdLSPServer LSPServer(
*TransportLayer, TFS, CCOpts, RenameOpts, CompileCommandsDirPath,
More information about the cfe-commits
mailing list