]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/lib/Config/Version.cpp
MFV r323523: 8331 zfs_unshare returns wrong error code for smb unshare failure
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / lib / Config / Version.cpp
1 //===- lib/Config/Version.cpp - LLD Version Number ---------------*- C++-=====//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines several version-related utility functions for LLD.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "lld/Config/Version.h"
15
16 using namespace llvm;
17
18 // Returns an SVN repository path, which is usually "trunk".
19 static std::string getRepositoryPath() {
20   StringRef S = LLD_REPOSITORY_STRING;
21   size_t Pos = S.find("lld/");
22   if (Pos != StringRef::npos)
23     return S.substr(Pos + 4);
24   return S;
25 }
26
27 // Returns an SVN repository name, e.g., " (trunk 284614)"
28 // or an empty string if no repository info is available.
29 static std::string getRepository() {
30   std::string Repo = getRepositoryPath();
31   std::string Rev = LLD_REVISION_STRING;
32
33   if (Repo.empty() && Rev.empty())
34     return "";
35   if (!Repo.empty() && !Rev.empty())
36     return " (" + Repo + " " + Rev + ")";
37   return " (" + Repo + Rev + ")";
38 }
39
40 // Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)".
41 std::string lld::getLLDVersion() {
42   return "LLD " + std::string(LLD_VERSION_STRING) + getRepository();
43 }