LLDB mainline
Version.cpp
Go to the documentation of this file.
1//===-- Version.cpp -------------------------------------------------------===//
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
10#include "VCSVersion.inc"
11#include "lldb/Version/Version.inc"
12#include "clang/Basic/Version.h"
13
14static const char *GetLLDBVersion() {
15#ifdef LLDB_FULL_VERSION_STRING
16 return LLDB_FULL_VERSION_STRING;
17#else
18 return "lldb version " LLDB_VERSION_STRING;
19#endif
20}
21
22static const char *GetLLDBRevision() {
23#ifdef LLDB_REVISION
24 return LLDB_REVISION;
25#else
26 return nullptr;
27#endif
28}
29
30static const char *GetLLDBRepository() {
31#ifdef LLDB_REPOSITORY
32 return LLDB_REPOSITORY;
33#else
34 return nullptr;
35#endif
36}
37
39 static std::string g_version_str;
40
41 if (g_version_str.empty()) {
42 const char *lldb_version = GetLLDBVersion();
43 const char *lldb_repo = GetLLDBRepository();
44 const char *lldb_rev = GetLLDBRevision();
45 g_version_str += lldb_version;
46 if (lldb_repo || lldb_rev) {
47 g_version_str += " (";
48 if (lldb_repo)
49 g_version_str += lldb_repo;
50 if (lldb_repo && lldb_rev)
51 g_version_str += " ";
52 if (lldb_rev) {
53 g_version_str += "revision ";
54 g_version_str += lldb_rev;
55 }
56 g_version_str += ")";
57 }
58
59 std::string clang_rev(clang::getClangRevision());
60 if (clang_rev.length() > 0) {
61 g_version_str += "\n clang revision ";
62 g_version_str += clang_rev;
63 }
64
65 std::string llvm_rev(clang::getLLVMRevision());
66 if (llvm_rev.length() > 0) {
67 g_version_str += "\n llvm revision ";
68 g_version_str += llvm_rev;
69 }
70 }
71
72 return g_version_str.c_str();
73}
static const char * GetLLDBVersion()
Definition: Version.cpp:14
static const char * GetLLDBRepository()
Definition: Version.cpp:30
static const char * GetLLDBRevision()
Definition: Version.cpp:22
const char * GetVersion()
Retrieves a string representing the complete LLDB version, which includes the lldb version number,...
Definition: Version.cpp:38