@@ -6409,6 +6409,21 @@ class Sema {
6409
6409
VariadicDoesNotApply
6410
6410
};
6411
6411
6412
+ VariadicCallType getVariadicCallType (FunctionDecl *FDecl,
6413
+ const FunctionProtoType *Proto,
6414
+ Expr *Fn);
6415
+
6416
+ // Used for determining in which context a type is allowed to be passed to a
6417
+ // vararg function.
6418
+ enum VarArgKind {
6419
+ VAK_Valid,
6420
+ VAK_ValidInCXX11,
6421
+ VAK_Invalid
6422
+ };
6423
+
6424
+ // Determines which VarArgKind fits an expression.
6425
+ VarArgKind isValidVarArgType (const QualType &Ty);
6426
+
6412
6427
// / GatherArgumentsForCall - Collector argument expressions for various
6413
6428
// / form of call prototypes.
6414
6429
bool GatherArgumentsForCall (SourceLocation CallLoc,
@@ -6421,10 +6436,14 @@ class Sema {
6421
6436
bool AllowExplicit = false );
6422
6437
6423
6438
// DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
6424
- // will warn if the resulting type is not a POD type.
6439
+ // will return ExprError() if the resulting type is not a POD type.
6425
6440
ExprResult DefaultVariadicArgumentPromotion (Expr *E, VariadicCallType CT,
6426
6441
FunctionDecl *FDecl);
6427
6442
6443
+ // / Checks to see if the given expression is a valid argument to a variadic
6444
+ // / function, issuing a diagnostic and returning NULL if not.
6445
+ bool variadicArgumentPODCheck (const Expr *E, VariadicCallType CT);
6446
+
6428
6447
// UsualArithmeticConversions - performs the UsualUnaryConversions on it's
6429
6448
// operands and then handles various conversions that are common to binary
6430
6449
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
@@ -6999,10 +7018,33 @@ class Sema {
6999
7018
const ArraySubscriptExpr *ASE=0 ,
7000
7019
bool AllowOnePastEnd=true , bool IndexNegated=false );
7001
7020
void CheckArrayAccess (const Expr *E);
7002
- bool CheckFunctionCall (FunctionDecl *FDecl, CallExpr *TheCall);
7021
+ // Used to grab the relevant information from a FormatAttr and a
7022
+ // FunctionDeclaration.
7023
+ struct FormatStringInfo {
7024
+ unsigned FormatIdx;
7025
+ unsigned FirstDataArg;
7026
+ bool HasVAListArg;
7027
+ };
7028
+
7029
+ bool getFormatStringInfo (const FormatAttr *Format, bool IsCXXMember,
7030
+ FormatStringInfo *FSI);
7031
+ bool CheckFunctionCall (FunctionDecl *FDecl, CallExpr *TheCall,
7032
+ const FunctionProtoType *Proto);
7003
7033
bool CheckObjCMethodCall (ObjCMethodDecl *Method, SourceLocation loc,
7004
7034
Expr **Args, unsigned NumArgs);
7005
- bool CheckBlockCall (NamedDecl *NDecl, CallExpr *TheCall);
7035
+ bool CheckBlockCall (NamedDecl *NDecl, CallExpr *TheCall,
7036
+ const FunctionProtoType *Proto);
7037
+ void CheckConstructorCall (FunctionDecl *FDecl,
7038
+ Expr **Args,
7039
+ unsigned NumArgs,
7040
+ const FunctionProtoType *Proto,
7041
+ SourceLocation Loc);
7042
+
7043
+ void checkCall (NamedDecl *FDecl, Expr **Args, unsigned NumArgs,
7044
+ unsigned NumProtoArgs, bool IsMemberFunction,
7045
+ SourceLocation Loc, SourceRange Range,
7046
+ VariadicCallType CallType);
7047
+
7006
7048
7007
7049
bool CheckObjCString (Expr *Arg);
7008
7050
@@ -7037,21 +7079,31 @@ class Sema {
7037
7079
FST_Unknown
7038
7080
};
7039
7081
static FormatStringType GetFormatStringType (const FormatAttr *Format);
7040
- bool SemaCheckStringLiteral (const Expr *E, Expr **Args, unsigned NumArgs,
7041
- bool HasVAListArg, unsigned format_idx,
7042
- unsigned firstDataArg, FormatStringType Type,
7043
- bool inFunctionCall = true );
7082
+
7083
+ enum StringLiteralCheckType {
7084
+ SLCT_NotALiteral,
7085
+ SLCT_UncheckedLiteral,
7086
+ SLCT_CheckedLiteral
7087
+ };
7088
+
7089
+ StringLiteralCheckType checkFormatStringExpr (const Expr *E,
7090
+ Expr **Args, unsigned NumArgs,
7091
+ bool HasVAListArg,
7092
+ unsigned format_idx,
7093
+ unsigned firstDataArg,
7094
+ FormatStringType Type,
7095
+ bool inFunctionCall = true );
7044
7096
7045
7097
void CheckFormatString (const StringLiteral *FExpr, const Expr *OrigFormatExpr,
7046
7098
Expr **Args, unsigned NumArgs, bool HasVAListArg,
7047
7099
unsigned format_idx, unsigned firstDataArg,
7048
7100
FormatStringType Type, bool inFunctionCall);
7049
7101
7050
- void CheckFormatArguments (const FormatAttr *Format, CallExpr *TheCall);
7051
- void CheckFormatArguments (const FormatAttr *Format, Expr **Args,
7102
+ bool CheckFormatArguments (const FormatAttr *Format, CallExpr *TheCall);
7103
+ bool CheckFormatArguments (const FormatAttr *Format, Expr **Args,
7052
7104
unsigned NumArgs, bool IsCXXMember,
7053
7105
SourceLocation Loc, SourceRange Range);
7054
- void CheckFormatArguments (Expr **Args, unsigned NumArgs,
7106
+ bool CheckFormatArguments (Expr **Args, unsigned NumArgs,
7055
7107
bool HasVAListArg, unsigned format_idx,
7056
7108
unsigned firstDataArg, FormatStringType Type,
7057
7109
SourceLocation Loc, SourceRange range);
0 commit comments