blob: ec707a33f656be006d4949aaeabfa82fd639cc82 [file] [log] [blame]
Sam McCall4ad9ec82021-08-05 14:27:40 +02001//===--- Feature.cpp - Compile-time configuration ------------------------===//
Sam McCall0c96a922021-04-15 14:29:57 +02002//
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 McCall4ad9ec82021-08-05 14:27:40 +02009#include "Feature.h"
Sam McCall0c96a922021-04-15 14:29:57 +020010#include "clang/Basic/Version.h"
Daniil Fukalovb8d68852024-09-06 16:41:24 +020011#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
Sam McCall0c96a922021-04-15 14:29:57 +020012#include "llvm/Support/Compiler.h"
Archibald Elliottd768bf92023-02-10 09:59:46 +000013#include "llvm/TargetParser/Host.h"
Sam McCall0c96a922021-04-15 14:29:57 +020014
15namespace clang {
16namespace clangd {
17
18std::string versionString() { return clang::getClangToolFullVersion("clangd"); }
19
Sam McCalle2559e52021-07-09 10:26:44 +020020std::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 McCall0c96a922021-04-15 14:29:57 +020033std::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 McCall462d4de2021-07-09 09:40:18 +020066
67#if !CLANGD_TIDY_CHECKS
68 "-tidy"
69#endif
Ilya Biryukovc9b32502022-12-07 13:50:47 +010070
71#if !CLANGD_DECISION_FOREST
72 "-decision_forest"
73#endif
Sam McCall0c96a922021-04-15 14:29:57 +020074 ;
75}
76
77} // namespace clangd
78} // namespace clang