blob: 9699ee416be5c0d279328a484fd01f70171d39a2 [file] [log] [blame]
Douglas Gregor60b5d8e2009-10-05 18:52:24 +00001//===- Version.cpp - Clang Version Number -----------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines several version-related utility functions for Clang.
11//
12//===----------------------------------------------------------------------===//
13#include <cstring>
14#include <cstdlib>
15using namespace std;
16
17namespace clang {
18
19const char *getClangSubversionPath() {
20 static const char *Path = 0;
21 if (Path)
22 return Path;
23
24 static char URL[] = "$URL$";
25 char *End = strstr(URL, "/lib/Basic");
26 if (End)
27 *End = 0;
28
29 char *Begin = strstr(URL, "cfe/");
30 if (Begin) {
31 Path = Begin + 4;
32 return Path;
33 }
34
35 Path = URL;
36 return Path;
37}
38
39
40unsigned getClangSubversionRevision() {
41#ifndef SVN_REVISION
Douglas Gregorb8d11912009-10-05 20:33:49 +000042 // Subversion was not available at build time?
Douglas Gregor60b5d8e2009-10-05 18:52:24 +000043 return 0;
44#else
Douglas Gregorb8d11912009-10-05 20:33:49 +000045 return strtol(SVN_REVISION, 0, 10);
Douglas Gregor60b5d8e2009-10-05 18:52:24 +000046#endif
47}
48
49} // end namespace clang