diff options
Diffstat (limited to 'lib/Config/Version.cpp')
-rw-r--r-- | lib/Config/Version.cpp | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/lib/Config/Version.cpp b/lib/Config/Version.cpp index 60687b9d8940e..25544756f8be5 100644 --- a/lib/Config/Version.cpp +++ b/lib/Config/Version.cpp @@ -12,46 +12,32 @@ //===----------------------------------------------------------------------===// #include "lld/Config/Version.h" -#include "llvm/Support/raw_ostream.h" using namespace llvm; -namespace lld { - -StringRef getLLDRepositoryPath() { -#ifdef LLD_REPOSITORY_STRING - return LLD_REPOSITORY_STRING; -#else - return ""; -#endif +// Returns an SVN repository path, which is usually "trunk". +static std::string getRepositoryPath() { + StringRef S = LLD_REPOSITORY_STRING; + size_t Pos = S.find("lld/"); + if (Pos != StringRef::npos) + return S.substr(Pos + 4); + return S; } -StringRef getLLDRevision() { -#ifdef LLD_REVISION_STRING - return LLD_REVISION_STRING; -#else - return ""; -#endif -} +// Returns an SVN repository name, e.g., " (trunk 284614)" +// or an empty string if no repository info is available. +static std::string getRepository() { + std::string Repo = getRepositoryPath(); + std::string Rev = LLD_REVISION_STRING; -std::string getLLDRepositoryVersion() { - std::string S = getLLDRepositoryPath(); - std::string T = getLLDRevision(); - if (S.empty() && T.empty()) + if (Repo.empty() && Rev.empty()) return ""; - if (!S.empty() && !T.empty()) - return "(" + S + " " + T + ")"; - if (!S.empty()) - return "(" + S + ")"; - return "(" + T + ")"; + if (!Repo.empty() && !Rev.empty()) + return " (" + Repo + " " + Rev + ")"; + return " (" + Repo + Rev + ")"; } -StringRef getLLDVersion() { -#ifdef LLD_VERSION_STRING - return LLD_VERSION_STRING; -#else - return ""; -#endif +// Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)". +std::string lld::getLLDVersion() { + return "LLD " + std::string(LLD_VERSION_STRING) + getRepository(); } - -} // end namespace lld |