Move version string generation (e.g., "clang 1.1 ...") to libBasic/Version.cpp, getClangFullVendorVersion().
llvm-svn: 94235
diff --git a/clang/include/clang/Basic/Version.h b/clang/include/clang/Basic/Version.h
index fe35e24..b9441f6 100644
--- a/clang/include/clang/Basic/Version.h
+++ b/clang/include/clang/Basic/Version.h
@@ -61,6 +61,11 @@
/// \brief Retrieves the full repository version that is an amalgamation of
/// the information in getClangRepositoryPath() and getClangRevision().
llvm::StringRef getClangFullRepositoryVersion();
+
+ /// \brief Retrieves a string representing the complete clang version,
+ /// which includes the clang version number, the repository version,
+ /// and the vendor tag.
+ llvm::StringRef getClangFullVendorVersion();
}
#endif // LLVM_CLANG_BASIC_VERSION_H
diff --git a/clang/lib/Basic/Makefile b/clang/lib/Basic/Makefile
index dc00450..f733578 100644
--- a/clang/lib/Basic/Makefile
+++ b/clang/lib/Basic/Makefile
@@ -17,6 +17,9 @@
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
+ifdef CLANG_VENDOR
+CPPFLAGS += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
+endif
include $(LEVEL)/Makefile.common
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index ca65130..76d5cf2 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/StringRef.h"
+#include "clang/Basic/Version.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <cstdlib>
@@ -52,8 +52,8 @@
#else
static std::string revision;
if (revision.empty()) {
- llvm::raw_string_ostream Out(revision);
- Out << strtol(SVN_REVISION, 0, 10);
+ llvm::raw_string_ostream OS(revision);
+ OS << strtol(SVN_REVISION, 0, 10);
}
return revision;
#endif
@@ -62,11 +62,24 @@
llvm::StringRef getClangFullRepositoryVersion() {
static std::string buf;
if (buf.empty()) {
- llvm::raw_string_ostream Out(buf);
- Out << getClangRepositoryPath();
+ llvm::raw_string_ostream OS(buf);
+ OS << getClangRepositoryPath();
llvm::StringRef Revision = getClangRevision();
if (!Revision.empty())
- Out << ' ' << Revision;
+ OS << ' ' << Revision;
+ }
+ return buf;
+}
+
+llvm::StringRef getClangFullVendorVersion() {
+ static std::string buf;
+ if (buf.empty()) {
+ llvm::raw_string_ostream OS(buf);
+#ifdef CLANG_VENDOR
+ OS << CLANG_VENDOR;
+#endif
+ OS << "clang version " CLANG_VERSION_STRING " ("
+ << getClangFullRepositoryVersion() << ')';
}
return buf;
}
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 298e173..46e7f10 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -282,13 +282,7 @@
void Driver::PrintVersion(const Compilation &C, llvm::raw_ostream &OS) const {
// FIXME: The following handlers should use a callback mechanism, we don't
// know what the client would like to do.
-#ifdef CLANG_VENDOR
- OS << CLANG_VENDOR;
-#endif
- OS << "clang version " CLANG_VERSION_STRING " ("
- << getClangFullRepositoryVersion();
- OS << ")" << '\n';
-
+ OS << getClangFullVendorVersion() << '\n';
const ToolChain &TC = C.getDefaultToolChain();
OS << "Target: " << TC.getTripleString() << '\n';
diff --git a/clang/lib/Driver/Makefile b/clang/lib/Driver/Makefile
index 4c3ca5c..dbacf8b 100644
--- a/clang/lib/Driver/Makefile
+++ b/clang/lib/Driver/Makefile
@@ -13,8 +13,5 @@
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
-ifdef CLANG_VENDOR
-CPPFLAGS += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
-endif
include $(LEVEL)/Makefile.common