[PATCH] D100346: [Clang] String Literal and Wide String Literal Encoding from the Preprocessor

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 13 05:58:10 PDT 2021


aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Thank you for this patch, I think this is useful functionality!

In D100346#2684736 <https://reviews.llvm.org/D100346#2684736>, @ThePhD wrote:

> The string literals work for people because, despite not being preprocessor-comparable, they can be manipulated at compile-time and switched on in the usual ways at `constexpr` time. See usages in:
>
> https://github.com/soasis/text/blob/main/include/ztd/text/detail/encoding_name.hpp#L198
> https://github.com/soasis/text/blob/main/include/ztd/text/literal.hpp#L54
>
> , which can be used at compile-time like:
>
> https://github.com/soasis/text/blob/main/tests/basic_compile_time/source/validate_code_points.cpp#L45

What about for folks using this from C where there isn't `constexpr` functionality to help them?



================
Comment at: clang/docs/LanguageExtensions.rst:387
+``__clang_literal_encoding__``
+  Defined to a string that represents the current encoding of string literals,
+  e.g., ``"hello"``. This is typically "UTF-8" (but may change in the future
----------------
In both cases, defined to a string *in what encoding* (<rimshot.wav>)? More seriously, we should probably be clear that this expands to a narrow string literal rather than, say, a `const char *` or `std::string`.


================
Comment at: clang/docs/LanguageExtensions.rst:388
+  Defined to a string that represents the current encoding of string literals,
+  e.g., ``"hello"``. This is typically "UTF-8" (but may change in the future
+  if the ``-fexec-charset="Encoding-Name"`` option is implemented.)
----------------
This is typically -> This macro typically expands to

(same below).


================
Comment at: clang/lib/Frontend/InitPreprocessor.cpp:781
 
+  // macros to help identify the narrow and wide character sets
+  // NOTE: clang currently ignores -fexec-charset=. If this changes,
----------------
macros -> Macros


================
Comment at: clang/lib/Frontend/InitPreprocessor.cpp:782
+  // macros to help identify the narrow and wide character sets
+  // NOTE: clang currently ignores -fexec-charset=. If this changes,
+  // then this may need to be updated.
----------------
NOTE -> FIXME


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

https://reviews.llvm.org/D100346



More information about the cfe-commits mailing list