r365992 - This reverts commit 632a36bfcfc8273c1861f04ff6758d863c47c784.

Sylvestre Ledru via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 23:27:36 PDT 2019


Author: sylvestre
Date: Fri Jul 12 23:27:35 2019
New Revision: 365992

URL: http://llvm.org/viewvc/llvm-project?rev=365992&view=rev
Log:
This reverts commit 632a36bfcfc8273c1861f04ff6758d863c47c784.

Some targets such as Python 2.7.16 still use VERSION in
their builds. Without VERSION defined, the source code
has syntax errors.

Reverting as it will probably break many other things.

Noticed by Sterling Augustine


Modified:
    cfe/trunk/docs/LanguageExtensions.rst
    cfe/trunk/docs/ReleaseNotes.rst
    cfe/trunk/lib/Basic/Version.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/Index/complete-exprs.c
    cfe/trunk/test/Preprocessor/init.c
    cfe/trunk/utils/builtin-defines.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 12 23:27:35 2019
@@ -324,8 +324,6 @@ option for a warning and returns true if
   ...
   #endif
 
-.. _languageextensions-builtin-macros:
-
 Builtin Macros
 ==============
 

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Jul 12 23:27:35 2019
@@ -56,11 +56,6 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -------------------------------------------------
 
-- The ``__VERSION__`` macro has been removed.
-  Previously this macro was set to a string aiming to achieve compatibility with 
-  GCC 4.2.1, but that should no longer be necessary. To get Clang's version,
-  use the :ref:`clang namespaced version macros <languageextensions-builtin-macros>`.
-
 - ...
 
 
@@ -84,11 +79,6 @@ Modified Compiler Flags
 
 - ...
 
-Removed Compiler Options
-------------------------
-
-- ...
-
 New Pragmas in Clang
 --------------------
 

Modified: cfe/trunk/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Fri Jul 12 23:27:35 2019
@@ -136,6 +136,8 @@ std::string getClangToolFullVersion(Stri
 }
 
 std::string getClangFullCPPVersion() {
+  // The version string we report in __VERSION__ is just a compacted version of
+  // the one we report on the command line.
   std::string buf;
   llvm::raw_string_ostream OS(buf);
 #ifdef CLANG_VENDOR

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Jul 12 23:27:35 2019
@@ -604,6 +604,12 @@ static void InitializePredefinedMacros(c
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
+  // As sad as it is, enough software depends on the __VERSION__ for version
+  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
+  // compatibility with) first.
+  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
+                      Twine(getClangFullCPPVersion()) + "\"");
+
   // Initialize language-specific preprocessor defines.
 
   // Standard conforming mode?

Modified: cfe/trunk/test/Index/complete-exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.c?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-exprs.c (original)
+++ cfe/trunk/test/Index/complete-exprs.c Fri Jul 12 23:27:35 2019
@@ -27,6 +27,7 @@ void f5(float f) {
 // RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
+// CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
@@ -38,6 +39,7 @@ void f5(float f) {
 // RUN: c-index-test -code-completion-at=%s:7:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
 // CHECK-CC2: NotImplemented:{TypedText float} (50)
 // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (34)

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Jul 12 23:27:35 2019
@@ -101,6 +101,7 @@
 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412
 // COMMON:#define __STDC_HOSTED__ 1
 // COMMON:#define __STDC__ 1
+// COMMON:#define __VERSION__ {{.*}}
 // COMMON:#define __clang__ 1
 // COMMON:#define __clang_major__ {{[0-9]+}}
 // COMMON:#define __clang_minor__ {{[0-9]+}}
@@ -8168,6 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
+// SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
@@ -9039,6 +9041,7 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
+// X86_64-CLOUDABI:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32
@@ -10040,6 +10043,7 @@
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_MAX__ 255
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_TYPE__ unsigned char
 // WEBASSEMBLY-NEXT:#define __USER_LABEL_PREFIX__
+// WEBASSEMBLY-NEXT:#define __VERSION__ "{{.*}}"
 // WEBASSEMBLY-NEXT:#define __WCHAR_MAX__ 2147483647
 // WEBASSEMBLY-NEXT:#define __WCHAR_TYPE__ int
 // WEBASSEMBLY-NOT:#define __WCHAR_UNSIGNED__

Modified: cfe/trunk/utils/builtin-defines.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/builtin-defines.c?rev=365992&r1=365991&r2=365992&view=diff
==============================================================================
--- cfe/trunk/utils/builtin-defines.c (original)
+++ cfe/trunk/utils/builtin-defines.c Fri Jul 12 23:27:35 2019
@@ -49,6 +49,7 @@ RUN: done;
 #undef __INT8_TYPE__
 #undef __SSP__
 #undef __APPLE_CC__
+#undef __VERSION__
 #undef __clang__
 #undef __llvm__
 #undef __nocona




More information about the cfe-commits mailing list