1 //===-- Version.cpp -------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Version/Version.h"
10 #include "VCSVersion.inc"
11 #include "lldb/Version/Version.inc"
12 #include "clang/Basic/Version.h"
14 static const char *GetLLDBVersion() {
15 #ifdef LLDB_FULL_VERSION_STRING
16 return LLDB_FULL_VERSION_STRING
;
18 return "lldb version " LLDB_VERSION_STRING
;
22 static const char *GetLLDBRevision() {
30 static const char *GetLLDBRepository() {
31 #ifdef LLDB_REPOSITORY
32 return LLDB_REPOSITORY
;
38 const char *lldb_private::GetVersion() {
39 static std::string g_version_str
;
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
+= " (";
49 g_version_str
+= lldb_repo
;
50 if (lldb_repo
&& lldb_rev
)
53 g_version_str
+= "revision ";
54 g_version_str
+= lldb_rev
;
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
;
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
;
72 return g_version_str
.c_str();