]> granicus.if.org Git - clang/commitdiff
Add placeholder function in Sema for new format string checking logic.
authorTed Kremenek <kremenek@apple.com>
Thu, 28 Jan 2010 01:18:22 +0000 (01:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 28 Jan 2010 01:18:22 +0000 (01:18 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94721 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaChecking.cpp

index 4fbc42cb0f5909dffd2793882531a9628a6547da..fb3ca1c46540153663536a06bbd959421a38aecc 100644 (file)
@@ -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);
index 9305ff7562d6b10d22167ae9f53e590443cdafaf..2a5136ee9d3560b74e5684fce3ba94ed7676d49d 100644 (file)
@@ -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<ObjCStringLiteral>(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);