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/Config/llvm-config.h" // for LLVM_ON_UNIX |
12 | #include "llvm/Support/Compiler.h" |
13 | #include "llvm/TargetParser/Host.h" |
14 | |
15 | namespace clang { |
16 | namespace clangd { |
17 | |
18 | std::string versionString() { return clang::getClangToolFullVersion(ToolName: "clangd"); } |
19 | |
20 | std::string platformString() { |
21 | static std::string PlatformString = []() { |
22 | std::string Host = llvm::sys::getProcessTriple(); |
23 | std::string Target = llvm::sys::getDefaultTargetTriple(); |
24 | if (Host != Target) { |
25 | Host += "; target="; |
26 | Host += Target; |
27 | } |
28 | return Host; |
29 | }(); |
30 | return PlatformString; |
31 | } |
32 | |
33 | std::string featureString() { |
34 | return |
35 | #if defined(_WIN32) |
36 | "windows" |
37 | #elif defined(__APPLE__) |
38 | "mac" |
39 | #elif defined(__linux__) |
40 | "linux" |
41 | #elif defined(LLVM_ON_UNIX) |
42 | "unix" |
43 | #else |
44 | "unknown" |
45 | #endif |
46 | |
47 | #ifndef NDEBUG |
48 | "+debug" |
49 | #endif |
50 | #if LLVM_ADDRESS_SANITIZER_BUILD |
51 | "+asan" |
52 | #endif |
53 | #if LLVM_THREAD_SANITIZER_BUILD |
54 | "+tsan" |
55 | #endif |
56 | #if LLVM_MEMORY_SANITIZER_BUILD |
57 | "+msan" |
58 | #endif |
59 | |
60 | #if CLANGD_ENABLE_REMOTE |
61 | "+grpc" |
62 | #endif |
63 | #if CLANGD_BUILD_XPC |
64 | "+xpc" |
65 | #endif |
66 | |
67 | #if !CLANGD_TIDY_CHECKS |
68 | "-tidy" |
69 | #endif |
70 | |
71 | #if !CLANGD_DECISION_FOREST |
72 | "-decision_forest" |
73 | #endif |
74 | ; |
75 | } |
76 | |
77 | } // namespace clangd |
78 | } // namespace clang |
79 |