mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 08:06:08 +00:00
[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
"Ascii" StringLiteral instances are actually narrow strings that are UTF-8 encoded and do not have an encoding prefix. (UTF8 StringLiteral are also UTF-8 encoded strings, but with the u8 prefix. To avoid possible confusion both with actuall ASCII strings, and with future works extending the set of literal encodings supported by clang, this rename StringLiteral::isAscii() to isOrdinary(), matching C++ standard terminology. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D128762
This commit is contained in:
parent
a7d6c3effe
commit
a9a60f20e6
@ -44,7 +44,7 @@ bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
|
||||
const StringLiteral *Literal,
|
||||
const CharsBitSet &DisallowedChars) {
|
||||
// FIXME: Handle L"", u8"", u"" and U"" literals.
|
||||
if (!Literal->isAscii())
|
||||
if (!Literal->isOrdinary())
|
||||
return false;
|
||||
|
||||
for (const unsigned char C : Literal->getBytes())
|
||||
|
@ -46,7 +46,7 @@ REGISTER_TWEAK(RawStringLiteral)
|
||||
static bool isNormalString(const StringLiteral &Str, SourceLocation Cursor,
|
||||
SourceManager &SM) {
|
||||
// All chunks must be normal ASCII strings, not u8"..." etc.
|
||||
if (!Str.isAscii())
|
||||
if (!Str.isOrdinary())
|
||||
return false;
|
||||
SourceLocation LastTokenBeforeCursor;
|
||||
for (auto I = Str.tokloc_begin(), E = Str.tokloc_end(); I != E; ++I) {
|
||||
|
@ -1786,7 +1786,7 @@ class StringLiteral final
|
||||
/// * 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<unsigned>) const { return 1; }
|
||||
@ -1883,7 +1883,7 @@ public:
|
||||
return static_cast<StringKind>(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; }
|
||||
|
@ -198,7 +198,7 @@ public:
|
||||
tok::TokenKind kind);
|
||||
|
||||
bool hadError() const { return HadError; }
|
||||
bool isAscii() const { return Kind == tok::char_constant; }
|
||||
bool isOrdinary() const { return Kind == tok::char_constant; }
|
||||
bool isWide() const { return Kind == tok::wide_char_constant; }
|
||||
bool isUTF8() const { return Kind == tok::utf8_char_constant; }
|
||||
bool isUTF16() const { return Kind == tok::utf16_char_constant; }
|
||||
@ -263,7 +263,7 @@ public:
|
||||
/// checking of the string literal and emit errors and warnings.
|
||||
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const;
|
||||
|
||||
bool isAscii() const { return Kind == tok::string_literal; }
|
||||
bool isOrdinary() const { return Kind == tok::string_literal; }
|
||||
bool isWide() const { return Kind == tok::wide_string_literal; }
|
||||
bool isUTF8() const { return Kind == tok::utf8_string_literal; }
|
||||
bool isUTF16() const { return Kind == tok::utf16_string_literal; }
|
||||
|
@ -11901,7 +11901,7 @@ ASTContext::getPredefinedStringLiteralFromCache(StringRef Key) const {
|
||||
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;
|
||||
|
@ -1023,7 +1023,7 @@ unsigned StringLiteral::mapCharByteWidth(TargetInfo const &Target,
|
||||
StringKind SK) {
|
||||
unsigned CharByteWidth = 0;
|
||||
switch (SK) {
|
||||
case Ascii:
|
||||
case Ordinary:
|
||||
case UTF8:
|
||||
CharByteWidth = Target.getCharWidth();
|
||||
break;
|
||||
@ -1123,7 +1123,8 @@ StringLiteral *StringLiteral::CreateEmpty(const ASTContext &Ctx,
|
||||
|
||||
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 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
|
||||
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");
|
||||
|
||||
|
@ -8783,7 +8783,7 @@ public:
|
||||
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);
|
||||
|
@ -201,7 +201,7 @@ bool clang::analyze_os_log::computeOSLogBufferLayout(
|
||||
}
|
||||
|
||||
const StringLiteral *Lit = cast<StringLiteral>(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(),
|
||||
|
@ -601,7 +601,7 @@ namespace {
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
@ -500,7 +500,7 @@ namespace {
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
@ -1681,7 +1681,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
|
||||
// If we see bad encoding for unprefixed character literals, warn and
|
||||
// simply copy the byte values, for compatibility with gcc and
|
||||
// older versions of clang.
|
||||
bool NoErrorOnBadEncoding = isAscii();
|
||||
bool NoErrorOnBadEncoding = isOrdinary();
|
||||
unsigned Msg = diag::err_bad_character_encoding;
|
||||
if (NoErrorOnBadEncoding)
|
||||
Msg = diag::warn_bad_character_encoding;
|
||||
@ -1731,9 +1731,9 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
|
||||
unsigned NumCharsSoFar = buffer_begin - &codepoint_buffer.front();
|
||||
|
||||
if (NumCharsSoFar > 1) {
|
||||
if (isAscii() && NumCharsSoFar == 4)
|
||||
if (isOrdinary() && NumCharsSoFar == 4)
|
||||
PP.Diag(Loc, diag::warn_four_char_character_literal);
|
||||
else if (isAscii())
|
||||
else if (isOrdinary())
|
||||
PP.Diag(Loc, diag::warn_multichar_character_literal);
|
||||
else {
|
||||
PP.Diag(Loc, diag::err_multichar_character_literal) << (isWide() ? 0 : 1);
|
||||
@ -1749,7 +1749,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
|
||||
// Narrow character literals act as though their value is concatenated
|
||||
// in this implementation, but warn on overflow.
|
||||
bool multi_char_too_long = false;
|
||||
if (isAscii() && isMultiChar()) {
|
||||
if (isOrdinary() && isMultiChar()) {
|
||||
LitVal = 0;
|
||||
for (size_t i = 0; i < NumCharsSoFar; ++i) {
|
||||
// check for enough leading zeros to shift into
|
||||
@ -1773,7 +1773,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
|
||||
// if 'char' is signed for this target (C99 6.4.4.4p10). Note that multiple
|
||||
// character constants are not sign extended in the this implementation:
|
||||
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
|
||||
if (isAscii() && NumCharsSoFar == 1 && (Value & 128) &&
|
||||
if (isOrdinary() && NumCharsSoFar == 1 && (Value & 128) &&
|
||||
PP.getLangOpts().CharIsSigned)
|
||||
Value = (signed char)Value;
|
||||
}
|
||||
@ -1878,7 +1878,7 @@ void StringLiteralParser::init(ArrayRef<Token> StringToks){
|
||||
// Remember if we see any wide or utf-8/16/32 strings.
|
||||
// Also check for illegal concatenations.
|
||||
if (StringToks[i].isNot(Kind) && StringToks[i].isNot(tok::string_literal)) {
|
||||
if (isAscii()) {
|
||||
if (isOrdinary()) {
|
||||
Kind = StringToks[i].getKind();
|
||||
} else {
|
||||
if (Diags)
|
||||
@ -2162,7 +2162,7 @@ bool StringLiteralParser::CopyStringFragment(const Token &Tok,
|
||||
// If we see bad encoding for unprefixed string literals, warn and
|
||||
// simply copy the byte values, for compatibility with gcc and older
|
||||
// versions of clang.
|
||||
bool NoErrorOnBadEncoding = isAscii();
|
||||
bool NoErrorOnBadEncoding = isOrdinary();
|
||||
if (NoErrorOnBadEncoding) {
|
||||
memcpy(ResultPtr, Fragment.data(), Fragment.size());
|
||||
ResultPtr += Fragment.size();
|
||||
|
@ -1423,7 +1423,7 @@ void Preprocessor::HandleLineDirective() {
|
||||
} else {
|
||||
// Parse and validate the string, converting it into a unique ID.
|
||||
StringLiteralParser Literal(StrTok, *this);
|
||||
assert(Literal.isAscii() && "Didn't allow wide strings in");
|
||||
assert(Literal.isOrdinary() && "Didn't allow wide strings in");
|
||||
if (Literal.hadError) {
|
||||
DiscardUntilEndOfDirective();
|
||||
return;
|
||||
@ -1574,7 +1574,7 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
|
||||
} else {
|
||||
// Parse and validate the string, converting it into a unique ID.
|
||||
StringLiteralParser Literal(StrTok, *this);
|
||||
assert(Literal.isAscii() && "Didn't allow wide strings in");
|
||||
assert(Literal.isOrdinary() && "Didn't allow wide strings in");
|
||||
if (Literal.hadError) {
|
||||
DiscardUntilEndOfDirective();
|
||||
return;
|
||||
|
@ -1353,7 +1353,7 @@ bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String,
|
||||
|
||||
// Concatenate and parse the strings.
|
||||
StringLiteralParser Literal(StrToks, *this);
|
||||
assert(Literal.isAscii() && "Didn't allow wide strings in");
|
||||
assert(Literal.isOrdinary() && "Didn't allow wide strings in");
|
||||
|
||||
if (Literal.hadError)
|
||||
return false;
|
||||
|
@ -1206,7 +1206,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
|
||||
// Also reject wide string literals.
|
||||
if (StringLiteral *MessageStringLiteral =
|
||||
cast_or_null<StringLiteral>(MessageExpr.get())) {
|
||||
if (!MessageStringLiteral->isAscii()) {
|
||||
if (!MessageStringLiteral->isOrdinary()) {
|
||||
Diag(MessageStringLiteral->getSourceRange().getBegin(),
|
||||
diag::err_expected_string_literal)
|
||||
<< /*Source='availability attribute'*/ 2;
|
||||
|
@ -1574,7 +1574,7 @@ ExprResult Parser::ParseAsmStringLiteral(bool ForAsmLabel) {
|
||||
ExprResult AsmString(ParseStringLiteralExpression());
|
||||
if (!AsmString.isInvalid()) {
|
||||
const auto *SL = cast<StringLiteral>(AsmString.get());
|
||||
if (!SL->isAscii()) {
|
||||
if (!SL->isOrdinary()) {
|
||||
Diag(Tok, diag::err_asm_operand_wide_string_literal)
|
||||
<< SL->isWide()
|
||||
<< SL->getSourceRange();
|
||||
|
@ -161,7 +161,7 @@ static bool SemaBuiltinAnnotation(Sema &S, CallExpr *TheCall) {
|
||||
// Second argument should be a constant string.
|
||||
Expr *StrArg = TheCall->getArg(1)->IgnoreParenCasts();
|
||||
StringLiteral *Literal = dyn_cast<StringLiteral>(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 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
|
||||
if (!Format)
|
||||
return;
|
||||
|
||||
if (!Format->isAscii() && !Format->isUTF8())
|
||||
if (!Format->isOrdinary() && !Format->isUTF8())
|
||||
return;
|
||||
|
||||
auto Diagnose = [&](unsigned ArgIndex, unsigned DestSize,
|
||||
@ -1184,7 +1184,7 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
|
||||
|
||||
if (auto *Format = dyn_cast<StringLiteral>(FormatExpr)) {
|
||||
|
||||
if (!Format->isAscii() && !Format->isUTF8())
|
||||
if (!Format->isOrdinary() && !Format->isUTF8())
|
||||
return;
|
||||
|
||||
StringRef FormatStrRef = Format->getString();
|
||||
@ -6938,7 +6938,7 @@ bool Sema::CheckObjCString(Expr *Arg) {
|
||||
Arg = Arg->IgnoreParenCasts();
|
||||
StringLiteral *Literal = dyn_cast<StringLiteral>(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 @@ ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ class FormatStringLiteral {
|
||||
|
||||
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(); }
|
||||
|
@ -345,7 +345,7 @@ bool Sema::checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI,
|
||||
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 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
|
||||
|
||||
if (const auto *StrLit = dyn_cast<StringLiteral>(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);
|
||||
|
@ -16274,7 +16274,7 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc,
|
||||
Expr *LangStr,
|
||||
SourceLocation LBraceLoc) {
|
||||
StringLiteral *Lit = cast<StringLiteral>(LangStr);
|
||||
if (!Lit->isAscii()) {
|
||||
if (!Lit->isOrdinary()) {
|
||||
Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_not_ascii)
|
||||
<< LangStr->getSourceRange();
|
||||
return nullptr;
|
||||
@ -16594,7 +16594,7 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
|
||||
llvm::raw_svector_ostream Msg(MsgBuffer);
|
||||
if (AssertMessage) {
|
||||
const auto *MsgStr = cast<StringLiteral>(AssertMessage);
|
||||
if (MsgStr->isAscii())
|
||||
if (MsgStr->isOrdinary())
|
||||
Msg << '"' << MsgStr->getString() << '"';
|
||||
else
|
||||
MsgStr->printPretty(Msg, nullptr, getPrintingPolicy());
|
||||
|
@ -1867,7 +1867,7 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
|
||||
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 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
|
||||
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 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
|
||||
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 @@ bool Sema::CheckConversionToObjCLiteral(QualType DstType, Expr *&Exp,
|
||||
if (!PT->isObjCIdType() &&
|
||||
!(ID && ID->getIdentifier()->isStr("NSString")))
|
||||
return false;
|
||||
if (!SL->isAscii())
|
||||
if (!SL->isOrdinary())
|
||||
return false;
|
||||
|
||||
if (Diagnose) {
|
||||
|
@ -4009,7 +4009,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
|
||||
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:
|
||||
|
@ -50,7 +50,7 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
|
||||
S = cast<StringLiteral>(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 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
|
||||
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 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
|
||||
}
|
||||
// If this is potentially an Objective-C string literal, add the '@'.
|
||||
else if (StringLiteral *String = dyn_cast<StringLiteral>(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 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
|
||||
if (CE->getCastKind() == CK_ArrayToPointerDecay)
|
||||
if (auto *SL =
|
||||
dyn_cast<StringLiteral>(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();
|
||||
|
@ -87,7 +87,7 @@ static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT,
|
||||
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())
|
||||
|
@ -254,7 +254,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
|
||||
SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
|
||||
|
||||
// The parser verifies that there is a string literal here.
|
||||
assert(AsmString->isAscii());
|
||||
assert(AsmString->isOrdinary());
|
||||
|
||||
FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext());
|
||||
llvm::StringMap<bool> FeatureMap;
|
||||
@ -262,7 +262,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
|
||||
|
||||
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 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
|
||||
|
||||
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 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
|
||||
// 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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user