[cfe-commits] r94235 - in /cfe/trunk: include/clang/Basic/Version.h lib/Basic/Makefile lib/Basic/Version.cpp lib/Driver/Driver.cpp lib/Driver/Makefile

Ted Kremenek kremenek at apple.com
Fri Jan 22 14:29:50 PST 2010


Author: kremenek
Date: Fri Jan 22 16:29:50 2010
New Revision: 94235

URL: http://llvm.org/viewvc/llvm-project?rev=94235&view=rev
Log:
Move version string generation (e.g., "clang 1.1 ...") to libBasic/Version.cpp, getClangFullVendorVersion().

Modified:
    cfe/trunk/include/clang/Basic/Version.h
    cfe/trunk/lib/Basic/Makefile
    cfe/trunk/lib/Basic/Version.cpp
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/Makefile

Modified: cfe/trunk/include/clang/Basic/Version.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.h?rev=94235&r1=94234&r2=94235&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/Version.h (original)
+++ cfe/trunk/include/clang/Basic/Version.h Fri Jan 22 16:29:50 2010
@@ -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

Modified: cfe/trunk/lib/Basic/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Makefile?rev=94235&r1=94234&r2=94235&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Makefile (original)
+++ cfe/trunk/lib/Basic/Makefile Fri Jan 22 16:29:50 2010
@@ -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
 

Modified: cfe/trunk/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=94235&r1=94234&r2=94235&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Fri Jan 22 16:29:50 2010
@@ -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;
 }

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=94235&r1=94234&r2=94235&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 22 16:29:50 2010
@@ -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';
 

Modified: cfe/trunk/lib/Driver/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Makefile?rev=94235&r1=94234&r2=94235&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Makefile (original)
+++ cfe/trunk/lib/Driver/Makefile Fri Jan 22 16:29:50 2010
@@ -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





More information about the cfe-commits mailing list