Sam McCall | 4ad9ec8 | 2021-08-05 14:27:40 +0200 | [diff] [blame] | 1 | //===--- Feature.cpp - Compile-time configuration ------------------------===// |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 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 | |
Sam McCall | 4ad9ec8 | 2021-08-05 14:27:40 +0200 | [diff] [blame] | 9 | #include "Feature.h" |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 10 | #include "clang/Basic/Version.h" |
Daniil Fukalov | b8d6885 | 2024-09-06 16:41:24 +0200 | [diff] [blame] | 11 | #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 12 | #include "llvm/Support/Compiler.h" |
Archibald Elliott | d768bf9 | 2023-02-10 09:59:46 +0000 | [diff] [blame] | 13 | #include "llvm/TargetParser/Host.h" |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 14 | |
| 15 | namespace clang { |
| 16 | namespace clangd { |
| 17 | |
| 18 | std::string versionString() { return clang::getClangToolFullVersion("clangd"); } |
| 19 | |
Sam McCall | e2559e5 | 2021-07-09 10:26:44 +0200 | [diff] [blame] | 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 | |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 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 |
Sam McCall | 462d4de | 2021-07-09 09:40:18 +0200 | [diff] [blame] | 66 | |
| 67 | #if !CLANGD_TIDY_CHECKS |
| 68 | "-tidy" |
| 69 | #endif |
Ilya Biryukov | c9b3250 | 2022-12-07 13:50:47 +0100 | [diff] [blame] | 70 | |
| 71 | #if !CLANGD_DECISION_FOREST |
| 72 | "-decision_forest" |
| 73 | #endif |
Sam McCall | 0c96a92 | 2021-04-15 14:29:57 +0200 | [diff] [blame] | 74 | ; |
| 75 | } |
| 76 | |
| 77 | } // namespace clangd |
| 78 | } // namespace clang |