* \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();
/**
* \brief Return a version string, suitable for showing to a user, but not
/// \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
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();
+ llvm::StringRef 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