aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-22 22:44:15 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-22 22:44:15 +0000
commit04bb716aea8fd2372ac10b0c640cabc5e5caa615 (patch)
tree2d0d7c430a386f7d9183ed1e0d7e25e5fded352b
parentf9d3e9bb0052d2605d6b33d7de356d534457c9ac (diff)
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
-rw-r--r--include/clang-c/Index.h13
-rw-r--r--include/clang/Basic/Version.h2
-rw-r--r--lib/Basic/Version.cpp4
-rw-r--r--tools/CIndex/CIndex.cpp15
-rw-r--r--tools/CIndex/CIndex.exports1
5 files changed, 32 insertions, 3 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 68028de7e7..2a9dd0f5a1 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -1238,6 +1238,19 @@ void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
* @}
*/
+
+/**
+ * \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 b9441f6e85..7e856e9a99 100644
--- a/include/clang/Basic/Version.h
+++ b/include/clang/Basic/Version.h
@@ -65,7 +65,7 @@ namespace clang {
/// \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 76d5cf244c..0521ab4889 100644
--- a/lib/Basic/Version.cpp
+++ b/lib/Basic/Version.cpp
@@ -71,7 +71,7 @@ llvm::StringRef getClangFullRepositoryVersion() {
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 @@ llvm::StringRef getClangFullVendorVersion() {
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 8ce3db63d5..ddbdf531d0 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 @@ void clang_disposeString(CXString string) {
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 ebeab8ec2d..d349086b9c 100644
--- a/tools/CIndex/CIndex.exports
+++ b/tools/CIndex/CIndex.exports
@@ -8,6 +8,7 @@ _clang_disposeString
_clang_disposeTranslationUnit
_clang_equalCursors
_clang_equalLocations
+_clang_getClangVersion
_clang_getCString
_clang_getCompletionChunkCompletionString
_clang_getCompletionChunkKind