[llvm-branch-commits] [cfe-tag] r96042 - in /cfe/tags/cremebrulee/cremebrulee-36.4: include/clang-c/Index.h include/clang/Basic/Version.h lib/Basic/Version.cpp lib/Frontend/PCHReader.cpp

Ted Kremenek kremenek at apple.com
Fri Feb 12 15:37:50 PST 2010


Author: kremenek
Date: Fri Feb 12 17:37:49 2010
New Revision: 96042

URL: http://llvm.org/viewvc/llvm-project?rev=96042&view=rev
Log:
Merge in r96041 and r96033.

Modified:
    cfe/tags/cremebrulee/cremebrulee-36.4/include/clang-c/Index.h
    cfe/tags/cremebrulee/cremebrulee-36.4/include/clang/Basic/Version.h
    cfe/tags/cremebrulee/cremebrulee-36.4/lib/Basic/Version.cpp
    cfe/tags/cremebrulee/cremebrulee-36.4/lib/Frontend/PCHReader.cpp

Modified: cfe/tags/cremebrulee/cremebrulee-36.4/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/cremebrulee/cremebrulee-36.4/include/clang-c/Index.h?rev=96042&r1=96041&r2=96042&view=diff

==============================================================================
--- cfe/tags/cremebrulee/cremebrulee-36.4/include/clang-c/Index.h (original)
+++ cfe/tags/cremebrulee/cremebrulee-36.4/include/clang-c/Index.h Fri Feb 12 17:37:49 2010
@@ -1260,7 +1260,7 @@
  * \brief Return a version string, suitable for showing to a user, but not
  *        intended to be parsed (the format is not guaranteed to be stable).
  */
