/// is NOT null-terminated, and the length of the string is determined by
/// calling getByteLength(). The C type for a string is always a
/// ConstantArrayType.
+///
+/// Note that strings in C can be formed by concatenation of multiple string
+/// literal pptokens in trnaslation phase #6. This keeps track of the locations
+/// of each of these pieces.
class StringLiteral : public Expr {
const char *StrData;
unsigned ByteLength;
bool IsWide;
- // If the StringLiteral was composed using token pasting, both locations
- // are needed. If not (the common case), firstTokLoc == lastTokLoc.
unsigned NumConcatenated;
SourceLocation TokLocs[1];
public:
private:
Action::OwningExprResult CheckFunctionCall(FunctionDecl *FDecl,
CallExpr *TheCall);
- bool CheckBuiltinCFStringArgument(Expr* Arg);
+ bool CheckObjCString(Expr *Arg);
bool SemaBuiltinVAStart(CallExpr *TheCall);
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
bool SemaBuiltinStackAddress(CallExpr *TheCall);
case Builtin::BI__builtin___CFStringMakeConstantString:
assert(TheCall->getNumArgs() == 1 &&
"Wrong # arguments to builtin CFStringMakeConstantString");
- if (CheckBuiltinCFStringArgument(TheCall->getArg(0)))
+ if (CheckObjCString(TheCall->getArg(0)))
return ExprError();
return move(TheCallResult);
case Builtin::BI__builtin_stdarg_start:
return move(TheCallResult);
}
-/// CheckBuiltinCFStringArgument - Checks that the argument to the builtin
+/// CheckObjCString - Checks that the argument to the builtin
/// CFString constructor is correct
-bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) {
+bool Sema::CheckObjCString(Expr *Arg) {
Arg = Arg->IgnoreParenCasts();
-
StringLiteral *Literal = dyn_cast<StringLiteral>(Arg);
if (!Literal || Literal->isWide()) {
AtLoc);
}
- if (CheckBuiltinCFStringArgument(S))
+ // Verify that this composite string is acceptable for ObjC strings.
+ if (CheckObjCString(S))
return true;
if (Context.getObjCConstantStringInterface().isNull()) {