Add 'clang_getClangVersion()' function to CIndex.  This exposes the full Clang version string through the CIndex API.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94242 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 68028de..2a9dd0f 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -1238,6 +1238,19 @@
  * @}
  */
   
+  
+/**
+ * \defgroup CINDEX_MISC Miscellaneous utility functions
+ *
+ * @{
+ */
+  
+CINDEX_LINKAGE const char *clang_getClangVersion();
+
+/**
+ * @}
+ */
+    
 /**
  * @}
  */
diff --git a/include/clang/Basic/Version.h b/include/clang/Basic/Version.h
index b9441f6..7e856e9 100644
--- a/include/clang/Basic/Version.h
+++ b/include/clang/Basic/Version.h
@@ -65,7 +65,7 @@
   /// \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();
+  const char *getClangFullVendorVersion();
 }
 
 #endif // LLVM_CLANG_BASIC_VERSION_H
diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp
index 76d5cf2..0521ab4 100644
--- a/lib/Basic/Version.cpp
+++ b/lib/Basic/Version.cpp
@@ -71,7 +71,7 @@
   return buf;
 }
   
-llvm::StringRef getClangFullVendorVersion() {
+const char *getClangFullVendorVersion() {
   static std::string buf;
   if (buf.empty()) {
     llvm::raw_string_ostream OS(buf);
@@ -81,7 +81,7 @@
     OS << "clang version " CLANG_VERSION_STRING " ("
        << getClangFullRepositoryVersion() << ')';
   }
-  return buf;
+  return buf.c_str();
 }
   
 } // end namespace clang
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index 8ce3db6..ddbdf53 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -15,6 +15,7 @@
 #include "CIndexer.h"
 #include "CXCursor.h"
 
+#include "clang/Basic/Version.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TypeLocVisitor.h"
@@ -1791,4 +1792,18 @@
   if (string.MustFreeString && string.Spelling)
     free((void*)string.Spelling);
 }
+
 } // end: extern "C"
+
+//===----------------------------------------------------------------------===//
+// Misc. utility functions.
+//===----------------------------------------------------------------------===//
+  
+extern "C" {
+
+const char *clang_getClangVersion() {
+  return getClangFullVendorVersion();
+}
+
+} // end: extern "C"
+
diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports
index ebeab8e..d349086 100644
--- a/tools/CIndex/CIndex.exports
+++ b/tools/CIndex/CIndex.exports
@@ -8,6 +8,7 @@
 _clang_disposeTranslationUnit
 _clang_equalCursors
 _clang_equalLocations
+_clang_getClangVersion
 _clang_getCString
 _clang_getCompletionChunkCompletionString
 _clang_getCompletionChunkKind