#include "ClangdMain.h"
#include "ClangdLSPServer.h"
#include "CodeComplete.h"
#include "Compiler.h"
#include "Config.h"
#include "ConfigProvider.h"
#include "Feature.h"
#include "IncludeCleaner.h"
#include "PathMapping.h"
#include "Protocol.h"
#include "TidyProvider.h"
#include "Transport.h"
#include "index/Background.h"
#include "index/Index.h"
#include "index/MemIndex.h"
#include "index/Merge.h"
#include "index/ProjectAware.h"
#include "index/remote/Client.h"
#include "support/Path.h"
#include "support/Shutdown.h"
#include "support/ThreadCrashReporter.h"
#include "support/ThreadsafeFS.h"
#include "support/Trace.h"
#include "clang/Basic/Stack.h"
#include "clang/Format/Format.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include <chrono>
#include <cstdlib>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#ifndef _WIN32
#include <unistd.h>
#endif
#ifdef __GLIBC__
#include <malloc.h>
#endif
namespace clang {
namespace clangd {
bool check(const llvm::StringRef File, const ThreadsafeFS &TFS,
const ClangdLSPServer::Options &Opts);
namespace {
cat;
CommaSeparated;
desc;
Hidden;
init;
list;
opt;
OptionCategory;
ValueOptional;
values;
OptionCategory CompileCommands("clangd compilation flags options");
OptionCategory Features("clangd feature options");
OptionCategory Misc("clangd miscellaneous options");
OptionCategory Protocol("clangd protocol and logging options");
OptionCategory Retired("clangd flags no longer in use");
const OptionCategory *ClangdCategories[] = …;
template <typename T> class RetiredFlag { … };
enum CompileArgsFrom { … };
opt<CompileArgsFrom> CompileArgsFrom{ … };
opt<Path> CompileCommandsDir{ … };
opt<Path> ResourceDir{ … };
list<std::string> QueryDriverGlobs{ … };
opt<bool> AllScopesCompletion{ … };
opt<bool> ShowOrigins{ … };
opt<bool> EnableBackgroundIndex{ … };
opt<llvm::ThreadPriority> BackgroundIndexPriority{ … };
opt<bool> EnableClangTidy{ … };
opt<CodeCompleteOptions::CodeCompletionParse> CodeCompletionParse{ … };
opt<CodeCompleteOptions::CodeCompletionRankingModel> RankingModel{ … };
enum CompletionStyleFlag { … };
opt<CompletionStyleFlag> CompletionStyle{ … };
opt<std::string> FallbackStyle{ … };
opt<bool> EnableFunctionArgSnippets{ … };
opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{ … };
opt<bool> ImportInsertions{ … };
opt<bool> HeaderInsertionDecorators{ … };
opt<bool> HiddenFeatures{ … };
opt<bool> IncludeIneligibleResults{ … };
RetiredFlag<bool> EnableIndex("index");
RetiredFlag<bool> SuggestMissingIncludes("suggest-missing-includes");
RetiredFlag<bool> RecoveryAST("recovery-ast");
RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
RetiredFlag<bool> AsyncPreamble("async-preamble");
RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
RetiredFlag<bool> CrossFileRename("cross-file-rename");
RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");
RetiredFlag<bool> InlayHints("inlay-hints");
RetiredFlag<bool> FoldingRanges("folding-ranges");
RetiredFlag<bool> IncludeCleanerStdlib("include-cleaner-stdlib");
opt<int> LimitResults{ … };
opt<int> ReferencesLimit{ … };
opt<int> RenameFileLimit{ … };
list<std::string> TweakList{ … };
opt<unsigned> WorkerThreadsCount{ … };
opt<Path> IndexFile{ … };
opt<bool> Test{ … };
opt<bool> CrashPragmas{ … };
opt<Path> CheckFile{ … };
enum PCHStorageFlag { … };
opt<PCHStorageFlag> PCHStorage{ … };
opt<bool> Sync{ … };
opt<JSONStreamStyle> InputStyle{ … };
opt<bool> EnableTestScheme{ … };
opt<std::string> PathMappingsArg{ … };
opt<Path> InputMirrorFile{ … };
opt<Logger::Level> LogLevel{ … };
opt<OffsetEncoding> ForceOffsetEncoding{ … };
opt<bool> PrettyPrint{ … };
opt<bool> EnableConfig{ … };
opt<bool> UseDirtyHeaders{ … };
opt<bool> PreambleParseForwardingFunctions{ … };
#if defined(__GLIBC__) && CLANGD_MALLOC_TRIM
opt<bool> EnableMallocTrim{ … };
std::function<void()> getMemoryCleanupFunction() { … }
#else
std::function<void()> getMemoryCleanupFunction() { return nullptr; }
#endif
#if CLANGD_ENABLE_REMOTE
opt<std::string> RemoteIndexAddress{
"remote-index-address",
cat(Features),
desc("Address of the remote index server"),
};
opt<std::string> ProjectRoot{
"project-root",
cat(Features),
desc("Path to the project root. Requires remote-index-address to be set."),
};
#endif
opt<bool> ExperimentalModulesSupport{ … };
class TestScheme : public URIScheme { … };
#ifdef _WIN32
const char TestScheme::TestDir[] = "C:\\clangd-test";
#else
const char TestScheme::TestDir[] = …;
#endif
std::unique_ptr<SymbolIndex>
loadExternalIndex(const Config::ExternalIndexSpec &External,
AsyncTaskRunner *Tasks) { … }
class FlagsConfigProvider : public config::Provider { … };
}
enum class ErrorResultCode : int { … };
int clangdMain(int argc, char *argv[]) { … }
}
}