blob: 986f4d5690d6657c8e2315f9c191d54b89d17369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
//===- Version.cpp - Clang Version Number -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines several version-related utility functions for Clang.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Version.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <cstdlib>
using namespace std;
namespace clang {
llvm::StringRef getClangRepositoryPath() {
static const char URL[] = "$URL: http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_28/lib/Basic/Version.cpp $";
const char *URLEnd = URL + strlen(URL);
const char *End = strstr(URL, "/lib/Basic");
if (End)
URLEnd = End;
// Strip off version from a build from an integration branch.
End = strstr(URL, "/src/tools/clang");
if (End)
URLEnd = End;
const char *Begin = strstr(URL, "cfe/");
if (Begin)
return llvm::StringRef(Begin + 4, URLEnd - Begin - 4);
return llvm::StringRef(URL, URLEnd - URL);
}
std::string getClangRevision() {
#ifdef SVN_REVISION
if (SVN_REVISION[0] != '\0') {
std::string revision;
llvm::raw_string_ostream OS(revision);
OS << strtol(SVN_REVISION, 0, 10);
return OS.str();
}
#endif
return "";
}
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 OS.str();
}
std::string getClangFullVersion() {
std::string buf;
llvm::raw_string_ostream OS(buf);
#ifdef CLANG_VENDOR
OS << CLANG_VENDOR;
#endif
OS << "clang version " CLANG_VERSION_STRING " ("
<< getClangFullRepositoryVersion() << ')';
#ifdef CLANG_VENDOR_SUFFIX
OS << CLANG_VENDOR_SUFFIX;
#endif
return OS.str();
}
} // end namespace clang
|