From c70ee8610d96e0a6c493a9522bd568442d675470 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 28 Jan 2010 01:18:22 +0000 Subject: [PATCH] Add placeholder function in Sema for new format string checking logic. This function will use the format string parsing logic in libAnalysis, and once it is shown to be better than the current implementation it will replace AlternateCheckPrintfString() entirely. llvm-svn: 94721 --- clang/lib/Sema/Sema.h | 7 +++++++ clang/lib/Sema/SemaChecking.cpp | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 4fbc42cb0f59..fb3ca1c46540 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -4047,6 +4047,13 @@ private: bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg); + // FIXME: This function is placeholder for transitioning the printf + // format string checking to a new codepath. It will eventually + // replace CheckPrintfString(). + void AlternateCheckPrintfString(const StringLiteral *FExpr, + const Expr *OrigFormatExpr, + const CallExpr *TheCall, bool HasVAListArg, + unsigned format_idx, unsigned firstDataArg); void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr, const CallExpr *TheCall, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 9305ff7562d6..2a5136ee9d35 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1036,6 +1036,14 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr, const CallExpr *TheCall, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg) { + + static bool UseAlternatePrintfChecking = false; + if (UseAlternatePrintfChecking) { + AlternateCheckPrintfString(FExpr, OrigFormatExpr, TheCall, + HasVAListArg, format_idx, firstDataArg); + return; + } + const ObjCStringLiteral *ObjCFExpr = dyn_cast(OrigFormatExpr); @@ -1059,7 +1067,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr, << OrigFormatExpr->getSourceRange(); return; } - + // We process the format string using a binary state machine. The // current state is stored in CurrentState. enum { @@ -1271,6 +1279,15 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr, } } +void +Sema::AlternateCheckPrintfString(const StringLiteral *FExpr, + const Expr *OrigFormatExpr, + const CallExpr *TheCall, bool HasVAListArg, + unsigned format_idx, unsigned firstDataArg) { + + +} + //===--- CHECK: Return Address of Stack Variable --------------------------===// static DeclRefExpr* EvalVal(Expr *E);