diff options
-rw-r--r-- | include/clang/Basic/Version.h | 5 | ||||
-rw-r--r-- | lib/Basic/Makefile | 3 | ||||
-rw-r--r-- | lib/Basic/Version.cpp | 25 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 8 | ||||
-rw-r--r-- | lib/Driver/Makefile | 3 |
5 files changed, 28 insertions, 16 deletions
diff --git a/include/clang/Basic/Version.h b/include/clang/Basic/Version.h index fe35e24d31..b9441f6e85 100644 --- a/include/clang/Basic/Version.h +++ b/include/clang/Basic/Version.h @@ -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 diff --git a/lib/Basic/Makefile b/lib/Basic/Makefile index dc00450bdf..f733578938 100644 --- a/lib/Basic/Makefile +++ b/lib/Basic/Makefile @@ -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 diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp index ca65130ffc..76d5cf244c 100644 --- a/lib/Basic/Version.cpp +++ b/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 @@ 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; } diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 298e173e38..46e7f10e85 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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'; diff --git a/lib/Driver/Makefile b/lib/Driver/Makefile index 4c3ca5ca84..dbacf8be01 100644 --- a/lib/Driver/Makefile +++ b/lib/Driver/Makefile @@ -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 |