brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · b391fe1 Raw
74 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Version/Version.h"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_STRING16  return LLDB_FULL_VERSION_STRING;17#else18  return "lldb version " LLDB_VERSION_STRING;19#endif20}21 22static const char *GetLLDBRevision() {23#ifdef LLDB_REVISION24  return LLDB_REVISION;25#else26  return nullptr;27#endif28}29 30static const char *GetLLDBRepository() {31#ifdef LLDB_REPOSITORY32  return LLDB_REPOSITORY;33#else34  return nullptr;35#endif36}37 38const char *lldb_private::GetVersion() {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}74