[cfe-commits] r41398 - /cfe/trunk/Sema/SemaChecking.cpp
Chris Lattner
sabre at nondot.org
Fri Aug 24 22:36:19 PDT 2007
Author: lattner
Date: Sat Aug 25 00:36:18 2007
New Revision: 41398
URL: http://llvm.org/viewvc/llvm-project?rev=41398&view=rev
Log:
Fix the test/Sema/format-strings.c regression. This code should be refactored.
Modified:
cfe/trunk/Sema/SemaChecking.cpp
Modified: cfe/trunk/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaChecking.cpp?rev=41398&r1=41397&r2=41398&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/Sema/SemaChecking.cpp Sat Aug 25 00:36:18 2007
@@ -81,6 +81,7 @@
/// 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 @@
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 @@
// 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(),
More information about the cfe-commits
mailing list