summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Version.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-22 22:12:47 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-22 22:12:47 +0000
commit18e066f6a9b1109cb0d3738cd0e570f79ce896ac (patch)
tree0bb879757d8367483d453540094a37b7ce915f0b /clang/lib/Basic/Version.cpp
parentf5c834fce159386feb5cfa2f2758975fa1f7e6e8 (diff)
downloadbcm5719-llvm-18e066f6a9b1109cb0d3738cd0e570f79ce896ac.tar.gz
bcm5719-llvm-18e066f6a9b1109cb0d3738cd0e570f79ce896ac.zip
(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... llvm-svn: 94231
Diffstat (limited to 'clang/lib/Basic/Version.cpp')
-rw-r--r--clang/lib/Basic/Version.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index 0751cfcf5d4..ca65130ffc8 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud