diff options
author | Andrew Trick <atrick@apple.com> | 2012-03-07 00:44:24 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-03-07 00:44:24 +0000 |
commit | 9179e8a4a37306291bf5a9c0ed7285dde4fa9de8 (patch) | |
tree | c6bf75db31ed5db0a58372e972980eb7bae7a333 /clang/lib/Basic/Version.cpp | |
parent | e86f8f4df9336ca29c3c4e351031c9cdb8fb3725 (diff) | |
download | llvm-9179e8a4a37306291bf5a9c0ed7285dde4fa9de8.zip llvm-9179e8a4a37306291bf5a9c0ed7285dde4fa9de8.tar.gz llvm-9179e8a4a37306291bf5a9c0ed7285dde4fa9de8.tar.bz2 |
More git-svn compatible version string, by request.
If you're using git-svn, the clang and llvm repository will typically
map to a different revision.
Before we had:
clang version 3.1 (trunk 152167 trunk 152162)
After this change:
clang version 3.1 (trunk 152167) (llvm/trunk 152162)
So it's self-descriptive with an extra parens group. Which is more
compatible with version string parsers is probably debatable, but this
style was requested.
llvm-svn: 152183
Diffstat (limited to 'clang/lib/Basic/Version.cpp')
-rw-r--r-- | clang/lib/Basic/Version.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp index 2934822..2183be4 100644 --- a/clang/lib/Basic/Version.cpp +++ b/clang/lib/Basic/Version.cpp @@ -58,9 +58,11 @@ std::string getLLVMRepositoryPath() { #endif // Trim path prefix off, assuming path came from standard llvm path. + // Leave "llvm/" prefix to distinguish the following llvm revision from the + // clang revision. size_t Start = URL.find("llvm/"); if (Start != StringRef::npos) - URL = URL.substr(Start + 5); + URL = URL.substr(Start); return URL; } @@ -86,20 +88,25 @@ std::string getClangFullRepositoryVersion() { llvm::raw_string_ostream OS(buf); std::string Path = getClangRepositoryPath(); std::string Revision = getClangRevision(); - if (!Path.empty()) - OS << Path; - if (!Revision.empty()) { + if (!Path.empty() || !Revision.empty()) { + OS << '('; if (!Path.empty()) - OS << ' '; - OS << Revision; - } + OS << Path; + if (!Revision.empty()) { + if (!Path.empty()) + OS << ' '; + OS << Revision; + } + OS << ')'; + } // Support LLVM in a separate repository. std::string LLVMRev = getLLVMRevision(); if (!LLVMRev.empty() && LLVMRev != Revision) { + OS << " ("; std::string LLVMRepo = getLLVMRepositoryPath(); if (!LLVMRepo.empty()) - OS << ' ' << LLVMRepo; - OS << ' ' << LLVMRev; + OS << LLVMRepo << ' '; + OS << LLVMRev << ')'; } return OS.str(); } @@ -110,8 +117,8 @@ std::string getClangFullVersion() { #ifdef CLANG_VENDOR OS << CLANG_VENDOR; #endif - OS << "clang version " CLANG_VERSION_STRING " (" - << getClangFullRepositoryVersion() << ')'; + OS << "clang version " CLANG_VERSION_STRING " " + << getClangFullRepositoryVersion(); // If vendor supplied, include the base LLVM version as well. #ifdef CLANG_VENDOR |