diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1786,7 +1786,7 @@ /// * An array of getByteLength() char used to store the string data. public: - enum StringKind { Ascii, Wide, UTF8, UTF16, UTF32 }; + enum StringKind { Ordinary, Wide, UTF8, UTF16, UTF32 }; private: unsigned numTrailingObjects(OverloadToken) const { return 1; } @@ -1883,7 +1883,7 @@ return static_cast(StringLiteralBits.Kind); } - bool isAscii() const { return getKind() == Ascii; } + bool isOrdinary() const { return getKind() == Ordinary; } bool isWide() const { return getKind() == Wide; } bool isUTF8() const { return getKind() == UTF8; } bool isUTF16() const { return getKind() == UTF16; } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -11901,7 +11901,7 @@ StringLiteral *&Result = StringLiteralCache[Key]; if (!Result) Result = StringLiteral::Create( - *this, Key, StringLiteral::Ascii, + *this, Key, StringLiteral::Ordinary, /*Pascal*/ false, getStringLiteralArrayType(CharTy, Key.size()), SourceLocation()); return Result; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1023,7 +1023,7 @@ StringKind SK) { unsigned CharByteWidth = 0; switch (SK) { - case Ascii: + case Ordinary: case UTF8: CharByteWidth = Target.getCharWidth(); break; @@ -1123,7 +1123,8 @@ void StringLiteral::outputString(raw_ostream &OS) const { switch (getKind()) { - case Ascii: break; // no prefix. + case Ordinary: + break; // no prefix. case Wide: OS << 'L'; break; case UTF8: OS << "u8"; break; case UTF16: OS << 'u'; break; @@ -1231,7 +1232,7 @@ const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken, unsigned *StartTokenByteOffset) const { - assert((getKind() == StringLiteral::Ascii || + assert((getKind() == StringLiteral::Ordinary || getKind() == StringLiteral::UTF8) && "Only narrow string literals are currently supported"); diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -8783,7 +8783,7 @@ ArrayType::Normal, 0); StringLiteral *SL = - StringLiteral::Create(Info.Ctx, ResultStr, StringLiteral::Ascii, + StringLiteral::Create(Info.Ctx, ResultStr, StringLiteral::Ordinary, /*Pascal*/ false, ArrayTy, E->getLocation()); evaluateLValue(SL, Result); diff --git a/clang/lib/AST/OSLog.cpp b/clang/lib/AST/OSLog.cpp --- a/clang/lib/AST/OSLog.cpp +++ b/clang/lib/AST/OSLog.cpp @@ -201,7 +201,7 @@ } const StringLiteral *Lit = cast(StringArg->IgnoreParenCasts()); - assert(Lit && (Lit->isAscii() || Lit->isUTF8())); + assert(Lit && (Lit->isOrdinary() || Lit->isUTF8())); StringRef Data = Lit->getString(); OSLogFormatStringHandler H(VarArgs); ParsePrintfString(H, Data.begin(), Data.end(), Ctx.getLangOpts(), diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -601,7 +601,7 @@ QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, ArrayType::Normal, 0); - return StringLiteral::Create(*Context, Str, StringLiteral::Ascii, + return StringLiteral::Create(*Context, Str, StringLiteral::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } }; diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -500,7 +500,7 @@ QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, ArrayType::Normal, 0); - return StringLiteral::Create(*Context, Str, StringLiteral::Ascii, + return StringLiteral::Create(*Context, Str, StringLiteral::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } }; diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1206,7 +1206,7 @@ // Also reject wide string literals. if (StringLiteral *MessageStringLiteral = cast_or_null(MessageExpr.get())) { - if (!MessageStringLiteral->isAscii()) { + if (!MessageStringLiteral->isOrdinary()) { Diag(MessageStringLiteral->getSourceRange().getBegin(), diag::err_expected_string_literal) << /*Source='availability attribute'*/ 2; diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1574,7 +1574,7 @@ ExprResult AsmString(ParseStringLiteralExpression()); if (!AsmString.isInvalid()) { const auto *SL = cast(AsmString.get()); - if (!SL->isAscii()) { + if (!SL->isOrdinary()) { Diag(Tok, diag::err_asm_operand_wide_string_literal) << SL->isWide() << SL->getSourceRange(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -161,7 +161,7 @@ // Second argument should be a constant string. Expr *StrArg = TheCall->getArg(1)->IgnoreParenCasts(); StringLiteral *Literal = dyn_cast(StrArg); - if (!Literal || !Literal->isAscii()) { + if (!Literal || !Literal->isOrdinary()) { S.Diag(StrArg->getBeginLoc(), diag::err_builtin_annotation_second_arg) << StrArg->getSourceRange(); return true; @@ -1139,7 +1139,7 @@ if (!Format) return; - if (!Format->isAscii() && !Format->isUTF8()) + if (!Format->isOrdinary() && !Format->isUTF8()) return; auto Diagnose = [&](unsigned ArgIndex, unsigned DestSize, @@ -1184,7 +1184,7 @@ if (auto *Format = dyn_cast(FormatExpr)) { - if (!Format->isAscii() && !Format->isUTF8()) + if (!Format->isOrdinary() && !Format->isUTF8()) return; StringRef FormatStrRef = Format->getString(); @@ -6938,7 +6938,7 @@ Arg = Arg->IgnoreParenCasts(); StringLiteral *Literal = dyn_cast(Arg); - if (!Literal || !Literal->isAscii()) { + if (!Literal || !Literal->isOrdinary()) { Diag(Arg->getBeginLoc(), diag::err_cfstring_literal_not_string_constant) << Arg->getSourceRange(); return true; @@ -6973,7 +6973,7 @@ } } - if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) { + if (!Literal || (!Literal->isOrdinary() && !Literal->isUTF8())) { return ExprError( Diag(Arg->getBeginLoc(), diag::err_os_log_format_not_string_constant) << Arg->getSourceRange()); @@ -8390,7 +8390,7 @@ QualType getType() const { return FExpr->getType(); } - bool isAscii() const { return FExpr->isAscii(); } + bool isAscii() const { return FExpr->isOrdinary(); } bool isWide() const { return FExpr->isWide(); } bool isUTF8() const { return FExpr->isUTF8(); } bool isUTF16() const { return FExpr->isUTF16(); } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -345,7 +345,7 @@ if (ArgLocation) *ArgLocation = E->getBeginLoc(); - if (!Literal || !Literal->isAscii()) { + if (!Literal || !Literal->isOrdinary()) { Diag(E->getBeginLoc(), diag::err_attribute_argument_type) << CI << AANT_ArgumentString; return false; @@ -620,7 +620,7 @@ if (const auto *StrLit = dyn_cast(ArgExp)) { if (StrLit->getLength() == 0 || - (StrLit->isAscii() && StrLit->getString() == StringRef("*"))) { + (StrLit->isOrdinary() && StrLit->getString() == StringRef("*"))) { // Pass empty strings to the analyzer without warnings. // Treat "*" as the universal lock. Args.push_back(ArgExp); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -16274,7 +16274,7 @@ Expr *LangStr, SourceLocation LBraceLoc) { StringLiteral *Lit = cast(LangStr); - if (!Lit->isAscii()) { + if (!Lit->isOrdinary()) { Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_not_ascii) << LangStr->getSourceRange(); return nullptr; @@ -16589,7 +16589,7 @@ llvm::raw_svector_ostream Msg(MsgBuffer); if (AssertMessage) { const auto *MsgStr = cast(AssertMessage); - if (MsgStr->isAscii()) + if (MsgStr->isOrdinary()) Msg << MsgStr->getString(); else MsgStr->printPretty(Msg, nullptr, getPrintingPolicy()); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1867,7 +1867,7 @@ StringTokLocs.push_back(Tok.getLocation()); QualType CharTy = Context.CharTy; - StringLiteral::StringKind Kind = StringLiteral::Ascii; + StringLiteral::StringKind Kind = StringLiteral::Ordinary; if (Literal.isWide()) { CharTy = Context.getWideCharType(); Kind = StringLiteral::Wide; @@ -3568,7 +3568,7 @@ ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr, ArrayType::Normal, /*IndexTypeQuals*/ 0); - SL = StringLiteral::Create(Context, Str, StringLiteral::Ascii, + SL = StringLiteral::Create(Context, Str, StringLiteral::Ordinary, /*Pascal*/ false, ResTy, Loc); } } @@ -3834,9 +3834,10 @@ QualType StrTy = Context.getConstantArrayType( Context.adjustStringLiteralBaseType(Context.CharTy.withConst()), llvm::APInt(32, Length + 1), nullptr, ArrayType::Normal, 0); - Expr *Lit = StringLiteral::Create( - Context, StringRef(TokSpelling.data(), Length), StringLiteral::Ascii, - /*Pascal*/false, StrTy, &TokLoc, 1); + Expr *Lit = + StringLiteral::Create(Context, StringRef(TokSpelling.data(), Length), + StringLiteral::Ordinary, + /*Pascal*/ false, StrTy, &TokLoc, 1); return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc); } @@ -16753,7 +16754,7 @@ if (!PT->isObjCIdType() && !(ID && ID->getIdentifier()->isStr("NSString"))) return false; - if (!SL->isAscii()) + if (!SL->isOrdinary()) return false; if (Diagnose) { diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4009,7 +4009,7 @@ case StringLiteral::UTF32: // We don't allow UTF literals to be implicitly converted break; - case StringLiteral::Ascii: + case StringLiteral::Ordinary: return (ToPointeeType->getKind() == BuiltinType::Char_U || ToPointeeType->getKind() == BuiltinType::Char_S); case StringLiteral::Wide: diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -50,7 +50,7 @@ S = cast(E); // ObjC strings can't be wide or UTF. - if (!S->isAscii()) { + if (!S->isOrdinary()) { Diag(S->getBeginLoc(), diag::err_cfstring_literal_not_string_constant) << S->getSourceRange(); return true; @@ -70,7 +70,7 @@ QualType StrTy = Context.getConstantArrayType( CAT->getElementType(), llvm::APInt(32, StrBuf.size() + 1), nullptr, CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers()); - S = StringLiteral::Create(Context, StrBuf, StringLiteral::Ascii, + S = StringLiteral::Create(Context, StrBuf, StringLiteral::Ordinary, /*Pascal=*/false, StrTy, &StrLocs[0], StrLocs.size()); } @@ -448,7 +448,7 @@ } // If this is potentially an Objective-C string literal, add the '@'. else if (StringLiteral *String = dyn_cast(OrigElement)) { - if (String->isAscii()) { + if (String->isOrdinary()) { S.Diag(OrigElement->getBeginLoc(), diag::err_box_literal_collection) << 0 << OrigElement->getSourceRange() << FixItHint::CreateInsertion(OrigElement->getBeginLoc(), "@"); @@ -533,7 +533,7 @@ if (CE->getCastKind() == CK_ArrayToPointerDecay) if (auto *SL = dyn_cast(CE->getSubExpr()->IgnoreParens())) { - assert((SL->isAscii() || SL->isUTF8()) && + assert((SL->isOrdinary() || SL->isUTF8()) && "unexpected character encoding"); StringRef Str = SL->getString(); const llvm::UTF8 *StrBegin = Str.bytes_begin(); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -87,7 +87,7 @@ if (ElemTy->isChar8Type()) return SIF_None; LLVM_FALLTHROUGH; - case StringLiteral::Ascii: + case StringLiteral::Ordinary: // char array can be initialized with a narrow string. // Only allow char x[] = "foo"; not char x[] = L"foo"; if (ElemTy->isCharType()) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -254,7 +254,7 @@ SmallVector OutputConstraintInfos; // The parser verifies that there is a string literal here. - assert(AsmString->isAscii()); + assert(AsmString->isOrdinary()); FunctionDecl *FD = dyn_cast(getCurLexicalContext()); llvm::StringMap FeatureMap; @@ -262,7 +262,7 @@ for (unsigned i = 0; i != NumOutputs; i++) { StringLiteral *Literal = Constraints[i]; - assert(Literal->isAscii()); + assert(Literal->isOrdinary()); StringRef OutputName; if (Names[i]) @@ -353,7 +353,7 @@ for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) { StringLiteral *Literal = Constraints[i]; - assert(Literal->isAscii()); + assert(Literal->isOrdinary()); StringRef InputName; if (Names[i]) @@ -459,7 +459,7 @@ // Check that the clobbers are valid. for (unsigned i = 0; i != NumClobbers; i++) { StringLiteral *Literal = Clobbers[i]; - assert(Literal->isAscii()); + assert(Literal->isOrdinary()); StringRef Clobber = Literal->getString();