1 //===- Version.cpp - Clang Version Number -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines several version-related utility functions for Clang.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Basic/Version.h"
15 #include "llvm/Support/raw_ostream.h"
23 llvm::StringRef getClangRepositoryPath() {
24 static const char URL[] = "$URL: http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_28/lib/Basic/Version.cpp $";
25 const char *URLEnd = URL + strlen(URL);
27 const char *End = strstr(URL, "/lib/Basic");
31 // Strip off version from a build from an integration branch.
32 End = strstr(URL, "/src/tools/clang");
36 const char *Begin = strstr(URL, "cfe/");
38 return llvm::StringRef(Begin + 4, URLEnd - Begin - 4);
40 return llvm::StringRef(URL, URLEnd - URL);
43 std::string getClangRevision() {
45 if (SVN_REVISION[0] != '\0') {
47 llvm::raw_string_ostream OS(revision);
48 OS << strtol(SVN_REVISION, 0, 10);
55 std::string getClangFullRepositoryVersion() {
57 llvm::raw_string_ostream OS(buf);
58 OS << getClangRepositoryPath();
59 const std::string &Revision = getClangRevision();
60 if (!Revision.empty())
61 OS << ' ' << Revision;
65 std::string getClangFullVersion() {
67 llvm::raw_string_ostream OS(buf);
71 OS << "clang version " CLANG_VERSION_STRING " ("
72 << getClangFullRepositoryVersion() << ')';
73 #ifdef CLANG_VENDOR_SUFFIX
74 OS << CLANG_VENDOR_SUFFIX;
79 } // end namespace clang