Skip to content

Commit 9179e8a

Browse files
committed
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
1 parent e86f8f4 commit 9179e8a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

clang/lib/Basic/Version.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ std::string getLLVMRepositoryPath() {
5858
#endif
5959

6060
// Trim path prefix off, assuming path came from standard llvm path.
61+
// Leave "llvm/" prefix to distinguish the following llvm revision from the
62+
// clang revision.
6163
size_t Start = URL.find("llvm/");
6264
if (Start != StringRef::npos)
63-
URL = URL.substr(Start + 5);
65+
URL = URL.substr(Start);
6466

6567
return URL;
6668
}
@@ -86,20 +88,25 @@ std::string getClangFullRepositoryVersion() {
8688
llvm::raw_string_ostream OS(buf);
8789
std::string Path = getClangRepositoryPath();
8890
std::string Revision = getClangRevision();
89-
if (!Path.empty())
90-
OS << Path;
91-
if (!Revision.empty()) {
91+
if (!Path.empty() || !Revision.empty()) {
92+
OS << '(';
9293
if (!Path.empty())
93-
OS << ' ';
94-
OS << Revision;
95-
}
94+
OS << Path;
95+
if (!Revision.empty()) {
96+
if (!Path.empty())
97+
OS << ' ';
98+
OS << Revision;
99+
}
100+
OS << ')';
101+
}
96102
// Support LLVM in a separate repository.
97103
std::string LLVMRev = getLLVMRevision();
98104
if (!LLVMRev.empty() && LLVMRev != Revision) {
105+
OS << " (";
99106
std::string LLVMRepo = getLLVMRepositoryPath();
100107
if (!LLVMRepo.empty())
101-
OS << ' ' << LLVMRepo;
102-
OS << ' ' << LLVMRev;
108+
OS << LLVMRepo << ' ';
109+
OS << LLVMRev << ')';
103110
}
104111
return OS.str();
105112
}
@@ -110,8 +117,8 @@ std::string getClangFullVersion() {
110117
#ifdef CLANG_VENDOR
111118
OS << CLANG_VENDOR;
112119
#endif
113-
OS << "clang version " CLANG_VERSION_STRING " ("
114-
<< getClangFullRepositoryVersion() << ')';
120+
OS << "clang version " CLANG_VERSION_STRING " "
121+
<< getClangFullRepositoryVersion();
115122

116123
// If vendor supplied, include the base LLVM version as well.
117124
#ifdef CLANG_VENDOR

0 commit comments

Comments
 (0)