<div dir="auto"><div>Thanks, looks good.<br><br><div class="gmail_quote"><div dir="ltr">On Mon, 30 Apr 2018, 23:52 Chandler Carruth via cfe-commits, <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I adjusted the test case in r331245 - it was failing for me and most of the build bots. Please check that I didn't miss anything.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 30, 2018 at 10:06 PM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon Apr 30 22:02:45 2018<br>
New Revision: 331244<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=331244&view=rev" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=331244&view=rev</a><br>
Log:<br>
Implement P0482R2, support for char8_t type.<br>
<br>
This is not yet part of any C++ working draft, and so is controlled by the flag<br>
-fchar8_t rather than a -std= flag. (The GCC implementation is controlled by a<br>
flag with the same name.)<br>
<br>
This implementation is experimental, and will be removed or revised<br>
substantially to match the proposal as it makes its way through the C++<br>
committee.<br>
<br>
Added:<br>
cfe/trunk/test/CodeGenCXX/char8_t.cpp<br>
cfe/trunk/test/Lexer/char8_t.cpp<br>
cfe/trunk/test/SemaCXX/char8_t.cpp<br>
Modified:<br>
cfe/trunk/include/clang/AST/ASTContext.h<br>
cfe/trunk/include/clang/AST/BuiltinTypes.def<br>
cfe/trunk/include/clang/AST/Type.h<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/include/clang/Basic/LangOptions.def<br>
cfe/trunk/include/clang/Basic/Specifiers.h<br>
cfe/trunk/include/clang/Basic/TokenKinds.def<br>
cfe/trunk/include/clang/Driver/Options.td<br>
cfe/trunk/include/clang/Sema/DeclSpec.h<br>
cfe/trunk/include/clang/Sema/Initialization.h<br>
cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
cfe/trunk/lib/AST/ASTContext.cpp<br>
cfe/trunk/lib/AST/ExprConstant.cpp<br>
cfe/trunk/lib/AST/ItaniumMangle.cpp<br>
cfe/trunk/lib/AST/MicrosoftMangle.cpp<br>
cfe/trunk/lib/AST/NSAPI.cpp<br>
cfe/trunk/lib/AST/Type.cpp<br>
cfe/trunk/lib/AST/TypeLoc.cpp<br>
cfe/trunk/lib/Analysis/PrintfFormatString.cpp<br>
cfe/trunk/lib/Basic/IdentifierTable.cpp<br>
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp<br>
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
cfe/trunk/lib/Format/FormatToken.cpp<br>
cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
cfe/trunk/lib/Frontend/InitPreprocessor.cpp<br>
cfe/trunk/lib/Index/USRGeneration.cpp<br>
cfe/trunk/lib/Lex/PPExpressions.cpp<br>
cfe/trunk/lib/Parse/ParseDecl.cpp<br>
cfe/trunk/lib/Parse/ParseExpr.cpp<br>
cfe/trunk/lib/Parse/ParseExprCXX.cpp<br>
cfe/trunk/lib/Parse/ParseTentative.cpp<br>
cfe/trunk/lib/Sema/DeclSpec.cpp<br>
cfe/trunk/lib/Sema/SemaDecl.cpp<br>
cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
cfe/trunk/lib/Sema/SemaExpr.cpp<br>
cfe/trunk/lib/Sema/SemaInit.cpp<br>
cfe/trunk/lib/Sema/SemaOverload.cpp<br>
cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp<br>
cfe/trunk/lib/Sema/SemaType.cpp<br>
cfe/trunk/lib/Serialization/ASTCommon.cpp<br>
cfe/trunk/lib/Serialization/ASTReader.cpp<br>
cfe/trunk/test/Lexer/cxx-features.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/ASTContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/ASTContext.h (original)<br>
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Apr 30 22:02:45 2018<br>
@@ -999,6 +999,7 @@ public:<br>
CanQualType WCharTy; // [C++ 3.9.1p5].<br>
CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.<br>
CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions.<br>
+ CanQualType Char8Ty; // [C++20 proposal]<br>
CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.<br>
CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.<br>
CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;<br>
<br>
Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)<br>
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Mon Apr 30 22:02:45 2018<br>
@@ -72,6 +72,9 @@ UNSIGNED_TYPE(UChar, UnsignedCharTy)<br>
// 'wchar_t' for targets where it's unsigned<br>
SHARED_SINGLETON_TYPE(UNSIGNED_TYPE(WChar_U, WCharTy))<br>
<br>
+// 'char8_t' in C++20 (proposed)<br>
+UNSIGNED_TYPE(Char8, Char8Ty)<br>
+<br>
// 'char16_t' in C++<br>
UNSIGNED_TYPE(Char16, Char16Ty)<br>
<br>
<br>
Modified: cfe/trunk/include/clang/AST/Type.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Type.h (original)<br>
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr 30 22:02:45 2018<br>
@@ -1777,6 +1777,7 @@ public:<br>
bool isBooleanType() const;<br>
bool isCharType() const;<br>
bool isWideCharType() const;<br>
+ bool isChar8Type() const;<br>
bool isChar16Type() const;<br>
bool isChar32Type() const;<br>
bool isAnyCharacterType() const;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 30 22:02:45 2018<br>
@@ -2421,6 +2421,9 @@ def err_template_different_associated_co<br>
def warn_cxx98_compat_unicode_type : Warning<<br>
"'%0' type specifier is incompatible with C++98">,<br>
InGroup<CXX98Compat>, DefaultIgnore;<br>
+def warn_cxx17_compat_unicode_type : Warning<<br>
+ "'char8_t' type specifier is incompatible with C++ standards before C++20">,<br>
+ InGroup<CXXPre2aCompat>, DefaultIgnore;<br>
<br>
// __make_integer_seq<br>
def err_integer_sequence_negative_length : Error<<br>
@@ -5822,6 +5825,13 @@ def err_array_init_wide_string_into_char<br>
"initializing char array with wide string literal">;<br>
def err_array_init_incompat_wide_string_into_wchar : Error<<br>
"initializing wide char array with incompatible wide string literal">;<br>
+def err_array_init_plain_string_into_char8_t : Error<<br>
+ "initializing 'char8_t' array with plain string literal">;<br>
+def note_array_init_plain_string_into_char8_t : Note<<br>
+ "add 'u8' prefix to form a 'char8_t' string literal">;<br>
+def err_array_init_utf8_string_into_char : Error<<br>
+ "initialization of char array with UTF-8 string literal is not permitted "<br>
+ "by '-fchar8_t'">;<br>
def err_array_init_different_type : Error<<br>
"cannot initialize array %diff{of type $ with array of type $|"<br>
"with different type of array}0,1">;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/LangOptions.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)<br>
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Apr 30 22:02:45 2018<br>
@@ -106,6 +106,7 @@ LANGOPT(LineComment , 1, 0, "'//'<br>
LANGOPT(Bool , 1, 0, "bool, true, and false keywords")<br>
LANGOPT(Half , 1, 0, "half keyword")<br>
LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")<br>
+LANGOPT(Char8 , 1, 0, "char8_t keyword")<br>
LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword")<br>
BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers")<br>
BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Specifiers.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)<br>
+++ cfe/trunk/include/clang/Basic/Specifiers.h Mon Apr 30 22:02:45 2018<br>
@@ -47,6 +47,7 @@ namespace clang {<br>
TST_void,<br>
TST_char,<br>
TST_wchar, // C++ wchar_t<br>
+ TST_char8, // C++20 char8_t (proposed)<br>
TST_char16, // C++11 char16_t<br>
TST_char32, // C++11 char32_t<br>
TST_int,<br>
<br>
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)<br>
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Mon Apr 30 22:02:45 2018<br>
@@ -260,6 +260,7 @@ PUNCTUATOR(caretcaret, "^^")<br>
// BOOLSUPPORT - This is a keyword if 'bool' is a built-in type<br>
// HALFSUPPORT - This is a keyword if 'half' is a built-in type<br>
// WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type<br>
+// CHAR8SUPPORT - This is a keyword if 'char8_t' is a built-in type<br>
//<br>
KEYWORD(auto , KEYALL)<br>
KEYWORD(break , KEYALL)<br>
@@ -380,6 +381,9 @@ KEYWORD(co_yield , KE<br>
MODULES_KEYWORD(module)<br>
MODULES_KEYWORD(import)<br>
<br>
+// C++ char8_t proposal<br>
+KEYWORD(char8_t , CHAR8SUPPORT)<br>
+<br>
// C11 Extension<br>
KEYWORD(_Float16 , KEYALL)<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/Options.td Mon Apr 30 22:02:45 2018<br>
@@ -1525,6 +1525,10 @@ def frtti : Flag<["-"], "frtti">, Group<<br>
def : Flag<["-"], "fsched-interblock">, Group<clang_ignored_f_Group>;<br>
def fshort_enums : Flag<["-"], "fshort-enums">, Group<f_Group>, Flags<[CC1Option]>,<br>
HelpText<"Allocate to an enum type only as many bytes as it needs for the declared range of possible values">;<br>
+def fchar8__t : Flag<["-"], "fchar8_t">, Group<f_Group>, Flags<[CC1Option]>,<br>
+ HelpText<"Enable C++ builtin type char8_t">;<br>
+def fno_char8__t : Flag<["-"], "fno-char8_t">, Group<f_Group>,<br>
+ HelpText<"Disable C++ builtin type char8_t">;<br>
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,<br>
HelpText<"Force wchar_t to be a short unsigned int">;<br>
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,<br>
<br>
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)<br>
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Mon Apr 30 22:02:45 2018<br>
@@ -273,6 +273,7 @@ public:<br>
static const TST TST_void = clang::TST_void;<br>
static const TST TST_char = clang::TST_char;<br>
static const TST TST_wchar = clang::TST_wchar;<br>
+ static const TST TST_char8 = clang::TST_char8;<br>
static const TST TST_char16 = clang::TST_char16;<br>
static const TST TST_char32 = clang::TST_char32;<br>
static const TST TST_int = clang::TST_int;<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Initialization.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Initialization.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Initialization.h Mon Apr 30 22:02:45 2018<br>
@@ -952,6 +952,12 @@ public:<br>
/// literal.<br>
FK_IncompatWideStringIntoWideChar,<br>
<br>
+ /// \brief Initializing char8_t array with plain string literal.<br>
+ FK_PlainStringIntoUTF8Char,<br>
+<br>
+ /// \brief Initializing char array with UTF-8 string literal.<br>
+ FK_UTF8StringIntoPlainChar,<br>
+<br>
/// \brief Array type mismatch.<br>
FK_ArrayTypeMismatch,<br>
<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Apr 30 22:02:45 2018<br>
@@ -936,6 +936,9 @@ namespace serialization {<br>
/// \brief The '_Float16' type<br>
PREDEF_TYPE_FLOAT16_ID = 44,<br>
<br>
+ /// \brief The C++ 'char8_t' type.<br>
+ PREDEF_TYPE_CHAR8_ID = 45,<br>
+<br>
/// \brief OpenCL image types with auto numeration<br>
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \<br>
PREDEF_TYPE_##Id##_ID,<br>
<br>
Modified: cfe/trunk/lib/AST/ASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ASTContext.cpp (original)<br>
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1151,6 +1151,9 @@ void ASTContext::InitBuiltinTypes(const<br>
<br>
WIntTy = getFromTargetType(Target.getWIntType());<br>
<br>
+ // C++20 (proposed)<br>
+ InitBuiltinType(Char8Ty, BuiltinType::Char8);<br>
+<br>
if (LangOpts.CPlusPlus) // C++0x 3.9.1p5, extension for C++<br>
InitBuiltinType(Char16Ty, BuiltinType::Char16);<br>
else // C99<br>
@@ -1739,6 +1742,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con<br>
case BuiltinType::Char_U:<br>
case BuiltinType::UChar:<br>
case BuiltinType::SChar:<br>
+ case BuiltinType::Char8:<br>
Width = Target->getCharWidth();<br>
Align = Target->getCharAlign();<br>
break;<br>
@@ -5456,6 +5460,7 @@ QualType ASTContext::getPromotedIntegerT<br>
// FIXME: Is there some better way to compute this?<br>
if (BT->getKind() == BuiltinType::WChar_S ||<br>
BT->getKind() == BuiltinType::WChar_U ||<br>
+ BT->getKind() == BuiltinType::Char8 ||<br>
BT->getKind() == BuiltinType::Char16 ||<br>
BT->getKind() == BuiltinType::Char32) {<br>
bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;<br>
@@ -6202,6 +6207,7 @@ static char getObjCEncodingForPrimitiveK<br>
switch (kind) {<br>
case BuiltinType::Void: return 'v';<br>
case BuiltinType::Bool: return 'B';<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char_U:<br>
case BuiltinType::UChar: return 'C';<br>
case BuiltinType::Char16:<br>
<br>
Modified: cfe/trunk/lib/AST/ExprConstant.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Apr 30 22:02:45 2018<br>
@@ -7326,6 +7326,7 @@ static int EvaluateBuiltinClassifyType(c<br>
return pointer_type_class;<br>
<br>
case BuiltinType::WChar_U:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
case BuiltinType::ObjCId:<br>
<br>
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)<br>
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Apr 30 22:02:45 2018<br>
@@ -2525,6 +2525,9 @@ void CXXNameMangler::mangleType(const Bu<br>
case BuiltinType::WChar_U:<br>
Out << 'w';<br>
break;<br>
+ case BuiltinType::Char8:<br>
+ Out << "Du";<br>
+ break;<br>
case BuiltinType::Char16:<br>
Out << "Ds";<br>
break;<br>
<br>
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)<br>
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1918,6 +1918,7 @@ void MicrosoftCXXNameMangler::mangleType<br>
Out << "$$T";<br>
break;<br>
<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Float16:<br>
mangleArtificalTagType(TTK_Struct, "_Float16", {"__clang"});<br>
break;<br>
<br>
Modified: cfe/trunk/lib/AST/NSAPI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NSAPI.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NSAPI.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/NSAPI.cpp (original)<br>
+++ cfe/trunk/lib/AST/NSAPI.cpp Mon Apr 30 22:02:45 2018<br>
@@ -436,6 +436,7 @@ NSAPI::getNSNumberFactoryMethodKind(Qual<br>
case BuiltinType::Void:<br>
case BuiltinType::WChar_U:<br>
case BuiltinType::WChar_S:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
case BuiltinType::Int128:<br>
<br>
Modified: cfe/trunk/lib/AST/Type.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/Type.cpp (original)<br>
+++ cfe/trunk/lib/AST/Type.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1763,6 +1763,12 @@ bool Type::isWideCharType() const {<br>
return false;<br>
}<br>
<br>
+bool Type::isChar8Type() const {<br>
+ if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))<br>
+ return BT->getKind() == BuiltinType::Char8;<br>
+ return false;<br>
+}<br>
+<br>
bool Type::isChar16Type() const {<br>
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))<br>
return BT->getKind() == BuiltinType::Char16;<br>
@@ -1785,6 +1791,7 @@ bool Type::isAnyCharacterType() const {<br>
case BuiltinType::Char_U:<br>
case BuiltinType::UChar:<br>
case BuiltinType::WChar_U:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
case BuiltinType::Char_S:<br>
@@ -2419,6 +2426,7 @@ bool Type::isPromotableIntegerType() con<br>
case BuiltinType::UShort:<br>
case BuiltinType::WChar_S:<br>
case BuiltinType::WChar_U:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
return true;<br>
@@ -2655,6 +2663,8 @@ StringRef BuiltinType::getName(const Pri<br>
case WChar_S:<br>
case WChar_U:<br>
return Policy.MSWChar ? "__wchar_t" : "wchar_t";<br>
+ case Char8:<br>
+ return "char8_t";<br>
case Char16:<br>
return "char16_t";<br>
case Char32:<br>
<br>
Modified: cfe/trunk/lib/AST/TypeLoc.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)<br>
+++ cfe/trunk/lib/AST/TypeLoc.cpp Mon Apr 30 22:02:45 2018<br>
@@ -317,6 +317,8 @@ TypeSpecifierType BuiltinTypeLoc::getWri<br>
case BuiltinType::Char_U:<br>
case BuiltinType::Char_S:<br>
return TST_char;<br>
+ case BuiltinType::Char8:<br>
+ return TST_char8;<br>
case BuiltinType::Char16:<br>
return TST_char16;<br>
case BuiltinType::Char32:<br>
<br>
Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)<br>
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Mon Apr 30 22:02:45 2018<br>
@@ -647,6 +647,7 @@ bool PrintfSpecifier::fixType(QualType Q<br>
case BuiltinType::Bool:<br>
case BuiltinType::WChar_U:<br>
case BuiltinType::WChar_S:<br>
+ case BuiltinType::Char8: // FIXME: Treat like 'char'?<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
case BuiltinType::UInt128:<br>
<br>
Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)<br>
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Mon Apr 30 22:02:45 2018<br>
@@ -115,14 +115,15 @@ namespace {<br>
KEYNOOPENCL = 0x02000,<br>
WCHARSUPPORT = 0x04000,<br>
HALFSUPPORT = 0x08000,<br>
- KEYCONCEPTS = 0x10000,<br>
- KEYOBJC2 = 0x20000,<br>
- KEYZVECTOR = 0x40000,<br>
- KEYCOROUTINES = 0x80000,<br>
- KEYMODULES = 0x100000,<br>
- KEYCXX2A = 0x200000,<br>
+ CHAR8SUPPORT = 0x10000,<br>
+ KEYCONCEPTS = 0x20000,<br>
+ KEYOBJC2 = 0x40000,<br>
+ KEYZVECTOR = 0x80000,<br>
+ KEYCOROUTINES = 0x100000,<br>
+ KEYMODULES = 0x200000,<br>
+ KEYCXX2A = 0x400000,<br>
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,<br>
- KEYALL = (0x3fffff & ~KEYNOMS18 &<br>
+ KEYALL = (0x7fffff & ~KEYNOMS18 &<br>
~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.<br>
};<br>
<br>
@@ -151,6 +152,7 @@ static KeywordStatus getKeywordStatus(co<br>
if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;<br>
if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;<br>
if (LangOpts.WChar && (Flags & WCHARSUPPORT)) return KS_Enabled;<br>
+ if (LangOpts.Char8 && (Flags & CHAR8SUPPORT)) return KS_Enabled;<br>
if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) return KS_Enabled;<br>
if (LangOpts.OpenCL && (Flags & KEYOPENCL)) return KS_Enabled;<br>
if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) return KS_Enabled;<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 30 22:02:45 2018<br>
@@ -665,6 +665,7 @@ llvm::DIType *CGDebugInfo::CreateType(co<br>
case BuiltinType::SChar:<br>
Encoding = llvm::dwarf::DW_ATE_signed_char;<br>
break;<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
Encoding = llvm::dwarf::DW_ATE_UTF;<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Mon Apr 30 22:02:45 2018<br>
@@ -437,6 +437,7 @@ llvm::Type *CodeGenTypes::ConvertType(Qu<br>
case BuiltinType::ULongLong:<br>
case BuiltinType::WChar_S:<br>
case BuiltinType::WChar_U:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
ResultType = llvm::IntegerType::get(getLLVMContext(),<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Apr 30 22:02:45 2018<br>
@@ -2706,6 +2706,7 @@ static bool TypeInfoIsInStandardLibrary(<br>
case BuiltinType::LongDouble:<br>
case BuiltinType::Float16:<br>
case BuiltinType::Float128:<br>
+ case BuiltinType::Char8:<br>
case BuiltinType::Char16:<br>
case BuiltinType::Char32:<br>
case BuiltinType::Int128:<br>
@@ -3567,7 +3568,8 @@ void ItaniumCXXABI::EmitFundamentalRTTID<br>
getContext().UnsignedInt128Ty, getContext().HalfTy,<br>
getContext().FloatTy, getContext().DoubleTy,<br>
getContext().LongDoubleTy, getContext().Float128Ty,<br>
- getContext().Char16Ty, getContext().Char32Ty<br>
+ getContext().Char8Ty, getContext().Char16Ty,<br>
+ getContext().Char32Ty<br>
};<br>
for (const QualType &FundamentalType : FundamentalTypes)<br>
EmitFundamentalRTTIDescriptor(FundamentalType, DLLExport);<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Apr 30 22:02:45 2018<br>
@@ -2687,6 +2687,9 @@ static void RenderCharacterOptions(const<br>
CmdArgs.push_back("-fno-signed-char");<br>
}<br>
<br>
+ if (Args.hasFlag(options::OPT_fchar8__t, options::OPT_fno_char8__t, false))<br>
+ CmdArgs.push_back("-fchar8_t");<br>
+<br>
if (const Arg *A = Args.getLastArg(options::OPT_fshort_wchar,<br>
options::OPT_fno_short_wchar)) {<br>
if (A->getOption().matches(options::OPT_fshort_wchar)) {<br>
<br>
Modified: cfe/trunk/lib/Format/FormatToken.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/FormatToken.cpp (original)<br>
+++ cfe/trunk/lib/Format/FormatToken.cpp Mon Apr 30 22:02:45 2018<br>
@@ -57,6 +57,7 @@ bool FormatToken::isSimpleTypeSpecifier(<br>
case tok::kw_bool:<br>
case tok::kw___underlying_type:<br>
case tok::annot_typename:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_typeof:<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Apr 30 22:02:45 2018<br>
@@ -2362,6 +2362,7 @@ static void ParseLangArgs(LangOptions &O<br>
Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);<br>
Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);<br>
Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);<br>
+ Opts.Char8 = Args.hasArg(OPT_fchar8__t);<br>
if (const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {<br>
Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())<br>
.Case("char", 1)<br>
<br>
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Apr 30 22:02:45 2018<br>
@@ -559,6 +559,10 @@ static void InitializeCPlusPlusFeatureTe<br>
Builder.defineMacro("__cpp_experimental_concepts", "1");<br>
if (LangOpts.CoroutinesTS)<br>
Builder.defineMacro("__cpp_coroutines", "201703L");<br>
+<br>
+ // Potential future breaking changes.<br>
+ if (LangOpts.Char8)<br>
+ Builder.defineMacro("__cpp_char8_t", "201803");<br>
}<br>
<br>
static void InitializePredefinedMacros(const TargetInfo &TI,<br>
@@ -939,6 +943,8 @@ static void InitializePredefinedMacros(c<br>
InlineWidthBits));<br>
DEFINE_LOCK_FREE_MACRO(BOOL, Bool);<br>
DEFINE_LOCK_FREE_MACRO(CHAR, Char);<br>
+ if (LangOpts.Char8)<br>
+ DEFINE_LOCK_FREE_MACRO(CHAR8_T, Char); // Treat char8_t like char.<br>
DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);<br>
DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);<br>
DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);<br>
<br>
Modified: cfe/trunk/lib/Index/USRGeneration.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)<br>
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Apr 30 22:02:45 2018<br>
@@ -650,6 +650,8 @@ void USRGenerator::VisitType(QualType T)<br>
c = 'b'; break;<br>
case BuiltinType::UChar:<br>
c = 'c'; break;<br>
+ case BuiltinType::Char8:<br>
+ c = 'u'; break; // FIXME: Check this doesn't collide<br>
case BuiltinType::Char16:<br>
c = 'q'; break;<br>
case BuiltinType::Char32:<br>
<br>
Modified: cfe/trunk/lib/Lex/PPExpressions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPExpressions.cpp Mon Apr 30 22:02:45 2018<br>
@@ -363,7 +363,7 @@ static bool EvaluateValue(PPValue &Resul<br>
NumBits = TI.getChar16Width();<br>
else if (Literal.isUTF32())<br>
NumBits = TI.getChar32Width();<br>
- else<br>
+ else // char or char8_t<br>
NumBits = TI.getCharWidth();<br>
<br>
// Set the width.<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 30 22:02:45 2018<br>
@@ -3587,6 +3587,10 @@ void Parser::ParseDeclarationSpecifiers(<br>
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec,<br>
DiagID, Policy);<br>
break;<br>
+ case tok::kw_char8_t:<br>
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char8, Loc, PrevSpec,<br>
+ DiagID, Policy);<br>
+ break;<br>
case tok::kw_char16_t:<br>
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char16, Loc, PrevSpec,<br>
DiagID, Policy);<br>
@@ -4585,6 +4589,7 @@ bool Parser::isKnownToBeTypeSpecifier(co<br>
case tok::kw_void:<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_int:<br>
@@ -4661,6 +4666,7 @@ bool Parser::isTypeSpecifierQualifier()<br>
case tok::kw_void:<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_int:<br>
@@ -4817,6 +4823,7 @@ bool Parser::isDeclarationSpecifier(bool<br>
case tok::kw_void:<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1224,6 +1224,7 @@ ExprResult Parser::ParseCastExpression(b<br>
case tok::annot_decltype:<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_bool:<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1962,6 +1962,9 @@ void Parser::ParseCXXSimpleTypeSpecifier<br>
case tok::kw_wchar_t:<br>
DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec, DiagID, Policy);<br>
break;<br>
+ case tok::kw_char8_t:<br>
+ DS.SetTypeSpecType(DeclSpec::TST_char8, Loc, PrevSpec, DiagID, Policy);<br>
+ break;<br>
case tok::kw_char16_t:<br>
DS.SetTypeSpecType(DeclSpec::TST_char16, Loc, PrevSpec, DiagID, Policy);<br>
break;<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseTentative.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1052,6 +1052,7 @@ Parser::isExpressionOrTypeSpecifierSimpl<br>
case tok::kw_class:<br>
case tok::kw_typename:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw__Decimal32:<br>
@@ -1523,6 +1524,7 @@ Parser::isCXXDeclarationSpecifier(Parser<br>
<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_bool:<br>
@@ -1614,6 +1616,7 @@ bool Parser::isCXXDeclarationSpecifierAT<br>
// simple-type-specifier<br>
case tok::kw_char:<br>
case tok::kw_wchar_t:<br>
+ case tok::kw_char8_t:<br>
case tok::kw_char16_t:<br>
case tok::kw_char32_t:<br>
case tok::kw_bool:<br>
<br>
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)<br>
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Mon Apr 30 22:02:45 2018<br>
@@ -329,6 +329,7 @@ bool Declarator::isDeclarationOfFunction<br>
case TST_auto_type:<br>
case TST_bool:<br>
case TST_char:<br>
+ case TST_char8:<br>
case TST_char16:<br>
case TST_char32:<br>
case TST_class:<br>
@@ -499,6 +500,7 @@ const char *DeclSpec::getSpecifierName(D<br>
case DeclSpec::TST_void: return "void";<br>
case DeclSpec::TST_char: return "char";<br>
case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";<br>
+ case DeclSpec::TST_char8: return "char8_t";<br>
case DeclSpec::TST_char16: return "char16_t";<br>
case DeclSpec::TST_char32: return "char32_t";<br>
case DeclSpec::TST_int: return "int";<br>
@@ -1202,7 +1204,9 @@ void DeclSpec::Finish(Sema &S, const Pri<br>
StorageClassSpec == SCS_auto)<br>
S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)<br>
<< FixItHint::CreateRemoval(StorageClassSpecLoc);<br>
- if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)<br>
+ if (TypeSpecType == TST_char8)<br>
+ S.Diag(TSTLoc, diag::warn_cxx17_compat_unicode_type);<br>
+ else if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)<br>
S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)<br>
<< (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");<br>
if (Constexpr_specified)<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 30 22:02:45 2018<br>
@@ -148,6 +148,9 @@ bool Sema::isSimpleTypeSpecifier(tok::To<br>
case tok::kw_decltype:<br>
return getLangOpts().CPlusPlus;<br>
<br>
+ case tok::kw_char8_t:<br>
+ return getLangOpts().Char8;<br>
+<br>
default:<br>
break;<br>
}<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Apr 30 22:02:45 2018<br>
@@ -13187,6 +13187,7 @@ bool Sema::CheckLiteralOperatorDeclarati<br>
ParamType->isSpecificBuiltinType(BuiltinType::LongDouble) ||<br>
Context.hasSameType(ParamType, Context.CharTy) ||<br>
Context.hasSameType(ParamType, Context.WideCharTy) ||<br>
+ Context.hasSameType(ParamType, Context.Char8Ty) ||<br>
Context.hasSameType(ParamType, Context.Char16Ty) ||<br>
Context.hasSameType(ParamType, Context.Char32Ty)) {<br>
} else if (const PointerType *Ptr = ParamType->getAs<PointerType>()) {<br>
@@ -13247,10 +13248,12 @@ bool Sema::CheckLiteralOperatorDeclarati<br>
}<br>
<br>
QualType InnerType = PointeeType.getUnqualifiedType();<br>
- // Only const char *, const wchar_t*, const char16_t*, and const char32_t*<br>
- // are allowed as the first parameter to a two-parameter function<br>
+ // Only const char *, const wchar_t*, const char8_t*, const char16_t*, and<br>
+ // const char32_t* are allowed as the first parameter to a two-parameter<br>
+ // function<br>
if (!(Context.hasSameType(InnerType, Context.CharTy) ||<br>
Context.hasSameType(InnerType, Context.WideCharTy) ||<br>
+ Context.hasSameType(InnerType, Context.Char8Ty) ||<br>
Context.hasSameType(InnerType, Context.Char16Ty) ||<br>
Context.hasSameType(InnerType, Context.Char32Ty))) {<br>
Diag((*Param)->getSourceRange().getBegin(),<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1535,6 +1535,8 @@ Sema::ActOnStringLiteral(ArrayRef<Token><br>
CharTy = Context.getWideCharType();<br>
Kind = StringLiteral::Wide;<br>
} else if (Literal.isUTF8()) {<br>
+ if (getLangOpts().Char8)<br>
+ CharTy = Context.Char8Ty;<br>
Kind = StringLiteral::UTF8;<br>
} else if (Literal.isUTF16()) {<br>
CharTy = Context.Char16Ty;<br>
@@ -3094,6 +3096,8 @@ ExprResult Sema::ActOnCharacterConstant(<br>
QualType Ty;<br>
if (Literal.isWide())<br>
Ty = Context.WideCharTy; // L'x' -> wchar_t in C and C++.<br>
+ else if (Literal.isUTF8() && getLangOpts().Char8)<br>
+ Ty = Context.Char8Ty; // u8'x' -> char8_t when it exists.<br>
else if (Literal.isUTF16())<br>
Ty = Context.Char16Ty; // u'x' -> char16_t in C11 and C++11.<br>
else if (Literal.isUTF32())<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaInit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Apr 30 22:02:45 2018<br>
@@ -49,6 +49,8 @@ enum StringInitFailureKind {<br>
SIF_NarrowStringIntoWideChar,<br>
SIF_WideStringIntoChar,<br>
SIF_IncompatWideStringIntoWideChar,<br>
+ SIF_UTF8StringIntoPlainChar,<br>
+ SIF_PlainStringIntoUTF8Char,<br>
SIF_Other<br>
};<br>
<br>
@@ -77,12 +79,21 @@ static StringInitFailureKind IsStringIni<br>
Context.getCanonicalType(AT->getElementType()).getUnqualifiedType();<br>
<br>
switch (SL->getKind()) {<br>
- case StringLiteral::Ascii:<br>
case StringLiteral::UTF8:<br>
+ // char8_t array can be initialized with a UTF-8 string.<br>
+ if (ElemTy->isChar8Type())<br>
+ return SIF_None;<br>
+ LLVM_FALLTHROUGH;<br>
+ case StringLiteral::Ascii:<br>
// char array can be initialized with a narrow string.<br>
// Only allow char x[] = "foo"; not char x[] = L"foo";<br>
if (ElemTy->isCharType())<br>
- return SIF_None;<br>
+ return (SL->getKind() == StringLiteral::UTF8 &&<br>
+ Context.getLangOpts().Char8)<br>
+ ? SIF_UTF8StringIntoPlainChar<br>
+ : SIF_None;<br>
+ if (ElemTy->isChar8Type())<br>
+ return SIF_PlainStringIntoUTF8Char;<br>
if (IsWideCharCompatible(ElemTy, Context))<br>
return SIF_NarrowStringIntoWideChar;<br>
return SIF_Other;<br>
@@ -94,7 +105,7 @@ static StringInitFailureKind IsStringIni<br>
case StringLiteral::UTF16:<br>
if (Context.typesAreCompatible(Context.Char16Ty, ElemTy))<br>
return SIF_None;<br>
- if (ElemTy->isCharType())<br>
+ if (ElemTy->isCharType() || ElemTy->isChar8Type())<br>
return SIF_WideStringIntoChar;<br>
if (IsWideCharCompatible(ElemTy, Context))<br>
return SIF_IncompatWideStringIntoWideChar;<br>
@@ -102,7 +113,7 @@ static StringInitFailureKind IsStringIni<br>
case StringLiteral::UTF32:<br>
if (Context.typesAreCompatible(Context.Char32Ty, ElemTy))<br>
return SIF_None;<br>
- if (ElemTy->isCharType())<br>
+ if (ElemTy->isCharType() || ElemTy->isChar8Type())<br>
return SIF_WideStringIntoChar;<br>
if (IsWideCharCompatible(ElemTy, Context))<br>
return SIF_IncompatWideStringIntoWideChar;<br>
@@ -110,7 +121,7 @@ static StringInitFailureKind IsStringIni<br>
case StringLiteral::Wide:<br>
if (Context.typesAreCompatible(Context.getWideCharType(), ElemTy))<br>
return SIF_None;<br>
- if (ElemTy->isCharType())<br>
+ if (ElemTy->isCharType() || ElemTy->isChar8Type())<br>
return SIF_WideStringIntoChar;<br>
if (IsWideCharCompatible(ElemTy, Context))<br>
return SIF_IncompatWideStringIntoWideChar;<br>
@@ -3185,6 +3196,8 @@ bool InitializationSequence::isAmbiguous<br>
case FK_NarrowStringIntoWideCharArray:<br>
case FK_WideStringIntoCharArray:<br>
case FK_IncompatWideStringIntoWideChar:<br>
+ case FK_PlainStringIntoUTF8Char:<br>
+ case FK_UTF8StringIntoPlainChar:<br>
case FK_AddressOfOverloadFailed: // FIXME: Could do better<br>
case FK_NonConstLValueReferenceBindingToTemporary:<br>
case FK_NonConstLValueReferenceBindingToBitfield:<br>
@@ -5362,6 +5375,12 @@ void InitializationSequence::InitializeF<br>
case SIF_IncompatWideStringIntoWideChar:<br>
SetFailed(FK_IncompatWideStringIntoWideChar);<br>
return;<br>
+ case SIF_PlainStringIntoUTF8Char:<br>
+ SetFailed(FK_PlainStringIntoUTF8Char);<br>
+ return;<br>
+ case SIF_UTF8StringIntoPlainChar:<br>
+ SetFailed(FK_UTF8StringIntoPlainChar);<br>
+ return;<br>
case SIF_Other:<br>
break;<br>
}<br>
@@ -7591,6 +7610,17 @@ bool InitializationSequence::Diagnose(Se<br>
S.Diag(Kind.getLocation(),<br>
diag::err_array_init_incompat_wide_string_into_wchar);<br>
break;<br>
+ case FK_PlainStringIntoUTF8Char:<br>
+ S.Diag(Kind.getLocation(),<br>
+ diag::err_array_init_plain_string_into_char8_t);<br>
+ S.Diag(Args.front()->getLocStart(),<br>
+ diag::note_array_init_plain_string_into_char8_t)<br>
+ << FixItHint::CreateInsertion(Args.front()->getLocStart(), "u8");<br>
+ break;<br>
+ case FK_UTF8StringIntoPlainChar:<br>
+ S.Diag(Kind.getLocation(),<br>
+ diag::err_array_init_utf8_string_into_char);<br>
+ break;<br>
case FK_ArrayTypeMismatch:<br>
case FK_NonConstantArrayInit:<br>
S.Diag(Kind.getLocation(),<br>
@@ -8000,6 +8030,14 @@ void InitializationSequence::dump(raw_os<br>
OS << "incompatible wide string into wide char array";<br>
break;<br>
<br>
+ case FK_PlainStringIntoUTF8Char:<br>
+ OS << "plain string literal into char8_t array";<br>
+ break;<br>
+<br>
+ case FK_UTF8StringIntoPlainChar:<br>
+ OS << "u8 string literal into char array";<br>
+ break;<br>
+<br>
case FK_ArrayTypeMismatch:<br>
OS << "array type mismatch";<br>
break;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Apr 30 22:02:45 2018<br>
@@ -7707,6 +7707,8 @@ class BuiltinOperatorOverloadBuilder {<br>
ArithmeticTypes.push_back(S.Context.BoolTy);<br>
ArithmeticTypes.push_back(S.Context.CharTy);<br>
ArithmeticTypes.push_back(S.Context.WCharTy);<br>
+ if (S.Context.getLangOpts().Char8)<br>
+ ArithmeticTypes.push_back(S.Context.Char8Ty);<br>
ArithmeticTypes.push_back(S.Context.Char16Ty);<br>
ArithmeticTypes.push_back(S.Context.Char32Ty);<br>
ArithmeticTypes.push_back(S.Context.SignedCharTy);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Apr 30 22:02:45 2018<br>
@@ -6771,11 +6771,11 @@ Sema::BuildExpressionFromIntegralTemplat<br>
<br>
Expr *E;<br>
if (T->isAnyCharacterType()) {<br>
- // This does not need to handle u8 character literals because those are<br>
- // of type char, and so can also be covered by an ASCII character literal.<br>
CharacterLiteral::CharacterKind Kind;<br>
if (T->isWideCharType())<br>
Kind = CharacterLiteral::Wide;<br>
+ else if (T->isChar8Type() && getLangOpts().Char8)<br>
+ Kind = CharacterLiteral::UTF8;<br>
else if (T->isChar16Type())<br>
Kind = CharacterLiteral::UTF16;<br>
else if (T->isChar32Type())<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Mon Apr 30 22:02:45 2018<br>
@@ -822,6 +822,7 @@ bool Sema::containsUnexpandedParameterPa<br>
case TST_void:<br>
case TST_char:<br>
case TST_wchar:<br>
+ case TST_char8:<br>
case TST_char16:<br>
case TST_char32:<br>
case TST_int:<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaType.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaType.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Apr 30 22:02:45 2018<br>
@@ -1277,6 +1277,11 @@ static QualType ConvertDeclSpecToType(Ty<br>
Result = Context.getUnsignedWCharType();<br>
}<br>
break;<br>
+ case DeclSpec::TST_char8:<br>
+ assert(DS.getTypeSpecSign() == DeclSpec::TSS_unspecified &&<br>
+ "Unknown TSS value");<br>
+ Result = Context.Char8Ty;<br>
+ break;<br>
case DeclSpec::TST_char16:<br>
assert(DS.getTypeSpecSign() == DeclSpec::TSS_unspecified &&<br>
"Unknown TSS value");<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTCommon.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTCommon.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTCommon.cpp Mon Apr 30 22:02:45 2018<br>
@@ -100,6 +100,9 @@ serialization::TypeIdxFromBuiltin(const<br>
case BuiltinType::NullPtr:<br>
ID = PREDEF_TYPE_NULLPTR_ID;<br>
break;<br>
+ case BuiltinType::Char8:<br>
+ ID = PREDEF_TYPE_CHAR8_ID;<br>
+ break;<br>
case BuiltinType::Char16:<br>
ID = PREDEF_TYPE_CHAR16_ID;<br>
break;<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Apr 30 22:02:45 2018<br>
@@ -6841,6 +6841,9 @@ QualType ASTReader::GetType(TypeID ID) {<br>
case PREDEF_TYPE_NULLPTR_ID:<br>
T = Context.NullPtrTy;<br>
break;<br>
+ case PREDEF_TYPE_CHAR8_ID:<br>
+ T = Context.Char8Ty;<br>
+ break;<br>
case PREDEF_TYPE_CHAR16_ID:<br>
T = Context.Char16Ty;<br>
break;<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/char8_t.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/char8_t.cpp?rev=331244&view=auto" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/char8_t.cpp?rev=331244&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/char8_t.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/char8_t.cpp Mon Apr 30 22:02:45 2018<br>
@@ -0,0 +1,8 @@<br>
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -fchar8_t -triple x86_64-linux %s -o - | FileCheck %s<br>
+<br>
+// CHECK: define void @_Z1fDu(<br>
+void f(char8_t c) {}<br>
+<br>
+// CHECK: define void @_Z1gIiEvDTplplcvT__ELA4_KDuELDu114EE<br>
+template<typename T> void g(decltype(T() + u8"foo" + u8'r')) {}<br>
+template void g<int>(const char8_t*);<br>
<br>
Added: cfe/trunk/test/Lexer/char8_t.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/char8_t.cpp?rev=331244&view=auto" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/char8_t.cpp?rev=331244&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/char8_t.cpp (added)<br>
+++ cfe/trunk/test/Lexer/char8_t.cpp Mon Apr 30 22:02:45 2018<br>
@@ -0,0 +1,17 @@<br>
+// RUN: %clang_cc1 -std=c++2a -verify %s<br>
+// RUN: %clang_cc1 -std=c++2a -verify %s -fchar8_t<br>
+<br>
+#if defined(__cpp_char8_t) && __is_identifier(char8_t)<br>
+#error char8_t is an identifier under -fchar8_t<br>
+#endif<br>
+<br>
+#if !defined(__cpp_char8_t) && !__is_identifier(char8_t)<br>
+#error char8_t is a keyword under -fno-char8_t<br>
+#endif<br>
+<br>
+char8_t c8t;<br>
+#ifndef __cpp_char8_t<br>
+// expected-error@-2 {{unknown type}}<br>
+#else<br>
+// expected-no-diagnostics<br>
+#endif<br>
<br>
Modified: cfe/trunk/test/Lexer/cxx-features.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=331244&r1=331243&r2=331244&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=331244&r1=331243&r2=331244&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)<br>
+++ cfe/trunk/test/Lexer/cxx-features.cpp Mon Apr 30 22:02:45 2018<br>
@@ -6,6 +6,7 @@<br>
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s<br>
// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation<br>
// RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s<br>
+// RUN: %clang_cc1 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s<br>
<br>
// expected-no-diagnostics<br>
<br>
@@ -242,3 +243,9 @@<br>
#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0)<br>
#error "wrong value for __cpp_coroutines"<br>
#endif<br>
+<br>
+// --- not-yet-standard features --<br>
+<br>
+#if defined(CHAR8_T) ? check(char8_t, 201803, 201803, 201803, 201803) : check(char8_t, 0, 0, 0, 0)<br>
+#error "wrong value for __cpp_char8_t"<br>
+#endif<br>
<br>
Added: cfe/trunk/test/SemaCXX/char8_t.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/char8_t.cpp?rev=331244&view=auto" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/char8_t.cpp?rev=331244&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/char8_t.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/char8_t.cpp Mon Apr 30 22:02:45 2018<br>
@@ -0,0 +1,44 @@<br>
+// RUN: %clang_cc1 -fchar8_t -std=c++2a -verify %s<br>
+<br>
+char8_t a = u8'a';<br>
+char8_t b[] = u8"foo";<br>
+char8_t c = 'a';<br>
+char8_t d[] = "foo"; // expected-error {{initializing 'char8_t' array with plain string literal}} expected-note {{add 'u8' prefix}}<br>
+<br>
+char e = u8'a';<br>
+char f[] = u8"foo"; // expected-error {{initialization of char array with UTF-8 string literal is not permitted by '-fchar8_t'}}<br>
+char g = 'a';<br>
+char h[] = "foo";<br>
+<br>
+void disambig() {<br>
+ char8_t (a) = u8'x';<br>
+}<br>
+<br>
+void operator""_a(char);<br>
+void operator""_a(const char*, decltype(sizeof(0)));<br>
+<br>
+void test_udl1() {<br>
+ int &x = u8'a'_a; // expected-error {{no matching literal operator}}<br>
+ float &y = u8"a"_a; // expected-error {{no matching literal operator}}<br>
+}<br>
+<br>
+int &operator""_a(char8_t);<br>
+float &operator""_a(const char8_t*, decltype(sizeof(0)));<br>
+<br>
+void test_udl2() {<br>
+ int &x = u8'a'_a;<br>
+ float &y = u8"a"_a;<br>
+}<br>
+<br>
+template<typename E, typename T> void check(T &&t) {<br>
+ using Check = E;<br>
+ using Check = T;<br>
+}<br>
+void check_deduction() {<br>
+ check<char8_t>(u8'a');<br>
+ check<const char8_t(&)[5]>(u8"a\u1000");<br>
+}<br>
+<br>
+static_assert(sizeof(char8_t) == 1);<br>
+static_assert(char8_t(-1) > 0);<br>
+static_assert(u8"\u0080"[0] > 0);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div>