Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -262,22 +262,13 @@ endif() # Compute the Clang version from the LLVM version. -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION - ${PACKAGE_VERSION}) +set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) +set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR}) +set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) +# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") message(STATUS "Clang version: ${CLANG_VERSION}") -string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR - ${CLANG_VERSION}) -string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR - ${CLANG_VERSION}) -if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - set(CLANG_HAS_VERSION_PATCHLEVEL 1) - string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CLANG_VERSION_PATCHLEVEL - ${CLANG_VERSION}) -else() - set(CLANG_HAS_VERSION_PATCHLEVEL 0) -endif() - # Configure the Version.inc file. configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in Index: include/clang/Basic/Version.h =================================================================== --- include/clang/Basic/Version.h +++ include/clang/Basic/Version.h @@ -19,26 +19,6 @@ #include "clang/Basic/Version.inc" #include "llvm/ADT/StringRef.h" -/// \brief Helper macro for CLANG_VERSION_STRING. -#define CLANG_MAKE_VERSION_STRING2(X) #X - -#ifdef CLANG_VERSION_PATCHLEVEL -/// \brief Helper macro for CLANG_VERSION_STRING. -#define CLANG_MAKE_VERSION_STRING(X,Y,Z) CLANG_MAKE_VERSION_STRING2(X.Y.Z) - -/// \brief A string that describes the Clang version number, e.g., "1.0". -#define CLANG_VERSION_STRING \ - CLANG_MAKE_VERSION_STRING(CLANG_VERSION_MAJOR,CLANG_VERSION_MINOR, \ - CLANG_VERSION_PATCHLEVEL) -#else -/// \brief Helper macro for CLANG_VERSION_STRING. -#define CLANG_MAKE_VERSION_STRING(X,Y) CLANG_MAKE_VERSION_STRING2(X.Y) - -/// \brief A string that describes the Clang version number, e.g., "1.0". -#define CLANG_VERSION_STRING \ - CLANG_MAKE_VERSION_STRING(CLANG_VERSION_MAJOR,CLANG_VERSION_MINOR) -#endif - namespace clang { /// \brief Retrieves the repository path (e.g., Subversion path) that /// identifies the particular Clang branch, tag, or trunk from which this Index: include/clang/Basic/Version.inc.in =================================================================== --- include/clang/Basic/Version.inc.in +++ include/clang/Basic/Version.inc.in @@ -1,6 +1,5 @@ #define CLANG_VERSION @CLANG_VERSION@ +#define CLANG_VERSION_STRING "@CLANG_VERSION@" #define CLANG_VERSION_MAJOR @CLANG_VERSION_MAJOR@ #define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@ -#if @CLANG_HAS_VERSION_PATCHLEVEL@ #define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@ -#endif Index: lib/Frontend/InitPreprocessor.cpp =================================================================== --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -511,16 +511,12 @@ #define TOSTR(X) TOSTR2(X) Builder.defineMacro("__clang_major__", TOSTR(CLANG_VERSION_MAJOR)); Builder.defineMacro("__clang_minor__", TOSTR(CLANG_VERSION_MINOR)); -#ifdef CLANG_VERSION_PATCHLEVEL Builder.defineMacro("__clang_patchlevel__", TOSTR(CLANG_VERSION_PATCHLEVEL)); -#else - Builder.defineMacro("__clang_patchlevel__", "0"); -#endif +#undef TOSTR +#undef TOSTR2 Builder.defineMacro("__clang_version__", "\"" CLANG_VERSION_STRING " " + getClangFullRepositoryVersion() + "\""); -#undef TOSTR -#undef TOSTR2 if (!LangOpts.MSVCCompat) { // Currently claim to be compatible with GCC 4.2.1-5621, but only if we're // not compiling for MSVC compatibility