1//===--- Feature.cpp - Compile-time configuration ------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "Feature.h"
10#include "clang/Basic/Version.h"
11#include "llvm/Support/Compiler.h"
12#include "llvm/TargetParser/Host.h"
13
14namespace clang {
15namespace clangd {
16
17std::string versionString() { return clang::getClangToolFullVersion(ToolName: "clangd"); }
18
19std::string platformString() {
20 static std::string PlatformString = []() {
21 std::string Host = llvm::sys::getProcessTriple();
22 std::string Target = llvm::sys::getDefaultTargetTriple();
23 if (Host != Target) {
24 Host += "; target=";
25 Host += Target;
26 }
27 return Host;
28 }();
29 return PlatformString;
30}
31
32std::string featureString() {
33 return
34#if defined(_WIN32)
35 "windows"
36#elif defined(__APPLE__)
37 "mac"
38#elif defined(__linux__)
39 "linux"
40#elif defined(LLVM_ON_UNIX)
41 "unix"
42#else
43 "unknown"
44#endif
45
46#ifndef NDEBUG
47 "+debug"
48#endif
49#if LLVM_ADDRESS_SANITIZER_BUILD
50 "+asan"
51#endif
52#if LLVM_THREAD_SANITIZER_BUILD
53 "+tsan"
54#endif
55#if LLVM_MEMORY_SANITIZER_BUILD
56 "+msan"
57#endif
58
59#if CLANGD_ENABLE_REMOTE
60 "+grpc"
61#endif
62#if CLANGD_BUILD_XPC
63 "+xpc"
64#endif
65
66#if !CLANGD_TIDY_CHECKS
67 "-tidy"
68#endif
69
70#if !CLANGD_DECISION_FOREST
71 "-decision_forest"
72#endif
73 ;
74}
75
76} // namespace clangd
77} // namespace clang
78

source code of clang-tools-extra/clangd/Feature.cpp