diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-20 00:05:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-20 00:05:45 +0000 |
commit | c27c665c88b49dfb212aedc7bab8b9bf67658b9e (patch) | |
tree | cd126fe2d2adc4a76f2fc4961f6f37d2eae1d010 | |
parent | 30ce344307f8a8b00054021307015571f83c7364 (diff) |
simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45235 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Sema/SemaChecking.cpp | 13 | ||||
-rw-r--r-- | Sema/SemaExpr.cpp | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp index 8bb263e84e..46afe7fea9 100644 --- a/Sema/SemaChecking.cpp +++ b/Sema/SemaChecking.cpp @@ -125,6 +125,8 @@ bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) { return false; } +/// SemaBuiltinVAStart - Check the arguments to __builtin_va_start for validity. +/// Emit an error and return true on failure, return false on success. bool Sema::SemaBuiltinVAStart(Expr *Fn, Expr** Args, unsigned NumArgs) { if (NumArgs > 2) { Diag(Args[2]->getLocStart(), @@ -133,14 +135,15 @@ bool Sema::SemaBuiltinVAStart(Expr *Fn, Expr** Args, unsigned NumArgs) { return true; } - FunctionTypeProto *Proto; + // Determine whether the current function is variadic or not. + bool isVariadic; if (CurFunctionDecl) - Proto = cast<FunctionTypeProto>(CurFunctionDecl->getType()); + isVariadic = + cast<FunctionTypeProto>(CurFunctionDecl->getType())->isVariadic(); else - Proto = - cast<FunctionTypeProto>(ObjcGetTypeForMethodDefinition(CurMethodDecl)); + isVariadic = CurMethodDecl->isVariadic(); - if (!Proto->isVariadic()) { + if (!isVariadic) { Diag(Fn->getLocStart(), diag::err_va_start_used_in_non_variadic_function); return true; } diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 8ca2879b00..9ae5255155 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -680,8 +680,13 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc, if (ImplicitCastExpr *IcExpr = dyn_cast<ImplicitCastExpr>(Fn)) if (DeclRefExpr *DRExpr = dyn_cast<DeclRefExpr>(IcExpr->getSubExpr())) if (FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRExpr->getDecl())) - if (CheckFunctionCall(Fn, RParenLoc, FDecl, Args, NumArgsInCall)) + if (CheckFunctionCall(Fn, RParenLoc, FDecl, Args, NumArgsInCall)) { + // Function rejected, delete sub-ast's. + delete Fn; + for (unsigned i = 0; i != NumArgsInCall; ++i) + delete Args[i]; return true; + } return new CallExpr(Fn, Args, NumArgsInCall, resultType, RParenLoc); } |