From: Chris Lattner Date: Wed, 18 Feb 2009 06:01:06 +0000 (+0000) Subject: rename CheckBuiltinCFStringArgument -> CheckObjCString X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=690398188ea5b428f06aa13c7d4ce6eb741ad4f9;p=clang rename CheckBuiltinCFStringArgument -> CheckObjCString git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64894 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 8bd0c9d759..8130f4f631 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -476,12 +476,14 @@ public: /// 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: diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 1bc469235a..fd59bf0691 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1989,7 +1989,7 @@ 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); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index e2ec2676c7..db622f6648 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -37,7 +37,7 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, 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: @@ -91,11 +91,10 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) { 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(Arg); if (!Literal || Literal->isWide()) { diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index b0b5367790..1da74b9c32 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -48,7 +48,8 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, AtLoc); } - if (CheckBuiltinCFStringArgument(S)) + // Verify that this composite string is acceptable for ObjC strings. + if (CheckObjCString(S)) return true; if (Context.getObjCConstantStringInterface().isNull()) {