Coverage Report

Created: 2021-12-07 08:24

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/lldb.cpp
Line
Count
Source (jump to first uncovered line)
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 "VCSVersion.inc"
10
#include "lldb/lldb-private.h"
11
#include "clang/Basic/Version.h"
12
13
using namespace lldb;
14
using namespace lldb_private;
15
16
// LLDB_VERSION_STRING is set through a define so unlike the other defines
17
// expanded with CMake, it lacks the double quotes.
18
#define QUOTE(str) #str
19
#define EXPAND_AND_QUOTE(str) QUOTE(str)
20
21
1.04k
static const char *GetLLDBVersion() {
22
#ifdef LLDB_VERSION_STRING
23
  return EXPAND_AND_QUOTE(LLDB_VERSION_STRING);
24
#else
25
1.04k
  return "lldb version " CLANG_VERSION_STRING;
26
1.04k
#endif
27
1.04k
}
28
29
1.04k
static const char *GetLLDBRevision() {
30
1.04k
#ifdef LLDB_REVISION
31
1.04k
  return LLDB_REVISION;
32
#else
33
  return NULL;
34
#endif
35
1.04k
}
36
37
1.04k
static const char *GetLLDBRepository() {
38
1.04k
#ifdef LLDB_REPOSITORY
39
1.04k
  return LLDB_REPOSITORY;
40
#else
41
  return NULL;
42
#endif
43
1.04k
}
44
45
1.04k
const char *lldb_private::GetVersion() {
46
1.04k
  static std::string g_version_str;
47
1.04k
  if (g_version_str.empty()) {
48
1.04k
    const char *lldb_version = GetLLDBVersion();
49
1.04k
    const char *lldb_repo = GetLLDBRepository();
50
1.04k
    const char *lldb_rev = GetLLDBRevision();
51
1.04k
    g_version_str += lldb_version;
52
1.04k
    if (lldb_repo || 
lldb_rev0
) {
53
1.04k
      g_version_str += " (";
54
1.04k
      if (lldb_repo)
55
1.04k
        g_version_str += lldb_repo;
56
1.04k
      if (lldb_repo && lldb_rev)
57
1.04k
        g_version_str += " ";
58
1.04k
      if (lldb_rev) {
59
1.04k
        g_version_str += "revision ";
60
1.04k
        g_version_str += lldb_rev;
61
1.04k
      }
62
1.04k
      g_version_str += ")";
63
1.04k
    }
64
65
1.04k
    std::string clang_rev(clang::getClangRevision());
66
1.04k
    if (clang_rev.length() > 0) {
67
1.04k
      g_version_str += "\n  clang revision ";
68
1.04k
      g_version_str += clang_rev;
69
1.04k
    }
70
1.04k
    std::string llvm_rev(clang::getLLVMRevision());
71
1.04k
    if (llvm_rev.length() > 0) {
72
1.04k
      g_version_str += "\n  llvm revision ";
73
1.04k
      g_version_str += llvm_rev;
74
1.04k
    }
75
1.04k
  }
76
1.04k
  return g_version_str.c_str();
77
1.04k
}