1 //===- Version.h - 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 /// \file
11 /// \brief Defines version macros and version-related utility functions
12 /// for Clang.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_BASIC_VERSION_H
17 #define LLVM_CLANG_BASIC_VERSION_H
18 
19 #include "clang/Basic/Version.inc"
20 #include "llvm/ADT/StringRef.h"
21 
22 /// \brief Helper macro for CLANG_VERSION_STRING.
23 #define CLANG_MAKE_VERSION_STRING2(X) #X
24 
25 #ifdef CLANG_VERSION_PATCHLEVEL
26 /// \brief Helper macro for CLANG_VERSION_STRING.
27 #define CLANG_MAKE_VERSION_STRING(X,Y,Z) CLANG_MAKE_VERSION_STRING2(X.Y.Z)
28 
29 /// \brief A string that describes the Clang version number, e.g., "1.0".
30 #define CLANG_VERSION_STRING \
31   CLANG_MAKE_VERSION_STRING(CLANG_VERSION_MAJOR,CLANG_VERSION_MINOR, \
32                             CLANG_VERSION_PATCHLEVEL)
33 #else
34 /// \brief Helper macro for CLANG_VERSION_STRING.
35 #define CLANG_MAKE_VERSION_STRING(X,Y) CLANG_MAKE_VERSION_STRING2(X.Y)
36 
37 /// \brief A string that describes the Clang version number, e.g., "1.0".
38 #define CLANG_VERSION_STRING \
39   CLANG_MAKE_VERSION_STRING(CLANG_VERSION_MAJOR,CLANG_VERSION_MINOR)
40 #endif
41 
42 namespace clang {
43   /// \brief Retrieves the repository path (e.g., Subversion path) that
44   /// identifies the particular Clang branch, tag, or trunk from which this
45   /// Clang was built.
46   std::string getClangRepositoryPath();
47 
48   /// \brief Retrieves the repository path from which LLVM was built.
49   ///
50   /// This supports LLVM residing in a separate repository from clang.
51   std::string getLLVMRepositoryPath();
52 
53   /// \brief Retrieves the repository revision number (or identifer) from which
54   /// this Clang was built.
55   std::string getClangRevision();
56 
57   /// \brief Retrieves the repository revision number (or identifer) from which
58   /// LLVM was built.
59   ///
60   /// If Clang and LLVM are in the same repository, this returns the same
61   /// string as getClangRevision.
62   std::string getLLVMRevision();
63 
64   /// \brief Retrieves the full repository version that is an amalgamation of
65   /// the information in getClangRepositoryPath() and getClangRevision().
66   std::string getClangFullRepositoryVersion();
67 
68   /// \brief Retrieves a string representing the complete clang version,
69   /// which includes the clang version number, the repository version,
70   /// and the vendor tag.
71   std::string getClangFullVersion();
72 
73   /// \brief Like getClangFullVersion(), but with a custom tool name.
74   std::string getClangToolFullVersion(llvm::StringRef ToolName);
75 
76   /// \brief Retrieves a string representing the complete clang version suitable
77   /// for use in the CPP __VERSION__ macro, which includes the clang version
78   /// number, the repository version, and the vendor tag.
79   std::string getClangFullCPPVersion();
80 }
81 
82 #endif // LLVM_CLANG_BASIC_VERSION_H
83