cor3ntin updated this revision to Diff 361639.
cor3ntin added a comment.
Herald added a project: clang-tools-extra.

Fix tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106577/new/

https://reviews.llvm.org/D106577

Files:
  clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===================================================================
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -284,6 +284,7 @@
 // RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-unknown-windows-cygnus -E /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s
 //
 // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
+// SHORTWCHAR-NOT: #define __STDC_ISO_10646__
 // SHORTWCHAR: #define __WCHAR_MAX__ 65535
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
@@ -292,6 +293,7 @@
 // RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
 //
 // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4
+// SHORTWCHAR2: #define __STDC_ISO_10646__ 202012L
 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32
 // Other definitions vary from platform to platform
 
@@ -1739,6 +1741,7 @@
 // WEBASSEMBLY-NOT:#define __STDC_NO_COMPLEX__
 // WEBASSEMBLY-NOT:#define __STDC_NO_VLA__
 // WEBASSEMBLY-NOT:#define __STDC_NO_THREADS__
+// WEBASSEMBLY-NEXT:#define __STDC_ISO_10646__ 202012L
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_16__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_32__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201710L
@@ -2310,6 +2313,7 @@
 // RISCV32: #define __SIZE_TYPE__ unsigned int
 // RISCV32: #define __SIZE_WIDTH__ 32
 // RISCV32: #define __STDC_HOSTED__ 0
+// RISCV32: #define __STDC_ISO_10646__ 202012L
 // RISCV32: #define __STDC_UTF_16__ 1
 // RISCV32: #define __STDC_UTF_32__ 1
 // RISCV32: #define __STDC_VERSION__ 201710L
@@ -2517,6 +2521,7 @@
 // RISCV64: #define __SIZE_TYPE__ long unsigned int
 // RISCV64: #define __SIZE_WIDTH__ 64
 // RISCV64: #define __STDC_HOSTED__ 0
+// RISCV64: #define __STDC_ISO_10646__ 202012L
 // RISCV64: #define __STDC_UTF_16__ 1
 // RISCV64: #define __STDC_UTF_32__ 1
 // RISCV64: #define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-x86.c
===================================================================
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1199,7 +1199,7 @@
 // X86_64-CLOUDABI:#define __SSE_MATH__ 1
 // X86_64-CLOUDABI:#define __SSE__ 1
 // X86_64-CLOUDABI:#define __STDC_HOSTED__ 0
-// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 201206L
+// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 202012L
 // X86_64-CLOUDABI:#define __STDC_UTF_16__ 1
 // X86_64-CLOUDABI:#define __STDC_UTF_32__ 1
 // X86_64-CLOUDABI:#define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-aarch64.c
===================================================================
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -235,6 +235,7 @@
 // AARCH64_CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 // AARCH64_CXX: #define __STDCPP_THREADS__ 1
 // AARCH64-NEXT: #define __STDC_HOSTED__ 1
+// AARCH64: #define __STDC_ISO_10646__ 202012L
 // AARCH64-NEXT: #define __STDC_UTF_16__ 1
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
 // AARCH64_C: #define __STDC_VERSION__ 201710L
@@ -648,6 +649,7 @@
 // AARCH64-MSVC: #define __SIZE_TYPE__ long long unsigned int
 // AARCH64-MSVC: #define __SIZE_WIDTH__ 64
 // AARCH64-MSVC: #define __STDC_HOSTED__ 0
+// AARCH64-MSVC-NOT: #define __STDC_ISO_10646__
 // AARCH64-MSVC: #define __STDC_UTF_16__ 1
 // AARCH64-MSVC: #define __STDC_UTF_32__ 1
 // AARCH64-MSVC: #define __STDC_VERSION__ 201710L
Index: clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -427,6 +427,16 @@
   Builder.defineMacro("__STDC_UTF_16__", "1");
   Builder.defineMacro("__STDC_UTF_32__", "1");
 
+  // Because Clang only supports UTF-32 or UTF-16 as the
+  // wide execution encoding, any platform that doesn't use
+  // short wchar_t can represent the entire Unicode code space.
+  // Unicode 13 was released in December 2020, which is why we're
+  // expanding to 202012L. Note that new Unicode versions are
+  // *very* unlikely to cause Clang to need to remove the
+  // predefined macro.
+  if (TI.getWCharWidth() >= 32)
+    Builder.defineMacro("__STDC_ISO_10646__", "202012L");
+
   if (LangOpts.ObjC)
     Builder.defineMacro("__OBJC__");
 
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -42,9 +42,6 @@
                     MacroBuilder &Builder) const override {
     Builder.defineMacro("__CloudABI__");
     Builder.defineMacro("__ELF__");
-
-    // CloudABI uses ISO/IEC 10646:2012 for wchar_t, char16_t and char32_t.
-    Builder.defineMacro("__STDC_ISO_10646__", "201206L");
     Builder.defineMacro("__STDC_UTF_16__");
     Builder.defineMacro("__STDC_UTF_32__");
   }
Index: clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
===================================================================
--- clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
@@ -31,6 +31,9 @@
 // CHECK:        MacroNameTok: __STDC_UTF_32__
 // CHECK-NEXT:   MacroDirective: MD_Define
 // CHECK:      - Callback: MacroDefined
+// CHECK:        MacroNameTok: __STDC_ISO_10646__
+// CHECK-NEXT:   MacroDirective: MD_Define
+// CHECK:      - Callback: MacroDefined
 // CHECK:      - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: MACRO
 // CHECK-NEXT:   MacroDirective: MD_Define
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to