r331244 - Implement P0482R2, support for char8_t type.
Shoaib Meenai via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 2 15:37:33 PDT 2018
That makes sense, thanks.
From: Richard Smith <richard at metafoo.co.uk>
Date: Tuesday, October 2, 2018 at 3:16 PM
To: Shoaib Meenai <smeenai at fb.com>
Cc: cfe-commits <cfe-commits at lists.llvm.org>
Subject: Re: r331244 - Implement P0482R2, support for char8_t type.
On Mon, 24 Sep 2018 at 16:42, Shoaib Meenai via cfe-commits <cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>> wrote:
Sorry to revive an old thread, but just to confirm, was it intentional for the fundamental typeinfo for char8_t to be always emitted, even when not building with -fchar8_t?
Yes; the ABI library should generally provide type_info objects for all fundamental types, including those that are not available in the current compilation, because it can be used with code built in other configurations. We do the same for (eg) long long, __float128, and __float16, even though they are not necessarily enabled in all compilation modes.
From: cfe-commits <cfe-commits-bounces at lists.llvm.org<mailto:cfe-commits-bounces at lists.llvm.org>> on behalf of Richard Smith via cfe-commits <cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>>
Reply-To: Richard Smith <richard-llvm at metafoo.co.uk<mailto:richard-llvm at metafoo.co.uk>>
Date: Monday, April 30, 2018 at 10:06 PM
To: "cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>" <cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>>
Subject: r331244 - Implement P0482R2, support for char8_t type.
Author: rsmith
Date: Mon Apr 30 22:02:45 2018
New Revision: 331244
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D331244-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=7fyjnMpg8tSWIPmJ46q5iSAomEeeXb5iAHykEvjG-Bs&e=
Log:
Implement P0482R2, support for char8_t type.
This is not yet part of any C++ working draft, and so is controlled by the flag
-fchar8_t rather than a -std= flag. (The GCC implementation is controlled by a
flag with the same name.)
This implementation is experimental, and will be removed or revised
substantially to match the proposal as it makes its way through the C++
committee.
Added:
cfe/trunk/test/CodeGenCXX/char8_t.cpp
cfe/trunk/test/Lexer/char8_t.cpp
cfe/trunk/test/SemaCXX/char8_t.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Lex/PPExpressions.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Lexer/cxx-features.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_AST_ASTContext.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=9xFtO5gx5AjdOJolymIqhtKCHN79DrOyjXIADk5NNOA&e=
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Apr 30 22:02:45 2018
@@ -999,6 +999,7 @@ public:
CanQualType WCharTy; // [C++ 3.9.1p5].
CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.
+ CanQualType Char8Ty; // [C++20 proposal]
CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;
Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_AST_BuiltinTypes.def-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=nVLJ5LpyHD_3I5wUoW4iW0yLjw4tuOCRr9ho0zcUwSQ&e=
==============================================================================
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Mon Apr 30 22:02:45 2018
@@ -72,6 +72,9 @@ UNSIGNED_TYPE(UChar, UnsignedCharTy)
// 'wchar_t' for targets where it's unsigned
SHARED_SINGLETON_TYPE(UNSIGNED_TYPE(WChar_U, WCharTy))
+// 'char8_t' in C++20 (proposed)
+UNSIGNED_TYPE(Char8, Char8Ty)
+
// 'char16_t' in C++
UNSIGNED_TYPE(Char16, Char16Ty)
Modified: cfe/trunk/include/clang/AST/Type.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_AST_Type.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=2uiDKJ1TYftSa5kjrUkp-8_xvI3vNA4fdrpDVMCx8wc&e=
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr 30 22:02:45 2018
@@ -1777,6 +1777,7 @@ public:
bool isBooleanType() const;
bool isCharType() const;
bool isWideCharType() const;
+ bool isChar8Type() const;
bool isChar16Type() const;
bool isChar32Type() const;
bool isAnyCharacterType() const;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_DiagnosticSemaKinds.td-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=71MfUp9muqJq_fGX1RDWoXGMia1DMIn_VMmdEvZ0RlE&e=
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 30 22:02:45 2018
@@ -2421,6 +2421,9 @@ def err_template_different_associated_co
def warn_cxx98_compat_unicode_type : Warning<
"'%0' type specifier is incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
+def warn_cxx17_compat_unicode_type : Warning<
+ "'char8_t' type specifier is incompatible with C++ standards before C++20">,
+ InGroup<CXXPre2aCompat>, DefaultIgnore;
// __make_integer_seq
def err_integer_sequence_negative_length : Error<
@@ -5822,6 +5825,13 @@ def err_array_init_wide_string_into_char
"initializing char array with wide string literal">;
def err_array_init_incompat_wide_string_into_wchar : Error<
"initializing wide char array with incompatible wide string literal">;
+def err_array_init_plain_string_into_char8_t : Error<
+ "initializing 'char8_t' array with plain string literal">;
+def note_array_init_plain_string_into_char8_t : Note<
+ "add 'u8' prefix to form a 'char8_t' string literal">;
+def err_array_init_utf8_string_into_char : Error<
+ "initialization of char array with UTF-8 string literal is not permitted "
+ "by '-fchar8_t'">;
def err_array_init_different_type : Error<
"cannot initialize array %diff{of type $ with array of type $|"
"with different type of array}0,1">;
Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_LangOptions.def-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=runF5kQwpvGO2zD2V0tQQ-OkczIU0zO5yo6YFYHzysk&e=
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Apr 30 22:02:45 2018
@@ -106,6 +106,7 @@ LANGOPT(LineComment , 1, 0, "'//'
LANGOPT(Bool , 1, 0, "bool, true, and false keywords")
LANGOPT(Half , 1, 0, "half keyword")
LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
+LANGOPT(Char8 , 1, 0, "char8_t keyword")
LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword")
BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers")
BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_Specifiers.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=im9MYO4ZJYhTyZGB43sN1QSMaDtQH80G3YjmDvMfZTE&e=
==============================================================================
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Mon Apr 30 22:02:45 2018
@@ -47,6 +47,7 @@ namespace clang {
TST_void,
TST_char,
TST_wchar, // C++ wchar_t
+ TST_char8, // C++20 char8_t (proposed)
TST_char16, // C++11 char16_t
TST_char32, // C++11 char32_t
TST_int,
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Basic_TokenKinds.def-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=WKP42u-fM1k_elNke1VNZiQl3FEMVH9eL4-KY5LAiFQ&e=
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Mon Apr 30 22:02:45 2018
@@ -260,6 +260,7 @@ PUNCTUATOR(caretcaret, "^^")
// BOOLSUPPORT - This is a keyword if 'bool' is a built-in type
// HALFSUPPORT - This is a keyword if 'half' is a built-in type
// WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type
+// CHAR8SUPPORT - This is a keyword if 'char8_t' is a built-in type
//
KEYWORD(auto , KEYALL)
KEYWORD(break , KEYALL)
@@ -380,6 +381,9 @@ KEYWORD(co_yield , KE
MODULES_KEYWORD(module)
MODULES_KEYWORD(import)
+// C++ char8_t proposal
+KEYWORD(char8_t , CHAR8SUPPORT)
+
// C11 Extension
KEYWORD(_Float16 , KEYALL)
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Driver_Options.td-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=H9sO5F67IvVzUZ2PVjcjdf6-RmvvMLIdADPwTqsmppE&e=
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Apr 30 22:02:45 2018
@@ -1525,6 +1525,10 @@ def frtti : Flag<["-"], "frtti">, Group<
def : Flag<["-"], "fsched-interblock">, Group<clang_ignored_f_Group>;
def fshort_enums : Flag<["-"], "fshort-enums">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Allocate to an enum type only as many bytes as it needs for the declared range of possible values">;
+def fchar8__t : Flag<["-"], "fchar8_t">, Group<f_Group>, Flags<[CC1Option]>,
+ HelpText<"Enable C++ builtin type char8_t">;
+def fno_char8__t : Flag<["-"], "fno-char8_t">, Group<f_Group>,
+ HelpText<"Disable C++ builtin type char8_t">;
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
HelpText<"Force wchar_t to be a short unsigned int">;
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Sema_DeclSpec.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=u5pfyoU8ST3absjsbc9CFlX5-EggS_makjnJBk69D-w&e=
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Mon Apr 30 22:02:45 2018
@@ -273,6 +273,7 @@ public:
static const TST TST_void = clang::TST_void;
static const TST TST_char = clang::TST_char;
static const TST TST_wchar = clang::TST_wchar;
+ static const TST TST_char8 = clang::TST_char8;
static const TST TST_char16 = clang::TST_char16;
static const TST TST_char32 = clang::TST_char32;
static const TST TST_int = clang::TST_int;
Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Sema_Initialization.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=wTYWJmCLg0Q-0gQ_mxBXbnAgcxX6IT9bzm9u6DFVm80&e=
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Mon Apr 30 22:02:45 2018
@@ -952,6 +952,12 @@ public:
/// literal.
FK_IncompatWideStringIntoWideChar,
+ /// \brief Initializing char8_t array with plain string literal.
+ FK_PlainStringIntoUTF8Char,
+
+ /// \brief Initializing char array with UTF-8 string literal.
+ FK_UTF8StringIntoPlainChar,
+
/// \brief Array type mismatch.
FK_ArrayTypeMismatch,
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Serialization_ASTBitCodes.h-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=C8nZZiGcPF9OUoIDB9mUwWmY6VGNKkWhpS_KDCy-MZY&e=
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Apr 30 22:02:45 2018
@@ -936,6 +936,9 @@ namespace serialization {
/// \brief The '_Float16' type
PREDEF_TYPE_FLOAT16_ID = 44,
+ /// \brief The C++ 'char8_t' type.
+ PREDEF_TYPE_CHAR8_ID = 45,
+
/// \brief OpenCL image types with auto numeration
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
PREDEF_TYPE_##Id##_ID,
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_ASTContext.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=cOs6KUZnMwaVJUQGRo6uR7eweOZPXmmluCQuOWNhrPU&e=
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr 30 22:02:45 2018
@@ -1151,6 +1151,9 @@ void ASTContext::InitBuiltinTypes(const
WIntTy = getFromTargetType(Target.getWIntType());
+ // C++20 (proposed)
+ InitBuiltinType(Char8Ty, BuiltinType::Char8);
+
if (LangOpts.CPlusPlus) // C++0x 3.9.1p5, extension for C++
InitBuiltinType(Char16Ty, BuiltinType::Char16);
else // C99
@@ -1739,6 +1742,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con
case BuiltinType::Char_U:
case BuiltinType::UChar:
case BuiltinType::SChar:
+ case BuiltinType::Char8:
Width = Target->getCharWidth();
Align = Target->getCharAlign();
break;
@@ -5456,6 +5460,7 @@ QualType ASTContext::getPromotedIntegerT
// FIXME: Is there some better way to compute this?
if (BT->getKind() == BuiltinType::WChar_S ||
BT->getKind() == BuiltinType::WChar_U ||
+ BT->getKind() == BuiltinType::Char8 ||
BT->getKind() == BuiltinType::Char16 ||
BT->getKind() == BuiltinType::Char32) {
bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
@@ -6202,6 +6207,7 @@ static char getObjCEncodingForPrimitiveK
switch (kind) {
case BuiltinType::Void: return 'v';
case BuiltinType::Bool: return 'B';
+ case BuiltinType::Char8:
case BuiltinType::Char_U:
case BuiltinType::UChar: return 'C';
case BuiltinType::Char16:
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_ExprConstant.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=H9oTx0hxRV2YiaqRaAT62rPqwLaeI6qSx1Jnr4eq33k&e=
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Apr 30 22:02:45 2018
@@ -7326,6 +7326,7 @@ static int EvaluateBuiltinClassifyType(c
return pointer_type_class;
case BuiltinType::WChar_U:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::ObjCId:
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_ItaniumMangle.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=8sy6OE5pi8Ry9q6y17BaUw30pa7hvsxmLVOkx_e3JOI&e=
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Apr 30 22:02:45 2018
@@ -2525,6 +2525,9 @@ void CXXNameMangler::mangleType(const Bu
case BuiltinType::WChar_U:
Out << 'w';
break;
+ case BuiltinType::Char8:
+ Out << "Du";
+ break;
case BuiltinType::Char16:
Out << "Ds";
break;
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_MicrosoftMangle.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=Oe755zBOlULArIedwdkG4ESB44N3II4b8ks8mqhWBXg&e=
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Apr 30 22:02:45 2018
@@ -1918,6 +1918,7 @@ void MicrosoftCXXNameMangler::mangleType
Out << "$$T";
break;
+ case BuiltinType::Char8:
case BuiltinType::Float16:
mangleArtificalTagType(TTK_Struct, "_Float16", {"__clang"});
break;
Modified: cfe/trunk/lib/AST/NSAPI.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_NSAPI.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=LszgOQ0OAtQi2smrBjINDfOOO0JW2QALu8AnaRQYETw&e=
==============================================================================
--- cfe/trunk/lib/AST/NSAPI.cpp (original)
+++ cfe/trunk/lib/AST/NSAPI.cpp Mon Apr 30 22:02:45 2018
@@ -436,6 +436,7 @@ NSAPI::getNSNumberFactoryMethodKind(Qual
case BuiltinType::Void:
case BuiltinType::WChar_U:
case BuiltinType::WChar_S:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::Int128:
Modified: cfe/trunk/lib/AST/Type.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_Type.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=orhBoXrhRRVshKrjW77pTveqJpEGpXW8tXyGtGjSeW4&e=
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Apr 30 22:02:45 2018
@@ -1763,6 +1763,12 @@ bool Type::isWideCharType() const {
return false;
}
+bool Type::isChar8Type() const {
+ if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+ return BT->getKind() == BuiltinType::Char8;
+ return false;
+}
+
bool Type::isChar16Type() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Char16;
@@ -1785,6 +1791,7 @@ bool Type::isAnyCharacterType() const {
case BuiltinType::Char_U:
case BuiltinType::UChar:
case BuiltinType::WChar_U:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::Char_S:
@@ -2419,6 +2426,7 @@ bool Type::isPromotableIntegerType() con
case BuiltinType::UShort:
case BuiltinType::WChar_S:
case BuiltinType::WChar_U:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
return true;
@@ -2655,6 +2663,8 @@ StringRef BuiltinType::getName(const Pri
case WChar_S:
case WChar_U:
return Policy.MSWChar ? "__wchar_t" : "wchar_t";
+ case Char8:
+ return "char8_t";
case Char16:
return "char16_t";
case Char32:
Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_AST_TypeLoc.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=czE7uVgwmaS0tL19k_4O_a107woTNWonZBuYRyuuFCE&e=
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Mon Apr 30 22:02:45 2018
@@ -317,6 +317,8 @@ TypeSpecifierType BuiltinTypeLoc::getWri
case BuiltinType::Char_U:
case BuiltinType::Char_S:
return TST_char;
+ case BuiltinType::Char8:
+ return TST_char8;
case BuiltinType::Char16:
return TST_char16;
case BuiltinType::Char32:
Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Analysis_PrintfFormatString.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=SMqf7-kzif3FR52t2zKRcorAotHjhJwTrs_EM_cSzmg&e=
==============================================================================
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Mon Apr 30 22:02:45 2018
@@ -647,6 +647,7 @@ bool PrintfSpecifier::fixType(QualType Q
case BuiltinType::Bool:
case BuiltinType::WChar_U:
case BuiltinType::WChar_S:
+ case BuiltinType::Char8: // FIXME: Treat like 'char'?
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::UInt128:
Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Basic_IdentifierTable.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=vs1ezrBwj1inarHICFoMMpHzh-isKMrQ_oIWI4tDT68&e=
==============================================================================
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Mon Apr 30 22:02:45 2018
@@ -115,14 +115,15 @@ namespace {
KEYNOOPENCL = 0x02000,
WCHARSUPPORT = 0x04000,
HALFSUPPORT = 0x08000,
- KEYCONCEPTS = 0x10000,
- KEYOBJC2 = 0x20000,
- KEYZVECTOR = 0x40000,
- KEYCOROUTINES = 0x80000,
- KEYMODULES = 0x100000,
- KEYCXX2A = 0x200000,
+ CHAR8SUPPORT = 0x10000,
+ KEYCONCEPTS = 0x20000,
+ KEYOBJC2 = 0x40000,
+ KEYZVECTOR = 0x80000,
+ KEYCOROUTINES = 0x100000,
+ KEYMODULES = 0x200000,
+ KEYCXX2A = 0x400000,
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
- KEYALL = (0x3fffff & ~KEYNOMS18 &
+ KEYALL = (0x7fffff & ~KEYNOMS18 &
~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
};
@@ -151,6 +152,7 @@ static KeywordStatus getKeywordStatus(co
if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;
if (LangOpts.WChar && (Flags & WCHARSUPPORT)) return KS_Enabled;
+ if (LangOpts.Char8 && (Flags & CHAR8SUPPORT)) return KS_Enabled;
if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) return KS_Enabled;
if (LangOpts.OpenCL && (Flags & KEYOPENCL)) return KS_Enabled;
if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) return KS_Enabled;
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGDebugInfo.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=ZLy817Da-x4STf9aqJo412qutq_dVtNvTJTDN6SMGa8&e=
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 30 22:02:45 2018
@@ -665,6 +665,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
case BuiltinType::SChar:
Encoding = llvm::dwarf::DW_ATE_signed_char;
break;
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
Encoding = llvm::dwarf::DW_ATE_UTF;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenTypes.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=OsF-jtYC21lQFNgvkQz4Mtp8zxviWAfMSwftzmhvVk4&e=
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Mon Apr 30 22:02:45 2018
@@ -437,6 +437,7 @@ llvm::Type *CodeGenTypes::ConvertType(Qu
case BuiltinType::ULongLong:
case BuiltinType::WChar_S:
case BuiltinType::WChar_U:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
ResultType = llvm::IntegerType::get(getLLVMContext(),
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_ItaniumCXXABI.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=w7v8KExQASD3UZXlqrj_pT-FocBs0XOblzHJE0C1nQ8&e=
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Apr 30 22:02:45 2018
@@ -2706,6 +2706,7 @@ static bool TypeInfoIsInStandardLibrary(
case BuiltinType::LongDouble:
case BuiltinType::Float16:
case BuiltinType::Float128:
+ case BuiltinType::Char8:
case BuiltinType::Char16:
case BuiltinType::Char32:
case BuiltinType::Int128:
@@ -3567,7 +3568,8 @@ void ItaniumCXXABI::EmitFundamentalRTTID
getContext().UnsignedInt128Ty, getContext().HalfTy,
getContext().FloatTy, getContext().DoubleTy,
getContext().LongDoubleTy, getContext().Float128Ty,
- getContext().Char16Ty, getContext().Char32Ty
+ getContext().Char8Ty, getContext().Char16Ty,
+ getContext().Char32Ty
};
for (const QualType &FundamentalType : FundamentalTypes)
EmitFundamentalRTTIDescriptor(FundamentalType, DLLExport);
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Driver_ToolChains_Clang.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=l3k9g0qkBeeGNJH0MzNw2aLvT4MjrQaWH0LPy60rACk&e=
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Apr 30 22:02:45 2018
@@ -2687,6 +2687,9 @@ static void RenderCharacterOptions(const
CmdArgs.push_back("-fno-signed-char");
}
+ if (Args.hasFlag(options::OPT_fchar8__t, options::OPT_fno_char8__t, false))
+ CmdArgs.push_back("-fchar8_t");
+
if (const Arg *A = Args.getLastArg(options::OPT_fshort_wchar,
options::OPT_fno_short_wchar)) {
if (A->getOption().matches(options::OPT_fshort_wchar)) {
Modified: cfe/trunk/lib/Format/FormatToken.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Format_FormatToken.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=HunWUFE1inKqgXgyZVZw51ADzS6j-VrgTcnDwcyCBjE&e=
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.cpp (original)
+++ cfe/trunk/lib/Format/FormatToken.cpp Mon Apr 30 22:02:45 2018
@@ -57,6 +57,7 @@ bool FormatToken::isSimpleTypeSpecifier(
case tok::kw_bool:
case tok::kw___underlying_type:
case tok::annot_typename:
+ case tok::kw_char8_t:
case tok::kw_char16_t:
case tok::kw_char32_t:
case tok::kw_typeof:
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Frontend_CompilerInvocation.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=7znGHdt6Gx2p7G7J6VutLbCsv3KOG4dsrbo-JCCQnEg&e=
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Apr 30 22:02:45 2018
@@ -2362,6 +2362,7 @@ static void ParseLangArgs(LangOptions &O
Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
+ Opts.Char8 = Args.hasArg(OPT_fchar8__t);
if (const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {
Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())
.Case("char", 1)
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Frontend_InitPreprocessor.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=7_7ZBPRO2eOpiTYqmJZnpn225YJ9GnSXs6EY6Zqid7k&e=
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Apr 30 22:02:45 2018
@@ -559,6 +559,10 @@ static void InitializeCPlusPlusFeatureTe
Builder.defineMacro("__cpp_experimental_concepts", "1");
if (LangOpts.CoroutinesTS)
Builder.defineMacro("__cpp_coroutines", "201703L");
+
+ // Potential future breaking changes.
+ if (LangOpts.Char8)
+ Builder.defineMacro("__cpp_char8_t", "201803");
}
static void InitializePredefinedMacros(const TargetInfo &TI,
@@ -939,6 +943,8 @@ static void InitializePredefinedMacros(c
InlineWidthBits));
DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
DEFINE_LOCK_FREE_MACRO(CHAR, Char);
+ if (LangOpts.Char8)
+ DEFINE_LOCK_FREE_MACRO(CHAR8_T, Char); // Treat char8_t like char.
DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);
DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);
DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);
Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Index_USRGeneration.cpp-3Frev-3D331244-26r1-3D331243-26r2-3D331244-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=1yVxc98c1AfALi19DC1J845Xm76O2Y-TVidL7ln97Ng&s=iaA8AE4rUs7fxePml91TsFyZuYPIQiiPkq9jg6p_OWA&e=
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Apr 30 22:02:45 2018
@@ -650,6 +650,8 @@ void USRGenerator::VisitType(QualType T)
c = 'b'; break;
case BuiltinType::UChar:
c = 'c'; break;
+ case BuiltinType::Char8:
+ c = 'u'; break; // FIXME: Check this doesn't collide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181002/50b88976/attachment-0001.html>
More information about the cfe-commits
mailing list