1 //===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
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/lldb-private.h"
12 using namespace lldb_private
;
14 #include "clang/Basic/Version.h"
16 #ifdef HAVE_VCS_VERSION_INC
17 #include "VCSVersion.inc"
20 static const char *GetLLDBRevision() {
28 static const char *GetLLDBRepository() {
29 #ifdef LLDB_REPOSITORY
30 return LLDB_REPOSITORY
;
36 #define QUOTE(str) #str
37 #define EXPAND_AND_QUOTE(str) QUOTE(str)
39 const char *lldb_private::GetVersion() {
40 // On platforms other than Darwin, report a version number in the same style
42 static std::string g_version_str
;
43 if (g_version_str
.empty()) {
44 g_version_str
+= "lldb version ";
45 g_version_str
+= CLANG_VERSION_STRING
;
47 const char *lldb_repo
= GetLLDBRepository();
48 const char *lldb_rev
= GetLLDBRevision();
49 if (lldb_repo
|| lldb_rev
) {
50 g_version_str
+= " (";
52 g_version_str
+= lldb_repo
;
54 g_version_str
+= " revision ";
55 g_version_str
+= lldb_rev
;
60 std::string
clang_rev(clang::getClangRevision());
61 if (clang_rev
.length() > 0) {
62 g_version_str
+= "\n clang revision ";
63 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
;
71 return g_version_str
.c_str();