-CINDEX_LINKAGE const char *clang_getClangVersion();
+CINDEX_LINKAGE CXString clang_getClangVersion();
 
 /**
  * @}

Modified: cfe/tags/cremebrulee/cremebrulee-36.4/include/clang/Basic/Version.h
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/cremebrulee/cremebrulee-36.4/include/clang/Basic/Version.h?rev=96042&r1=96041&r2=96042&view=diff

==============================================================================
--- cfe/tags/cremebrulee/cremebrulee-36.4/include/clang/Basic/Version.h (original)
+++ cfe/tags/cremebrulee/cremebrulee-36.4/include/clang/Basic/Version.h Fri Feb 12 17:37:49 2010
@@ -56,16 +56,16 @@
   
   /// \brief Retrieves the repository revision number (or identifer) from which
   ///  this Clang was built.
-  llvm::StringRef getClangRevision();
+  std::string getClangRevision();
   
   /// \brief Retrieves the full repository version that is an amalgamation of
   ///  the information in getClangRepositoryPath() and getClangRevision().
-  llvm::StringRef getClangFullRepositoryVersion();
+  std::string getClangFullRepositoryVersion();
   
   /// \brief Retrieves a string representing the complete clang version,
   ///   which includes the clang version number, the repository version, 
   ///   and the vendor tag.
-  const char *getClangFullVersion();
+  std::string getClangFullVersion();
 }
 
 #endif // LLVM_CLANG_BASIC_VERSION_H

Modified: cfe/tags/cremebrulee/cremebrulee-36.4/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/cremebrulee/cremebrulee-36.4/lib/Basic/Version.cpp?rev=96042&r1=96041&r2=96042&view=diff

==============================================================================
--- cfe/tags/cremebrulee/cremebrulee-36.4/lib/Basic/Version.cpp (original)
+++ cfe/tags/cremebrulee/cremebrulee-36.4/lib/Basic/Version.cpp Fri Feb 12 17:37:49 2010
@@ -21,67 +21,55 @@
 namespace clang {
   
 llvm::StringRef getClangRepositoryPath() {
-  static const char *Path = 0;
-  if (Path)
-    return Path;
-  
-  static char URL[] = "$URL$";
-  char *End = strstr(URL, "/lib/Basic");
+  static const char URL[] = "$URL$";
+  const char *URLEnd = URL + strlen(URL);
+
+  const char *End = strstr(URL, "/lib/Basic");
   if (End)
-    *End = 0;
-  
+    URLEnd = End;
+
   End = strstr(URL, "/clang/tools/clang");
   if (End)
-    *End = 0;
-  
-  char *Begin = strstr(URL, "cfe/");
-  if (Begin) {
-    Path = Begin + 4;
-    return Path;
-  }
-  
-  Path = URL;
-  return Path;
-}
+    URLEnd = End;
+
+  const char *Begin = strstr(URL, "cfe/");
+  if (Begin)
+    return llvm::StringRef(Begin + 4, URLEnd - Begin - 4);
 
+  return llvm::StringRef(URL, URLEnd - URL);
+}
 
-llvm::StringRef getClangRevision() {
+std::string getClangRevision() {
 #ifndef SVN_REVISION
   // Subversion was not available at build time?
-  return llvm::StringRef();
+  return "";
 #else
-  static std::string revision;
-  if (revision.empty()) {
-    llvm::raw_string_ostream OS(revision);
-    OS << strtol(SVN_REVISION, 0, 10);
-  }
+  std::string revision;
+  llvm::raw_string_ostream OS(revision);
+  OS << strtol(SVN_REVISION, 0, 10);
   return revision;
 #endif
 }
 
-llvm::StringRef getClangFullRepositoryVersion() {
-  static std::string buf;
-  if (buf.empty()) {
-    llvm::raw_string_ostream OS(buf);
-    OS << getClangRepositoryPath();
-    llvm::StringRef Revision = getClangRevision();
-    if (!Revision.empty())
-      OS << ' ' << Revision;
-  }
+std::string getClangFullRepositoryVersion() {
+  std::string buf;
+  llvm::raw_string_ostream OS(buf);
+  OS << getClangRepositoryPath();
+  const std::string &Revision = getClangRevision();
+  if (!Revision.empty())
+    OS << ' ' << Revision;
   return buf;
 }
   
-const char *getClangFullVersion() {
-  static std::string buf;
-  if (buf.empty()) {
-    llvm::raw_string_ostream OS(buf);
+std::string getClangFullVersion() {
+  std::string buf;
+  llvm::raw_string_ostream OS(buf);
 #ifdef CLANG_VENDOR
-    OS << CLANG_VENDOR;
+  OS << CLANG_VENDOR;
 #endif
-    OS << "clang version " CLANG_VERSION_STRING " ("
-       << getClangFullRepositoryVersion() << ')';
-  }
-  return buf.c_str();
+  OS << "clang version " CLANG_VERSION_STRING " ("
+     << getClangFullRepositoryVersion() << ')';
+  return buf;
 }
-  
+
 } // end namespace clang

Modified: cfe/tags/cremebrulee/cremebrulee-36.4/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/cremebrulee/cremebrulee-36.4/lib/Frontend/PCHReader.cpp?rev=96042&r1=96041&r2=96042&view=diff

==============================================================================
--- cfe/tags/cremebrulee/cremebrulee-36.4/lib/Frontend/PCHReader.cpp (original)
+++ cfe/tags/cremebrulee/cremebrulee-36.4/lib/Frontend/PCHReader.cpp Fri Feb 12 17:37:49 2010
@@ -1404,9 +1404,9 @@
       break;
         
     case pch::VERSION_CONTROL_BRANCH_REVISION: {
-      llvm::StringRef CurBranch = getClangFullRepositoryVersion();
+      const std::string &CurBranch = getClangFullRepositoryVersion();
       llvm::StringRef PCHBranch(BlobStart, BlobLen);
-      if (CurBranch != PCHBranch) {
+      if (llvm::StringRef(CurBranch) != PCHBranch) {
         Diag(diag::warn_pch_different_branch) << PCHBranch << CurBranch;
         return IgnorePCH;
       }





More information about the llvm-branch-commits mailing list