[PATCH] D100346: [Clang] String Literal and Wide String Literal Encoding from the Preprocessor
ThePhD via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 12 18:00:19 PDT 2021
ThePhD updated this revision to Diff 337008.
ThePhD added a comment.
Fixes formatting derps in the pre-linter check.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100346/new/
https://reviews.llvm.org/D100346
Files:
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Preprocessor/init.c
Index: clang/test/Preprocessor/init.c
===================================================================
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -119,6 +119,8 @@
// COMMON:#define __clang_minor__ {{[0-9]+}}
// COMMON:#define __clang_patchlevel__ {{[0-9]+}}
// COMMON:#define __clang_version__ {{.*}}
+// COMMON:#define __clang_literal_encoding__ {{.*}}
+// COMMON:#define __clang_wide_literal_encoding__ {{.*}}
// COMMON:#define __llvm__ 1
//
// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-win32 < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
Index: clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -778,6 +778,21 @@
}
}
+ // macros to help identify the narrow and wide character sets
+ // NOTE: clang currently ignores -fexec-charset=. If this changes,
+ // then this code may need to change.
+ Builder.defineMacro("__clang_literal_encoding__", "\"UTF-8\"");
+ if (TI.getTypeWidth(TI.getWCharType()) >= 32) {
+ // NOTE: 32-bit wchar_t signals UTF-32. This may change
+ // if -fwide-exec-charset= is ever supported.
+ Builder.defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\"");
+ } else {
+ // NOTE: Less-than 32-bit wchar_t generally means UTF-16
+ // (e.g., Windows, 32-bit IBM). This may change if
+ // -fwide-exec-charset= is ever supported.
+ Builder.defineMacro("__clang_wide_literal_encoding__", "\"UTF-16\"");
+ }
+
if (LangOpts.Optimize)
Builder.defineMacro("__OPTIMIZE__");
if (LangOpts.OptimizeSize)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100346.337008.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210413/2eeef061/attachment.bin>
More information about the cfe-commits
mailing list