aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/Version.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-02-20 13:06:31 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-02-20 13:06:31 +0000
commitbca07a4524feb4edec581062d631a13116320a24 (patch)
treea9243275843fbeaa590afc07ee888e006b8d54ea /lib/Basic/Version.cpp
parent998bc5802ecdd65ce3b270f6c69a8ae8557f0a10 (diff)
downloadsrc-bca07a4524feb4edec581062d631a13116320a24.tar.gz
src-bca07a4524feb4edec581062d631a13116320a24.zip
Vendor import of clang trunk r126079:vendor/clang/clang-r126079
Notes
Notes: svn path=/vendor/clang/dist/; revision=218887 svn path=/vendor/clang/clang-r126079/; revision=218888; tag=vendor/clang/clang-r126079
Diffstat (limited to 'lib/Basic/Version.cpp')
-rw-r--r--lib/Basic/Version.cpp62
1 files changed, 38 insertions, 24 deletions
diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp
index 28f29541aae6..6573eb96e3f3 100644
--- a/lib/Basic/Version.cpp
+++ b/lib/Basic/Version.cpp
@@ -13,6 +13,7 @@
#include "clang/Basic/Version.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Config/config.h"
#include <cstring>
#include <cstdlib>
@@ -20,45 +21,52 @@ using namespace std;
namespace clang {
-llvm::StringRef getClangRepositoryPath() {
- static const char URL[] = "$URL: http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_28/lib/Basic/Version.cpp $";
- const char *URLEnd = URL + strlen(URL);
+std::string getClangRepositoryPath() {
+#ifdef SVN_REPOSITORY
+ llvm::StringRef URL(SVN_REPOSITORY);
+#else
+ llvm::StringRef URL("");
+#endif
- const char *End = strstr(URL, "/lib/Basic");
- if (End)
- URLEnd = End;
+ // If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us
+ // pick up a tag in an SVN export, for example.
+ static llvm::StringRef SVNRepository("$URL: http://llvm.org/svn/llvm-project/cfe/trunk/lib/Basic/Version.cpp $");
+ if (URL.empty()) {
+ URL = SVNRepository.slice(SVNRepository.find(':'),
+ SVNRepository.find("/lib/Basic"));
+ }
// Strip off version from a build from an integration branch.
- End = strstr(URL, "/src/tools/clang");
- if (End)
- URLEnd = End;
+ URL = URL.slice(0, URL.find("/src/tools/clang"));
- const char *Begin = strstr(URL, "cfe/");
- if (Begin)
- return llvm::StringRef(Begin + 4, URLEnd - Begin - 4);
+ // Trim path prefix off, assuming path came from standard cfe path.
+ size_t Start = URL.find("cfe/");
+ if (Start != llvm::StringRef::npos)
+ URL = URL.substr(Start + 4);
- return llvm::StringRef(URL, URLEnd - URL);
+ return URL;
}
std::string getClangRevision() {
#ifdef SVN_REVISION
- if (SVN_REVISION[0] != '\0') {
- std::string revision;
- llvm::raw_string_ostream OS(revision);
- OS << strtol(SVN_REVISION, 0, 10);
- return OS.str();
- }
-#endif
+ return SVN_REVISION;
+#else
return "";
+#endif
}
std::string getClangFullRepositoryVersion() {
std::string buf;
llvm::raw_string_ostream OS(buf);
- OS << getClangRepositoryPath();
- const std::string &Revision = getClangRevision();
- if (!Revision.empty())
- OS << ' ' << Revision;
+ std::string Path = getClangRepositoryPath();
+ std::string Revision = getClangRevision();
+ if (!Path.empty())
+ OS << Path;
+ if (!Revision.empty()) {
+ if (!Path.empty())
+ OS << ' ';
+ OS << Revision;
+ }
return OS.str();
}
@@ -70,6 +78,12 @@ std::string getClangFullVersion() {
#endif
OS << "clang version " CLANG_VERSION_STRING " ("
<< getClangFullRepositoryVersion() << ')';
+
+ // If vendor supplied, include the base LLVM version as well.
+#ifdef CLANG_VENDOR
+ OS << " (based on LLVM " << PACKAGE_VERSION << ")";
+#endif
+
return OS.str();
}