diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-25 05:36:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-25 05:36:18 +0000 |
commit | 459e8488046be5df0bf57f0a8677316abf253167 (patch) | |
tree | a4026c0ef8f87b71cd0ad4410320701bdf2e150a /Sema/SemaChecking.cpp | |
parent | e45fa6af52d0a99ad3c6e4b58a4e4c351c987b87 (diff) |
Fix the test/Sema/format-strings.c regression. This code should be refactored.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Sema/SemaChecking.cpp')
-rw-r--r-- | Sema/SemaChecking.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp index a62c73e8fb..cc682af99f 100644 --- a/Sema/SemaChecking.cpp +++ b/Sema/SemaChecking.cpp @@ -81,6 +81,7 @@ Sema::CheckFunctionCall(Expr *Fn, /// CheckBuiltinCFStringArgument - Checks that the argument to the builtin /// CFString constructor is correct bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) { + // FIXME: This should go in a helper. while (1) { if (ParenExpr *PE = dyn_cast<ParenExpr>(Arg)) Arg = PE->getSubExpr(); @@ -180,6 +181,17 @@ Sema::CheckPrintfArguments(Expr *Fn, return; } + Expr *OrigFormatExpr = Args[format_idx]; + // FIXME: This should go in a helper. + while (1) { + if (ParenExpr *PE = dyn_cast<ParenExpr>(OrigFormatExpr)) + OrigFormatExpr = PE->getSubExpr(); + else if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(OrigFormatExpr)) + OrigFormatExpr = ICE->getSubExpr(); + else + break; + } + // CHECK: format string is not a string literal. // // Dynamically generated format strings are difficult to @@ -187,7 +199,7 @@ Sema::CheckPrintfArguments(Expr *Fn, // are string literals: (1) permits the checking of format strings by // the compiler and thereby (2) can practically remove the source of // many format string exploits. - StringLiteral *FExpr = dyn_cast<StringLiteral>(Args[format_idx]); + StringLiteral *FExpr = dyn_cast<StringLiteral>(OrigFormatExpr); if (FExpr == NULL) { Diag(Args[format_idx]->getLocStart(), |