From f7a96a39958b3f919f26764777eec948b43d74bc Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 22 Jan 2010 22:12:47 +0000 Subject: (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 --- lib/Basic/Version.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/Basic/Version.cpp') 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 #include @@ -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 -- cgit v1.2.3-70-g09d2