]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/source/lldb.cpp
Update to bmake-20200902
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / source / lldb.cpp
1 //===-- lldb.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
9 #include "lldb/lldb-private.h"
10
11 using namespace lldb;
12 using namespace lldb_private;
13
14 #include "clang/Basic/Version.h"
15
16 #ifdef HAVE_VCS_VERSION_INC
17 #include "VCSVersion.inc"
18 #endif
19
20 static const char *GetLLDBRevision() {
21 #ifdef LLDB_REVISION
22   return LLDB_REVISION;
23 #else
24   return NULL;
25 #endif
26 }
27
28 static const char *GetLLDBRepository() {
29 #ifdef LLDB_REPOSITORY
30   return LLDB_REPOSITORY;
31 #else
32   return NULL;
33 #endif
34 }
35
36 #define QUOTE(str) #str
37 #define EXPAND_AND_QUOTE(str) QUOTE(str)
38
39 const char *lldb_private::GetVersion() {
40   // On platforms other than Darwin, report a version number in the same style
41   // as the clang tool.
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;
46
47     const char *lldb_repo = GetLLDBRepository();
48     const char *lldb_rev = GetLLDBRevision();
49     if (lldb_repo || lldb_rev) {
50       g_version_str += " (";
51       if (lldb_repo)
52         g_version_str += lldb_repo;
53       if (lldb_repo && lldb_rev)
54         g_version_str += " ";
55       if (lldb_rev) {
56         g_version_str += "revision ";
57         g_version_str += lldb_rev;
58       }
59       g_version_str += ")";
60     }
61
62     std::string clang_rev(clang::getClangRevision());
63     if (clang_rev.length() > 0) {
64       g_version_str += "\n  clang revision ";
65       g_version_str += clang_rev;
66     }
67     std::string llvm_rev(clang::getLLVMRevision());
68     if (llvm_rev.length() > 0) {
69       g_version_str += "\n  llvm revision ";
70       g_version_str += llvm_rev;
71     }
72   }
73   return g_version_str.c_str();
74 }