Move version string generation (e.g., "clang 1.1 ...") to libBasic/Version.cpp, getClangFullVendorVersion().

llvm-svn: 94235
This commit is contained in:
Ted Kremenek 2010-01-22 22:29:50 +00:00
parent 6007cf2e9e
commit 51b8bc93f8
5 changed files with 28 additions and 16 deletions

View File

@ -61,6 +61,11 @@ namespace clang {
/// \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

View File

@ -17,6 +17,9 @@ BUILD_ARCHIVE = 1
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

View File

@ -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 @@ llvm::StringRef getClangRevision() {
#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 getClangRevision() {
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;
}

View File

@ -282,13 +282,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
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';

View File

@ -13,8 +13,5 @@ BUILD_ARCHIVE = 1
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