diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-22 22:12:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-22 22:12:47 +0000 |
commit | f7a96a39958b3f919f26764777eec948b43d74bc (patch) | |
tree | ba5b7f7dfe1695d6fb5496095a0a2a1f06be96f9 /lib/Basic/Version.cpp | |
parent | e07b6e58d3a23803f537ba861298475c1eb65eab (diff) |
(1) Rename getClangSubversionRevision() to getClangRevision(), and
have it return a StringRef instead of an integer (to be more VCS
agnostic).
(2) Add getClangFullRepositoryVersion(), which contains an
amalgamation of the repository name and the revision.
(3) Change PCH to only emit the string returned by
getClangFullRepositoryVersion() instead of also emitting the value
of getClangSubversionRevision() (which has been removed). This is
functionally equivalent.
More cleanup to version string generation pending...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Version.cpp')
-rw-r--r-- | lib/Basic/Version.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp index 0751cfcf5d..ca65130ffc 100644 --- a/lib/Basic/Version.cpp +++ b/lib/Basic/Version.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" #include <cstring> #include <cstdlib> @@ -44,13 +45,30 @@ llvm::StringRef getClangRepositoryPath() { } -unsigned getClangSubversionRevision() { +llvm::StringRef getClangRevision() { #ifndef SVN_REVISION // Subversion was not available at build time? - return 0; + return llvm::StringRef(); #else - return strtol(SVN_REVISION, 0, 10); + static std::string revision; + if (revision.empty()) { + llvm::raw_string_ostream Out(revision); + Out << strtol(SVN_REVISION, 0, 10); + } + return revision; #endif } +llvm::StringRef getClangFullRepositoryVersion() { + static std::string buf; + if (buf.empty()) { + llvm::raw_string_ostream Out(buf); + Out << getClangRepositoryPath(); + llvm::StringRef Revision = getClangRevision(); + if (!Revision.empty()) + Out << ' ' << Revision; + } + return buf; +} + } // end namespace clang |